question: 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" ) ; } }
target:  Translate an RSA key into a SunRsaSign RSA key. If conversion is not possible, throw an InvalidKeyException. See also JCA doc.