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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier 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
-
PemUtils
public PemUtils()
-
-
Method Details
-
decodeCertificate
Decode a X509 Certificate from a PEM string- Parameters:
cert-- Returns:
- Throws:
Exception
-
decodeCertificates
Decode one or more X509 Certificates from a PEM string (certificate bundle)- Parameters:
certs-- Returns:
- Throws:
Exception
-
decodePublicKey
Decode a Public Key from a PEM string- Parameters:
pem-- Returns:
- Throws:
Exception
-
decodePublicKey
Decode a Public Key from a PEM string- Parameters:
pem- The pem encoded pblic keytype- The type of the key (RSA, EC,...)- Returns:
- The public key or null
-
decodePrivateKey
Decode a Private Key from a PEM string- Parameters:
pem-- Returns:
- Throws:
Exception
-
encodeKey
Encode a Key to a PEM string- Parameters:
key-- Returns:
- Throws:
Exception
-
encodeCertificate
Encode a X509 Certificate to a PEM string- Parameters:
certificate-- Returns:
-
pemToDer
-
removeBeginEnd
-
addPrivateKeyBeginEnd
-
addCertificateBeginEnd
-
addRsaPrivateKeyBeginEnd
-
generateThumbprint
public static String generateThumbprint(String[] certChain, String encoding) throws NoSuchAlgorithmException - Throws:
NoSuchAlgorithmException
-