Home | History | Annotate | Download | only in security
      1 /*
      2  *  Licensed to the Apache Software Foundation (ASF) under one or more
      3  *  contributor license agreements.  See the NOTICE file distributed with
      4  *  this work for additional information regarding copyright ownership.
      5  *  The ASF licenses this file to You under the Apache License, Version 2.0
      6  *  (the "License"); you may not use this file except in compliance with
      7  *  the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  */
     17 
     18 package java.security;
     19 
     20 import java.io.IOException;
     21 import java.io.InputStream;
     22 import java.io.OutputStream;
     23 
     24 /**
     25  * {@code Certificate} represents an identity certificate, such as X.509 or PGP.
     26  * Note: A {@code Certificate} instances does not make any statement about the
     27  * validity of itself. It's in the responsibility of the application to verify
     28  * the validity of its certificates.
     29  *
     30  * @deprecated Use {@link java.security.cert.Certificate} instead.
     31  * @see java.security.cert.Certificate
     32  */
     33 @Deprecated
     34 public interface Certificate {
     35 
     36     /**
     37      * Decodes a certificate from the given {@code InputStream}. The format of
     38      * the data to encode must be that identified by {@link #getFormat()} and
     39      * encoded by {@link #encode(OutputStream)}.
     40      *
     41      * @param stream
     42      *            the {@code InputStream} to read from.
     43      * @throws KeyException
     44      *             if certificate information is incomplete or incorrect.
     45      * @throws IOException
     46      *             if an exception is thrown by accessing the provided stream.
     47      * @see #encode(OutputStream)
     48      * @see #getFormat()
     49      */
     50     public void decode(InputStream stream) throws KeyException, IOException;
     51 
     52     /**
     53      * Encodes this certificate to an output stream. The
     54      * {@link #decode(InputStream)} method must be able to decode the format
     55      * written by this method.
     56      *
     57      * @param stream
     58      *            the {@code OutputStream} to encode this certificate to.
     59      * @throws KeyException
     60      *             if certificate information is incomplete or incorrect.
     61      * @throws IOException
     62      *             if an exception is thrown by accessing the provided stream.
     63      * @see #decode(InputStream)
     64      */
     65     public void encode(OutputStream stream) throws KeyException, IOException;
     66 
     67     /**
     68      * Returns a string identifying the format of this certificate.
     69      *
     70      * @return a string identifying the format of this certificate.
     71      */
     72     public String getFormat();
     73 
     74     /**
     75      * Returns the guarantor of this certificate. That guarantor guarantees,
     76      * that the public key of this certificate is from the principal returned by
     77      * {@link #getPrincipal()}.
     78      *
     79      * @return the guarantor of this certificate.
     80      * @see #getPrincipal()
     81      */
     82     public Principal getGuarantor();
     83 
     84     /**
     85      * Returns the principal of this certificate. The principal is guaranteed by
     86      * the guarantor returned by {@link #getGuarantor()}.
     87      *
     88      * @return the principal of this certificate.
     89      * @see #getGuarantor()
     90      */
     91     public Principal getPrincipal();
     92 
     93     /**
     94      * Returns the public key of this certificate. The public key is guaranteed
     95      * by the guarantor to belong to the principal.
     96      *
     97      * @return the public key of this certificate.
     98      * @see #getGuarantor()
     99      * @see Certificate#getPrincipal()
    100      */
    101     public PublicKey getPublicKey();
    102 
    103     /**
    104      * Returns a string containing a concise, human-readable description of the
    105      * this {@code Certificate}.
    106      *
    107      * @param detailed
    108      *            whether or not this method should return detailed information.
    109      * @return a string representation of this certificate.
    110      */
    111     public String toString(boolean detailed);
    112 }
    113