Top Description Constructors Methods
org.keycloak.common.crypto

public abstract Class PemUtilsProvider

extends Object
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, java.security.Key, .MessageDigest, .NoSuchAlgorithmException, .PrivateKey, .PublicKey, java.security.cert.Certificate, .X509Certificate, org.keycloak.common.util.Base64, .Base64Url, .DerUtils, .PemException

Utility classes to extract PublicKey, PrivateKey, and X509Certificate from openssl generated PEM files
Author
Bill Burke
Version
$Revision: 1 $

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public X509Certificate
decodeCertificate(String cert)

Decode a X509 Certificate from a PEM string

public abstract PrivateKey
decodePrivateKey(String pem)

Decode a Private Key from a PEM string

public PublicKey
decodePublicKey(String pem)

Decode a Public Key from a PEM string

public PublicKey

Returns:

The public key or null
decodePublicKey
(String
The pem encoded pblic key
pem
,
String
The type of the key (RSA, EC,...)
type
)

Decode a Public Key from a PEM string

protected abstract String
public String
encodeCertificate(Certificate certificate)

Encode a X509 Certificate to a PEM string

public String
encodeKey(Key key)

Encode a Key to a PEM string

public String
generateThumbprint(String[] certChain, String encoding)

private byte[]
generateThumbprintBytes(String[] certChain, String encoding)

public byte[]
public String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

PemUtilsProviderback to summary
public PemUtilsProvider()

Method Detail

decodeCertificateback to summary
public X509Certificate decodeCertificate(String cert)

Decode a X509 Certificate from a PEM string

decodePrivateKeyback to summary
public abstract PrivateKey decodePrivateKey(String pem)

Decode a Private Key from a PEM string

decodePublicKeyback to summary
public PublicKey decodePublicKey(String pem)

Decode a Public Key from a PEM string

decodePublicKeyback to summary
public PublicKey decodePublicKey(String pem, String type)

Decode a Public Key from a PEM string

Parameters
pem:String

The pem encoded pblic key

type:String

The type of the key (RSA, EC,...)

Returns:PublicKey

The public key or null

encodeback to summary
protected abstract String encode(Object obj)
encodeCertificateback to summary
public String encodeCertificate(Certificate certificate)

Encode a X509 Certificate to a PEM string

encodeKeyback to summary
public String encodeKey(Key key)

Encode a Key to a PEM string

generateThumbprintback to summary
public String generateThumbprint(String[] certChain, String encoding) throws NoSuchAlgorithmException
generateThumbprintBytesback to summary
private byte[] generateThumbprintBytes(String[] certChain, String encoding) throws NoSuchAlgorithmException
pemToDerback to summary
public byte[] pemToDer(String pem)
removeBeginEndback to summary
public String removeBeginEnd(String pem)