Package org.keycloak.common.util
Class PemUtils
java.lang.Object
org.keycloak.common.util.PemUtils
Utility classes to extract PublicKey, PrivateKey, and X509Certificate from openssl generated PEM files
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringaddCertificateBeginEnd(String certificate) static StringaddPrivateKeyBeginEnd(String privateKeyPem) static StringaddRsaPrivateKeyBeginEnd(String privateKeyPem) static X509CertificatedecodeCertificate(String cert) Decode a X509 Certificate from a PEM stringstatic X509Certificate[]decodeCertificates(String certs) Decode one or more X509 Certificates from a PEM string (certificate bundle)static PrivateKeydecodePrivateKey(String pem) Decode a Private Key from a PEM stringstatic PublicKeydecodePublicKey(String pem) Decode a Public Key from a PEM stringstatic PublicKeydecodePublicKey(String pem, String type) Decode a Public Key from a PEM stringstatic StringencodeCertificate(Certificate certificate) Encode a X509 Certificate to a PEM stringstatic StringEncode a Key to a PEM stringstatic StringgenerateThumbprint(String[] certChain, String encoding) static byte[]static StringremoveBeginEnd(String pem) 
- 
Field Details- 
BEGIN_CERT- See Also:
 
- 
END_CERT- See Also:
 
- 
BEGIN_PRIVATE_KEY- See Also:
 
- 
END_PRIVATE_KEY- See Also:
 
- 
BEGIN_RSA_PRIVATE_KEY- See Also:
 
- 
END_RSA_PRIVATE_KEY- See Also:
 
 
- 
- 
Constructor Details- 
PemUtilspublic PemUtils()
 
- 
- 
Method Details- 
decodeCertificateDecode a X509 Certificate from a PEM string- Parameters:
- cert-
- Returns:
- Throws:
- Exception
 
- 
decodeCertificatesDecode one or more X509 Certificates from a PEM string (certificate bundle)- Parameters:
- certs-
- Returns:
- Throws:
- Exception
 
- 
decodePublicKeyDecode a Public Key from a PEM string- Parameters:
- pem-
- Returns:
- Throws:
- Exception
 
- 
decodePublicKeyDecode a Public Key from a PEM string- Parameters:
- pem- The pem encoded pblic key
- type- The type of the key (RSA, EC,...)
- Returns:
- The public key or null
 
- 
decodePrivateKeyDecode a Private Key from a PEM string- Parameters:
- pem-
- Returns:
- Throws:
- Exception
 
- 
encodeKeyEncode a Key to a PEM string- Parameters:
- key-
- Returns:
- Throws:
- Exception
 
- 
encodeCertificateEncode a X509 Certificate to a PEM string- Parameters:
- certificate-
- Returns:
 
- 
pemToDer
- 
removeBeginEnd
- 
addPrivateKeyBeginEnd
- 
addCertificateBeginEnd
- 
addRsaPrivateKeyBeginEnd
- 
generateThumbprintpublic static String generateThumbprint(String[] certChain, String encoding) throws NoSuchAlgorithmException - Throws:
- NoSuchAlgorithmException
 
 
-