1 /* X509CertBridge.java -- bridge between JDK and JSSE cert APIs.
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., 51 Franklin Street, Fifth Floor, 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
.math
.BigInteger
;
42 import java
.security
.InvalidKeyException
;
43 import java
.security
.NoSuchAlgorithmException
;
44 import java
.security
.NoSuchProviderException
;
45 import java
.security
.Principal
;
46 import java
.security
.PublicKey
;
47 import java
.security
.SignatureException
;
48 import java
.util
.Date
;
51 * <p>An implementation of the {@link X509Certificate} class that delegates
52 * calls to a {@link java.security.cert.X509Certificate}.</p>
54 final class X509CertBridge
extends X509Certificate
58 // -------------------------------------------------------------------------
60 private java
.security
.cert
.X509Certificate cert
;
63 // -------------------------------------------------------------------------
65 X509CertBridge(java
.security
.cert
.X509Certificate cert
)
71 // -------------------------------------------------------------------------
73 public byte[] getEncoded() throws CertificateEncodingException
77 return cert
.getEncoded();
79 catch (java
.security
.cert
.CertificateEncodingException cee
)
81 throw new CertificateEncodingException(cee
.getMessage());
85 public void verify(PublicKey key
)
86 throws CertificateException
, NoSuchAlgorithmException
, InvalidKeyException
,
87 NoSuchProviderException
, SignatureException
93 catch (java
.security
.cert
.CertificateException ce
)
95 throw new CertificateException(ce
.getMessage());
99 public void verify(PublicKey key
, String sigProvider
)
100 throws CertificateException
, NoSuchAlgorithmException
, InvalidKeyException
,
101 NoSuchProviderException
, SignatureException
105 cert
.verify(key
, sigProvider
);
107 catch (java
.security
.cert
.CertificateException ce
)
109 throw new CertificateException(ce
.getMessage());
113 public String
toString()
115 return cert
.toString();
118 public PublicKey
getPublicKey()
120 return cert
.getPublicKey();
123 public void checkValidity()
124 throws CertificateExpiredException
, CertificateNotYetValidException
128 cert
.checkValidity();
130 catch (java
.security
.cert
.CertificateExpiredException cee
)
132 throw new CertificateExpiredException(cee
.getMessage());
134 catch (java
.security
.cert
.CertificateNotYetValidException cnyve
)
136 throw new CertificateNotYetValidException(cnyve
.getMessage());
140 public void checkValidity(Date date
)
141 throws CertificateExpiredException
, CertificateNotYetValidException
145 cert
.checkValidity(date
);
147 catch (java
.security
.cert
.CertificateExpiredException cee
)
149 throw new CertificateExpiredException(cee
.getMessage());
151 catch (java
.security
.cert
.CertificateNotYetValidException cnyve
)
153 throw new CertificateNotYetValidException(cnyve
.getMessage());
157 public int getVersion()
159 return cert
.getVersion();
162 public BigInteger
getSerialNumber()
164 return cert
.getSerialNumber();
167 public Principal
getIssuerDN()
169 return cert
.getIssuerDN();
172 public Principal
getSubjectDN()
174 return cert
.getSubjectDN();
177 public Date
getNotBefore()
179 return cert
.getNotBefore();
182 public Date
getNotAfter()
184 return cert
.getNotAfter();
187 public String
getSigAlgName()
189 return cert
.getSigAlgName();
192 public String
getSigAlgOID()
194 return cert
.getSigAlgOID();
197 public byte[] getSigAlgParams()
199 return cert
.getSigAlgParams();