< prev index next >

src/java.base/share/classes/sun/security/pkcs/PKCS8Key.java

Print this page




 201 
 202             sunProvider = Security.getProvider("SUN");
 203             if (sunProvider == null)
 204                 throw new InstantiationException();
 205             classname = sunProvider.getProperty("PrivateKey.PKCS#8." +
 206               algid.getName());
 207             if (classname == null) {
 208                 throw new InstantiationException();
 209             }
 210 
 211             Class<?> keyClass = null;
 212             try {
 213                 keyClass = Class.forName(classname);
 214             } catch (ClassNotFoundException e) {
 215                 ClassLoader cl = ClassLoader.getSystemClassLoader();
 216                 if (cl != null) {
 217                     keyClass = cl.loadClass(classname);
 218                 }
 219             }
 220 
 221             Object      inst = null;

 222             PKCS8Key    result;
 223 
 224             if (keyClass != null)
 225                 inst = keyClass.newInstance();
 226             if (inst instanceof PKCS8Key) {
 227                 result = (PKCS8Key) inst;
 228                 result.algid = algid;
 229                 result.key = key;
 230                 result.parseKeyBits();
 231                 return result;
 232             }
 233         } catch (ClassNotFoundException e) {
 234         } catch (InstantiationException e) {
 235         } catch (IllegalAccessException e) {
 236             // this should not happen.
 237             throw new IOException (classname + " [internal error]");
 238         }
 239 
 240         PKCS8Key result = new PKCS8Key();
 241         result.algid = algid;
 242         result.key = key;
 243         return result;
 244     }
 245 




 201 
 202             sunProvider = Security.getProvider("SUN");
 203             if (sunProvider == null)
 204                 throw new InstantiationException();
 205             classname = sunProvider.getProperty("PrivateKey.PKCS#8." +
 206               algid.getName());
 207             if (classname == null) {
 208                 throw new InstantiationException();
 209             }
 210 
 211             Class<?> keyClass = null;
 212             try {
 213                 keyClass = Class.forName(classname);
 214             } catch (ClassNotFoundException e) {
 215                 ClassLoader cl = ClassLoader.getSystemClassLoader();
 216                 if (cl != null) {
 217                     keyClass = cl.loadClass(classname);
 218                 }
 219             }
 220 
 221             @SuppressWarnings("deprecation")
 222             Object      inst = (keyClass != null) ? keyClass.newInstance() : null;
 223             PKCS8Key    result;
 224 


 225             if (inst instanceof PKCS8Key) {
 226                 result = (PKCS8Key) inst;
 227                 result.algid = algid;
 228                 result.key = key;
 229                 result.parseKeyBits();
 230                 return result;
 231             }
 232         } catch (ClassNotFoundException e) {
 233         } catch (InstantiationException e) {
 234         } catch (IllegalAccessException e) {
 235             // this should not happen.
 236             throw new IOException (classname + " [internal error]");
 237         }
 238 
 239         PKCS8Key result = new PKCS8Key();
 240         result.algid = algid;
 241         result.key = key;
 242         return result;
 243     }
 244 


< prev index next >