codec.util
Class CertificateStore

java.lang.Object
  |
  +--codec.util.CertificateStore
All Implemented Interfaces:
CertificateSource

public class CertificateStore
extends Object
implements CertificateSource

This class wraps around regular KeyStore instances and supports retrieval of certificates in it by means of the CertificateSource interface.

Version:
"$Id: CertificateStore.java,v 1.4 2000/12/06 17:47:34 vroth Exp $"
Author:
Volker Roth

Inner Class Summary
 class CertificateStore.IdxKey
          This class represents an entry in the map that maps subject, issuer and serial number info to an alias.
 
Field Summary
protected  Map isnIdx_
          The cached certificates indexed by their issuer names and serial numbers.
protected  Map sdnIdx_
          The cached certificates indexed by their subject names.
 
Fields inherited from interface codec.util.CertificateSource
ALL, DATA_ENCIPHERMENT, KEY_AGREEMENT, KEY_CERT_SIGN, KEY_ENCIPHERMENT, NON_REPUDIATION
 
Constructor Summary
CertificateStore(Collection c)
          Creates an instance that loads certificates from the given Collection.
CertificateStore(KeyStore keystore)
          Creates an instance that loads certificates from the given KeyStore.
 
Method Summary
 Iterator certificates(Principal subject)
          Retrieves certificates based on the distinguished name of the certificate's subject.
 Iterator certificates(Principal subject, int keyUsage)
          Retrieves certificates based on the distinguished name of the certificate's subject and a number of key usage bits.
 X509Certificate getCertificate(Principal issuer, BigInteger serial)
          This method retrieves a certificate based on the distinguished name of the certificate's issuer as well as its serial number, as assigned by the issuer.
protected  void init(Collection c)
          Initializes this instance.
protected  void init(KeyStore keystore)
          Initializes this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sdnIdx_

protected Map sdnIdx_
The cached certificates indexed by their subject names.

isnIdx_

protected Map isnIdx_
The cached certificates indexed by their issuer names and serial numbers.
Constructor Detail

CertificateStore

public CertificateStore(KeyStore keystore)
                 throws KeyStoreException
Creates an instance that loads certificates from the given KeyStore.
Parameters:
keystore - The KeyStore to load certificates from.
Throws:
KeyStoreException - if a certificate could not be retrieved from the KeyStore.

CertificateStore

public CertificateStore(Collection c)
Creates an instance that loads certificates from the given Collection.
Parameters:
c - The Collection to load certificates from.
Method Detail

init

protected void init(KeyStore keystore)
             throws KeyStoreException
Initializes this instance. Only X.509 certificates are cached and can be retrieved since only those are known to have issuers and subjects and serial numbers.

init

protected void init(Collection c)
Initializes this instance. Only X.509 certificates are cached and can be retrieved since only those are known to have issuers and subjects and serial numbers.

getCertificate

public X509Certificate getCertificate(Principal issuer,
                                      BigInteger serial)
This method retrieves a certificate based on the distinguished name of the certificate's issuer as well as its serial number, as assigned by the issuer.
Specified by:
getCertificate in interface CertificateSource
Parameters:
issuer - The issuer distinguished name.
serial - The serial number.
Returns:
The certificate or null if it is not found.

certificates

public Iterator certificates(Principal subject)
Description copied from interface: CertificateSource
Retrieves certificates based on the distinguished name of the certificate's subject.
Specified by:
certificates in interface CertificateSource
Parameters:
subject - The subject DN of the certificate that should be retrieved.
Returns:
An Iterator of all known certificates with the given subject DN.
See Also:
CertificateIterator

certificates

public Iterator certificates(Principal subject,
                             int keyUsage)
Description copied from interface: CertificateSource
Retrieves certificates based on the distinguished name of the certificate's subject and a number of key usage bits.
Specified by:
certificates in interface CertificateSource
Parameters:
subject - The subject DN of the certificate that should be retrieved. A value of null matches every subject DN.
keyUsage - The mask of key usage bits; at least one of these bits must be set in the key usage extension of matching certificates. A value of 0 disables key usage checking.
Returns:
An Iterator of all known certificates with the given subject DN that match at least one of the given key usage bits.
See Also:
CertificateIterator


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.