Class X509CertInfo
- java.lang.Object
-
- org.mozilla.jss.netscape.security.x509.X509CertInfo
-
- All Implemented Interfaces:
java.io.Serializable,CertAttrSet
- Direct Known Subclasses:
CertInfo
public class X509CertInfo extends java.lang.Object implements CertAttrSet, java.io.Serializable
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.
- See Also:
CertAttrSet,Serializable,X509CertImpl, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected CertificateAlgorithmIdalgIdstatic java.lang.StringALGORITHM_IDprotected CertificateExtensionsextensionsstatic java.lang.StringEXTENSIONSstatic java.lang.StringIDENTIdentifier for this attribute, to be used with the get, set, delete methods of Certificate, x509 type.protected CertificateValidityintervalprotected CertificateIssuerNameissuerstatic java.lang.StringISSUERstatic java.lang.StringISSUER_IDprotected CertificateIssuerUniqueIdentityissuerUniqueIdstatic java.lang.StringKEYstatic java.lang.StringNAMEprotected CertificateX509KeypubKeystatic java.lang.StringSERIAL_NUMBERprotected CertificateSerialNumberserialNumprotected CertificateSubjectNamesubjectstatic java.lang.StringSUBJECTstatic java.lang.StringSUBJECT_IDprotected CertificateSubjectUniqueIdentitysubjectUniqueIdstatic java.lang.StringVALIDITYprotected CertificateVersionversionstatic java.lang.StringVERSION
-
Constructor Summary
Constructors Constructor Description X509CertInfo()Construct 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddecode(java.io.InputStream in)Decode an X.509 certificate from an input stream.voiddelete(java.lang.String name)Delete the certificate attribute.voidencode(java.io.OutputStream out)Appends the certificate to an output stream.voidencode(java.io.OutputStream out, boolean ignoreCache)Appends the certificate to an output stream.booleanequals(java.lang.Object other)Compares two X509CertInfo objects.booleanequals(X509CertInfo other)Compares two certificates, returning false if any data differs between the two.java.lang.Objectget(java.lang.String name)Get the certificate attribute.java.util.Enumeration<java.lang.String>getAttributeNames()Return an enumeration of names of attributes existing within this attribute.byte[]getEncodedInfo()Returns the encoded certificate info.byte[]getEncodedInfo(boolean ignoreCache)CertificateIssuerNamegetIssuerObj()java.lang.StringgetName()Return the name of this attribute.CertificateSubjectNamegetSubjectObj()inthashCode()Calculates a hash code value for the object.voidset(java.lang.String name, java.lang.Object val)Set the certificate attribute.java.lang.StringtoString()Returns a printable representation of the certificate.
-
-
-
Field Detail
-
IDENT
public static final java.lang.String IDENT
Identifier for this attribute, to be used with the get, set, delete methods of Certificate, x509 type.- See Also:
- Constant Field Values
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
VERSION
public static final java.lang.String VERSION
- See Also:
- Constant Field Values
-
SERIAL_NUMBER
public static final java.lang.String SERIAL_NUMBER
- See Also:
- Constant Field Values
-
ALGORITHM_ID
public static final java.lang.String ALGORITHM_ID
- See Also:
- Constant Field Values
-
ISSUER
public static final java.lang.String ISSUER
- See Also:
- Constant Field Values
-
VALIDITY
public static final java.lang.String VALIDITY
- See Also:
- Constant Field Values
-
SUBJECT
public static final java.lang.String SUBJECT
- See Also:
- Constant Field Values
-
KEY
public static final java.lang.String KEY
- See Also:
- Constant Field Values
-
ISSUER_ID
public static final java.lang.String ISSUER_ID
- See Also:
- Constant Field Values
-
SUBJECT_ID
public static final java.lang.String SUBJECT_ID
- See Also:
- Constant Field Values
-
EXTENSIONS
public static final java.lang.String EXTENSIONS
- See Also:
- Constant Field Values
-
version
protected CertificateVersion version
-
serialNum
protected CertificateSerialNumber serialNum
-
algId
protected CertificateAlgorithmId algId
-
issuer
protected CertificateIssuerName issuer
-
interval
protected CertificateValidity interval
-
subject
protected CertificateSubjectName subject
-
pubKey
protected CertificateX509Key pubKey
-
issuerUniqueId
protected CertificateIssuerUniqueIdentity issuerUniqueId
-
subjectUniqueId
protected CertificateSubjectUniqueIdentity subjectUniqueId
-
extensions
protected CertificateExtensions extensions
-
-
Constructor Detail
-
X509CertInfo
public X509CertInfo()
Construct an uninitialized X509CertInfo on which decode must later be called (or which may be deserialized).
-
X509CertInfo
public X509CertInfo(byte[] cert) throws java.security.cert.CertificateParsingExceptionUnmarshals 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:
java.security.cert.CertificateParsingException- on parsing errors.
-
X509CertInfo
public X509CertInfo(DerValue derVal) throws java.security.cert.CertificateParsingException
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:
java.security.cert.CertificateParsingException- on parsing errors.
-
-
Method Detail
-
decode
public void decode(java.io.InputStream in) throws java.security.cert.CertificateParsingException, java.io.IOExceptionDecode an X.509 certificate from an input stream.- Specified by:
decodein interfaceCertAttrSet- Parameters:
in- an input stream holding at least one certificate- Throws:
java.security.cert.CertificateParsingException- on decoding errors.java.io.IOException- on other errors.
-
encode
public void encode(java.io.OutputStream out) throws java.security.cert.CertificateException, java.io.IOExceptionAppends the certificate to an output stream.- Specified by:
encodein interfaceCertAttrSet- Parameters:
out- an output stream to which the certificate is appended.- Throws:
java.security.cert.CertificateException- on encoding errors.java.io.IOException- on other errors.
-
encode
public void encode(java.io.OutputStream out, boolean ignoreCache) throws java.io.IOException, java.security.cert.CertificateExceptionAppends 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:
java.io.IOExceptionjava.security.cert.CertificateException
-
getAttributeNames
public java.util.Enumeration<java.lang.String> getAttributeNames()
Return an enumeration of names of attributes existing within this attribute.- Specified by:
getAttributeNamesin interfaceCertAttrSet- Returns:
- an enumeration of the attribute names.
-
getName
public java.lang.String getName()
Return the name of this attribute.- Specified by:
getNamein interfaceCertAttrSet- Returns:
- the name of this CertAttrSet.
-
getEncodedInfo
public byte[] getEncodedInfo() throws java.security.cert.CertificateEncodingExceptionReturns the encoded certificate info.- Throws:
java.security.cert.CertificateEncodingException- on encoding information errors.
-
getEncodedInfo
public byte[] getEncodedInfo(boolean ignoreCache) throws java.security.cert.CertificateEncodingException- Throws:
java.security.cert.CertificateEncodingException
-
equals
public boolean equals(java.lang.Object other)
Compares two X509CertInfo objects. This is false if the certificates are not both X.509 certs, otherwise it compares them as binary data.- Overrides:
equalsin classjava.lang.Object- Parameters:
other- the object being compared with this one- Returns:
- true iff the certificates are equivalent
-
equals
public boolean equals(X509CertInfo other)
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.- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
Returns a printable representation of the certificate.- Specified by:
toStringin interfaceCertAttrSet- Overrides:
toStringin classjava.lang.Object- Returns:
- value of this certificate attribute in printable form.
-
set
public void set(java.lang.String name, java.lang.Object val) throws java.security.cert.CertificateException, java.io.IOExceptionSet the certificate attribute.- Specified by:
setin interfaceCertAttrSet- Parameters:
name- the name of the Certificate attribute.val- the value of the Certificate attribute.- Throws:
java.security.cert.CertificateException- on invalid attributes.java.io.IOException- on other errors.
-
delete
public void delete(java.lang.String name) throws java.security.cert.CertificateException, java.io.IOExceptionDelete the certificate attribute.- Specified by:
deletein interfaceCertAttrSet- Parameters:
name- the name of the Certificate attribute.- Throws:
java.security.cert.CertificateException- on invalid attributes.java.io.IOException- on other errors.
-
get
public java.lang.Object get(java.lang.String name) throws java.security.cert.CertificateException, java.io.IOExceptionGet the certificate attribute.- Specified by:
getin interfaceCertAttrSet- Parameters:
name- the name of the Certificate attribute.- Throws:
java.security.cert.CertificateException- on invalid attributes.java.io.IOException- on other errors.
-
getIssuerObj
public CertificateIssuerName getIssuerObj()
-
getSubjectObj
public CertificateSubjectName getSubjectObj()
-
-