Package org.keycloak.common.util
Class PemUtils
- java.lang.Object
- 
- org.keycloak.common.util.PemUtils
 
- 
 public class PemUtils extends Object Utility classes to extract PublicKey, PrivateKey, and X509Certificate from openssl generated PEM files- Version:
- $Revision: 1 $
- Author:
- Bill Burke
 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringBEGIN_CERTstatic StringBEGIN_PRIVATE_KEYstatic StringBEGIN_RSA_PRIVATE_KEYstatic StringEND_CERTstatic StringEND_PRIVATE_KEYstatic StringEND_RSA_PRIVATE_KEY
 - 
Constructor SummaryConstructors Constructor Description PemUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static StringaddPrivateKeyBeginEnd(String privateKeyPem)static StringaddRsaPrivateKeyBeginEnd(String privateKeyPem)static X509CertificatedecodeCertificate(String cert)Decode a X509 Certificate from a PEM stringstatic 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 StringencodeKey(Key key)Encode a Key to a PEM stringstatic StringgenerateThumbprint(String[] certChain, String encoding)static byte[]pemToDer(String pem)static StringremoveBeginEnd(String pem)
 
- 
- 
- 
Field Detail- 
BEGIN_CERTpublic static final String BEGIN_CERT - See Also:
- Constant Field Values
 
 - 
END_CERTpublic static final String END_CERT - See Also:
- Constant Field Values
 
 - 
BEGIN_PRIVATE_KEYpublic static final String BEGIN_PRIVATE_KEY - See Also:
- Constant Field Values
 
 - 
END_PRIVATE_KEYpublic static final String END_PRIVATE_KEY - See Also:
- Constant Field Values
 
 - 
BEGIN_RSA_PRIVATE_KEYpublic static final String BEGIN_RSA_PRIVATE_KEY - See Also:
- Constant Field Values
 
 - 
END_RSA_PRIVATE_KEYpublic static final String END_RSA_PRIVATE_KEY - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
decodeCertificatepublic static X509Certificate decodeCertificate(String cert) Decode a X509 Certificate from a PEM string- Parameters:
- cert-
- Returns:
- Throws:
- Exception
 
 - 
decodePublicKeypublic static PublicKey decodePublicKey(String pem) Decode a Public Key from a PEM string- Parameters:
- pem-
- Returns:
- Throws:
- Exception
 
 - 
decodePublicKeypublic static PublicKey decodePublicKey(String pem, String type) Decode 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
 
 - 
decodePrivateKeypublic static PrivateKey decodePrivateKey(String pem) Decode a Private Key from a PEM string- Parameters:
- pem-
- Returns:
- Throws:
- Exception
 
 - 
encodeKeypublic static String encodeKey(Key key) Encode a Key to a PEM string- Parameters:
- key-
- Returns:
- Throws:
- Exception
 
 - 
encodeCertificatepublic static String encodeCertificate(Certificate certificate) Encode a X509 Certificate to a PEM string- Parameters:
- certificate-
- Returns:
 
 - 
pemToDerpublic static byte[] pemToDer(String pem) 
 - 
generateThumbprintpublic static String generateThumbprint(String[] certChain, String encoding) throws NoSuchAlgorithmException - Throws:
- NoSuchAlgorithmException
 
 
- 
 
-