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 CertificateAlgorithmIdstatic final Stringprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprotected CertificateExtensionsstatic final Stringstatic final StringIdentifier for this attribute, to be used with the get, set, delete methods of Certificate, x509 type.protected CertificateValidityprotected CertificateIssuerNamestatic final Stringstatic final Stringprotected CertificateIssuerUniqueIdentitystatic final Stringprivate static final org.slf4j.Loggerstatic final Stringprotected CertificateX509Keyprivate byte[]static final Stringprotected CertificateSerialNumberprivate static final longprotected CertificateSubjectNamestatic final Stringstatic final Stringprotected CertificateSubjectUniqueIdentitystatic final Stringprotected CertificateVersionstatic 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 intattributeMap(String name) Returns the integer attribute number for the passed attribute name.voiddecode(InputStream in) Decode an X.509 certificate from an input stream.voidDelete the certificate attribute.private voidemit(DerOutputStream out) voidencode(OutputStream out) Appends the certificate to an output stream.voidencode(OutputStream out, boolean ignoreCache) Appends the certificate to an output stream.booleanCompares two X509CertInfo objects.booleanequals(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.inthashCode()Calculates a hash code value for the object.private voidprivate voidreadObject(ObjectInputStream stream) Serialization read ...voidSet the certificate attribute.private voidsetAlgorithmId(Object val) Set the algorithm id of the certificate.private voidsetExtensions(Object val) Set the extensions in the certificate.private voidSet the issuer name of the certificate.private voidsetIssuerUniqueId(Object val) Set the Issuer Unique Identity in the certificate.private voidSet the public key in the certificate.private voidsetSerialNumber(Object val) Set the serial number of the certificate.private voidsetSubject(Object val) Set the subject name of the certificate.private voidsetSubjectUniqueId(Object val) Set the Subject Unique Identity in the certificate.private voidsetValidity(Object val) Set the validity interval of the certificate.private voidsetVersion(Object val) Set the version number of the certificate.toString()Returns a printable representation of the certificate.private voidwriteObject(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:
decodein 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:
encodein 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:
IOExceptionCertificateException
-
getAttributeNames
Return an enumeration of names of attributes existing within this attribute.- Specified by:
getAttributeNamesin interfaceCertAttrSet- Returns:
- an enumeration of the attribute names.
-
getName
Return the name of this attribute.- Specified by:
getNamein 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:
toStringin interfaceCertAttrSet- Overrides:
toStringin classObject- Returns:
- value of this certificate attribute in printable form.
-
set
Set the certificate attribute.- Specified by:
setin 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:
deletein 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:
getin interfaceCertAttrSet- Parameters:
name- the name of the Certificate attribute.- Returns:
- attribute value
- Throws:
CertificateException- on invalid attributes.IOException- on other errors.
-
parse
-
emit
- Throws:
CertificateExceptionIOException
-
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:
CertificateExceptionIOException
-
readObject
Serialization read ... X.509 certificates serialize as themselves, and they're parsed when they get read back.- Throws:
CertificateExceptionIOException
-
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
-