public RSAPublicKey parsePEMPublicKey(String pem) throws GeneralSecurityException {
  try {
    byte[] bs=decodeAsciiArmoredPEM(pem);
    ByteBuffer data=ByteBuffer.wrap(bs);
    final ASN1Object ob=asn1Parser.parseASN1(data);
    final List<ASN1Object> seq=asn1ObjectToSequence(ob,2);
    final BigInteger modulus=asn1ObjectToBigInt(seq.get(0));
    final BigInteger exponent=asn1ObjectToBigInt(seq.get(1));
    return createKeyFromModulusAndExponent(modulus,exponent);
  }
 catch (  IllegalArgumentException e) {
    throw new InvalidKeyException();
  }
}

public RSAPublicKey parsePEMPublicKey ( String pem ) throws GeneralSecurityException { try { byte [ ] bs = decodeAsciiArmoredPEM ( pem ) ; ByteBuffer data = ByteBuffer . wrap ( bs ) ; final ASN1Object ob = asn1Parser . parseASN1 ( data ) ; final List < ASN1Object > seq = asn1ObjectToSequence ( ob , 2 ) ; final BigInteger modulus = asn1ObjectToBigInt ( seq . get ( 0 ) ) ; final BigInteger exponent = asn1ObjectToBigInt ( seq . get ( 1 ) ) ; return createKeyFromModulusAndExponent ( modulus , exponent ) ; } catch ( IllegalArgumentException e ) { throw new InvalidKeyException ( ) ; } }
parse a pkcs1 pem encoded rsa public key into the modulus / exponent components and construct a new rsapublickey
