equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
167 { |
167 { |
168 PublicKey key = null; |
168 PublicKey key = null; |
169 |
169 |
170 try { |
170 try { |
171 KeyFactory keyFactory = |
171 KeyFactory keyFactory = |
172 KeyFactory.getInstance(encodedKeyAlgorithm, "SunJCE"); |
172 KeyFactory.getInstance(encodedKeyAlgorithm, |
|
173 SunJCE.getInstance()); |
173 X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encodedKey); |
174 X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encodedKey); |
174 key = keyFactory.generatePublic(keySpec); |
175 key = keyFactory.generatePublic(keySpec); |
175 } catch (NoSuchAlgorithmException nsae) { |
176 } catch (NoSuchAlgorithmException nsae) { |
176 // Try to see whether there is another |
177 // Try to see whether there is another |
177 // provider which supports this algorithm |
178 // provider which supports this algorithm |
189 } catch (InvalidKeySpecException ikse2) { |
190 } catch (InvalidKeySpecException ikse2) { |
190 // Should never happen. |
191 // Should never happen. |
191 } |
192 } |
192 } catch (InvalidKeySpecException ikse) { |
193 } catch (InvalidKeySpecException ikse) { |
193 // Should never happen. |
194 // Should never happen. |
194 } catch (NoSuchProviderException nspe) { |
|
195 // Should never happen. |
|
196 } |
195 } |
197 |
196 |
198 return key; |
197 return key; |
199 } |
198 } |
200 |
199 |
213 { |
212 { |
214 PrivateKey key = null; |
213 PrivateKey key = null; |
215 |
214 |
216 try { |
215 try { |
217 KeyFactory keyFactory = |
216 KeyFactory keyFactory = |
218 KeyFactory.getInstance(encodedKeyAlgorithm, "SunJCE"); |
217 KeyFactory.getInstance(encodedKeyAlgorithm, |
|
218 SunJCE.getInstance()); |
219 PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encodedKey); |
219 PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encodedKey); |
220 return keyFactory.generatePrivate(keySpec); |
220 return keyFactory.generatePrivate(keySpec); |
221 } catch (NoSuchAlgorithmException nsae) { |
221 } catch (NoSuchAlgorithmException nsae) { |
222 // Try to see whether there is another |
222 // Try to see whether there is another |
223 // provider which supports this algorithm |
223 // provider which supports this algorithm |
235 } catch (InvalidKeySpecException ikse2) { |
235 } catch (InvalidKeySpecException ikse2) { |
236 // Should never happen. |
236 // Should never happen. |
237 } |
237 } |
238 } catch (InvalidKeySpecException ikse) { |
238 } catch (InvalidKeySpecException ikse) { |
239 // Should never happen. |
239 // Should never happen. |
240 } catch (NoSuchProviderException nspe) { |
|
241 // Should never happen. |
|
242 } |
240 } |
243 |
241 |
244 return key; |
242 return key; |
245 } |
243 } |
246 |
244 |