protected Key engineTranslateKey(Key key) throws InvalidKeyException {
  if (key == null) {
    throw new InvalidKeyException("Key must not be null");
  }
  String keyAlg=key.getAlgorithm();
  if (keyAlg.equals("RSA") == false) {
    throw new InvalidKeyException("Not an RSA key: " + keyAlg);
  }
  if (key instanceof PublicKey) {
    return translatePublicKey((PublicKey)key);
  }
 else   if (key instanceof PrivateKey) {
    return translatePrivateKey((PrivateKey)key);
  }
 else {
    throw new InvalidKeyException("Neither a public nor a private key");
  }
}

protected Key engineTranslateKey ( Key key ) throws InvalidKeyException { if ( key == null ) { throw new InvalidKeyException ( "Key must not be null" ) ; } String keyAlg = key . getAlgorithm ( ) ; if ( keyAlg . equals ( "RSA" ) == false ) { throw new InvalidKeyException ( "Not an RSA key: " + keyAlg ) ; } if ( key instanceof PublicKey ) { return translatePublicKey ( ( PublicKey ) key ) ; } else if ( key instanceof PrivateKey ) { return translatePrivateKey ( ( PrivateKey ) key ) ; } else { throw new InvalidKeyException ( "Neither a public nor a private key" ) ; } }
translate an rsa key into a sunrsasign rsa key . if conversion is not possible , throw an invalidkeyexception . see also jca doc .
