Class X509CertInfo
java.lang.Object
org.mozilla.jss.netscape.security.x509.X509CertInfo
- All Implemented Interfaces:
Serializable
,CertAttrSet
- Direct Known Subclasses:
CertInfo
The X509CertInfo class represents X.509 certificate information.
X.509 certificates have several base data elements, including:
- The Subject Name, an X.500 Distinguished Name for the entity (subject) for which the certificate was issued.
- The Subject Public Key, the public key of the subject. This is one of the most important parts of the certificate.
- The Validity Period, a time period (e.g. six months) within which the certificate is valid (unless revoked).
- The Issuer Name, an X.500 Distinguished Name for the Certificate Authority (CA) which issued the certificate.
- A Serial Number assigned by the CA, for use in certificate revocation and other applications.
- Version:
- 1.16
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CertificateAlgorithmId
static final String
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
protected CertificateExtensions
static final String
static final String
Identifier for this attribute, to be used with the get, set, delete methods of Certificate, x509 type.protected CertificateValidity
protected CertificateIssuerName
static final String
static final String
protected CertificateIssuerUniqueIdentity
static final String
private static final org.slf4j.Logger
static final String
protected CertificateX509Key
private byte[]
static final String
protected CertificateSerialNumber
private static final long
protected CertificateSubjectName
static final String
static final String
protected CertificateSubjectUniqueIdentity
static final String
protected CertificateVersion
static final String
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an uninitialized X509CertInfo on which decode must later be called (or which may be deserialized).X509CertInfo
(byte[] cert) Unmarshals a certificate from its encoded form, parsing the encoded bytes.X509CertInfo
(DerValue derVal) Unmarshal a certificate from its encoded form, parsing a DER value. -
Method Summary
Modifier and TypeMethodDescriptionprivate int
attributeMap
(String name) Returns the integer attribute number for the passed attribute name.void
decode
(InputStream in) Decode an X.509 certificate from an input stream.void
Delete the certificate attribute.private void
emit
(DerOutputStream out) void
encode
(OutputStream out) Appends the certificate to an output stream.void
encode
(OutputStream out, boolean ignoreCache) Appends the certificate to an output stream.boolean
Compares two X509CertInfo objects.boolean
equals
(X509CertInfo other) Compares two certificates, returning false if any data differs between the two.Get the certificate attribute.Return an enumeration of names of attributes existing within this attribute.byte[]
Returns the encoded certificate info.byte[]
getEncodedInfo
(boolean ignoreCache) getName()
Return the name of this attribute.int
hashCode()
Calculates a hash code value for the object.private void
private void
readObject
(ObjectInputStream stream) Serialization read ...void
Set the certificate attribute.private void
setAlgorithmId
(Object val) Set the algorithm id of the certificate.private void
setExtensions
(Object val) Set the extensions in the certificate.private void
Set the issuer name of the certificate.private void
setIssuerUniqueId
(Object val) Set the Issuer Unique Identity in the certificate.private void
Set the public key in the certificate.private void
setSerialNumber
(Object val) Set the serial number of the certificate.private void
setSubject
(Object val) Set the subject name of the certificate.private void
setSubjectUniqueId
(Object val) Set the Subject Unique Identity in the certificate.private void
setValidity
(Object val) Set the validity interval of the certificate.private void
setVersion
(Object val) Set the version number of the certificate.toString()
Returns a printable representation of the certificate.private void
writeObject
(ObjectOutputStream stream) Serialization write ...
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
logger
private static final org.slf4j.Logger logger -
IDENT
Identifier for this attribute, to be used with the get, set, delete methods of Certificate, x509 type.- See Also:
-
NAME
- See Also:
-
VERSION
- See Also:
-
SERIAL_NUMBER
- See Also:
-
ALGORITHM_ID
- See Also:
-
ISSUER
- See Also:
-
VALIDITY
- See Also:
-
SUBJECT
- See Also:
-
KEY
- See Also:
-
ISSUER_ID
- See Also:
-
SUBJECT_ID
- See Also:
-
EXTENSIONS
- See Also:
-
version
-
serialNum
-
algId
-
issuer
-
interval
-
subject
-
pubKey
-
issuerUniqueId
-
subjectUniqueId
-
extensions
-
ATTR_VERSION
private static final int ATTR_VERSION- See Also:
-
ATTR_SERIAL
private static final int ATTR_SERIAL- See Also:
-
ATTR_ALGORITHM
private static final int ATTR_ALGORITHM- See Also:
-
ATTR_ISSUER
private static final int ATTR_ISSUER- See Also:
-
ATTR_VALIDITY
private static final int ATTR_VALIDITY- See Also:
-
ATTR_SUBJECT
private static final int ATTR_SUBJECT- See Also:
-
ATTR_KEY
private static final int ATTR_KEY- See Also:
-
ATTR_ISSUER_ID
private static final int ATTR_ISSUER_ID- See Also:
-
ATTR_SUBJECT_ID
private static final int ATTR_SUBJECT_ID- See Also:
-
ATTR_EXTENSIONS
private static final int ATTR_EXTENSIONS- See Also:
-
rawCertInfo
private byte[] rawCertInfo -
map
-
-
Constructor Details
-
X509CertInfo
public X509CertInfo()Construct an uninitialized X509CertInfo on which decode must later be called (or which may be deserialized). -
X509CertInfo
Unmarshals a certificate from its encoded form, parsing the encoded bytes. This form of constructor is used by agents which need to examine and use certificate contents. That is, this is one of the more commonly used constructors. Note that the buffer must include only a certificate, and no "garbage" may be left at the end. If you need to ignore data at the end of a certificate, use another constructor.- Parameters:
cert
- the encoded bytes, with no trailing data.- Throws:
CertificateParsingException
- on parsing errors.
-
X509CertInfo
Unmarshal a certificate from its encoded form, parsing a DER value. This form of constructor is used by agents which need to examine and use certificate contents.- Parameters:
derVal
- the der value containing the encoded cert.- Throws:
CertificateParsingException
- on parsing errors.
-
-
Method Details
-
decode
Decode an X.509 certificate from an input stream.- Specified by:
decode
in interfaceCertAttrSet
- Parameters:
in
- an input stream holding at least one certificate- Throws:
CertificateParsingException
- on decoding errors.IOException
- on other errors.
-
encode
Appends the certificate to an output stream.- Specified by:
encode
in interfaceCertAttrSet
- Parameters:
out
- an output stream to which the certificate is appended.- Throws:
CertificateException
- on encoding errors.IOException
- on other errors.
-
encode
Appends the certificate to an output stream.- Parameters:
out
- An output stream to which the certificate is appended.ignoreCache
- Whether to ignore the internal cache when encoding. (the cache can easily become out of date).- Throws:
IOException
CertificateException
-
getAttributeNames
Return an enumeration of names of attributes existing within this attribute.- Specified by:
getAttributeNames
in interfaceCertAttrSet
- Returns:
- an enumeration of the attribute names.
-
getName
Return the name of this attribute.- Specified by:
getName
in interfaceCertAttrSet
- Returns:
- the name of this CertAttrSet.
-
getEncodedInfo
Returns the encoded certificate info.- Throws:
CertificateEncodingException
- on encoding information errors.
-
getEncodedInfo
- Throws:
CertificateEncodingException
-
equals
Compares two X509CertInfo objects. This is false if the certificates are not both X.509 certs, otherwise it compares them as binary data. -
equals
Compares two certificates, returning false if any data differs between the two.- Parameters:
other
- the object being compared with this one- Returns:
- true iff the certificates are equivalent
-
hashCode
public int hashCode()Calculates a hash code value for the object. Objects which are equal will also have the same hashcode. -
toString
Returns a printable representation of the certificate.- Specified by:
toString
in interfaceCertAttrSet
- Overrides:
toString
in classObject
- Returns:
- value of this certificate attribute in printable form.
-
set
Set the certificate attribute.- Specified by:
set
in interfaceCertAttrSet
- Parameters:
name
- the name of the Certificate attribute.val
- the value of the Certificate attribute.- Throws:
CertificateException
- on invalid attributes.IOException
- on other errors.
-
delete
Delete the certificate attribute.- Specified by:
delete
in interfaceCertAttrSet
- Parameters:
name
- the name of the Certificate attribute.- Throws:
CertificateException
- on invalid attributes.IOException
- on other errors.
-
get
Get the certificate attribute.- Specified by:
get
in interfaceCertAttrSet
- Parameters:
name
- the name of the Certificate attribute.- Returns:
- attribute value
- Throws:
CertificateException
- on invalid attributes.IOException
- on other errors.
-
parse
-
emit
- Throws:
CertificateException
IOException
-
writeObject
Serialization write ... X.509 certificates serialize as themselves, and they're parsed when they get read back. (Actually they serialize as some type data from the serialization subsystem, then the cert data.)- Throws:
CertificateException
IOException
-
readObject
Serialization read ... X.509 certificates serialize as themselves, and they're parsed when they get read back.- Throws:
CertificateException
IOException
-
attributeMap
Returns the integer attribute number for the passed attribute name. -
setVersion
Set the version number of the certificate.- Parameters:
val
- the Object class value for the Extensions- Throws:
CertificateException
- on invalid data.
-
setSerialNumber
Set the serial number of the certificate.- Parameters:
val
- the Object class value for the CertificateSerialNumber- Throws:
CertificateException
- on invalid data.
-
setAlgorithmId
Set the algorithm id of the certificate.- Parameters:
val
- the Object class value for the AlgorithmId- Throws:
CertificateException
- on invalid data.
-
setIssuer
Set the issuer name of the certificate.- Parameters:
val
- the Object class value for the issuer- Throws:
CertificateException
- on invalid data.
-
getIssuerObj
-
setValidity
Set the validity interval of the certificate.- Parameters:
val
- the Object class value for the CertificateValidity- Throws:
CertificateException
- on invalid data.
-
setSubject
Set the subject name of the certificate.- Parameters:
val
- the Object class value for the Subject- Throws:
CertificateException
- on invalid data.
-
getSubjectObj
-
setKey
Set the public key in the certificate.- Parameters:
val
- the Object class value for the PublicKey- Throws:
CertificateException
- on invalid data.
-
setIssuerUniqueId
Set the Issuer Unique Identity in the certificate.- Parameters:
val
- the Object class value for the IssuerUniqueId- Throws:
CertificateException
-
setSubjectUniqueId
Set the Subject Unique Identity in the certificate.- Parameters:
val
- the Object class value for the SubjectUniqueId- Throws:
CertificateException
-
setExtensions
Set the extensions in the certificate.- Parameters:
val
- the Object class value for the Extensions- Throws:
CertificateException
-