public class CertificateSet
extends java.lang.Object
CertificateSet ::= SET OF CertificateChoicesUse the empty
CertificateChoices ::= CHOICE { certificate Certificate, -- See X.509 extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete attrCert [1] IMPLICIT AttributeCertificate } -- See X.509 & X9.57
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) 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);
X509Certificate,
AttributeCertificate| Constructor and Description |
|---|
CertificateSet()
Default constructor.
|
CertificateSet(java.io.InputStream is)
Creates a new CertificateSet where the DER encoded data
is read from the given InputStream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCertificate(java.security.cert.Certificate certificate)
Adds the given certificate 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 |
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.
|
java.security.cert.Certificate[] |
getCertificates()
Gets the 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 |
setCertificates(java.security.cert.Certificate[] certificates)
Sets the certificates 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) |
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 CertificateSetjava.io.IOException - if an I/O error occurs during reading from the InputStreamCMSParsingException - if an error occurs while parsing the object;
e.g. the encoding is invalid, or PKCS#6 extended certificates
(obsolete) are includedpublic 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) can be
added to this CertificateSet; PKCS#6 extended certificates are obsolete
and therefore not supported.
certificates - the certificates to be setjava.lang.IllegalArgumentException - if any of the supplied certificates
is not a iaik.x509.X509Certificate or
iaik.x509.attr.AttributeCertificate 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) can be
added to this CertificateSet; PKCS#6 extended certificates are obsolete
and therefore not supported.
certificates - the certificates to addjava.lang.IllegalArgumentException - if any of the supplied certificates
is not a iaik.x509.X509Certificate or
iaik.x509.attr.AttributeCertificate 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) can be
added to this CertificateSet; PKCS#6 extended certificates are obsolete
and therefore not supported.
certificate - the certificates to be addedjava.lang.IllegalArgumentException - if the supplied certificate
is not a iaik.x509.X509Certificate or
iaik.x509.attr.AttributeCertificate 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.
null if there are no
certificates in this setpublic 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
certificatenull
if not foundpublic X509Certificate[] getX509Certificates()
null if there are no X.509
certificates in this setpublic AttributeCertificate[] getAttributeCertificates()
null if there are no attribute
certificates in this setpublic boolean isEmpty()
true if there are no certificates in this CertificateSet,
false otherwisepublic boolean containsAttributeCertificates()
true if there are attribute certificates in this CertificateSet,
false otherwisepublic boolean containsX509Certificates()
true if there are X.509 certificates in this CertificateSet,
false otherwisepublic void removeAllCertificates()
public void decode(java.io.InputStream is)
throws java.io.IOException,
CMSParsingException
is - the input stream supplying the encoded CertificateSetjava.io.IOException - if an I/O error occurs during reading from the InputStreamCMSParsingException - 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 2630 specifies the CertificateSet type as SET OF CertificateChoices:
CertificateChoices ::= CHOICE {
certificate Certificate, -- See X.509
extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete
attrCert [1] IMPLICIT AttributeCertificate } -- See X.509 & X9.57
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.IOExceptionpublic java.lang.String toString()
CertificateSet object.toString in class java.lang.Object