Save This Page
Home » openjdk-7 » sun.security » x509 » [javadoc | source]
sun.security.x509
public class: X509CertImpl [javadoc | source]
java.lang.Object
   java.security.cert.Certificate
      java.security.cert.X509Certificate
         sun.security.x509.X509CertImpl

All Implemented Interfaces:
    DerEncoder, X509Extension, Serializable

The X509CertImpl class represents an X.509 certificate. These certificates are widely used to support authentication and other functionality in Internet security systems. Common applications include Privacy Enhanced Mail (PEM), Transport Layer Security (SSL), code signing for trusted software distribution, and Secure Electronic Transactions (SET). There is a commercial infrastructure ready to manage large scale deployments of X.509 identity certificates.

These certificates are managed and vouched for by Certificate Authorities (CAs). CAs are services which create certificates by placing data in the X.509 standard format and then digitally signing that data. Such signatures are quite difficult to forge. CAs act as trusted third parties, making introductions between agents who have no direct knowledge of each other. CA certificates are either signed by themselves, or by some other CA such as a "root" CA.

RFC 1422 is very informative, though it does not describe much of the recent work being done with X.509 certificates. That includes a 1996 version (X.509v3) and a variety of enhancements being made to facilitate an explosion of personal certificates used as "Internet Drivers' Licences", or with SET for credit card transactions.

More recent work includes the IETF PKIX Working Group efforts, especially RFC2459.

Field Summary
public static final  String NAME    Public attribute names. 
public static final  String INFO     
public static final  String ALG_ID     
public static final  String SIGNATURE     
public static final  String SIGNED_CERT     
public static final  String SUBJECT_DN    The following are defined for ease-of-use. These are the most frequently retrieved attributes. 
public static final  String ISSUER_DN     
public static final  String SERIAL_ID     
public static final  String PUBLIC_KEY     
public static final  String VERSION     
public static final  String SIG_ALG     
public static final  String SIG     
protected  X509CertInfo info     
protected  AlgorithmId algId     
protected  byte[] signature     
Constructor:
 public X509CertImpl() 
 public X509CertImpl(byte[] certData) throws CertificateException 
    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:
    certData - the encoded bytes, with no trailing padding.
    Throws:
    CertificateException - on parsing and initialization errors.
    exception: CertificateException - on parsing and initialization errors.
 public X509CertImpl(InputStream in) throws CertificateException 
    unmarshals an X.509 certificate from an input stream. If the certificate is RFC1421 hex-encoded, then it must begin with the line X509Factory.BEGIN_CERT and end with the line X509Factory.END_CERT.
    Parameters:
    in - an input stream holding at least one certificate that may be either DER-encoded or RFC1421 hex-encoded version of the DER-encoded certificate.
    Throws:
    CertificateException - on parsing and initialization errors.
    exception: CertificateException - on parsing and initialization errors.
 public X509CertImpl(X509CertInfo certInfo) 
    Construct an initialized X509 Certificate. The certificate is stored in raw form and has to be signed to be useful.
    params: info - the X509CertificateInfo which the Certificate is to be created from.
 public X509CertImpl(DerValue derVal) throws CertificateException 
    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:
    CertificateException - on parsing and initialization errors.
    exception: CertificateException - on parsing and initialization errors.
