|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.security.cert.Certificate | +--iaik.x509.attr.AttributeCertificate
This class represents an attribute certificate, as specified by the PKIX Internet Attribute Certificate Profile for Authorization.
Attribute Certificates (see RFC 3281) do not contain a public key, rather they bind some kind of property to some entity:
An attribute certificate (AC) may contain attributes that specify group
membership, role, security clearance, or other authorization information
associated with the AC holder
.
A public key certificate (PKC) can be considered to be like a passport: it
identifies the holder, tends to last for a long time, and should not
be trivial to obtain. An AC is more like an entry visa: it is
typically issued by a different authority and does not last for as
long a time. As acquiring an entry visa typically requires
presenting a passport, getting a visa can be a simpler process.
Authorization information may be placed in a PKC extension or placed
in a separate attribute certificate (AC). The placement of
authorization information in PKCs is usually undesirable for two
reasons. First, authorization information often does not have the
same lifetime as the binding of the identity and the public key.
When authorization information is placed in a PKC extension, the
general result is the shortening of the PKC useful lifetime. Second,
the PKC issuer is not usually authoritative for the authorization
information. This results in additional steps for the PKC issuer to
obtain authorization information from the authoritative source.
For these reasons, it is often better to separate authorization
information from the PKC. Yet, authorization information also needs
to be bound to an identity. An AC provides this binding; it is
simply a digitally signed (or certified) identity and set of
attributes.
An AC may be used with various security services, including access
control, data origin authentication, and non-repudiation.
PKCs can provide an identity to access control decision functions.
However, in many contexts the identity is not the criterion that is
used for access control decisions, rather the role or group-
membership of the accessor is the criterion used. Such access
control schemes are called role-based access control.
When making an access control decision based on an AC, an access
control decision function may need to ensure that the appropriate AC
holder is the entity that has requested access. One way in which the
linkage between the request or identity and the AC can be achieved
is the inclusion of a reference to a PKC within the AC and the use
of the private key corresponding to the PKC for authentication
within the access request.
The PKIX attribute certificate format is defined as an ASN.1 SEQUENCE structure containing the following components:
AttributeCertificate ::= SEQUENCE { acinfo AttributeCertificateInfo, signatureAlgorithm AlgorithmIdentifier, signatureValue BIT STRING }where signatureAlgorithm identifies the signature algorithm used by the issuer for computing the digital signature upon the ASN.1 DER encoded
AttributeCertificateInfo
structure, which itself is
expressed as ASN.1 SEQUENCE structure specifying holder and issuer of the
AC, signature algorithm (the same as specified in Certificate
above), version and serial numbers, validity period, attributes and optionally
unique identifier of the issuer and certificate extensions:
AttributeCertificateInfo ::= SEQUENCE { version AttCertVersion -- version is v2, holder Holder, issuer AttCertIssuer, signature AlgorithmIdentifier, serialNumber CertificateSerialNumber, attrCertValidityPeriod AttCertValidityPeriod, attributes SEQUENCE OF Attribute, issuerUniqueID UniqueIdentifier OPTIONAL, extensions Extensions OPTIONAL }
where:
AttCertVersion ::= INTEGER { v2(1) }
Holder ::= SEQUENCE { baseCertificateID [0] IssuerSerial OPTIONAL, -- the issuer and serial number of -- the holder's Public Key Certificate entityName [1] GeneralNames OPTIONAL, -- the name of the claimant or role objectDigestInfo [2] ObjectDigestInfo OPTIONAL -- used to directly authenticate the holder, -- for example, an executable }
AttCertIssuer ::= CHOICE { v1Form GeneralNames, -- MUST NOT be used in this -- profile v2Form [0] V2Form -- v2 only
V2Form ::= SEQUENCE { issuerName GeneralNames OPTIONAL, baseCertificateID [0] IssuerSerial OPTIONAL, objectDigestInfo [1] ObjectDigestInfo OPTIONAL -- issuerName MUST be present in this profile -- baseCertificateID and objectDigestInfo MUST NOT -- be present in this profile }
AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY DEFINED BY algorithm OPTIONAL }
CertificateSerialNumber ::= INTEGER
AttCertValidityPeriod ::= SEQUENCE { notBeforeTime GeneralizedTime, notAfter GeneralizedTime }
Attribute ::= SEQUENCE { type AttributeType, values SET OF AttributeValue -- at least one value is required }
AttributeType ::= OBJECT IDENTIFIER
AttributeValue ::= ANY DEFINED BY AttributeType
UniqueIdentifier ::= BIT STRING
Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
Extension ::= SEQUENCE { extnID OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING }
For a detailled description of the several fields refer to RFC 3281)
For each value extists a set<Value>
and a get<Value>
method.
After creating a new attribute certificate by means of the default constructor
, setting AC holder
and AC issuer
, setting validity
period and serial number
, and
adding any attribute
and extension
to be included,
finally the certificate can be signed
with the private key of the issuer.
The AttributeCertificate(byte[])
and
AttributeCertificate(InputStream)
constructors
may be used for parsing an AttributeCertificate from its DER encoding.
The Internet Attribute Certificate Profile for Authorization ( RFC 3281) only specified attribute certificate with version number v2 (1). However, this class is also able to parse v1 (0) attribute certificates according to the ITU X.509-1997 specification.
X509Extensions
,
V3Extension
,
UnknownExtension
,
Holder
,
AttCertIssuer
,
Attribute
, Serialized FormInner classes inherited from class java.security.cert.Certificate |
Certificate.CertificateRep |
Constructor Summary | |
AttributeCertificate()
Default constructor for creating a new empty attribute certificate. |
|
AttributeCertificate(byte[] array)
Creates an AttributeCertificate form a PEM or DER byte array. |
|
AttributeCertificate(InputStream is)
Creates an AttributeCertificate from an input stream. |
Method Summary | |
void |
addAttribute(Attribute attribute)
Adds one Atribute to this attribute certificate. |
void |
addExtension(V3Extension e)
Adds the given X509v3 extension. |
void |
checkValidity()
Checks if this attribute certificate currently is valid. |
void |
checkValidity(Date date)
Checks if this attribute certificate would be valid at the given date value. |
int |
countExtensions()
Returns the number of extensions included into this certificate. |
void |
decode(ASN1Object obj)
Creates an AttributeCertificate from an ASN1Object. |
void |
decode(InputStream is)
Decodes an AttributeCertificate from an inputstream. |
byte[] |
getAcInfo()
Returns the DER encoded AttributeCertificateInfo ASN.1 data
structure of this attribute certificate.
|
Attribute |
getAttribute(ObjectID type)
Gets all the Atributes matching to a specific type (object identifier). |
Enumeration |
getAttributes()
Gets the Atributes of this CertificateRequest. |
Set |
getCriticalExtensionOIDs()
Returns a Set of the OID strings identifying the extension(s) that are marked CRITICAL in this attribute certificate. |
byte[] |
getEncoded()
Returns this attribute certificate as DER encoded ASN.1 data structure |
V3Extension |
getExtension(ObjectID oid)
Returns a specific extension, identified by its object identifier. |
byte[] |
getExtensionValue(String oid)
Returns a byte array representing the DER encoding of the extension value identified by the passed-in OID string. |
byte[] |
getFingerprint()
Returns the fingerprint of this certificate. |
byte[] |
getFingerprint(String digestAlgorithm)
Returns the fingerprint of this certificate calculated with the given hash algorithm. |
byte[] |
getFingerprintSHA()
Get the SHA fingerprint of this attribute certificate. |
Holder |
getHolder()
Returns the Holder of this attribute certificate. |
AttCertIssuer |
getIssuer()
Returns the Issuer of this attribute certificate. |
boolean[] |
getIssuerUniqueID()
Returns the issuer unique identifier of this certificate, or null if no
IssuerUniqueID is specified by this certificate.
|
Set |
getNonCriticalExtensionOIDs()
Returns a Set of the OID strings for the extension(s) marked NON-CRITICAL in this attribute certificate. |
Date |
getNotAfterTime()
Returns the notAfterTime value of this certificate.
|
Date |
getNotBeforeTime()
Returns the notBeforeTime value of this certificate.
|
PublicKey |
getPublicKey()
Returns null !!!!
|
BigInteger |
getSerialNumber()
Returns the serial number of this certificate as BigInteger .
|
String |
getSigAlgName()
Returns the name of the signature algorithm used by the issuer for signing this certificate. |
String |
getSigAlgOID()
Returns the OID of the signature algorithm used by the issuer for signing this certificate. |
byte[] |
getSigAlgParams()
Returns the algorithm parameters associated with the signature algorithm used by the issuer for signing this certificate. |
byte[] |
getSignature()
Returns the signature value of this certificate. |
AlgorithmID |
getSignatureAlgorithm()
Returns the signature algorithm of this certificate. |
int |
getVersion()
Returns the version number of this certificate as int .
|
boolean |
hasExtensions()
Checks, if there are any extensions included into this certificate. |
boolean |
hasUnsupportedCriticalExtension()
Returns true if there are unsupported critical extensions. |
Enumeration |
listExtensions()
Returns an enumeration of all extensions included in this attribute certificate. |
void |
removeAllAttributes()
Removes all attributes included. |
void |
removeAllExtensions()
Removes all extensions from this attribute certificate. |
Attribute |
removeAttribute(ObjectID type)
Removes the attribute of the given type, if present. |
boolean |
removeExtension(ObjectID oid)
Removes the extension specified by its object identifier. |
void |
setAttributes(Attribute[] attributes)
Sets the Atributes of this Attribute certificate. |
void |
setHolder(Holder holder)
Sets the Holder of this attribute certificate. |
void |
setIssuer(AttCertIssuer issuer)
Sets the issuer of this attribute certificate. |
void |
setIssuerUniqueID(boolean[] id)
Sets the issuer unique ID for this certificate. |
void |
setNotAfterTime(Date validNotAfter)
Sets the notAfterTime value of this certificate.
|
void |
setNotBeforeTime(Date validNotBefore)
Sets the notBeforeTime value of this atttribute certificate.
|
void |
setSerialNumber(BigInteger serialNumber)
Sets the serial number of this certificate. |
void |
setSignature(byte[] signatureValue)
Sets the signature value of this attribute certificate. |
void |
setSignatureAlgorithm(AlgorithmID signatureAlg)
Sets the signature algorithm to be used for signing. |
void |
sign(AlgorithmID signatureAlg,
PrivateKey issuerPK)
Signs the attribute certificate with the private key of the issuer. |
void |
sign(AlgorithmID signatureAlg,
PrivateKey issuerPK,
String provider)
Signs the attribute certificate with the private key of the issuer. |
ASN1Object |
toASN1Object()
Returns this attribute certificate as an ASN1Object. |
byte[] |
toByteArray()
Returns this attribute certificate as DER encoded ASN.1 data structure. |
String |
toString()
Returns a string that represents the contents of the certificate. |
String |
toString(boolean detailed)
Returns a string that represents the contents of the certificate. |
void |
verify(DSAPublicKey key,
DSAParameterSpec dsaParams)
Uses the given public DSA key and DSA parameters to verify this certificate. |
void |
verify(PublicKey key)
Verifies a certificate using the given public key. |
void |
verify(PublicKey key,
String sigProvider)
Uses the given public key to verify a certificate based on a signature algorithm supplied by the specified provider. |
void |
writeTo(OutputStream os)
Writes this attribute certificate DER encoded to the given output stream. |
Methods inherited from class java.security.cert.Certificate |
equals, getType, hashCode, writeReplace |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public AttributeCertificate()
Any value may be set using the corrseponding set<Value>
method.
According to the Internet Attribute Certificate Profile for Authorization
presented in
RFC 3281) the version number is set to 2
indicating a Version 2
attribute certificate. Note that
this is not the default version number (1).
public AttributeCertificate(InputStream is) throws IOException, CertificateException
The supplied attribute certificate can be in PEM or DER format.
This constructor reads and decodes an AttributeCertificate that may have been
previously written (encoded) by calling method writeTo(OutputStream)
.
For instance:
InputStream fis = new FileInputStream("cert.der"); AttributeCertificate cert = new AttributeCertificate(fis); fis.close();
is
- InputStream from which to create the certificateIOException
- if the certificate cannot not be readCertificateException
- if the certificate cannot be parsedpublic AttributeCertificate(byte[] array) throws CertificateException
This constructor may be used for parsing an already exisiting
AttributeCertifcate
ASN.1 object, supplied as DER encoded
byte array, which may have been created by calling the toByteArray
or the getEncoded
method.
array
- the byte array containing the DER encoded certificateCertificateException
- if the format of the cert is wrongMethod Detail |
public void decode(ASN1Object obj) throws CodingException
The given ASN1Object represents an already existing AttributeCertificate
which may have been created by calling the toASN1Object
method.
decode
in interface ASN1Type
obj
- the attribute certificate as ASN1ObjectCodingException
- if there is a problem when parsing the certificatepublic void decode(InputStream is) throws IOException, CertificateException
is
- the InputStream from where the encoded certificate shall be readIOException
- if an I/O error occursCertificateException
- if the certificate cannot be parsedpublic void sign(AlgorithmID signatureAlg, PrivateKey issuerPK) throws CertificateException, InvalidKeyException, NoSuchAlgorithmException
signatureAlg
- the AlgorithmID of the signature algorithmissuerPK
- the private key of the issuerCertificateException
- if the certificate could not be signedInvalidKeyException
- if the format of the key is wrongNoSuchAlgorithmException
- if there is no implementation for the
specified algorithmpublic void sign(AlgorithmID signatureAlg, PrivateKey issuerPK, String provider) throws CertificateException, InvalidKeyException, NoSuchAlgorithmException
signatureAlg
- the AlgorithmID of the signature algorithmissuerPK
- the private key of the issuerCertificateException
- if the certificate could not be signedInvalidKeyException
- if the format of the key is wrongNoSuchAlgorithmException
- if there is no implementation for the
specified algorithmpublic void setSignature(byte[] signatureValue) throws CertificateException
This method provides an alternative to method sign
when
it is required to set the signature value from outside (e.g. calculated
by means of a smartcard):
AttributeCertificate cert = ...; ... // set issuer, holder, attributes, ... ... // set the signature algorithm to be used for signing cert.setSignatureAlgorithm(AlgorithmID.sha1WithRSAEncryption); // get the to-be-signed value byte[] acInfo = cert.getAcInfo(); // now calculate the signature over the attribute certificate info byte[] signatureValue = calculateSignature(acInfo); // and set the signatureValue cert.setSignature(signatureValue); // encode the certificate byte[] encodedCert = cert.getEncoded();
signatureValue
- the signature calculated outsideCertificateException
- if the certificate could not be signedpublic void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException
Attribute certificates have a limited period of validity prescribed by the
notBeforeTime
and notAfterTime
values.
This method just checks if the given date/time value lies between notBeforeTime
and notAfterTime
and throws an exception if this does not come true.
CertificateExpiredException
- if the certificate alreay has expired or the
notAfterTime value yet has not been setCertificateNotYetValidException
- if the certificate yet is not valid or the
notBeforeTime value yet has not been setcheckValidity(java.util.Date)
public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException
notBeforeTime
and notAfterTime
values:
AttCertValidityPeriod ::= SEQUENCE { notBeforeTime GeneralizedTime, notAfterTime GeneralizedTime }The
notBeforeTime
and notAfterTime
time values can be set
by using the setNotBeforeTime
and
setNotAfterTime
methods.
This checkValidity
method only calls checkValidity(Date)
with the current date to check if it lies between
the two time values specified by notBeforeTime
and notAfterTime
.
CertificateExpiredException
- if the certificate already has expiredCertificateNotYetValidException
- if the certificate is yet not validGeneralizedTime
public byte[] getEncoded() throws CertificateEncodingException
getEncoded
in class Certificate
CertificateEncodingException
- if the certificate cannot be encoded correctlypublic int getVersion()
int
.
The version number may specify a v1 or v2 attribute certificate.
ASN.1 definition:
AttCertVersion ::= INTEGER { v1(0), v2(1) }
int
,
1 for a v1 cert, 2 for a v2 certpublic BigInteger getSerialNumber()
BigInteger
.
Attribute certificates are labelled with positive serial numbers by the issuing
certification authority for unequivocally identifying them:
ASN.1 definition:
CertificateSerialNumber ::= INTEGER
BigInteger
public AttCertIssuer getIssuer()
The issuer
of an attribute
certificate either may be represented as V1Form
or as V2Form
:
AttCertIssuer ::= CHOICE { v1Form GeneralNames, -- MUST NOT be used in this -- profile v2Form [0] V2Form -- v2 only }Attribute certifcates conforming to the Internet Attribute Certificate Profile for Authorization presented in RFC 3281 are not allowed to use the
V1Form
choice
for representing the issuer, theay should use the V2Form
:
V2Form ::= SEQUENCE { issuerName GeneralNames OPTIONAL, baseCertificateID [0] IssuerSerial OPTIONAL, objectDigestInfo [1] ObjectDigestInfo OPTIONAL -- issuerName MUST be present in this profile -- baseCertificateID and objectDigestInfo MUST NOT ACs conforming to this profile MUST use the v2Form choice, which MUST contain one and only one GeneralName in the issuerName, which MUST contain a non-empty distinguished name in the directoryName field. This means that all AC issuers MUST have non-empty distinguished names. ACs conforming to this profile MUST omit the baseCertificateID and objectDigestInfo fields. Part of the reason for the use of the v2Form containing only an issuerName is that it means that the AC issuer does not have to know which PKC the AC verifier will use for it (the AC issuer). Using the baseCertificateID field to reference the AC issuer would mean that the AC verifier would have to trust the PKC that the AC issuer chose (for itself) at AC creation time.
Use class Name
for
creating a V2Form
attCertIssuer holding
a directoryName
to be set
as the issuer of an AttributeCertificate:
Name issuerName = ...; V2Form v2Form = new V2Form(issuerName); attributeCertificate.setIssuer(v2Form);
AttCertIssuer
,
V1Form
,
V2Form
public Holder getHolder()
The Attribute certifcates conforming to the Internet Attribute
Certificate Profile for Authorization presented in RFC 3281
specifies the Holder
type for identifying the entity to
which the AttributeCertificate
belongs:
Holder ::= SEQUENCE { baseCertificateID [0] IssuerSerial OPTIONAL, -- the issuer and serial number of -- the holder's Public Key Certificate entityName [1] GeneralNames OPTIONAL, -- the name of the claimant or role objectDigestInfo [2] ObjectDigestInfo OPTIONAL -- used to directly authenticate the holder, -- for example, an executable }For any environment where the AC is passed in an authenticated message or session and where the authentication is based on the use of an X.509 public key certificate, the
holder
should be identified by means of a baseCertificateID
pointing to the right X.509 public key certificate by issuer
name and issuer-specific serial number, e.g.:
X509Certificate baseCert = ...; IssuerSerial baseCertificateID = new IssuerSerial(baseCert); Holder holder = new Holder(); holder.setBaseCertificateID(baseCertificateID); attributeCertificate.setHolder(holder);If the holder field uses the
entityName
option and the underlying authentication is based on a PKC,
then the entityName MUST be the same as the PKC subject field or one of
the values of the PKC subjectAltName field extension (if present), e.g.:
X509Certificate cert = ...; Name subject = (Name)cert.getSubjectDN(); GeneralName subjectName = new GeneralName(GeneralName.directoryName, subject); GeneralNames entityName = new GeneralNames(subjectName); Holder holder = new Holder(); holder.setEntityName(entityName); attributeCertificate.setHolder(holder);The
ObjectDigestInfo
component may be
used for linking the AC to an object by placing a hash of that
object into the holder field of the AC. For example, this allows
production of ACs that are linked to public keys rather than names
(see RFC 3281 for
more information):
// the public key to which to link the AC: PublicKey publicKey = ...; // the digest algorithm to use AlgorithmID digestAlgorithm = ...; ObjectDigestInfo odi = new ObjectDigestInfo(publicKey, digestAlgorithm); Holder holder = new Holder(); holder.setObjectDigestInfo(odi); attributeCertificate.setHolder(holder);
Holder
,
IssuerSerial
,
ObjectDigestInfo
,
GeneralNames
public PublicKey getPublicKey()
null
!!!!
Attention!!! This method anytime returns null
since a Attribute Certificate does not contain a public key.
This method only is included because inherited from
java.security.cert.Certificate
which is the highest
JCA "cerrificate level" and extended by this class to
incorporate attribute certificates into the JCA certificate
management.
getPublicKey
in class Certificate
null
public Date getNotBeforeTime()
notBeforeTime
value of this certificate.
The notBeforeTime
value denotes the date on which the certificate
becomes valid and can be set using the setNotBeforeTime
method.
null
if the notBefore date has yet not been setcheckValidity(java.util.Date)
public Date getNotAfterTime()
notAfterTime
value of this certificate.
The notAfterTime
value denotes the date on which
the certificate´s validity expires. The notAfterTime
date can be
set using the setNotAfterTime
method.
null
if the notAfter date has yet not been setcheckValidity(java.util.Date)
public byte[] getAcInfo() throws CertificateEncodingException
AttributeCertificateInfo
ASN.1 data
structure of this attribute certificate.
AttributeCertificateInfo ::= SEQUENCE { version AttCertVersion DEFAULT v1, holder Holder, issuer AttCertIssuer, signature AlgorithmIdentifier, serialNumber CertificateSerialNumber, attrCertValidityPeriod AttCertValidityPeriod, attributes SEQUENCE OF Attribute, issuerUniqueID UniqueIdentifier OPTIONAL, extensions Extensions OPTIONAL }
AttributeCertificateInfo
as DER encoded ASN.1 structureCertificateEncodingException
- if an encoding error occurspublic void setSignatureAlgorithm(AlgorithmID signatureAlg)
getAcInfo
before signing the cert. When using this fearure
an application itsself is responsible to ensure that the signature
algorithm specified by this method is equal to that supplied to
the sign(AlgorithmID, PrivateKey)
method when finally signing the certificate.signatureAlg
- the signature algorithm to be used for signingpublic byte[] getSignature()
public String getSigAlgName()
null
if the signature algorithm yet has not been setpublic String getSigAlgOID()
null
if the signature algorithm yet has not been setObjectID
,
AlgorithmID
public byte[] getSigAlgParams()
null
if there are no parameters used or the signature algorithm
yet has been not setpublic boolean[] getIssuerUniqueID()
null
if no
IssuerUniqueID
is specified by this certificate.
An IssuerUniqueID only may be included if the attribute certificate is linked
to a public key certificate
(PKC) and this PKC
contains the issuer unique id. In this case the issuer unique ids of PKC and
corresponding AC have to be the same.
The issuer unique identifier is defined as ASN.1 BIT STRING structure:
UniqueIdentifier ::= BIT STRINGThis method scans the issuer unique identifier and returns it as an array of boolean values.
IssuerUniqueID
of this certificate as array of booleans, or
null
if no issuer unique identifier is speciifedpublic void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
verify
in class Certificate
key
- the public key (of the issuer) to verify the certsigProvider
- the name of the provider supplying the signature algorithmCertificateException
- if an encoding error occursNoSuchAlgorithmException
- if there is no implementation for the algorithm used to sign this certInvalidKeyException
- if the format of the public key is wrongNoSuchProviderException
- if there is no such providerSignatureException
- if the signature does not verifypublic void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
This method only calls verify(PublicKey, String)
setting the provider name to
null
for relying on the default provider signature architecture.
verify
in class Certificate
key
- the public key of the issuerCertificateException
- if an encoding error occursNoSuchAlgorithmException
- if there is no implementation for the algorithm used to sign this certInvalidKeyException
- if the format of the public key is wrongNoSuchProviderException
- if there is no default providerSignatureException
- if the signature does not verifypublic void verify(DSAPublicKey key, DSAParameterSpec dsaParams) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
Attention! This method only may be used to verify a certificate that has been signed with the DSA algorithm and the public DSA key now used for verification does not contain the DSA parameters. Additionally this method only can be used with the IAIK provider.
key
- the public DSA key (of the issuer) to verify the certdsaParams
- the DSA parameters provided by other meansCertificateException
- if an encoding error occursNoSuchAlgorithmException
- if there is no implementation for the algorithm used to sign this certInvalidKeyException
- if the format of the public key is wrongNoSuchProviderException
- if there is no such providerSignatureException
- if the signature does not verifypublic ASN1Object toASN1Object()
toASN1Object
in interface ASN1Type
public byte[] toByteArray()
public void writeTo(OutputStream os) throws IOException
os
- the output stream where the certifiacte shall be written toIOException
- if an I/O error occurspublic void setSerialNumber(BigInteger serialNumber)
serialNumber
- the serial number of the certificate as BigIntegergetSerialNumber()
public void setIssuer(AttCertIssuer issuer)
The issuer
of an attribute
certificate either may be represented as V1Form
or as V2Form
:
AttCertIssuer ::= CHOICE { v1Form GeneralNames, -- MUST NOT be used in this -- profile v2Form [0] V2Form -- v2 only }Attribute certifcates conforming to the Internet Attribute Certificate Profile for Authorization presented in RFC 3281 are not allowed to use the
V1Form
choice
for representing the issuer, theay should use the V2Form
:
V2Form ::= SEQUENCE { issuerName GeneralNames OPTIONAL, baseCertificateID [0] IssuerSerial OPTIONAL, objectDigestInfo [1] ObjectDigestInfo OPTIONAL -- issuerName MUST be present in this profile -- baseCertificateID and objectDigestInfo MUST NOT ACs conforming to this profile MUST use the v2Form choice, which MUST contain one and only one GeneralName in the issuerName, which MUST contain a non-empty distinguished name in the directoryName field. This means that all AC issuers MUST have non-empty distinguished names. ACs conforming to this profile MUST omit the baseCertificateID and objectDigestInfo fields. Part of the reason for the use of the v2Form containing only an issuerName is that it means that the AC issuer does not have to know which PKC the AC verifier will use for it (the AC issuer). Using the baseCertificateID field to reference the AC issuer would mean that the AC verifier would have to trust the PKC that the AC issuer chose (for itself) at AC creation time.
Use class Name
for
creating a V2Form
attCertIssuer holding
a directoryName
to be set
as the issuer of an AttributeCertificate:
Name issuerName = ...; V2Form v2Form = new V2Form(issuerName); attributeCertificate.setIssuer(v2Form);
getIssuer()
,
AttCertIssuer
,
V1Form
,
V2Form
public void setNotBeforeTime(Date validNotBefore)
notBeforeTime
value of this atttribute certificate.
For instance:
GregorianCalendar date = (GregorianCalendar)Calendar.getInstance(); cert.setNotBeforeTime(date.getTime());
The certificate is not valid before this Date.
validNotBefore
- Date when cert will become validgetNotBeforeTime()
public void setNotAfterTime(Date validNotAfter)
notAfterTime
value of this certificate.
For instance:
GregorianCalendar date = (GregorianCalendar)Calendar.getInstance(); date.add(Calendar.MONTH, 6); cert.setNotAfterTime(date.getTime());
The certificate will expire at this Date.
validNotAfter
- Date on which the certificate will expiregetNotAfterTime()
public void setHolder(Holder holder)
The Attribute certifcates conforming to the Internet Attribute
Certificate Profile for Authorization presented in RFC 3281
specifies the Holder
type for identifying the entity to
which the AttributeCertificate
belongs:
Holder ::= SEQUENCE { baseCertificateID [0] IssuerSerial OPTIONAL, -- the issuer and serial number of -- the holder's Public Key Certificate entityName [1] GeneralNames OPTIONAL, -- the name of the claimant or role objectDigestInfo [2] ObjectDigestInfo OPTIONAL -- used to directly authenticate the holder, -- for example, an executable }For any environment where the AC is passed in an authenticated message or session and where the authentication is based on the use of an X.509 public key certificate, the
holder
should be identified by means of a baseCertificateID
pointing to the right X.509 public key certificate by issuer
name and issuer-specific serial number, e.g.:
X509Certificate baseCert = ...; IssuerSerial baseCertificateID = new IssuerSerial(baseCert); Holder holder = new Holder(); holder.setBaseCertificateID(baseCertificateID); attributeCertificate.setHolder(holder);If the holder field uses the
entityName
option and the underlying authentication is based on a PKC,
then the entityName MUST be the same as the PKC subject field or one of
the values of the PKC subjectAltName field extension (if present), e.g.:
X509Certificate cert = ...; Name subject = (Name)cert.getSubjectDN(); GeneralName subjectName = new GeneralName(GeneralName.directoryName, subject); GeneralNames entityName = new GeneralNames(subjectName); Holder holder = new Holder(); holder.setEntityName(entityName); attributeCertificate.setHolder(holder);The
ObjectDigestInfo
component may be
used for linking the AC to an object by placing a hash of that
object into the holder field of the AC. For example, this allows
production of ACs that are linked to public keys rather than names
(see RFC 3281 for
more information):
// the public key to which to link the AC: PublicKey publicKey = ...; // the digest algorithm to use AlgorithmID digestAlgorithm = ...; ObjectDigestInfo odi = new ObjectDigestInfo(publicKey, digestAlgorithm); Holder holder = new Holder(); holder.setObjectDigestInfo(odi); attributeCertificate.setHolder(holder);
holder
- the holder of this attribute certificateHolder
,
IssuerSerial
,
ObjectDigestInfo
,
GeneralNames
public void setIssuerUniqueID(boolean[] id)
An IssuerUniqueID only may be included if the attribute certificate is linked
to a public key certificate
(PKC) and this PKC
contains the issuer unique id. In this case the issuer unique ids of PKC and
corresponding AC have to be the same.
The issuer unique identifier is defined as ASN.1 BIT STRING structure:
UniqueIdentifier ::= BIT STRING
id
- the unique identifier of the issuer as array of boolean valuesgetIssuerUniqueID()
public AlgorithmID getSignatureAlgorithm()
AlgorithmID
public byte[] getFingerprint()
public byte[] getFingerprint(String digestAlgorithm) throws NoSuchAlgorithmException
digestAlgorithm
- the digest algorithm to be usedNoSuchAlgorithmException
- if the requested algorithm is not supportedpublic byte[] getFingerprintSHA()
public String toString()
toString
in class Certificate
public Set getCriticalExtensionOIDs()
getCriticalExtensionOIDs
in interface X509Extension
null
getNonCriticalExtensionOIDs()
public Set getNonCriticalExtensionOIDs()
getNonCriticalExtensionOIDs
in interface X509Extension
getCriticalExtensionOIDs()
public byte[] getExtensionValue(String oid)
The oid
string is represented by a set of positive whole numbers
separated by periods, e.g. "2.5.29.55" for the ACTargeting
extension.
In ASN.1, the Extensions
field is defined as a SEQUENCE of Extension:
Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
Extension ::= SEQUENCE { extnID OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING }
where critical
specifies whether an extension has to be treated
as being critical or not; the default value is FALSE. An extension can be identified by
its object identifier, given in the extnID
field. The value of the extension
is represented as ASN.1 OCTET STRING data structure in the extnValue
field. Only one instance of a particular extension may be present in a particular
certificate.
The byte value returned by this method represents the DER encoding of the extnValue (OCTET_STRING) from above, and the value of this OCTET STRING represents the DER encoding of the specific extension´s ASN.1 representation itsself.
Attention: For compatibility reasons to the standard JCA certificate API this method has been changed to return the OCTET STRING value as described above. Prior versions of this class have returned the DER encoding of the specific extension´s ASN.1 representation itsself.
getExtensionValue
in interface X509Extension
oid
- the Object Identifier of the extension to be queried fornull
if it is not presentpublic void addExtension(V3Extension e) throws X509ExtensionException
For reading back some extension, use the
getExtension(ObjectID)
method.
e
- the X509v3 extension to add to the list of extensionsX509ExtensionException
- if an error occurs while DER encoding the extensionV3Extension
public boolean removeExtension(ObjectID oid)
objectID
- the object ID of the extension to removetrue
if the extension has been successfully removed,
false
otherwisepublic void removeAllExtensions()
public Enumeration listExtensions()
The enumeration returned may contain unknown extensions (instances of
UnknownExtension
if there are any extensions included in this certificate, for which there
exists no registered implementation, and it may contain error extensions
(instances of ErrorExtension
) indicating extensions which cannot be
parsed properly because of some kind of error.
If any extension cannot be parsed properly, an ErrorExtension
is created from it and written
to the enumeration list returned by this method.
null
if there are no
extensions present at allpublic boolean hasExtensions()
true
if there are extensions, false
if notpublic boolean hasUnsupportedCriticalExtension()
hasUnsupportedCriticalExtension
in interface X509Extension
public int countExtensions()
public V3Extension getExtension(ObjectID oid) throws X509ExtensionInitException
If the extension cannot be initialized
for some reason, an X509ExtensionInitException is thrown. If the requested extension is
an unknown extension, which is not supported by a registered implementation,
this method creates and returns an UnknownExtension
which may be queried for obtaining as much information
as possible about the unknown extension.
objectID
- the object ID of the extensionnull
if the requested
extension is not presentX509ExtensionInitException
- if the extension can not be initializedpublic void addAttribute(Attribute attribute)
Since only one attribute per attribute type is allowed to be included in an attribute certificate this method replaces an already included attribute of same type with the given attribute.
Note that the attributes have to be set before the certificate is
signed
with the issuer´s private key!
attribute
- the Attribute to addpublic void setAttributes(Attribute[] attributes)
iaik.asn1.structures.Attribute
objects.
signed
with the issuer´s private key!attributes
- the Attributes to setpublic void removeAllAttributes()
public Attribute removeAttribute(ObjectID type)
type
- the type OID identifying the attribute in mindnull
if no attribute
has been removed because no attribute with the given type
is presentpublic Enumeration getAttributes()
null
is returned.
Otherwise the atributes are returned as an array of
iaik.asn1.structures.Attribute
objects:
Attribute[] attributes = request.getAttributes(); if (attributes != null) { for (int i = 0; i < attributes.length; i++) { Attribute attr = attributes[i]; System.out.println(attr.getType()); ASN1Object[] asn1Obj = attr.getValue(); for (int j = 0; j < asn1Obj.length; j++) { System.out.println(asn1Obj[j].toString()); } } }
null
if there are no attributes includedpublic Attribute getAttribute(ObjectID type)
null
is returned.
Otherwise the matching atributes are returned as an array of
iaik.asn1.structures.Attribute
objects. The following sample queries if the challangePassword attribute
is included:
Attribute[] attributes = request.getAttributes(ObjectID.challengePassword); if (attributes != null) { //expected only one: Attribute attr = attributes[0]; System.out.println(attr.getType()); ASN1Object[] asn1Obj = attr.getValue(); //again, only one expected: System.out.println(asn1Obj[0].getValue()); }
null
if there are no attributes of the given type includedpublic String toString(boolean detailed)
detailed
- whether or not to give detailed information about the certificate.
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |