|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.ArrayList
|
+--codec.asn1.ASN1AbstractCollection
|
+--codec.asn1.ASN1Sequence
|
+--codec.x509.X509TBSCertificate
Implements a X.509v3 certificate TBS block according to the following ASN.1 data structure:
TBSCertificate ::= SEQUENCE {
version [0] EXPLICIT Version DEFAULT v1,
serialNumber CertificateSerialNumber,
signature AlgorithmIdentifier,
issuer Name,
validity Validity,
subject Name,
subjectPublicKeyInfo SubjectPublicKeyInfo,
issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, -- If present, version must be v2 or v3
subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, -- If present, version must be v2 or v3
extensions [3] EXPLICIT Extensions OPTIONAL -- If present, version must be v3
}
UniqueIdentifier ::= BIT STRING
Validity ::= SEQUENCE {
notBefore Time,
notAfter Time
}
Time ::= CHOICE {
utcTime UTCTime,
generalTime GeneralizedTime
}
If you want to create a certificate, you should create a
X509TBSCertificate, fill it with useful data
(certificate serial number, validity period, subject and issuer DN, subject
public key) and the signature algorithm!
Note that you have to set the signature algorithm before encoding a X509TBSCertificate or putting it into a X509Certificate!
Certificate version will be set automatically to "V2" if issuerUniqueID or subjectUniqueID is set and to "V3" if any extension is added. Version defaults to "V1".
Example:
... tbd
| Field Summary | |
static int |
DEFAULT_VERSION
The default version identifier for this class, which is v3(2). |
| Fields inherited from class java.util.AbstractList |
modCount |
| Constructor Summary | |
X509TBSCertificate()
Constructor that builds the data structure |
|
| Method Summary | |
void |
addExtension(X509Extension ext)
Adds an extension to this certificate. |
int |
getBasicConstraints()
From java.security.cert.X509Certificate. |
Set |
getCriticalExtensionOIDs()
From java.security.cert.X509Extension. |
byte[] |
getEncoded()
returns the DER-encoded bytearray of this certificate |
Collection |
getExtensions()
Returns a Collection containing all extensions |
byte[] |
getExtensionValue(String ex)
From java.security.cert.X509Extension. |
Principal |
getIssuerDN()
From java.security.cert.X509Certificate. |
boolean[] |
getIssuerUniqueID()
From java.security.cert.X509Certificate. |
boolean[] |
getKeyUsage()
From java.security.cert.X509Certificate. |
Set |
getNonCriticalExtensionOIDs()
From java.security.cert.X509Extension. |
Date |
getNotAfter()
From java.security.cert.X509Certificate. |
Date |
getNotBefore()
From java.security.cert.X509Certificate. |
PublicKey |
getPublicKey()
From java.security.cert.X509Certificate. |
BigInteger |
getSerialNumber()
From java.security.cert.X509Certificate. |
String |
getSigAlgName()
From java.security.cert.X509Certificate. |
String |
getSigAlgOID()
From java.security.cert.X509Certificate. |
byte[] |
getSigAlgParams()
From java.security.cert.X509Certificate. |
Principal |
getSubjectDN()
From java.security.cert.X509Certificate. |
boolean[] |
getSubjectUniqueID()
From java.security.cert.X509Certificate. |
int |
getVersion()
Returns the version of this X509 certificate (0=v1, 1=v2, 2=v3) |
boolean |
hasUnsupportedCriticalExtension()
From java.security.cert.X509Extension. |
void |
setIssuerDN(Principal nissuer)
Sets the issuers distinguished name (DN). |
void |
setIssuerDN(Principal nissuer,
int encType)
needed to explicitly name an encoding method in order to change between encodings during runtime. |
void |
setIssuerUniqueID(byte[] nid)
Sets the issuer's unique id. |
void |
setNotAfter(Calendar nnaf)
Sets the "not after" field. |
void |
setNotAfter(Date nnaf)
Sets the "not after" field. |
void |
setNotBefore(Calendar nnbf)
Sets the "not before" field. |
void |
setNotBefore(Date nnbf)
Sets the "not before" field. |
void |
setSerialNumber(BigInteger nsnr)
Sets the serial number of this certificate |
void |
setSerialNumber(int nsnr)
Sets the serial number of this certificate |
void |
setSignatureAlgorithm(AlgorithmIdentifier aid)
Sets the signature algorithm. |
void |
setSubjectDN(Principal nsubject)
Sets the subject's distinguished name (DN). |
void |
setSubjectDN(Principal nsubject,
int encType)
same as above but with an explicit name encoding |
void |
setSubjectPublicKey(PublicKey pk)
Sets the subject's public key |
void |
setSubjectUniqueID(byte[] nid)
Sets the subjects's unique id. |
void |
setVersion(int version)
Sets the version number of this instance explicitly. |
String |
toString()
human-readable String representation of this certificate |
| Methods inherited from class codec.asn1.ASN1Sequence |
getTag |
| Methods inherited from class codec.asn1.ASN1AbstractCollection |
checkConstraints, decode, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, 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 class java.util.AbstractList |
equals, hashCode, iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
containsAll, remove, removeAll, retainAll |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.io.Externalizable |
readExternal, writeExternal |
| Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Methods inherited from interface java.util.List |
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList |
| Field Detail |
public static final int DEFAULT_VERSION
| Constructor Detail |
public X509TBSCertificate()
| Method Detail |
public void addExtension(X509Extension ext)
ext - the extension to be added.public int getBasicConstraints()
BasicConstraints ::= SEQUENCE {
cA BOOLEAN DEFAULT FALSE,
pathLenConstraint INTEGER (0..MAX) OPTIONAL
}
public Set getCriticalExtensionOIDs()
public byte[] getEncoded()
throws CertificateEncodingException
CertificateEncodingException - if TBSCertificate could not be encoded correctlypublic Collection getExtensions()
public byte[] getExtensionValue(String ex)
public Principal getIssuerDN()
public boolean[] getIssuerUniqueID()
public boolean[] getKeyUsage()
KeyUsage ::= BIT STRING {
digitalSignature (0),
nonRepudiation (1),
keyEncipherment (2),
dataEncipherment (3),
keyAgreement (4),
keyCertSign (5),
cRLSign (6),
encipherOnly (7),
decipherOnly (8)
}
public Set getNonCriticalExtensionOIDs()
public Date getNotAfter()
public Date getNotBefore()
public PublicKey getPublicKey()
throws NoSuchAlgorithmException
public BigInteger getSerialNumber()
public String getSigAlgName()
public String getSigAlgOID()
public byte[] getSigAlgParams()
public Principal getSubjectDN()
public boolean[] getSubjectUniqueID()
public int getVersion()
public void setVersion(int version)
version - The internal version number, one of v1(0), v2(1), v3(2).IllegalArgumentException - if version number is smaller than 2 but extensions are
present.public boolean hasUnsupportedCriticalExtension()
Currently, this function will always return false since extensions are managed in an abstract way.
public void setIssuerDN(Principal nissuer,
int encType)
nissuer - the name of the issuerencType - ITU Tag of the Stringtypepublic void setIssuerDN(Principal nissuer)
nissuer - the Principal object describing the issuer.public void setIssuerUniqueID(byte[] nid)
nid - the issuer's unique idpublic void setNotAfter(Calendar nnaf)
nnaf - "not after" datepublic void setNotAfter(Date nnaf)
nnaf - "not after" datepublic void setNotBefore(Calendar nnbf)
nnbf - "not before" datepublic void setNotBefore(Date nnbf)
nnbf - "not before" datepublic void setSerialNumber(int nsnr)
public void setSerialNumber(BigInteger nsnr)
public void setSignatureAlgorithm(AlgorithmIdentifier aid)
aid - AlgorithmID of the signature algorithmpublic void setSubjectDN(Principal nsubject)
nsubject - the Principal object describing the subject.
public void setSubjectDN(Principal nsubject,
int encType)
nsubject - encType - (the String Type the Name shall be encoded.
public void setSubjectPublicKey(PublicKey pk)
throws InvalidKeyException
public void setSubjectUniqueID(byte[] nid)
nid - the subjects's unique idpublic String toString()
toString in class ASN1AbstractCollectioncodec.asn1.ASN1AbstractCollection
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||