jdk/src/share/classes/java/security/cert/X509Certificate.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 6114 9d463b9408ba
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.security.cert;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.math.BigInteger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.Principal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.PublicKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Collection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Date;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.security.auth.x500.X500Principal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.security.x509.X509CertImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Abstract class for X.509 certificates. This provides a standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * way to access all the attributes of an X.509 certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * In June of 1996, the basic X.509 v3 format was completed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * ISO/IEC and ANSI X9, which is described below in ASN.1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * Certificate  ::=  SEQUENCE  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *     tbsCertificate       TBSCertificate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *     signatureAlgorithm   AlgorithmIdentifier,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *     signature            BIT STRING  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * These certificates are widely used to support authentication and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * other functionality in Internet security systems. Common applications
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * include Privacy Enhanced Mail (PEM), Transport Layer Security (SSL),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * code signing for trusted software distribution, and Secure Electronic
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * Transactions (SET).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * These certificates are managed and vouched for by <em>Certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * Authorities</em> (CAs). CAs are services which create certificates by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * placing data in the X.509 standard format and then digitally signing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * that data. CAs act as trusted third parties, making introductions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * between principals who have no direct knowledge of each other.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * CA certificates are either signed by themselves, or by some other
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * CA such as a "root" CA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * More information can be found in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <a href="http://www.ietf.org/rfc/rfc3280.txt">RFC 3280: Internet X.509
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * Public Key Infrastructure Certificate and CRL Profile</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * The ASN.1 definition of <code>tbsCertificate</code> is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * TBSCertificate  ::=  SEQUENCE  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *     version         [0]  EXPLICIT Version DEFAULT v1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *     serialNumber         CertificateSerialNumber,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *     signature            AlgorithmIdentifier,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *     issuer               Name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *     validity             Validity,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *     subject              Name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *     subjectPublicKeyInfo SubjectPublicKeyInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *     issuerUniqueID  [1]  IMPLICIT UniqueIdentifier OPTIONAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *                          -- If present, version must be v2 or v3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *     subjectUniqueID [2]  IMPLICIT UniqueIdentifier OPTIONAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *                          -- If present, version must be v2 or v3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *     extensions      [3]  EXPLICIT Extensions OPTIONAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *                          -- If present, version must be v3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * Certificates are instantiated using a certificate factory. The following is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * an example of how to instantiate an X.509 certificate:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * InputStream inStream = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 *     inStream = new FileInputStream("fileName-of-cert");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *     CertificateFactory cf = CertificateFactory.getInstance("X.509");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *     X509Certificate cert = (X509Certificate)cf.generateCertificate(inStream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 *     if (inStream != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 *         inStream.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * @author Hemma Prafullchandra
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * @see Certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * @see CertificateFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * @see X509Extension
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
public abstract class X509Certificate extends Certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
implements X509Extension {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    private static final long serialVersionUID = -2491127588187038216L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    private transient X500Principal subjectX500Principal, issuerX500Principal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * Constructor for X.509 certificates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    protected X509Certificate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        super("X.509");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Checks that the certificate is currently valid. It is if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * the current date and time are within the validity period given in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * The validity period consists of two date/time values:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * the first and last dates (and times) on which the certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * is valid. It is defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * ASN.1 as:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * validity             Validity<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Validity ::= SEQUENCE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *     notBefore      CertificateValidityDate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *     notAfter       CertificateValidityDate }<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * CertificateValidityDate ::= CHOICE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *     utcTime        UTCTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *     generalTime    GeneralizedTime }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @exception CertificateExpiredException if the certificate has expired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @exception CertificateNotYetValidException if the certificate is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * yet valid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public abstract void checkValidity()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        throws CertificateExpiredException, CertificateNotYetValidException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * Checks that the given date is within the certificate's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * validity period. In other words, this determines whether the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * certificate would be valid at the given date/time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @param date the Date to check against to see if this certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *        is valid at that date/time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @exception CertificateExpiredException if the certificate has expired
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * with respect to the <code>date</code> supplied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @exception CertificateNotYetValidException if the certificate is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * yet valid with respect to the <code>date</code> supplied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @see #checkValidity()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public abstract void checkValidity(Date date)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        throws CertificateExpiredException, CertificateNotYetValidException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * Gets the <code>version</code> (version number) value from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * version  [0] EXPLICIT Version DEFAULT v1<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * Version ::=  INTEGER  {  v1(0), v2(1), v3(2)  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @return the version number, i.e. 1, 2 or 3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public abstract int getVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * Gets the <code>serialNumber</code> value from the certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * The serial number is an integer assigned by the certification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * authority to each certificate. It must be unique for each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * certificate issued by a given CA (i.e., the issuer name and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * serial number identify a unique certificate).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * serialNumber     CertificateSerialNumber<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * CertificateSerialNumber  ::=  INTEGER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @return the serial number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public abstract BigInteger getSerialNumber();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * <strong>Denigrated</strong>, replaced by {@linkplain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * #getIssuerX500Principal()}. This method returns the <code>issuer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * as an implementation specific Principal object, which should not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * relied upon by portable code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * Gets the <code>issuer</code> (issuer distinguished name) value from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * the certificate. The issuer name identifies the entity that signed (and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * issued) the certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * <p>The issuer name field contains an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * X.500 distinguished name (DN).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * issuer    Name<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * Name ::= CHOICE { RDNSequence }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * RelativeDistinguishedName ::=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     *     SET OF AttributeValueAssertion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * AttributeValueAssertion ::= SEQUENCE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *                               AttributeType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *                               AttributeValue }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * AttributeType ::= OBJECT IDENTIFIER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * AttributeValue ::= ANY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * The <code>Name</code> describes a hierarchical name composed of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * such as country name, and corresponding values, such as US.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * The type of the <code>AttributeValue</code> component is determined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * the <code>AttributeType</code>; in general it will be a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * <code>directoryString</code>. A <code>directoryString</code> is usually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * one of <code>PrintableString</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * <code>TeletexString</code> or <code>UniversalString</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @return a Principal whose name is the issuer distinguished name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    public abstract Principal getIssuerDN();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * Returns the issuer (issuer distinguished name) value from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * certificate as an <code>X500Principal</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * It is recommended that subclasses override this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @return an <code>X500Principal</code> representing the issuer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     *          distinguished name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public X500Principal getIssuerX500Principal() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        if (issuerX500Principal == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            issuerX500Principal = X509CertImpl.getIssuerX500Principal(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        return issuerX500Principal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * <strong>Denigrated</strong>, replaced by {@linkplain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * #getSubjectX500Principal()}. This method returns the <code>subject</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * as an implementation specific Principal object, which should not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * relied upon by portable code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * Gets the <code>subject</code> (subject distinguished name) value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * from the certificate.  If the <code>subject</code> value is empty,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * then the <code>getName()</code> method of the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * <code>Principal</code> object returns an empty string ("").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * <p> The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * subject    Name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * <p>See {@link #getIssuerDN() getIssuerDN} for <code>Name</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * and other relevant definitions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @return a Principal whose name is the subject name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    public abstract Principal getSubjectDN();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Returns the subject (subject distinguished name) value from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * certificate as an <code>X500Principal</code>.  If the subject value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * is empty, then the <code>getName()</code> method of the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * <code>X500Principal</code> object returns an empty string ("").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * It is recommended that subclasses override this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @return an <code>X500Principal</code> representing the subject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *          distinguished name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public X500Principal getSubjectX500Principal() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        if (subjectX500Principal == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            subjectX500Principal = X509CertImpl.getSubjectX500Principal(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        return subjectX500Principal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * Gets the <code>notBefore</code> date from the validity period of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * the certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * The relevant ASN.1 definitions are:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * validity             Validity<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * Validity ::= SEQUENCE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *     notBefore      CertificateValidityDate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     *     notAfter       CertificateValidityDate }<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * CertificateValidityDate ::= CHOICE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     *     utcTime        UTCTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *     generalTime    GeneralizedTime }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * @return the start date of the validity period.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @see #checkValidity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    public abstract Date getNotBefore();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * Gets the <code>notAfter</code> date from the validity period of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * the certificate. See {@link #getNotBefore() getNotBefore}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * for relevant ASN.1 definitions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @return the end date of the validity period.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @see #checkValidity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    public abstract Date getNotAfter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * Gets the DER-encoded certificate information, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * <code>tbsCertificate</code> from this certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * This can be used to verify the signature independently.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * @return the DER-encoded certificate information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @exception CertificateEncodingException if an encoding error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    public abstract byte[] getTBSCertificate()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        throws CertificateEncodingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * Gets the <code>signature</code> value (the raw signature bits) from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * the certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * signature     BIT STRING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * @return the signature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    public abstract byte[] getSignature();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * Gets the signature algorithm name for the certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * signature algorithm. An example is the string "SHA-1/DSA".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * signatureAlgorithm   AlgorithmIdentifier<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * AlgorithmIdentifier  ::=  SEQUENCE  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     *     algorithm               OBJECT IDENTIFIER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     *     parameters              ANY DEFINED BY algorithm OPTIONAL  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     *                             -- contains a value of the type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *                             -- registered for use with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     *                             -- algorithm object identifier value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * <p>The algorithm name is determined from the <code>algorithm</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * OID string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @return the signature algorithm name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    public abstract String getSigAlgName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * Gets the signature algorithm OID string from the certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * An OID is represented by a set of nonnegative whole numbers separated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * by periods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * For example, the string "1.2.840.10040.4.3" identifies the SHA-1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * with DSA signature algorithm defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * <a href="http://www.ietf.org/rfc/rfc3279.txt">RFC 3279: Algorithms and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * Identifiers for the Internet X.509 Public Key Infrastructure Certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * and CRL Profile</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * <p>See {@link #getSigAlgName() getSigAlgName} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * relevant ASN.1 definitions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @return the signature algorithm OID string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    public abstract String getSigAlgOID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * Gets the DER-encoded signature algorithm parameters from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * certificate's signature algorithm. In most cases, the signature
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * algorithm parameters are null; the parameters are usually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * supplied with the certificate's public key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * If access to individual parameter values is needed then use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * {@link java.security.AlgorithmParameters AlgorithmParameters}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * and instantiate with the name returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * {@link #getSigAlgName() getSigAlgName}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * <p>See {@link #getSigAlgName() getSigAlgName} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * relevant ASN.1 definitions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * @return the DER-encoded signature algorithm parameters, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     *         null if no parameters are present.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    public abstract byte[] getSigAlgParams();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * Gets the <code>issuerUniqueID</code> value from the certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * The issuer unique identifier is present in the certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * to handle the possibility of reuse of issuer names over time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * RFC 3280 recommends that names not be reused and that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * conforming certificates not make use of unique identifiers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * Applications conforming to that profile should be capable of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * parsing unique identifiers and making comparisons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * <p>The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * issuerUniqueID  [1]  IMPLICIT UniqueIdentifier OPTIONAL<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * UniqueIdentifier  ::=  BIT STRING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * @return the issuer unique identifier or null if it is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * present in the certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    public abstract boolean[] getIssuerUniqueID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * Gets the <code>subjectUniqueID</code> value from the certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * <p>The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * subjectUniqueID  [2]  IMPLICIT UniqueIdentifier OPTIONAL<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * UniqueIdentifier  ::=  BIT STRING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @return the subject unique identifier or null if it is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * present in the certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    public abstract boolean[] getSubjectUniqueID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * Gets a boolean array representing bits of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * the <code>KeyUsage</code> extension, (OID = 2.5.29.15).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * The key usage extension defines the purpose (e.g., encipherment,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * signature, certificate signing) of the key contained in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * KeyUsage ::= BIT STRING {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *     digitalSignature        (0),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     *     nonRepudiation          (1),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *     keyEncipherment         (2),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     *     dataEncipherment        (3),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     *     keyAgreement            (4),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     *     keyCertSign             (5),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     *     cRLSign                 (6),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     *     encipherOnly            (7),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *     decipherOnly            (8) }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * RFC 3280 recommends that when used, this be marked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * as a critical extension.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @return the KeyUsage extension of this certificate, represented as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * an array of booleans. The order of KeyUsage values in the array is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * the same as in the above ASN.1 definition. The array will contain a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * value for each KeyUsage defined above. If the KeyUsage list encoded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * in the certificate is longer than the above list, it will not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * truncated. Returns null if this certificate does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * contain a KeyUsage extension.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    public abstract boolean[] getKeyUsage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * Gets an unmodifiable list of Strings representing the OBJECT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * IDENTIFIERs of the <code>ExtKeyUsageSyntax</code> field of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * extended key usage extension, (OID = 2.5.29.37).  It indicates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * one or more purposes for which the certified public key may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * used, in addition to or in place of the basic purposes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * indicated in the key usage extension field.  The ASN.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * KeyPurposeId ::= OBJECT IDENTIFIER<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * Key purposes may be defined by any organization with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * need. Object identifiers used to identify key purposes shall be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * assigned in accordance with IANA or ITU-T Rec. X.660 |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * ISO/IEC/ITU 9834-1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * This method was added to version 1.4 of the Java 2 Platform Standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * Edition. In order to maintain backwards compatibility with existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * service providers, this method is not <code>abstract</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * and it provides a default implementation. Subclasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * should override this method with a correct implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @return the ExtendedKeyUsage extension of this certificate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *         as an unmodifiable list of object identifiers represented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     *         as Strings. Returns null if this certificate does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     *         contain an ExtendedKeyUsage extension.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * @throws CertificateParsingException if the extension cannot be decoded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    public List<String> getExtendedKeyUsage() throws CertificateParsingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        return X509CertImpl.getExtendedKeyUsage(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * Gets the certificate constraints path length from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * critical <code>BasicConstraints</code> extension, (OID = 2.5.29.19).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * The basic constraints extension identifies whether the subject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * of the certificate is a Certificate Authority (CA) and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * how deep a certification path may exist through that CA. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * <code>pathLenConstraint</code> field (see below) is meaningful
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * only if <code>cA</code> is set to TRUE. In this case, it gives the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * maximum number of CA certificates that may follow this certificate in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * certification path. A value of zero indicates that only an end-entity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * certificate may follow in the path.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * The ASN.1 definition for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * BasicConstraints ::= SEQUENCE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     *     cA                  BOOLEAN DEFAULT FALSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     *     pathLenConstraint   INTEGER (0..MAX) OPTIONAL }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * @return the value of <code>pathLenConstraint</code> if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * BasicConstraints extension is present in the certificate and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * subject of the certificate is a CA, otherwise -1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * If the subject of the certificate is a CA and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * <code>pathLenConstraint</code> does not appear,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * <code>Integer.MAX_VALUE</code> is returned to indicate that there is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * limit to the allowed length of the certification path.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    public abstract int getBasicConstraints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * Gets an immutable collection of subject alternative names from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * <code>SubjectAltName</code> extension, (OID = 2.5.29.17).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * The ASN.1 definition of the <code>SubjectAltName</code> extension is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * SubjectAltName ::= GeneralNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * GeneralNames :: = SEQUENCE SIZE (1..MAX) OF GeneralName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * GeneralName ::= CHOICE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *      otherName                       [0]     OtherName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     *      rfc822Name                      [1]     IA5String,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     *      dNSName                         [2]     IA5String,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     *      x400Address                     [3]     ORAddress,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *      directoryName                   [4]     Name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     *      ediPartyName                    [5]     EDIPartyName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     *      uniformResourceIdentifier       [6]     IA5String,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     *      iPAddress                       [7]     OCTET STRING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     *      registeredID                    [8]     OBJECT IDENTIFIER}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * If this certificate does not contain a <code>SubjectAltName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * extension, <code>null</code> is returned. Otherwise, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * <code>Collection</code> is returned with an entry representing each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * <code>GeneralName</code> included in the extension. Each entry is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * <code>List</code> whose first entry is an <code>Integer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * (the name type, 0-8) and whose second entry is a <code>String</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * or a byte array (the name, in string or ASN.1 DER encoded form,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * respectively).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * <a href="http://www.ietf.org/rfc/rfc822.txt">RFC 822</a>, DNS, and URI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * names are returned as <code>String</code>s,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * using the well-established string formats for those types (subject to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * the restrictions included in RFC 3280). IPv4 address names are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * returned using dotted quad notation. IPv6 address names are returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * in the form "a1:a2:...:a8", where a1-a8 are hexadecimal values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * representing the eight 16-bit pieces of the address. OID names are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * returned as <code>String</code>s represented as a series of nonnegative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * integers separated by periods. And directory names (distinguished names)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * are returned in <a href="http://www.ietf.org/rfc/rfc2253.txt">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * RFC 2253</a> string format. No standard string format is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * defined for otherNames, X.400 names, EDI party names, or any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * other type of names. They are returned as byte arrays
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * containing the ASN.1 DER encoded form of the name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * Note that the <code>Collection</code> returned may contain more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * than one name of the same type. Also, note that the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * <code>Collection</code> is immutable and any entries containing byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * arrays are cloned to protect against subsequent modifications.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * This method was added to version 1.4 of the Java 2 Platform Standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * Edition. In order to maintain backwards compatibility with existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * service providers, this method is not <code>abstract</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * and it provides a default implementation. Subclasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * should override this method with a correct implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * @return an immutable <code>Collection</code> of subject alternative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * names (or <code>null</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * @throws CertificateParsingException if the extension cannot be decoded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    public Collection<List<?>> getSubjectAlternativeNames()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        throws CertificateParsingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        return X509CertImpl.getSubjectAlternativeNames(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * Gets an immutable collection of issuer alternative names from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * <code>IssuerAltName</code> extension, (OID = 2.5.29.18).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * The ASN.1 definition of the <code>IssuerAltName</code> extension is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * IssuerAltName ::= GeneralNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * The ASN.1 definition of <code>GeneralNames</code> is defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * in {@link #getSubjectAlternativeNames getSubjectAlternativeNames}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * If this certificate does not contain an <code>IssuerAltName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * extension, <code>null</code> is returned. Otherwise, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * <code>Collection</code> is returned with an entry representing each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * <code>GeneralName</code> included in the extension. Each entry is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * <code>List</code> whose first entry is an <code>Integer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * (the name type, 0-8) and whose second entry is a <code>String</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * or a byte array (the name, in string or ASN.1 DER encoded form,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * respectively). For more details about the formats used for each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * name type, see the <code>getSubjectAlternativeNames</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * Note that the <code>Collection</code> returned may contain more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * than one name of the same type. Also, note that the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * <code>Collection</code> is immutable and any entries containing byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * arrays are cloned to protect against subsequent modifications.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * This method was added to version 1.4 of the Java 2 Platform Standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * Edition. In order to maintain backwards compatibility with existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * service providers, this method is not <code>abstract</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * and it provides a default implementation. Subclasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * should override this method with a correct implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * @return an immutable <code>Collection</code> of issuer alternative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * names (or <code>null</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * @throws CertificateParsingException if the extension cannot be decoded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    public Collection<List<?>> getIssuerAlternativeNames()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        throws CertificateParsingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        return X509CertImpl.getIssuerAlternativeNames(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
}