Method from sun.security.x509.X509CertImpl Summary:
checkValidity,   checkValidity,   delete,   derEncode,   encode,   get,   getAuthorityInfoAccessExtension,   getAuthorityKeyIdentifierExtension,   getBasicConstraints,   getBasicConstraintsExtension,   getCRLDistributionPointsExtension,   getCertificatePoliciesExtension,   getCriticalExtensionOIDs,   getElements,   getEncoded,   getEncodedInternal,   getEncodedInternal,   getExtendedKeyUsage,   getExtendedKeyUsage,   getExtendedKeyUsageExtension,   getExtension,   getExtensionValue,   getIssuerAlternativeNameExtension,   getIssuerAlternativeNames,   getIssuerAlternativeNames,   getIssuerDN,   getIssuerUniqueID,   getIssuerX500Principal,   getIssuerX500Principal,   getKeyUsage,   getName,   getNameConstraintsExtension,   getNonCriticalExtensionOIDs,   getNotAfter,   getNotBefore,   getPolicyConstraintsExtension,   getPolicyMappingsExtension,   getPrivateKeyUsageExtension,   getPublicKey,   getSerialNumber,   getSerialNumberObject,   getSigAlgName,   getSigAlgOID,   getSigAlgParams,   getSignature,   getSubjectAlternativeNameExtension,   getSubjectAlternativeNames,   getSubjectAlternativeNames,   getSubjectDN,   getSubjectKeyIdentifierExtension,   getSubjectUniqueID,   getSubjectX500Principal,   getSubjectX500Principal,   getTBSCertificate,   getUnparseableExtension,   getVersion,   hasUnsupportedCriticalExtension,   isSelfIssued,   isSelfSigned,   set,   sign,   sign,   toImpl,   toString,   verify,   verify
Methods from java.security.cert.X509Certificate:
checkValidity,   checkValidity,   getBasicConstraints,   getExtendedKeyUsage,   getIssuerAlternativeNames,   getIssuerDN,   getIssuerUniqueID,   getIssuerX500Principal,   getKeyUsage,   getNotAfter,   getNotBefore,   getSerialNumber,   getSigAlgName,   getSigAlgOID,   getSigAlgParams,   getSignature,   getSubjectAlternativeNames,   getSubjectDN,   getSubjectUniqueID,   getSubjectX500Principal,   getTBSCertificate,   getVersion
Methods from java.security.cert.Certificate:
equals,   getEncoded,   getPublicKey,   getType,   hashCode,   toString,   verify,   verify
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sun.security.x509.X509CertImpl Detail:
 public  void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException 
    Checks that the certificate is currently valid, i.e. the current time is within the specified validity period.
 public  void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException 
    Checks that the specified date is within the certificate's validity period, or basically if the certificate would be valid at the specified date/time.
 public  void delete(String name) throws IOException, CertificateException 
    Delete the requested attribute from the certificate.
 public  void derEncode(OutputStream out) throws IOException 
    DER encode this object onto an output stream. Implements the DerEncoder interface.
 public  void encode(OutputStream out) throws CertificateEncodingException 
    Appends the certificate to an output stream.
 public Object get(String name) throws CertificateParsingException 
    Return the requested attribute from the certificate. Note that the X509CertInfo is not cloned for performance reasons. Callers must ensure that they do not modify it. All other attributes are cloned.
 public AuthorityInfoAccessExtension getAuthorityInfoAccessExtension() 
 public AuthorityKeyIdentifierExtension getAuthorityKeyIdentifierExtension() 
    Get AuthorityKeyIdentifier extension
 public int getBasicConstraints() 
    Get the certificate constraints path length from the the critical BasicConstraints extension, (oid = 2.5.29.19).
 public BasicConstraintsExtension getBasicConstraintsExtension() 
    Get BasicConstraints extension
 public CRLDistributionPointsExtension getCRLDistributionPointsExtension() 
    Get CRLDistributionPoints extension
 public CertificatePoliciesExtension getCertificatePoliciesExtension() 
    Get CertificatePoliciesExtension
 public Set getCriticalExtensionOIDs() 
    Gets a Set of the extension(s) marked CRITICAL in the certificate. In the returned set, each extension is represented by its OID string.
 public Enumeration getElements() 
    Return an enumeration of names of attributes existing within this attribute.
 public byte[] getEncoded() throws CertificateEncodingException 
    Returns the encoded form of this certificate. It is assumed that each certificate type would have only a single form of encoding; for example, X.509 certificates would be encoded as ASN.1 DER.
 public byte[] getEncodedInternal() throws CertificateEncodingException 
    Returned the encoding as an uncloned byte array. Callers must guarantee that they neither modify it nor expose it to untrusted code.
 public static byte[] getEncodedInternal(Certificate cert) throws CertificateEncodingException 
    Returned the encoding of the given certificate for internal use. Callers must guarantee that they neither modify it nor expose it to untrusted code. Uses getEncodedInternal() if the certificate is instance of X509CertImpl, getEncoded() otherwise.
 public synchronized List getExtendedKeyUsage() throws CertificateParsingException 
    This method are the overridden implementation of getExtendedKeyUsage method in X509Certificate in the Sun provider. It is better performance-wise since it returns cached values.
 public static List getExtendedKeyUsage(X509Certificate cert) throws CertificateParsingException 
    This static method is the default implementation of the getExtendedKeyUsage method in X509Certificate. A X509Certificate provider generally should overwrite this to provide among other things caching for better performance.
 public ExtendedKeyUsageExtension getExtendedKeyUsageExtension() 
    Get ExtendedKeyUsage extension
 public Extension getExtension(ObjectIdentifier oid) 
    Gets the extension identified by the given ObjectIdentifier
 public byte[] getExtensionValue(String oid) 
    Gets the DER encoded extension identified by the given oid String.
 public IssuerAlternativeNameExtension getIssuerAlternativeNameExtension() 
    Get IssuerAlternativeName extension
 public synchronized Collection getIssuerAlternativeNames() throws CertificateParsingException 
    This method are the overridden implementation of getIssuerAlternativeNames method in X509Certificate in the Sun provider. It is better performance-wise since it returns cached values.
 public static Collection getIssuerAlternativeNames(X509Certificate cert) throws CertificateParsingException 
    This static method is the default implementation of the getIssuerAlternaitveNames method in X509Certificate. A X509Certificate provider generally should overwrite this to provide among other things caching for better performance.
 public Principal getIssuerDN() 
    Gets the issuer distinguished name from the certificate.
 public boolean[] getIssuerUniqueID() 
    Gets the Issuer Unique Identity from the certificate.
 public X500Principal getIssuerX500Principal() 
    Get issuer name as X500Principal. Overrides implementation in X509Certificate with a slightly more efficient version that is also aware of X509CertImpl mutability.
 public static X500Principal getIssuerX500Principal(X509Certificate cert) 
    Extract the issuer X500Principal from an X509Certificate. Called from java.security.cert.X509Certificate.getIssuerX500Principal().
 public boolean[] getKeyUsage() 
    Get a boolean array representing the bits of the KeyUsage extension, (oid = 2.5.29.15).
 public String getName() 
    Return the name of this attribute.
 public NameConstraintsExtension getNameConstraintsExtension() 
    Get NameConstraints extension
 public Set getNonCriticalExtensionOIDs() 
    Gets a Set of the extension(s) marked NON-CRITICAL in the certificate. In the returned set, each extension is represented by its OID string.
 public Date getNotAfter() 
    Gets the notAfter date from the validity period of the certificate.
 public Date getNotBefore() 
    Gets the notBefore date from the validity period of the certificate.
 public PolicyConstraintsExtension getPolicyConstraintsExtension() 
    Get PolicyConstraints extension
 public PolicyMappingsExtension getPolicyMappingsExtension() 
    Get PolicyMappingsExtension extension
 public PrivateKeyUsageExtension getPrivateKeyUsageExtension() 
    Get PrivateKeyUsage extension
 public PublicKey getPublicKey() 
    Gets the publickey from this certificate.
 public BigInteger getSerialNumber() 
    Gets the serial number from the certificate.
 public SerialNumber getSerialNumberObject() 
    Gets the serial number from the certificate as a SerialNumber object.
 public String getSigAlgName() 
    Gets the signature algorithm name for the certificate signature algorithm. For example, the string "SHA-1/DSA" or "DSS".
 public String getSigAlgOID() 
    Gets the signature algorithm OID string from the certificate. For example, the string "1.2.840.10040.4.3"
 public byte[] getSigAlgParams() 
    Gets the DER encoded signature algorithm parameters from this certificate's signature algorithm.
 public byte[] getSignature() 
    Gets the raw Signature bits from the certificate.
 public SubjectAlternativeNameExtension getSubjectAlternativeNameExtension() 
    Get SubjectAlternativeName extension
 public synchronized Collection getSubjectAlternativeNames() throws CertificateParsingException 
    This method are the overridden implementation of getSubjectAlternativeNames method in X509Certificate in the Sun provider. It is better performance-wise since it returns cached values.
 public static Collection getSubjectAlternativeNames(X509Certificate cert) throws CertificateParsingException 
    This static method is the default implementation of the getSubjectAlternaitveNames method in X509Certificate. A X509Certificate provider generally should overwrite this to provide among other things caching for better performance.
 public Principal getSubjectDN() 
    Gets the subject distinguished name from the certificate.
 public SubjectKeyIdentifierExtension getSubjectKeyIdentifierExtension() 
    Get SubjectKeyIdentifier extension
 public boolean[] getSubjectUniqueID() 
    Gets the Subject Unique Identity from the certificate.
 public X500Principal getSubjectX500Principal() 
    Get subject name as X500Principal. Overrides implementation in X509Certificate with a slightly more efficient version that is also aware of X509CertImpl mutability.
 public static X500Principal getSubjectX500Principal(X509Certificate cert) 
    Extract the subject X500Principal from an X509Certificate. Called from java.security.cert.X509Certificate.getSubjectX500Principal().
 public byte[] getTBSCertificate() throws CertificateEncodingException 
    Gets the DER encoded certificate informations, the tbsCertificate from this certificate. This can be used to verify the signature independently.
 public Extension getUnparseableExtension(ObjectIdentifier oid) 
 public int getVersion() 
    Gets the version number from the certificate.
 public boolean hasUnsupportedCriticalExtension() 
    Return true if a critical extension is found that is not supported, otherwise return false.
 public static boolean isSelfIssued(X509Certificate cert) 
    Utility method to test if a certificate is self-issued. This is the case iff the subject and issuer X500Principals are equal.
 public static boolean isSelfSigned(X509Certificate cert,
    String sigProvider) 
    Utility method to test if a certificate is self-signed. This is the case iff the subject and issuer X500Principals are equal AND the certificate's subject public key can be used to verify the certificate. In case of exception, returns false.
 public  void set(String name,
    Object obj) throws IOException, CertificateException 
    Set the requested attribute in the certificate.
 public  void sign(PrivateKey key,
    String algorithm) throws SignatureException, NoSuchProviderException, InvalidKeyException, NoSuchAlgorithmException, CertificateException 
    Creates an X.509 certificate, and signs it using the given key (associating a signature algorithm and an X.500 name). This operation is used to implement the certificate generation functionality of a certificate authority.
 public  void sign(PrivateKey key,
    String algorithm,
    String provider) throws SignatureException, NoSuchProviderException, InvalidKeyException, NoSuchAlgorithmException, CertificateException 
    Creates an X.509 certificate, and signs it using the given key (associating a signature algorithm and an X.500 name). This operation is used to implement the certificate generation functionality of a certificate authority.
 public static X509CertImpl toImpl(X509Certificate cert) throws CertificateException 
    Utility method to convert an arbitrary instance of X509Certificate to a X509CertImpl. Does a cast if possible, otherwise reparses the encoding.
 public String toString() 
    Returns a printable representation of the certificate. This does not contain all the information available to distinguish this from any other certificate. The certificate must be fully constructed before this function may be called.
 public  void verify(PublicKey key) throws SignatureException, NoSuchProviderException, InvalidKeyException, NoSuchAlgorithmException, CertificateException 
    Throws an exception if the certificate was not signed using the verification key provided. Successfully verifying a certificate does not indicate that one should trust the entity which it represents.
 public synchronized  void verify(PublicKey key,
    String sigProvider) throws SignatureException, NoSuchProviderException, InvalidKeyException, NoSuchAlgorithmException, CertificateException 
    Throws an exception if the certificate was not signed using the verification key provided. Successfully verifying a certificate does not indicate that one should trust the entity which it represents.