1 /* X509Certificate.java -- base class of X.509 certificates.
2 Copyright (C) 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax
.security
.cert
;
41 import java
.io
.ByteArrayInputStream
;
42 import java
.io
.InputStream
;
44 import java
.math
.BigInteger
;
46 import java
.security
.Principal
;
47 import java
.security
.cert
.CertificateFactory
;
49 import java
.util
.Date
;
52 * <p>The base class of all X.509 certificates.</p>
54 * <p><b>This class is deprecated in favor of the {@link
55 * java.security.cert.X509Certificate} class. It should not be used in new
56 * applications.</b></p>
58 public abstract class X509Certificate
extends Certificate
62 // -------------------------------------------------------------------------
65 * <p>Get an instance of X509Certificate for the given encoded bytes.</p>
67 * @param encoded The encoded certificate.
68 * @return An instance of X509Certificate.
69 * @throws CertificateException If the encoded certificate cannot be parsed.
71 public static X509Certificate
getInstance(byte[] encoded
)
72 throws CertificateException
74 return getInstance(new ByteArrayInputStream(encoded
));
78 * <p>Get an instance of X509Certificate for the given encoded stream.</p>
80 * @param encoded The encoded certificate stream..
81 * @return An instance of X509Certificate.
82 * @throws CertificateException If the encoded certificate cannot be parsed.
84 public static X509Certificate
getInstance(InputStream encoded
)
85 throws CertificateException
89 CertificateFactory cf
= CertificateFactory
.getInstance("X.509");
90 return new X509CertBridge((java
.security
.cert
.X509Certificate
)
91 cf
.generateCertificate(encoded
));
93 catch (java
.security
.cert
.CertificateException ce
)
95 throw new CertificateException(ce
.getMessage());
100 // -------------------------------------------------------------------------
103 * <p>Check if this certificate is valid now.</p>
105 * @throws CertificateExpiredException If the certificate has expired.
106 * @throws CertificateNotYetValidException If the certificate is not yet valid.
107 * @see #checkValidity(java.util.Date)
109 public abstract void checkValidity()
110 throws CertificateExpiredException
, CertificateNotYetValidException
;
113 * <p>Check if this certificate is valid for the given date.</p>
115 * @param date The date to check.
116 * @throws CertificateExpiredException If the certificate has expired.
117 * @throws CertificateNotYetValidException If the certificate is not yet valid.
119 public abstract void checkValidity(Date date
)
120 throws CertificateExpiredException
, CertificateNotYetValidException
;
123 * <p>Returns the X.509 version number.</p>
125 * @return The version number.
127 public abstract int getVersion();
130 * <p>Returns this certificate's serial number.</p>
132 * @return The serial number.
134 public abstract BigInteger
getSerialNumber();
137 * <p>Returns the distinguished name of this certificate's issuer.</p>
139 * @return The issuer's distinguished name.
141 public abstract Principal
getIssuerDN();
144 * <p>Returns the distinguished name of this certificate's subject.</p>
146 * @return The subject's distinguished name.
148 public abstract Principal
getSubjectDN();
151 * <p>Returns the <i>not before</i> portion of this certificate's validity
154 * @return The not before date.
156 public abstract Date
getNotBefore();
159 * <p>Returns the <i>not after</i> portion of this certificate's validity
162 * @return The not after date.
164 public abstract Date
getNotAfter();
167 * <p>Returns the name of this certificate's signature algorithm.</p>
169 * @return The name of the signature algorithm.
171 public abstract String
getSigAlgName();
174 * <p>Returns the object identifier (OID) of this certificate's signature
175 * algorithm. The returned string is a sequence of integers separated by
178 * @return The signature OID.
180 public abstract String
getSigAlgOID();
183 * <p>Returns the signature parameters. The returned byte array contains the
184 * raw DER-encoded parameters.</p>
186 * @return The signature parameters.
188 public abstract byte[] getSigAlgParams();