APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.pkcs10

public Class PKCS10

extends Object
Class Inheritance
Imports
java.io.PrintStream, .IOException, java.math.BigInteger, java.security.*, java.util.Arrays, .Base64, sun.security.util.*, .SignatureUtil, sun.security.x509.AlgorithmId, .X509Key, .X500Name

A PKCS #10 certificate request is created and sent to a Certificate Authority, which then creates an X.509 certificate and returns it to the entity that requested it. A certificate request basically consists of the subject's X.500 name, public key, and optionally some attributes, signed using the corresponding private key. The ASN.1 syntax for a Certification Request is:
CertificationRequest ::= SEQUENCE {
   certificationRequestInfo CertificationRequestInfo,
   signatureAlgorithm       SignatureAlgorithmIdentifier,
   signature                Signature
 }

SignatureAlgorithmIdentifier ::= AlgorithmIdentifier
Signature ::= BIT STRING

CertificationRequestInfo ::= SEQUENCE {
   version                 Version,
   subject                 Name,
   subjectPublicKeyInfo    SubjectPublicKeyInfo,
   attributes [0] IMPLICIT Attributes
}
Attributes ::= SET OF Attribute
Authors
David Brownell, Amit Kapoor, Hemma Prafullchandra

Field Summary

Modifier and TypeField and Description
private final PKCS10Attributes
private byte[]
private String
private X500Name
private final PublicKey

Constructor Summary

AccessConstructor and Description
public
PKCS10(PublicKey
the public key that should be placed into the certificate generated by the CA.
publicKey
)

Constructs an unsigned PKCS #10 certificate request.

public
PKCS10(PublicKey
the public key that should be placed into the certificate generated by the CA.
publicKey
,
PKCS10Attributes
additional set of PKCS10 attributes requested for in the certificate.
attributes
)

Constructs an unsigned PKCS #10 certificate request.

public
PKCS10(byte[]
the DER-encoded PKCS #10 request.
data
)

Parses an encoded, signed PKCS #10 certificate request, verifying the request's signature as it does so.

Method Summary

Modifier and TypeMethod and Description
public void
encodeAndSign(X500Name
identifies the signer (by X.500 name).
subject
,
PrivateKey
private key to use.
key
,
String
signing algorithm to use.
algorithm
)

Create the signed certificate request.

public boolean

Returns:

true iff the encoded forms of the two certificate requests match, false otherwise.
equals
(Object
the object to test for equality with this object.
obj
)

Overrides java.lang.Object.equals.

Compares this object for equality with the specified object.

public PKCS10Attributes
getAttributes()

Returns the additional attributes requested.

public byte[]

Returns:

the certificate request, or null if encodeAndSign() has not yet been called.
getEncoded
()

Returns the encoded and signed certificate request as a DER-encoded byte array.

public String
getSigAlg()

Returns the signature algorithm.

public X500Name
getSubjectName()

Returns the subject's name.

public PublicKey
getSubjectPublicKeyInfo()

Returns the subject's public key.

public int

Returns:

the hashcode value for this certificate request from its encoded form
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the hashcode value for this certificate request from its encoded form.

public String
toString()

Overrides java.lang.Object.toString.

Provides a short description of this request.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

attributeSetback to summary
private final PKCS10Attributes attributeSet
encodedback to summary
private byte[] encoded
sigAlgback to summary
private String sigAlg
subjectback to summary
private X500Name subject
subjectPublicKeyInfoback to summary
private final PublicKey subjectPublicKeyInfo

Constructor Detail

PKCS10back to summary
public PKCS10(PublicKey publicKey)

Constructs an unsigned PKCS #10 certificate request. Before this request may be used, it must be encoded and signed. Then it must be retrieved in some conventional format (e.g. string).

Parameters
publicKey:PublicKey

the public key that should be placed into the certificate generated by the CA.

PKCS10back to summary
public PKCS10(PublicKey publicKey, PKCS10Attributes attributes)

Constructs an unsigned PKCS #10 certificate request. Before this request may be used, it must be encoded and signed. Then it must be retrieved in some conventional format (e.g. string).

Parameters
publicKey:PublicKey

the public key that should be placed into the certificate generated by the CA.

attributes:PKCS10Attributes

additional set of PKCS10 attributes requested for in the certificate.

PKCS10back to summary
public PKCS10(byte[] data) throws IOException, SignatureException, NoSuchAlgorithmException

Parses an encoded, signed PKCS #10 certificate request, verifying the request's signature as it does so. This constructor would typically be used by a Certificate Authority, from which a new certificate would then be constructed.

Parameters
data:byte[]

the DER-encoded PKCS #10 request.

Exceptions
IOException:
for low level errors reading the data
SignatureException:
when the signature is invalid
NoSuchAlgorithmException:
when the signature algorithm is not supported in this environment

Method Detail

encodeAndSignback to summary
public void encodeAndSign(X500Name subject, PrivateKey key, String algorithm) throws SignatureException, NoSuchAlgorithmException, InvalidKeyException

Create the signed certificate request. This will later be retrieved in either string or binary format.

Parameters
subject:X500Name

identifies the signer (by X.500 name).

key:PrivateKey

private key to use.

algorithm:String

signing algorithm to use.

Exceptions
SignatureException:
on signature handling errors.
NoSuchAlgorithmException:
algorithm is not recognized
InvalidKeyException:
key has a problem
IOException:
on errors.
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares this object for equality with the specified object. If the obj object is an instanceof PKCS10, then its encoded form is retrieved and compared with the encoded form of this certificate request.

Parameters
obj:Object

the object to test for equality with this object.

Returns:boolean

true iff the encoded forms of the two certificate requests match, false otherwise.

Annotations
@Override
getAttributesback to summary
public PKCS10Attributes getAttributes()

Returns the additional attributes requested.

getEncodedback to summary
public byte[] getEncoded()

Returns the encoded and signed certificate request as a DER-encoded byte array.

Returns:byte[]

the certificate request, or null if encodeAndSign() has not yet been called.

getSigAlgback to summary
public String getSigAlg()

Returns the signature algorithm.

getSubjectNameback to summary
public X500Name getSubjectName()

Returns the subject's name.

getSubjectPublicKeyInfoback to summary
public PublicKey getSubjectPublicKeyInfo()

Returns the subject's public key.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns the hashcode value for this certificate request from its encoded form.

Returns:int

the hashcode value for this certificate request from its encoded form

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Provides a short description of this request.