|
IAIK CMS/SMIME Toolkit API Documentation
Version 6.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectiaik.asn1.structures.AttributeValue
iaik.smime.ess.ESSAttributeValue
iaik.smime.ess.SigningCertificate
public class SigningCertificate
This class implements the S/MIMEv3 SigningCertificate type.
The Enhanced Security Services
for S/MIMEv3 (ESS) (RFC 2634) specify the SigningCertificate
type for providing a way to include certificate identification information
into the signed attributes of a CMS SignerInfo
object:
SigningCertificate ::= SEQUENCE {
certs SEQUENCE OF ESSCertID,
policies SEQUENCE OF PolicyInformation OPTIONAL
}
ESSCertID ::= SEQUENCE {
certHash Hash,
issuerSerial IssuerSerial OPTIONAL }
Hash ::= OCTET STRING -- SHA1 hash of entire certificate
IssuerSerial ::= SEQUENCE {
issuer GeneralNames,
serialNumber CertificateSerialNumber }
The ESSCertID type is used for for identifying a
certificate by cert hash and optionally issuer information and issuer-specific
certificate serial number. PolicyInformations (X.509) are used for indicating
the policy under which a certificate has been issued and the purposes for
which the certificate may be used.
When creating a SigningCertificate, you either immediately may supply the ESSCertID objects to
be added or you may supply certificates
to let this class calculate the corresponding ESSCertIDs, e.g.:
// the cert used for signing:
X509Certificate signerCert = ...;
// the issuer of the signer:
X509Certificate issuerCert = ...;
// an attribute certificate:
AttributeCertificate attributeCert = ...;
// the certificate of the signer must be the first!
Certificate[] certs = { signerCert, issuerCert, attributeCert };
SigningCertificate signingCertificate = new SigningCertificate(certs);
Use method setPolicies for including any
PolicyInformation terms:
PolicyInformation[] policies = ...; signingCertificate.setPolicies(policies);For adding a SigningCertificate to the signed attributes field of a
SignerInfo object, use method setSignedAttributes:
Attribute[] signedAttributes = ...; ... signedAttributes[i] = new Attribute(signingCertificate); ... signerInfo.setSignedAttributes(signedAttributes);Use method
getSignedAttributeValue for
getting the SigningCertificate (if included) attribute from a SignerInfo object:
SigningCertificate signingCertificate =
(SigningCertificate)signerInfo.getSignedAttributeValue(SigningCertificate.oid);
if (signingCertificate != null) {
...
}
If you want to use the SigningCertificate attribute with other hash
algorithms than SHA-1, use the SigningCertificateV2
attribute.
ESSIssuerSerial,
ESSCertID,
X509Certificate,
AttributeCertificate,
Attribute,
PolicyInformation,
CertificateSet,
SignerInfo| Field Summary | |
|---|---|
static iaik.asn1.ObjectID |
oid
The attributeType object identifier of this SigningCertificate extension. |
| Constructor Summary | |
|---|---|
SigningCertificate()
Empty default constructor. |
|
SigningCertificate(iaik.asn1.ASN1Object obj)
Creates a new SigningCertificate from an ASN1Object. |
|
SigningCertificate(java.security.cert.Certificate[] certs)
Creates a SigningCertificate attribute for the given certificates. |
|
SigningCertificate(java.security.cert.Certificate[] certs,
boolean includeIssuerSerial)
Creates a SigningCertificate attribute for the given certificates. |
|
SigningCertificate(java.security.cert.Certificate[] certs,
boolean includeIssuerSerial,
SecurityProvider securityProvider)
Creates a SigningCertificate attribute for the given certificates. |
|
SigningCertificate(CertificateSet certSet,
boolean includeIssuerSerial)
Creates a SigningCertificate attribute for the given certificates. |
|
SigningCertificate(ESSCertID[] essCertIDs)
Creates a SigningCertificate for the given ESSCertIDs. |
|
| Method Summary | |
|---|---|
int |
countPolicies()
Returns the number of PolicyInformation terms included. |
void |
decode(iaik.asn1.ASN1Object obj)
Decodes the given ASN.1 SigningCertificate object for parsing
the internal structure. |
boolean |
equals(java.lang.Object obj)
Compares this SigningCertificate to the specified object. |
iaik.asn1.ObjectID |
getAttributeType()
Returns the OID identifying the SigningCertificate attribute type. |
java.security.cert.Certificate[] |
getAuthorizedCertificates(java.security.cert.Certificate[] certificates)
Gets the authorized certificates from the set of supplied certificates. |
ESSCertID |
getESSCertID(java.security.cert.Certificate cert)
Searches for the ESSCertID identifying the given cert. |
ESSCertID[] |
getESSCertIDs()
Returns the ESS certs IDs. |
iaik.asn1.structures.PolicyInformation[] |
getPolicies()
Returns the policiy informations. |
java.security.cert.Certificate[] |
getPolicyInformationCerts(java.security.cert.Certificate[] certificates)
Gets those certificates from the supplied set of certificates having a CertificatePolicies extension with any of the PolicyInformation terms included in this SigningCertificate set. |
iaik.asn1.structures.PolicyInformation[] |
getPolicyInformations(java.security.cert.Certificate cert)
Looks if the supplied certificate has a CertificatePolicies extension containing any of the PolicyInformation terms of this SigningCertificate attribute. |
SecurityProvider |
getSecurityProvider()
Gets the SecurityProvider installed for this SigningCertificate. |
int |
hashCode()
Returns a hashcode for this object. |
boolean |
isSignerCertificate(iaik.x509.X509Certificate certificate)
Checks if this SigningCertificate identifies the given certificate as certificate of the signer to whom this SigningCertificate belongs. |
void |
setPolicies(iaik.asn1.structures.PolicyInformation[] policies)
Sets the policy informations of this SigningCertificate. |
void |
setSecurityProvider(SecurityProvider securityProvider)
Sets the SecurityProvider for this SigningCertificate. |
iaik.asn1.ASN1Object |
toASN1Object()
Returns this SigningCertificate as ASN1Object. |
java.lang.String |
toString()
Returns a string that represents the contents of this SigningCertificate object. |
| Methods inherited from class iaik.smime.ess.ESSAttributeValue |
|---|
multipleAllowed |
| Methods inherited from class iaik.asn1.structures.AttributeValue |
|---|
getName |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final iaik.asn1.ObjectID oid
SigningCertificate extension.
The corresponding OID string is "1.2.840.113549.1.9.16.2.12".
| Constructor Detail |
|---|
public SigningCertificate()
public SigningCertificate(ESSCertID[] essCertIDs)
essCertIDs - the cert IDs to be set
public SigningCertificate(java.security.cert.Certificate[] certs)
throws java.security.NoSuchAlgorithmException,
java.security.cert.CertificateException
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 handled by this constructor; PKCS#6 ExtendedCertificates are obsolete
and therefore not supported.
When using the constructor for creating a SigningCertificate
attribute, the IssuerSerial component is calculated and set
for each ESSCertID element to be created.
certs - the certificates for which to create an SigningCertificate (may
be instances of iaik.x509.X509Certificate and/or instances of
iaik.x509.attr.AttributeCertificate
java.lang.IllegalArgumentException - if any of the supplied certificates is not an
iaik.x509.X509Certificate or
iaik.x509.attr.AttributeCertificate
java.security.NoSuchAlgorithmException - if SHA-1, required for hash computation,
is not supported by the installed providers
java.security.cert.CertificateException - if an error occurs while encoding any of the
certificates for computing the hash, or any of the given certificates
is an attribute certificate, but the issuer information included
is not sufficient to construct an IssuerSerial (if V2Form is used
for indicating the issuer, but not the issuerName option)
public SigningCertificate(java.security.cert.Certificate[] certs,
boolean includeIssuerSerial)
throws java.security.NoSuchAlgorithmException,
java.security.cert.CertificateException
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 handled by this constructor; PKCS#6 ExtendedCertificates are obsolete
and therefore not supported.
certs - the certificates for which to create an SigningCertificate (may
be instances of iaik.x509.X509Certificate and/or instances of
iaik.x509.attr.AttributeCertificateincludeIssuerSerial - if the IssuerSerial component should be set for the
ESSCertIDs to be created for the given certificates
java.lang.IllegalArgumentException - if any of the supplied certificates is not an
iaik.x509.X509Certificate or
iaik.x509.attr.AttributeCertificate
java.security.NoSuchAlgorithmException - if SHA-1, required for hash computation,
is not supported by the installed providers
java.security.cert.CertificateException - if an error occurs while encoding any of the
certificates for computing the hash, or any of the given certificates
is an attribute certificate, but the issuer information included
is not sufficient to construct an IssuerSerial (if V2Form is used
for indicating the issuer, but not the issuerName option)
public SigningCertificate(java.security.cert.Certificate[] certs,
boolean includeIssuerSerial,
SecurityProvider securityProvider)
throws java.security.NoSuchAlgorithmException,
java.security.cert.CertificateException
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 handled by this constructor; PKCS#6 ExtendedCertificates are obsolete
and therefore not supported.
certs - the certificates for which to create an SigningCertificate (may
be instances of iaik.x509.X509Certificate and/or instances of
iaik.x509.attr.AttributeCertificateincludeIssuerSerial - if the IssuerSerial component should be set for the
ESSCertIDs to be created for the given certificatessecurityProvider - the SecurityProvider to be explicitly used for the
cryptographic operations (cert hash calculation) required by this object,
if null the default system-wide installed security provider
will be used
java.lang.IllegalArgumentException - if any of the supplied certificates is not an
iaik.x509.X509Certificate or
iaik.x509.attr.AttributeCertificate
java.security.NoSuchAlgorithmException - if SHA-1, required for hash computation,
is not supported by the installed providers
java.security.cert.CertificateException - if an error occurs while encoding any of the
certificates for computing the hash, or any of the given certificates
is an attribute certificate, but the issuer information included
is not sufficient to construct an IssuerSerial (if V2Form is used
for indicating the issuer, but not the issuerName option)
public SigningCertificate(CertificateSet certSet,
boolean includeIssuerSerial)
throws java.security.NoSuchAlgorithmException,
java.security.cert.CertificateException
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 handled by this constructor; PKCS#6 ExtendedCertificates are obsolete
and therefore not supported.
certSet - the certificates for which to create an SigningCertificate (may
be instances of iaik.x509.X509Certificate and/or instances of
iaik.x509.attr.AttributeCertificateincludeIssuerSerial - if the IssuerSerial component should be set for the
ESSCertIDs to be created for the given certificates
java.lang.IllegalArgumentException - if any of the supplied certificates is not an
iaik.x509.X509Certificate or
iaik.x509.attr.AttributeCertificate
java.security.NoSuchAlgorithmException - if SHA-1, required for hash computation,
is not supported by the installed providers
java.security.cert.CertificateException - if an error occurs while encoding any of the
certificates for computing the hash, or any of the given certificates
is an attribute certificate, but the issuer information included
is not sufficient to construct an IssuerSerial (if V2Form is used
for indicating the issuer, but not the issuerName option)
public SigningCertificate(iaik.asn1.ASN1Object obj)
throws iaik.asn1.CodingException
SigningCertificate from an ASN1Object.
The ASN1Object supplied to this constructor represents an
already exisiting SigningCertificate object that may
have been created by calling toASN1Object.
obj - the SigningCertificate as ASN1Object
iaik.asn1.CodingException - if the ASN1Object could not be parsed| Method Detail |
|---|
public void setSecurityProvider(SecurityProvider securityProvider)
This method allows to explicitly set a SecurityProvider for this SigningCertificate. If no explicit SecurityProvider is set, the default system wide installed SecurityProvider will be used for the required cryptographic operations.
This class may use the following method(s) of the SecurityProvider, which may be overriden by an application, if required:
getHash()
to calculate an SHA-1 hash from the encoded certificates required for the
ESSCertID objects of the SigningCertificate
creating a new SigningCertificate for some certificate.
securityProvider - the SecurityProvider to be setpublic SecurityProvider getSecurityProvider()
This class uses the following method(s) of the SecurityProvider, which may be overriden by an application, if required:
getHash()
to calculate an SHA-1 hash from the encoded certificates required for the
ESSCertID objects of the SigningCertificate
set for this object,
the default system wide installed SecurityProvider will be used for the required cryptographic
operations. However, this method will return null if it does not have its own
SecurityProvider.
null if
this object does not have its own SecurityProviderpublic void setPolicies(iaik.asn1.structures.PolicyInformation[] policies)
policies - the the policy informations to be setpublic iaik.asn1.ObjectID getAttributeType()
getAttributeType in class iaik.asn1.structures.AttributeValuepublic ESSCertID[] getESSCertIDs()
null if no
cert ID is setpublic ESSCertID getESSCertID(java.security.cert.Certificate cert)
cert - the cert for which to look if a corresponding ESSCertID
is included
null
if no corresponding certID can be found
public boolean isSignerCertificate(iaik.x509.X509Certificate certificate)
throws java.security.NoSuchAlgorithmException
certificate - the certificate to be checked of being the certificate
of the signer
true if this SigningCertificate attribute does not
contain any ESSCertIDs or if
the first ESSCertID of this SigningCertificate identifies the
given certificate, false in any other case
java.security.NoSuchAlgorithmException - if the check cannot be performed since
the required SHA-1 algorithm is not supported by the
installed cryptography providerspublic java.security.cert.Certificate[] getAuthorizedCertificates(java.security.cert.Certificate[] certificates)
The S/MIMEv3 ESS SigningCertificate attribute allows to limit the set
of authorization certificates that are used during signature
validation. Authorization certificates may be attribute certificates
or public key certificates. This method scans the provided certificate set
for those certificates authorized by the ESSCertID identifiers included in this SigningCertificate. The array returned
by this method may contain all certificates supplied if this SigningCertificate
does not limit the set of authorization certificates at all (only contains
one ESSCertID, the one identifying the signing certificate) or if this
SigningCertificate contains ESSCertIDs for all the certificates supplied.
Note that only authorization certificates are returned, i.e. the first
ESSCertID is not checked, e.g.:
Assuming you supply five certificates cert1, cert2, ... , cert5 to this
method and only for the first three certs ESSCertIDs are included in this
SigningCertificate attribute, this method will return cert2 and cert3 as
authorization cerificates (cert1 will be not returned since it is the
signer certificate itself).
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 handled by this method; PKCS#6 ExtendedCertificates are obsolete
and therefore not supported.
certificates - the certificates to be asked if being authorized
null if none of the supplied certificates is
an authorization certificate; if this SigningCertificate contains
only one ESSCertID (the one identifying the signer cert), all
supplied certificates are returned by this method since there is
no limitation to the set of authorization certificates
java.lang.IllegalArgumentException - if any of the supplied certificates is not an
iaik.x509.X509Certificate or
iaik.x509.attr.AttributeCertificatepublic iaik.asn1.structures.PolicyInformation[] getPolicyInformations(java.security.cert.Certificate cert)
cert - the cert for which to look if having a CertificatePolicies extension
containing any of the PolicyInformation terms of this SigningCertificate
attribute.
null if the supplied certificate
does not contain the CertificatePolicies extension at all, or if
none of the PolicyInformation terms of the CertificatePolicies extension
of the certificate matches to any one of the PolicyInformation terms
of this SigningCertificate attribute
java.lang.IllegalArgumentException - if any of the supplied certificates is not an
iaik.x509.X509Certificate or
iaik.x509.attr.AttributeCertificatepublic java.security.cert.Certificate[] getPolicyInformationCerts(java.security.cert.Certificate[] certificates)
The S/MIMEv3 ESS SigningCertificate attribute allows to identify those certificate policies that the signer asserts apply to a certificate, and under which the certificate should rely upon. This value suggests a policy value to be used by certification path validation of the relying party.
This method scans the provided certificate set and for those certificates having a CertificatePolicies extension with any of the PolicyInformation terms included in this SigningCertificate. The array returned by this method may contain all certificates supplied if this SigningCertificate does contain any PolicyInformation terms at all or if each certificate supplied has a CertificatePolicies extensions containing at least one of the PolicyInformation terms included in this SigningCertificate attribute.
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 handled by this method; PKCS#6 ExtendedCertificates are obsolete
and therefore not supported.
certificates - the certificates to be asked of having a CertificatePolicies
extension containing any of the PolicyInformation terms of this
SigningCertificate
null if none of the supplied certificates has a
CertificatePolicies extensions with any of the PolicyInformation terms
of this SigningCertificate attribute; if this SigningCertificate does
not contain any PolicyInformation terms, all supplied certificates
are returned by this method
java.lang.IllegalArgumentException - if any of the supplied certificates is not an
iaik.x509.X509Certificate or
iaik.x509.attr.AttributeCertificatepublic iaik.asn1.structures.PolicyInformation[] getPolicies()
null if no
policy informations are setpublic int countPolicies()
public void decode(iaik.asn1.ASN1Object obj)
throws iaik.asn1.CodingException
SigningCertificate object for parsing
the internal structure.
This method internally is called when creating a SigningCertificate
object from an already existing SigningCertificate object,
supplied as ASN1Object.
obj - the ESS SigningCertificate as ASN1Object
iaik.asn1.CodingException - if the object can not be parsedpublic iaik.asn1.ASN1Object toASN1Object()
SigningCertificate as ASN1Object.
The ASN1Object returned by this method may be used as parameter value
when creating an SigningCertificate object using the
SigningCertificate(ASN1Object obj)
constructor.
SigningCertificate as ASN1Objectpublic boolean equals(java.lang.Object obj)
SigningCertificate to the specified object.
equals in class ESSAttributeValueobj - the object to compare this SigningCertificate
against.
true, if the given object is equal to this
SigningCertificate,
false otherwisepublic int hashCode()
hashCode in class ESSAttributeValuepublic java.lang.String toString()
SigningCertificate object.
toString in class iaik.asn1.structures.AttributeValue
|
IAIK CMS/SMIME Toolkit API Documentation
Version 6.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
|
v6.1 (c) 2002 IAIK, (c) 2003 - 2025 SIC |
|