jdk/src/share/classes/java/security/Certificate.java
author juh
Mon, 09 Sep 2013 10:52:56 -0700
changeset 19828 b4f91bc595fe
parent 18579 b678846778ad
permissions -rw-r--r--
8024432: Fix doclint issues in java.security Reviewed-by: darcy, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
     2
 * Copyright (c) 1996, 2013, 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;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Date;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * <p>This is an interface of abstract methods for managing a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * variety of identity certificates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * An identity certificate is a guarantee by a principal that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * a public key is that of another principal.  (A principal represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * an entity such as an individual user, a group, or a corporation.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>In particular, this interface is intended to be a common
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * abstraction for constructs that have different formats but
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * important common uses.  For example, different types of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * certificates, such as X.509 certificates and PGP certificates,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * share general certificate functionality (the need to encode and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * decode certificates) and some types of information, such as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * public key, the principal whose key it is, and the guarantor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * guaranteeing that the public key is that of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * principal. So an implementation of X.509 certificates and an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * implementation of PGP certificates can both utilize the Certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * interface, even though their formats and additional types and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * amounts of information stored are different.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <p><b>Important</b>: This interface is useful for cataloging and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * grouping objects sharing certain common uses. It does not have any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * semantics of its own. In particular, a Certificate object does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * make any statement as to the <i>validity</i> of the binding. It is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * the duty of the application implementing this interface to verify
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * the certificate and satisfy itself of its validity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @author Benjamin Renaud
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * @deprecated A new certificate handling package is created in the Java platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *             This Certificate interface is entirely deprecated and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *             is here to allow for a smooth transition to the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *             package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @see java.security.cert.Certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
@Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
public interface Certificate {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Returns the guarantor of the certificate, that is, the principal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * guaranteeing that the public key associated with this certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * is that of the principal associated with this certificate. For X.509
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * certificates, the guarantor will typically be a Certificate Authority
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * (such as the United States Postal Service or Verisign, Inc.).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @return the guarantor which guaranteed the principal-key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public abstract Principal getGuarantor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Returns the principal of the principal-key pair being guaranteed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * the guarantor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @return the principal to which this certificate is bound.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public abstract Principal getPrincipal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * Returns the key of the principal-key pair being guaranteed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * the guarantor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @return the public key that this certificate certifies belongs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * to a particular principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public abstract PublicKey getPublicKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Encodes the certificate to an output stream in a format that can
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    99
     * be decoded by the {@code decode} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @param stream the output stream to which to encode the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @exception KeyException if the certificate is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * properly initialized, or data is missing, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @exception IOException if a stream exception occurs while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * trying to output the encoded certificate to the output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @see #decode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @see #getFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    public abstract void encode(OutputStream stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        throws KeyException, IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Decodes a certificate from an input stream. The format should be
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   118
     * that returned by {@code getFormat} and produced by
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   119
     * {@code encode}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @param stream the input stream from which to fetch the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * being decoded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @exception KeyException if the certificate is not properly initialized,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * or data is missing, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @exception IOException if an exception occurs while trying to input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * the encoded certificate from the input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @see #encode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @see #getFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public abstract void decode(InputStream stream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        throws KeyException, IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Returns the name of the coding format. This is used as a hint to find
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * an appropriate parser. It could be "X.509", "PGP", etc. This is
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   140
     * the format produced and understood by the {@code encode}
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   141
     * and {@code decode} methods.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @return the name of the coding format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    public abstract String getFormat();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Returns a string that represents the contents of the certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @param detailed whether or not to give detailed information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * about the certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @return a string representing the contents of the certificate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public String toString(boolean detailed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
}