< prev index next >

src/java.base/share/classes/sun/security/x509/X509Key.java

Print this page




 238 
 239             sunProvider = Security.getProvider("SUN");
 240             if (sunProvider == null)
 241                 throw new InstantiationException();
 242             classname = sunProvider.getProperty("PublicKey.X.509." +
 243               algid.getName());
 244             if (classname == null) {
 245                 throw new InstantiationException();
 246             }
 247 
 248             Class<?> keyClass = null;
 249             try {
 250                 keyClass = Class.forName(classname);
 251             } catch (ClassNotFoundException e) {
 252                 ClassLoader cl = ClassLoader.getSystemClassLoader();
 253                 if (cl != null) {
 254                     keyClass = cl.loadClass(classname);
 255                 }
 256             }
 257 
 258             Object      inst = null;

 259             X509Key     result;
 260 
 261             if (keyClass != null)
 262                 inst = keyClass.newInstance();
 263             if (inst instanceof X509Key) {
 264                 result = (X509Key) inst;
 265                 result.algid = algid;
 266                 result.setKey(key);
 267                 result.parseKeyBits();
 268                 return result;
 269             }
 270         } catch (ClassNotFoundException e) {
 271         } catch (InstantiationException e) {
 272         } catch (IllegalAccessException e) {
 273             // this should not happen.
 274             throw new IOException (classname + " [internal error]");
 275         }
 276 
 277         X509Key result = new X509Key(algid, key);
 278         return result;
 279     }
 280 
 281     /**
 282      * Returns the algorithm to be used with this key.




 238 
 239             sunProvider = Security.getProvider("SUN");
 240             if (sunProvider == null)
 241                 throw new InstantiationException();
 242             classname = sunProvider.getProperty("PublicKey.X.509." +
 243               algid.getName());
 244             if (classname == null) {
 245                 throw new InstantiationException();
 246             }
 247 
 248             Class<?> keyClass = null;
 249             try {
 250                 keyClass = Class.forName(classname);
 251             } catch (ClassNotFoundException e) {
 252                 ClassLoader cl = ClassLoader.getSystemClassLoader();
 253                 if (cl != null) {
 254                     keyClass = cl.loadClass(classname);
 255                 }
 256             }
 257 
 258             @SuppressWarnings("deprecation")
 259             Object      inst = (keyClass != null) ? keyClass.newInstance() : null;
 260             X509Key     result;
 261 


 262             if (inst instanceof X509Key) {
 263                 result = (X509Key) inst;
 264                 result.algid = algid;
 265                 result.setKey(key);
 266                 result.parseKeyBits();
 267                 return result;
 268             }
 269         } catch (ClassNotFoundException e) {
 270         } catch (InstantiationException e) {
 271         } catch (IllegalAccessException e) {
 272             // this should not happen.
 273             throw new IOException (classname + " [internal error]");
 274         }
 275 
 276         X509Key result = new X509Key(algid, key);
 277         return result;
 278     }
 279 
 280     /**
 281      * Returns the algorithm to be used with this key.


< prev index next >