private final PrivateKey constructPrivateKey(byte[] encodedKey,String encodedKeyAlgorithm) throws InvalidKeyException, NoSuchAlgorithmException {
  PrivateKey key=null;
  try {
    KeyFactory keyFactory=KeyFactory.getInstance(encodedKeyAlgorithm,SunJCE.getInstance());
    PKCS8EncodedKeySpec keySpec=new PKCS8EncodedKeySpec(encodedKey);
    return keyFactory.generatePrivate(keySpec);
  }
 catch (  NoSuchAlgorithmException nsae) {
    try {
      KeyFactory keyFactory=KeyFactory.getInstance(encodedKeyAlgorithm);
      PKCS8EncodedKeySpec keySpec=new PKCS8EncodedKeySpec(encodedKey);
      key=keyFactory.generatePrivate(keySpec);
    }
 catch (    NoSuchAlgorithmException nsae2) {
      throw new NoSuchAlgorithmException("No installed providers " + "can create keys for the " + encodedKeyAlgorithm + "algorithm");
    }
catch (    InvalidKeySpecException ikse2) {
    }
  }
catch (  InvalidKeySpecException ikse) {
  }
  return key;
}

private final PrivateKey constructPrivateKey ( byte [ ] encodedKey , String encodedKeyAlgorithm ) throws InvalidKeyException , NoSuchAlgorithmException { PrivateKey key = null ; try { KeyFactory keyFactory = KeyFactory . getInstance ( encodedKeyAlgorithm , SunJCE . getInstance ( ) ) ; PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec ( encodedKey ) ; return keyFactory . generatePrivate ( keySpec ) ; } catch ( NoSuchAlgorithmException nsae ) { try { KeyFactory keyFactory = KeyFactory . getInstance ( encodedKeyAlgorithm ) ; PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec ( encodedKey ) ; key = keyFactory . generatePrivate ( keySpec ) ; } catch ( NoSuchAlgorithmException nsae2 ) { throw new NoSuchAlgorithmException ( "No installed providers " + "can create keys for the " + encodedKeyAlgorithm + "algorithm" ) ; } catch ( InvalidKeySpecException ikse2 ) { } } catch ( InvalidKeySpecException ikse ) { } return key ; }
construct a private key from its encoding .
