|
|||||||||
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.pkcs10.CertificationRequest
public class CertificationRequest
PKCS#10 Certification Request. This Object can be used to build a PKCS#10 compliant certification request for a self-created public key pair. The public key and the name of the subject have to be put into this certification request that is to be sent to a certification authority for certificate generation.
PKCS#10 defines the following data structure for certificate requests:
CertificationRequest ::= SEQUENCE { certificationRequestInfo CertificationRequestInfo, signatureAlgorithm AlgorithmIdentifier, signature BIT STRING } CertificationRequestInfo ::= SEQUENCE { version Integer, subject Name, subjectPublicKeyInfo SubjectPublicKeyInfo, attributes [0] IMPLICIT Attributes } Attributes ::= SET OF Attribute -- see PKCS#9To build a PKCS#10 certification request, you can use the constructor
CertificationRequest(PublicKey,Name)
with your public key and name. After
that, you have to call getTBS()
to get the to-be-signed (tbs)
data, sign them outside and call setSignature()
to
fill-in the signature data. After that, you can export the certification
request using getEncoded()
.
Creation date: (18.08.99 15:23:09)
Field Summary | |
---|---|
private ASN1Set |
attributes_
|
private ASN1Sequence |
certificationRequestInfo_
|
private ASN1BitString |
signature_
|
private AlgorithmIdentifier |
signatureAlgorithmIdentifier_
|
private Name |
subject_
|
private SubjectPublicKeyInfo |
subjectPublicKeyInfo_
|
private ASN1Integer |
version_
|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
CertificationRequest()
Structure-constructor that builds the ASN.1 data structure. |
|
CertificationRequest(byte[] enc)
Constructor upon an byte-array that holds the DER-encoded Certification Request. |
|
CertificationRequest(InputStream in)
Constructor upon an input stream. |
|
CertificationRequest(PublicKey pk,
Name sub)
The given public key and name objects are put into this certification request. |
|
CertificationRequest(PublicKey pk,
Name sub,
Collection attr)
Standard-constructor upon JAVA-Objects. |
Method Summary | |
---|---|
List |
getAttributes()
Returns an unmodifiable list view on the attributes. |
byte[] |
getEncoded()
Returns the DER-encoded PKCS#10 data structure. |
PublicKey |
getPublicKey()
Returns the public key inside this Certification Request. |
AlgorithmIdentifier |
getPublicKeyAlgorithm()
Returns the AlgorithmIdentifier describing the public key's algorithm. |
byte[] |
getSignature()
Returns the signature on this certification request that is done by appliying the corresponding private key. |
Name |
getSubjectDN()
Returns the subject's distinguished name. |
byte[] |
getTBS()
Returns the to-be-signed (TBS) data structure, meaning the data to be applied on the signature algorithm. |
void |
setAttributes(Collection attributes)
Sets the given attributes. |
private void |
setPublicKey(PublicKey pk)
Sets the public key. |
void |
setSignature(byte[] sg,
AlgorithmIdentifier algID)
Sets the signature. |
private void |
setSubjectDN(Name sub)
Sets the subject's distinguished name (DN). |
String |
toString()
Human-readable string representation of this Certification Request. |
void |
verify()
With this method, the certification request can be verified in an easy, but less secure way. |
void |
verify(String pro)
With this method, the certification request can be verified in an easy, but less secure way. |
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 ASN1Sequence certificationRequestInfo_
private ASN1Integer version_
private Name subject_
private SubjectPublicKeyInfo subjectPublicKeyInfo_
private ASN1Set attributes_
private AlgorithmIdentifier signatureAlgorithmIdentifier_
private ASN1BitString signature_
Constructor Detail |
---|
public CertificationRequest() throws ASN1Exception
ASN1Exception
public CertificationRequest(byte[] enc) throws ASN1Exception
ASN1Exception
public CertificationRequest(InputStream in) throws ASN1Exception, IOException
enc
- InputStream that delivers the DER-encoded PKCS#10 Certification Request
Creation date: (20.08.99 21:42:03)
ASN1Exception
IOException
public CertificationRequest(PublicKey pk, Name sub) throws ASN1Exception, InvalidKeyException
getTBS()
to get the
to-be-signed (tbs) data, sign them outside and call #setSignature()
to fill-in the signature data. After that, you can
export the certification request using getEncoded()
.
pk
- the public key that is to be put inside this certification requestsub
- the Subject's name
Creation date: (20.08.99 21:42:03)
ASN1Exception
InvalidKeyException
public CertificationRequest(PublicKey pk, Name sub, Collection attr) throws ASN1Exception, InvalidKeyException
getTBS()
to
get the to-be-signed (tbs) data, sign them outside and call #setSignature()
to
fill-in the signature data. After that, you can export the certification request using
getEncoded()
.
pk
- the public key that is to be put inside this certification requestsub
- the Subject's nameattr
- the Subject's attributes
Creation date: (20.05.00 18:46:46)
ASN1Exception
InvalidKeyException
Method Detail |
---|
public List getAttributes()
public byte[] getEncoded() throws ASN1Exception
ASN1Exception
- if an encoding problem occurspublic PublicKey getPublicKey() throws CorruptedCodeException, NoSuchAlgorithmException
CorruptedCodeException
NoSuchAlgorithmException
public AlgorithmIdentifier getPublicKeyAlgorithm()
public byte[] getSignature()
public Name getSubjectDN()
public byte[] getTBS() throws CorruptedCodeException
CorruptedCodeException
public void setAttributes(Collection attributes)
attributes
- The attributes.
Creation date: (20.05.00 18:46:46)private void setPublicKey(PublicKey pk) throws InvalidKeyException
pk
- the public key to be put into this certification request
Creation date: (20.08.99 21:42:03)
InvalidKeyException
public void setSignature(byte[] sg, AlgorithmIdentifier algID)
getTBS()
.
Note that the AlgorithmIdentifier algID
is not copied, meaning
that after calling this method, it must not be changed. Otherwise the validity
of the signature is lost and the object contents are corrupted!
sg
- the new signaturealgID
- the algorithm identifier that describes the signature algorithm
Creation date: (20.08.99 21:42:03)private void setSubjectDN(Name sub)
sub
- the distinguished name
Creation date: (20.08.99 21:42:03)public String toString()
toString
in class ASN1AbstractCollection
public void verify() throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
getTBS()
, getPublicKey()
and getSignature()
should be used along with an external verification.
Verification is successful if the signature can be verified using the public key inside this
object. Successful verification is done if no exception is thrown from this method.
CertificateException
NoSuchAlgorithmException
InvalidKeyException
NoSuchProviderException
SignatureException
public void verify(String pro) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException
getTBS()
, getPublicKey()
and getSignature()
should be used along with an external verification.
Verification is successful if the signature can be verified using the public key inside this
object. Successful verification is done if no exception is thrown from this method.
pro
- Provider to be used for signature mechanism
CertificateException
NoSuchAlgorithmException
InvalidKeyException
NoSuchProviderException
SignatureException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |