Package org.keycloak.common.crypto
Class PemUtilsProvider
- java.lang.Object
-
- org.keycloak.common.crypto.PemUtilsProvider
-
public abstract class PemUtilsProvider extends Object
Utility classes to extract PublicKey, PrivateKey, and X509Certificate from openssl generated PEM files- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
-
Constructor Summary
Constructors Constructor Description PemUtilsProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description X509Certificate
decodeCertificate(String cert)
Decode a X509 Certificate from a PEM stringabstract PrivateKey
decodePrivateKey(String pem)
Decode a Private Key from a PEM stringPublicKey
decodePublicKey(String pem)
Decode a Public Key from a PEM stringPublicKey
decodePublicKey(String pem, String type)
Decode a Public Key from a PEM stringprotected abstract String
encode(Object obj)
String
encodeCertificate(Certificate certificate)
Encode a X509 Certificate to a PEM stringString
encodeKey(Key key)
Encode a Key to a PEM stringString
generateThumbprint(String[] certChain, String encoding)
byte[]
pemToDer(String pem)
String
removeBeginEnd(String pem)
-
-
-
Method Detail
-
decodeCertificate
public X509Certificate decodeCertificate(String cert)
Decode a X509 Certificate from a PEM string- Parameters:
cert
-- Returns:
- Throws:
Exception
-
decodePublicKey
public PublicKey decodePublicKey(String pem)
Decode a Public Key from a PEM string- Parameters:
pem
-- Returns:
- Throws:
Exception
-
decodePublicKey
public PublicKey decodePublicKey(String pem, String type)
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
public abstract PrivateKey decodePrivateKey(String pem)
Decode a Private Key from a PEM string- Parameters:
pem
-- Returns:
- Throws:
Exception
-
encodeKey
public String encodeKey(Key key)
Encode a Key to a PEM string- Parameters:
key
-- Returns:
- Throws:
Exception
-
encodeCertificate
public String encodeCertificate(Certificate certificate)
Encode a X509 Certificate to a PEM string- Parameters:
certificate
-- Returns:
-
pemToDer
public byte[] pemToDer(String pem)
-
generateThumbprint
public String generateThumbprint(String[] certChain, String encoding) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
-