View Javadoc
1 /* 2 * Copyright �, Aegeus Technology Limited. All rights reserved. 3 */ 4 package jsdsi.certstore; 5 6 import java.security.InvalidAlgorithmParameterException; 7 import java.security.cert.CertStoreException; 8 import java.security.cert.CertStoreParameters; 9 import java.security.cert.Certificate; 10 import java.security.cert.CollectionCertStoreParameters; 11 import java.util.Collection; 12 import java.util.Iterator; 13 14 /*** 15 * An Adaptor class between a java.security.CertStore and a jsdsi.certstore.CertificateDAO 16 * 17 * @author Sean Radford 18 * @version $Revision: 1.1.4.2 $ $Date: 2004/12/12 17:01:39 $ 19 */ 20 public class JsdsiCertStore extends AbstractJsdsiCertStore { 21 22 protected CertificateDAO dao; 23 24 /*** 25 * @param params 26 * @throws java.security.InvalidAlgorithmParameterException 27 */ 28 public JsdsiCertStore(CertStoreParameters params) throws InvalidAlgorithmParameterException { 29 super(params); 30 if (params == null) { 31 throw new IllegalArgumentException( 32 "jsdsi.certstore.JsdsiCertStore requires jsdsi.certstore.JsdsiCertStoreParameters"); 33 } 34 if (params instanceof JsdsiCertStoreParameters) { 35 init((JsdsiCertStoreParameters) params); 36 } else { 37 throw (InvalidAlgorithmParameterException) new InvalidAlgorithmParameterException( 38 "Unsupported CertStoreParameter: " + params.getClass().getName()); 39 } 40 } 41 42 /*** 43 * @param parameters 44 */ 45 protected void init(JsdsiCertStoreParameters parameters) { 46 this.dao = parameters.getDao(); 47 loadCertificates(parameters.getCollection()); 48 } 49 50 protected void loadCertificates(Collection certificates) { 51 if (certificates != null) { 52 Iterator it = certificates.iterator(); 53 while (it.hasNext()) { 54 java.security.cert.Certificate cert = (Certificate) it.next(); 55 if (cert instanceof jsdsi.Certificate) { 56 this.dao.store((jsdsi.Certificate) cert); 57 } else { 58 throw new IllegalArgumentException("Only jsdsi.Certificates supported (was " 59 + cert.getClass().getName() + ")."); 60 } 61 } 62 } 63 } 64 65 /*** 66 * @see jsdsi.certstore.AbstractJsdsiCertStore#getCertificates(jsdsi.CertSelector) 67 */ 68 public Collection getCertificates(jsdsi.CertSelector selector) throws CertStoreException { 69 return this.dao.retrieve(selector); 70 } 71 72 }

This page was automatically generated by Maven