7 |
it under the terms of the GNU General Public License as published by |
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) |
the Free Software Foundation; either version 2, or (at your option) |
9 |
any later version. |
any later version. |
10 |
|
|
11 |
GNU Classpath is distributed in the hope that it will be useful, but |
GNU Classpath is distributed in the hope that it will be useful, but |
12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
44 |
import java.io.IOException; |
import java.io.IOException; |
45 |
|
|
46 |
import java.security.cert.Certificate; |
import java.security.cert.Certificate; |
47 |
|
import java.security.cert.CertificateEncodingException; |
48 |
import java.security.cert.CertificateException; |
import java.security.cert.CertificateException; |
49 |
import java.security.cert.CertificateFactorySpi; |
import java.security.cert.CertificateFactorySpi; |
50 |
|
import java.security.cert.CertPath; |
51 |
import java.security.cert.CRL; |
import java.security.cert.CRL; |
52 |
import java.security.cert.CRLException; |
import java.security.cert.CRLException; |
53 |
|
|
54 |
import java.util.Collection; |
import java.util.Collection; |
55 |
|
import java.util.Iterator; |
56 |
import java.util.LinkedList; |
import java.util.LinkedList; |
57 |
|
import java.util.List; |
58 |
|
|
59 |
import gnu.java.io.Base64InputStream; |
import gnu.java.io.Base64InputStream; |
60 |
import gnu.java.security.x509.X509Certificate; |
import gnu.java.security.x509.X509Certificate; |
61 |
|
import gnu.java.security.x509.X509CertPath; |
62 |
import gnu.java.security.x509.X509CRL; |
import gnu.java.security.x509.X509CRL; |
63 |
|
|
64 |
public class X509CertificateFactory extends CertificateFactorySpi |
public class X509CertificateFactory extends CertificateFactorySpi |
92 |
} |
} |
93 |
catch (IOException ioe) |
catch (IOException ioe) |
94 |
{ |
{ |
95 |
throw new CertificateException(ioe.toString()); |
CertificateException ce = new CertificateException(ioe.getMessage()); |
96 |
|
ce.initCause (ioe); |
97 |
|
throw ce; |
98 |
} |
} |
99 |
} |
} |
100 |
|
|
114 |
} |
} |
115 |
catch (IOException ioe) |
catch (IOException ioe) |
116 |
{ |
{ |
117 |
throw new CertificateException(ioe.toString()); |
CertificateException ce = new CertificateException(ioe.getMessage()); |
118 |
|
ce.initCause (ioe); |
119 |
|
throw ce; |
120 |
} |
} |
121 |
} |
} |
122 |
return certs; |
return certs; |
130 |
} |
} |
131 |
catch (IOException ioe) |
catch (IOException ioe) |
132 |
{ |
{ |
133 |
throw new CRLException(ioe.toString()); |
CRLException crle = new CRLException(ioe.getMessage()); |
134 |
|
crle.initCause (ioe); |
135 |
|
throw crle; |
136 |
} |
} |
137 |
} |
} |
138 |
|
|
152 |
} |
} |
153 |
catch (IOException ioe) |
catch (IOException ioe) |
154 |
{ |
{ |
155 |
throw new CRLException(ioe.toString()); |
CRLException crle = new CRLException(ioe.getMessage()); |
156 |
|
crle.initCause (ioe); |
157 |
|
throw crle; |
158 |
} |
} |
159 |
} |
} |
160 |
return crls; |
return crls; |
161 |
} |
} |
162 |
|
|
163 |
|
public CertPath engineGenerateCertPath(List certs) |
164 |
|
{ |
165 |
|
return new X509CertPath(certs); |
166 |
|
} |
167 |
|
|
168 |
|
public CertPath engineGenerateCertPath(InputStream in) |
169 |
|
throws CertificateEncodingException |
170 |
|
{ |
171 |
|
return new X509CertPath(in); |
172 |
|
} |
173 |
|
|
174 |
|
public CertPath engineGenerateCertPath(InputStream in, String encoding) |
175 |
|
throws CertificateEncodingException |
176 |
|
{ |
177 |
|
return new X509CertPath(in, encoding); |
178 |
|
} |
179 |
|
|
180 |
|
public Iterator engineGetCertPathEncodings() |
181 |
|
{ |
182 |
|
return X509CertPath.ENCODINGS.iterator(); |
183 |
|
} |
184 |
|
|
185 |
// Own methods. |
// Own methods. |
186 |
// ------------------------------------------------------------------------ |
// ------------------------------------------------------------------------ |
187 |
|
|
188 |
private X509Certificate generateCert(InputStream inStream) |
private X509Certificate generateCert(InputStream inStream) |
189 |
throws IOException, CertificateException |
throws IOException, CertificateException |
190 |
{ |
{ |
191 |
|
if (inStream == null) |
192 |
|
throw new CertificateException("missing input stream"); |
193 |
if (!inStream.markSupported()) |
if (!inStream.markSupported()) |
194 |
inStream = new BufferedInputStream(inStream, 8192); |
inStream = new BufferedInputStream(inStream, 8192); |
195 |
inStream.mark(20); |
inStream.mark(20); |
248 |
private X509CRL generateCRL(InputStream inStream) |
private X509CRL generateCRL(InputStream inStream) |
249 |
throws IOException, CRLException |
throws IOException, CRLException |
250 |
{ |
{ |
251 |
|
if (inStream == null) |
252 |
|
throw new CRLException("missing input stream"); |
253 |
if (!inStream.markSupported()) |
if (!inStream.markSupported()) |
254 |
inStream = new BufferedInputStream(inStream, 8192); |
inStream = new BufferedInputStream(inStream, 8192); |
255 |
inStream.mark(20); |
inStream.mark(20); |
304 |
return new X509CRL(inStream); |
return new X509CRL(inStream); |
305 |
} |
} |
306 |
} |
} |
|
|
|
307 |
} |
} |