Package netscape.security.x509
Class X509CertInfo
- java.lang.Object
-
- 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.
- Version:
- 1.16
- Author:
- Amit Kapoor, Hemma Prafullchandra
- See Also:
CertAttrSet
,Serializable
,X509CertImpl
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected CertificateAlgorithmId
algId
static java.lang.String
ALGORITHM_ID
protected CertificateExtensions
extensions
static java.lang.String
EXTENSIONS
static java.lang.String
IDENT
Identifier for this attribute, to be used with the get, set, delete methods of Certificate, x509 type.protected CertificateValidity
interval
protected CertificateIssuerName
issuer
static java.lang.String
ISSUER
static java.lang.String
ISSUER_ID
protected CertificateIssuerUniqueIdentity
issuerUniqueId
static java.lang.String
KEY
static java.lang.String
NAME
protected CertificateX509Key
pubKey
static java.lang.String
SERIAL_NUMBER
protected CertificateSerialNumber
serialNum
protected CertificateSubjectName
subject
static java.lang.String
SUBJECT
static java.lang.String
SUBJECT_ID
protected CertificateSubjectUniqueIdentity
subjectUniqueId
static java.lang.String
VALIDITY
protected CertificateVersion
version
static java.lang.String
VERSION
-
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 void
decode(java.io.InputStream in)
Decode an X.509 certificate from an input stream.void
delete(java.lang.String name)
Delete the certificate attribute.void
encode(java.io.OutputStream out)
Appends the certificate to an output stream.void
encode(java.io.OutputStream out, boolean ignoreCache)
Appends the certificate to an output stream.boolean
equals(java.lang.Object other)
Compares two X509CertInfo objects.boolean
equals(X509CertInfo other)
Compares two certificates, returning false if any data differs between the two.java.lang.Object
get(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)
CertificateIssuerName
getIssuerObj()
java.lang.String
getName()
Return the name of this attribute.CertificateSubjectName
getSubjectObj()
int
hashCode()
Calculates a hash code value for the object.void
set(java.lang.String name, java.lang.Object val)
Set the certificate attribute.java.lang.String
toString()
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.CertificateParsingException
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:
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.IOException
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:
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.IOException
Appends the certificate to an output stream.- Specified by:
encode
in 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.CertificateException
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:
java.io.IOException
java.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:
getAttributeNames
in interfaceCertAttrSet
- Returns:
- an enumeration of the attribute names.
-
getName
public java.lang.String getName()
Return the name of this attribute.- Specified by:
getName
in interfaceCertAttrSet
- Returns:
- the name of this CertAttrSet.
-
getEncodedInfo
public byte[] getEncodedInfo() throws java.security.cert.CertificateEncodingException
Returns 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:
equals
in 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:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
Returns a printable representation of the certificate.- Specified by:
toString
in interfaceCertAttrSet
- Overrides:
toString
in 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.IOException
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:
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.IOException
Delete the certificate attribute.- Specified by:
delete
in 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.IOException
Get the certificate attribute.- Specified by:
get
in 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()
-
-