1 /* X509CertBridge.java -- bridge between JDK and JSSE cert APIs. 2 Copyright (C) 2004 Free Software Foundation, Inc. 3 4 This file is part of GNU Classpath. 5 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) 9 any later version. 10 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. 15 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 19 02110-1301 USA. 20 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 24 combination. 25 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. */ 37 38 39 package javax.security.cert; 40 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; 49 50 /** 51 * <p>An implementation of the {@link X509Certificate} class that delegates 52 * calls to a {@link java.security.cert.X509Certificate}.</p> 53 */ 54 final class X509CertBridge extends X509Certificate 55 { 56 57 // Fields. 58 // ------------------------------------------------------------------------- 59 60 private java.security.cert.X509Certificate cert; 61 62 // Constructor. 63 // ------------------------------------------------------------------------- 64 X509CertBridge(java.security.cert.X509Certificate cert)65 X509CertBridge(java.security.cert.X509Certificate cert) 66 { 67 this.cert = cert; 68 } 69 70 // Instance methods. 71 // ------------------------------------------------------------------------- 72 getEncoded()73 public byte[] getEncoded() throws CertificateEncodingException 74 { 75 try 76 { 77 return cert.getEncoded(); 78 } 79 catch (java.security.cert.CertificateEncodingException cee) 80 { 81 throw new CertificateEncodingException(cee.getMessage()); 82 } 83 } 84 verify(PublicKey key)85 public void verify(PublicKey key) 86 throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, 87 NoSuchProviderException, SignatureException 88 { 89 try 90 { 91 cert.verify(key); 92 } 93 catch (java.security.cert.CertificateException ce) 94 { 95 throw new CertificateException(ce.getMessage()); 96 } 97 } 98 verify(PublicKey key, String sigProvider)99 public void verify(PublicKey key, String sigProvider) 100 throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, 101 NoSuchProviderException, SignatureException 102 { 103 try 104 { 105 cert.verify(key, sigProvider); 106 } 107 catch (java.security.cert.CertificateException ce) 108 { 109 throw new CertificateException(ce.getMessage()); 110 } 111 } 112 toString()113 public String toString() 114 { 115 return cert.toString(); 116 } 117 getPublicKey()118 public PublicKey getPublicKey() 119 { 120 return cert.getPublicKey(); 121 } 122 checkValidity()123 public void checkValidity() 124 throws CertificateExpiredException, CertificateNotYetValidException 125 { 126 try 127 { 128 cert.checkValidity(); 129 } 130 catch (java.security.cert.CertificateExpiredException cee) 131 { 132 throw new CertificateExpiredException(cee.getMessage()); 133 } 134 catch (java.security.cert.CertificateNotYetValidException cnyve) 135 { 136 throw new CertificateNotYetValidException(cnyve.getMessage()); 137 } 138 } 139 checkValidity(Date date)140 public void checkValidity(Date date) 141 throws CertificateExpiredException, CertificateNotYetValidException 142 { 143 try 144 { 145 cert.checkValidity(date); 146 } 147 catch (java.security.cert.CertificateExpiredException cee) 148 { 149 throw new CertificateExpiredException(cee.getMessage()); 150 } 151 catch (java.security.cert.CertificateNotYetValidException cnyve) 152 { 153 throw new CertificateNotYetValidException(cnyve.getMessage()); 154 } 155 } 156 getVersion()157 public int getVersion() 158 { 159 return cert.getVersion(); 160 } 161 getSerialNumber()162 public BigInteger getSerialNumber() 163 { 164 return cert.getSerialNumber(); 165 } 166 getIssuerDN()167 public Principal getIssuerDN() 168 { 169 return cert.getIssuerDN(); 170 } 171 getSubjectDN()172 public Principal getSubjectDN() 173 { 174 return cert.getSubjectDN(); 175 } 176 getNotBefore()177 public Date getNotBefore() 178 { 179 return cert.getNotBefore(); 180 } 181 getNotAfter()182 public Date getNotAfter() 183 { 184 return cert.getNotAfter(); 185 } 186 getSigAlgName()187 public String getSigAlgName() 188 { 189 return cert.getSigAlgName(); 190 } 191 getSigAlgOID()192 public String getSigAlgOID() 193 { 194 return cert.getSigAlgOID(); 195 } 196 getSigAlgParams()197 public byte[] getSigAlgParams() 198 { 199 return cert.getSigAlgParams(); 200 } 201 } 202