|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.cms.CertificateSet
public class CertificateSet
This class implements the CMS type CertificateSet. The Cryptographic Message Syntax (CMS) (RFC 5652) specifies the CertificateSet type for modeling certificates:
CertificateSet ::= SET OF CertificateChoicesFor creating an empty CertificateSet use the
CertificateChoices ::= CHOICE { certificate Certificate, -- see X.509 extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete; see PKCS#6 v1AttrCert [1] IMPLICIT AttributeCertificateV1, -- Obsolete; see X.509-1997 v2AttrCert [2] IMPLICIT AttributeCertificateV2, -- see X509-2000 other [3] IMPLICIT OtherCertificateFormat } OtherCertificateFormat ::= SEQUENCE { otherCertFormat OBJECT IDENTIFIER, otherCert ANY DEFINED BY otherCertFormat } CertificateSet ::= SET OF CertificateChoices
default
constructor and subsequently supply certificates by calling method setCertificates
or a addCertificate
method.
Attention! Only X.509 public key certificates (instances of
iaik.x509.X509Certificate
) or X.509 attribute certificates
(instances of iaik.x509.attr.AttributeCertificate
) or other
certificates (instances of iaik.cms.OtherCertificate
) can be
added to this CertificateSet; PKCS#6 extended certificates are obsolete
and therefore not supported, e.g.:
CertificateSet certSet = new CertificateSet(); X509Certificate x509Cert = ...; certSet.addCertificate(x509Cert); AttributeCertificate attCert = ...; certSet.addCertificate(attCert); OtherCertificate otherCert = ...; certSet.addCertificate(otherCert);
X509Certificate
,
AttributeCertificate
Constructor Summary | |
---|---|
CertificateSet()
Default constructor. |
|
CertificateSet(java.io.InputStream is)
Creates a new CertificateSet where the DER encoded data is read from the given InputStream. |
Method Summary | |
---|---|
void |
addCertificate(java.security.cert.Certificate certificate)
Adds the given certificate to this CertificateSet. |
void |
addCertificateChoices(CertificateChoices certificateChoices)
Adds the given CertificateChoices to this CertificateSet. |
void |
addCertificateChoices(CertificateChoices[] certificateChoices)
Adds the given CertificateChoices array to this CertificateSet. |
void |
addCertificates(java.security.cert.Certificate[] certificates)
Adds the given certificates to this CertificateSet. |
boolean |
containsAttributeCertificates()
Asks whether attribute certificates are included. |
boolean |
containsOtherCertificates()
Asks whether RFC 5652 other certificates are included. |
boolean |
containsX509Certificates()
Asks whether X.509 certificates are included. |
void |
decode(java.io.InputStream is)
Decodes a CertifcateSet from the given InputStream. |
AttributeCertificate[] |
getAttributeCertificates()
Gets all included attribute certificates from this CertificateSet. |
int |
getAttributeCertificateType()
Checks if version 1 or 2 AttributeCertificates are included in this CertificateSet. |
CertificateChoices[] |
getCertificateChoices()
Gets all included CertificateChoices elements. |
java.security.cert.Certificate[] |
getCertificates()
Gets the certificates from this CertificateSet. |
OtherCertificate[] |
getOtherCertificates()
Gets all included RFC 5652 other certificates from this CertificateSet. |
X509Certificate |
getX509Certificate(CertificateIdentifier certID)
Gets the X.509 certificate identified by the given CertIdentifier. |
X509Certificate[] |
getX509Certificates()
Gets all included X.509 certificates from this CertificateSet. |
boolean |
isEmpty()
Asks if this CertificateSet is empty. |
void |
removeAllCertificates()
Removes all certificates from this CertificateSet. |
void |
setCertificateChoices(CertificateChoices[] certificateChoices)
Sets the CertificateChoices of this CertificateSet. |
void |
setCertificates(java.security.cert.Certificate[] certificates)
Sets the certificates of this CertificateSet. |
int |
size()
Gets size of this CertificateSet. |
ASN1Object |
toASN1Object()
Returns this CertifcateSet as ASN1Object. |
java.lang.String |
toString()
Returns a string giving some information about this CertificateSet object. |
void |
writeTo(java.io.OutputStream os)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CertificateSet()
Creates an empty CertificateSet.
Supply certificates to be included by calling method
setCertificates
or a
addCertificate
method.
public CertificateSet(java.io.InputStream is) throws CMSParsingException, java.io.IOException
is
- the InputStream holding a DER encoded CertificateSet
java.io.IOException
- if an I/O error occurs during reading from the InputStream
CMSParsingException
- if an error occurs while parsing the object;
e.g. the encoding is invalid, or PKCS#6 extended certificates
(obsolete) are includedMethod Detail |
---|
public void setCertificates(java.security.cert.Certificate[] certificates)
Attention! Only X.509 public key certificates (instances of
iaik.x509.X509Certificate
) or X.509 attribute certificates
(instances of iaik.x509.attr.AttributeCertificate
) or other
certificates (instances of iaik.cms.OtherCertificate
) can be
added to this CertificateSet; PKCS#6 extended certificates are obsolete
and therefore not supported.
certificates
- the certificates to be set
java.lang.IllegalArgumentException
- if any of the supplied certificates
is not a iaik.x509.X509Certificate
or
iaik.x509.attr.AttributeCertificate
or
iaik.cms.OtherCertificate
objectpublic void addCertificates(java.security.cert.Certificate[] certificates)
Attention! Only X.509 public key certificates (instances of
iaik.x509.X509Certificate
) or X.509 attribute certificates
(instances of iaik.x509.attr.AttributeCertificate
) or other
certificates (instances of iaik.cms.OtherCertificate
) can be
added to this CertificateSet; PKCS#6 extended certificates are obsolete
and therefore not supported.
certificates
- the certificates to add
java.lang.IllegalArgumentException
- if any of the supplied certificates
is not a iaik.x509.X509Certificate
or
iaik.x509.attr.AttributeCertificate
or
iaik.cms.OtherCertificate
objectpublic void addCertificate(java.security.cert.Certificate certificate)
Attention! Only X.509 public key certificates (instances of
iaik.x509.X509Certificate
) or X.509 attribute certificates
(instances of iaik.x509.attr.AttributeCertificate
) or other
certificates (instances of iaik.cms.OtherCertificate
) can be
added to this CertificateSet; PKCS#6 extended certificates are obsolete
and therefore not supported.
certificate
- the certificates to be added
java.lang.IllegalArgumentException
- if the supplied certificate
is not a iaik.x509.X509Certificate
or
iaik.x509.attr.AttributeCertificate
or
iaik.cms.OtherCertificate
objectpublic java.security.cert.Certificate[] getCertificates()
The array returned may contain X.509 public key certificates (instances
of iaik.x509.X509Certificate
and/or X.509 attribute
certificates (instances of iaik.x509.attr.AttributeCertificate
);
PKCS#6 extended certificates are obsolete and therefore not supported.
public X509Certificate getX509Certificate(CertificateIdentifier certID)
If no certificate in this CertificateSet is identified by the given
certificate identifier null
is returned.
certID
- the CertificateIdentifier to be searched for a matching
certificate
null
if not foundpublic X509Certificate[] getX509Certificates()
public AttributeCertificate[] getAttributeCertificates()
public OtherCertificate[] getOtherCertificates()
public boolean isEmpty()
true
if there are no certificates in this CertificateSet,
false
otherwisepublic int size()
public boolean containsAttributeCertificates()
true
if there are attribute certificates in this CertificateSet,
false
otherwisepublic int getAttributeCertificateType()
public boolean containsX509Certificates()
true
if there are X.509 certificates in this CertificateSet,
false
otherwisepublic boolean containsOtherCertificates()
true
if there are other certificates in this CertificateSet,
false
otherwisepublic void removeAllCertificates()
public void addCertificateChoices(CertificateChoices certificateChoices)
certificateChoices
- the CertificateChoices to be addedpublic void addCertificateChoices(CertificateChoices[] certificateChoices)
certificateChoices
- the CertificateChoices array to be addedpublic void setCertificateChoices(CertificateChoices[] certificateChoices)
certificateChoices
- the CertificateChoices to be setpublic CertificateChoices[] getCertificateChoices()
Note that this method returns an array of CertificateChoices
objects, whereas method getCertificates
returns the
Certificate elements included in the CertificateChoices objects. Calling
getCertificateChoices
may be preferred to get the encoding of
each CertificateChoices
object if required:
CertificateSet certSet = ...; CertificateChoices[] certificateChoices = certSet.getCertificateChoices(); for (int i = 0; i < certificateChoices.length; i++) { byte[] encodedCertificateChoices = certificateChoices[i].getEncoded(); }
public void decode(java.io.InputStream is) throws java.io.IOException, CMSParsingException
is
- the input stream supplying the encoded CertificateSet
java.io.IOException
- if an I/O error occurs during reading from the InputStream
CMSParsingException
- if an error occurs while parsing the object
e.g. the encoding is invalid, or PKCS#6 extended certificates
(obsolete) are includedpublic ASN1Object toASN1Object() throws CodingException
RFC 5652 specifies the CertificateSet type as SET OF CertificateChoices:
CertificateSet ::= SET OF CertificateChoices
CertificateChoices ::= CHOICE { certificate Certificate, -- see X.509 extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete; see PKCS#6 v1AttrCert [1] IMPLICIT AttributeCertificateV1, -- Obsolete; see X.509-1997 v2AttrCert [2] IMPLICIT AttributeCertificateV2, -- see X509-2000 other [3] IMPLICIT OtherCertificateFormat } OtherCertificateFormat ::= SEQUENCE { otherCertFormat OBJECT IDENTIFIER, otherCert ANY DEFINED BY otherCertFormat } CertificateSet ::= SET OF CertificateChoices
CodingException
- if an error occurs while building the ASN.1 structurepublic void writeTo(java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
CertificateSet
object.
toString
in class java.lang.Object
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |