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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
addPrivateKeyBeginEnd
(String privateKeyPem) static String
addRsaPrivateKeyBeginEnd
(String privateKeyPem) static X509Certificate
decodeCertificate
(String cert) Decode a X509 Certificate from a PEM stringstatic PrivateKey
decodePrivateKey
(String pem) Decode a Private Key from a PEM stringstatic PublicKey
decodePublicKey
(String pem) Decode a Public Key from a PEM stringstatic PublicKey
decodePublicKey
(String pem, String type) Decode a Public Key from a PEM stringstatic String
encodeCertificate
(Certificate certificate) Encode a X509 Certificate to a PEM stringstatic String
Encode a Key to a PEM stringstatic String
generateThumbprint
(String[] certChain, String encoding) static byte[]
static String
removeBeginEnd
(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
-
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
-
addRsaPrivateKeyBeginEnd
-
generateThumbprint
public static String generateThumbprint(String[] certChain, String encoding) throws NoSuchAlgorithmException - Throws:
NoSuchAlgorithmException
-