|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<E> java.util.ArrayList codec.asn1.ASN1AbstractCollection codec.asn1.ASN1Sequence codec.x509.X509TBSCertificate
public class 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,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 | |
---|---|
private ASN1SequenceOf |
extensions_
|
private ASN1TaggedType |
extensionsTag_
|
private Name |
issuer_
|
private ASN1BitString |
issuerUniqueID_
|
private ASN1TaggedType |
issuerUniqueIDTag_
|
private ASN1Choice |
notAfter_
|
private ASN1Choice |
notBefore_
|
private ASN1Integer |
serialNumber_
|
private AlgorithmIdentifier |
signature_
|
private Name |
subject_
|
private SubjectPublicKeyInfo |
subjectPublicKeyInfo_
|
private ASN1BitString |
subjectUniqueID_
|
private ASN1TaggedType |
subjectUniqueIDTag_
|
private ASN1Integer |
version_
|
private ASN1TaggedType |
versionTag_
|
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 |
readExternal(ObjectInput s)
|
void |
setIssuerDN(Principal nissuer)
Sets the issuers distinguished name (DN). |
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 |
setSubjectPublicKey(PublicKey pk)
Sets the subject's public key |
void |
setSubjectUniqueID(byte[] nid)
Sets the subjects's unique id. |
String |
toString()
human-readable String representation of this certificate |
void |
writeExternal(ObjectOutput s)
|
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, setConstraint, setExplicit, setOptional |
Methods inherited from class java.util.ArrayList |
---|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, 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, removeAll, retainAll |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
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, removeAll, retainAll, subList |
Field Detail |
---|
private ASN1Integer version_
private ASN1TaggedType versionTag_
private ASN1Integer serialNumber_
private AlgorithmIdentifier signature_
private Name issuer_
private ASN1Choice notBefore_
private ASN1Choice notAfter_
private Name subject_
private SubjectPublicKeyInfo subjectPublicKeyInfo_
private ASN1BitString issuerUniqueID_
private ASN1TaggedType issuerUniqueIDTag_
private ASN1BitString subjectUniqueID_
private ASN1TaggedType subjectUniqueIDTag_
private ASN1SequenceOf extensions_
private ASN1TaggedType extensionsTag_
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
NoSuchAlgorithmException
public BigInteger getSerialNumber()
public String getSigAlgName()
public String getSigAlgOID()
public byte[] getSigAlgParams()
public Principal getSubjectDN()
public boolean[] getSubjectUniqueID()
public int getVersion()
public boolean hasUnsupportedCriticalExtension()
Currently, this function will always return false since extensions are managed in an abstract way.
public 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 setSubjectPublicKey(PublicKey pk) throws InvalidKeyException
InvalidKeyException
public void setSubjectUniqueID(byte[] nid)
nid
- the subjects's unique idpublic String toString()
toString
in class ASN1AbstractCollection
public void writeExternal(ObjectOutput s) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput s) throws IOException
readExternal
in interface Externalizable
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |