codec.pkcs7
Class Certificates
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.ArrayList
|
+--codec.asn1.ASN1AbstractCollection
|
+--codec.asn1.ASN1Set
|
+--codec.asn1.ASN1SetOf
|
+--codec.pkcs7.Certificates
- All Implemented Interfaces:
- ASN1Collection, ASN1CollectionOf, ASN1Type, CertificateSource, Cloneable, Collection, Externalizable, List, Serializable
- public class Certificates
- extends ASN1SetOf
- implements CertificateSource
Represents a set of certificates. The ASN.1 structure of this type is:
Certificates ::= SET OF Certificate
This tye is a convenience type for transporting sets of certificates. It
decodes certificates using X.509 certificate factories of the installed
providers.
This class des a little optimization - it decodes certificates using the
ASN1Opaque type. Therefor, the structure of certificates
is not decoded immediately, only the identifier and length octets are
decoded. Certificate decoding takes place in a postprocessing step which
generates transparent certificate representations using a X.509 certificate
factory.
- Version:
- "$Id: Certificates.java,v 1.2 2000/12/06 17:47:31 vroth Exp $"
- Author:
- Volker Roth
- See Also:
- Serialized Form
|
Constructor Summary |
Certificates()
Creates an instance ready for decoding. |
| Methods inherited from class codec.asn1.ASN1AbstractCollection |
checkConstraints, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, toString, writeExternal |
| Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize |
| Methods inherited from interface codec.asn1.ASN1Type |
checkConstraints, getConstraint, getTag, getTagClass, getValue, isExplicit, isOptional, isType, setConstraint, setExplicit, setOptional |
| Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
factory_
protected CertificateFactory factory_
- The certificate factory that is used for decoding certificates.
cache_
protected ASN1Set cache_
- The cache encoded X.509 certificates. This cache is filled with opaque
versions on encoding this instance.
Certificates
public Certificates()
- Creates an instance ready for decoding.
decode
public void decode(Decoder dec)
throws ASN1Exception,
IOException
- Decodes this instance using the given decoder. After decoding, the opaque
certificates are transformed into instances of X509Certificate by means
of a CertificateFactory. If no such factory was set then a default
factory of type "X.509" is requested. If no such factory is
available then "X509" is tried instead. If neither of these
attempts is successful then an ASN1Exception is raised.
- Overrides:
decode in class ASN1SetOf
- Parameters:
dec - The decoder to use.- Throws:
ASN1Exception - if a decoding error occurs.IOException - if guess what...
encode
public void encode(Encoder enc)
throws ASN1Exception,
IOException
- Encodes this using the given
Encoder. There is a trick
behind encoded this instance. Actually not this instance is encoded but a
cache that is filled with encoded instances of the certificates in this
type.
- Overrides:
encode in class ASN1AbstractCollection
- Parameters:
enc - The encoder to use for encoding.- Throws:
ASN1Exception - if an encoding error occurs.IOException - if guess what...
setCertificateFactory
public void setCertificateFactory(CertificateFactory factory)
- Sets the certificate factory to use for decoding certificates.
- Parameters:
factory - The certificate factory or null
if the
default X.509 factory shall be used.
addCertificate
public boolean addCertificate(X509Certificate cert)
- Adds the given certificate to this structure if none with the same issuer
and serial number already exists.
- Parameters:
cert - The certificate to add.- Returns:
true if the certificate was added and
false if it already existed.
getCertificate
public X509Certificate getCertificate(Principal issuer,
BigInteger serial)
- Description copied from interface:
CertificateSource
- 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
- Following copied from interface:
codec.util.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
- Following copied from interface:
codec.util.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
- Following copied from interface:
codec.util.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.