Top Description Methods
org.keycloak.common.crypto

public Interface CryptoProvider

Imports
java.security.InvalidAlgorithmParameterException, .KeyFactory, .KeyPairGenerator, .KeyStore, .KeyStoreException, .NoSuchAlgorithmException, .NoSuchProviderException, .Provider, .Signature, java.security.cert.CertPathBuilder, .CertStore, .CertificateException, .CertificateFactory, .CollectionCertStoreParameters, java.security.spec.ECParameterSpec, java.util.stream.Stream, javax.crypto.Cipher, .NoSuchPaddingException, .SecretKeyFactory, javax.net.ssl.SSLSocketFactory, org.keycloak.common.util.KeystoreUtil.KeystoreFormat

Abstraction to handle differences between the APIs for non-fips and fips mode
Author
Marek Posolda

Method Summary

Modifier and TypeMethod and Description
public ECParameterSpec
createECParams(String curveName)

Create the param spec for the EC curve

public Cipher
public Cipher
public <T> T
getAlgorithmProvider(Class<T>
Returned class.
clazz
,
String
Type of the algorithm, which we want to return
algorithm
)

Get some algorithm provider implementation.

public Provider

Returns:

BouncyCastle security provider. Can be either non-FIPS or FIPS based provider
getBouncyCastleProvider
()

public CertificateUtilsProvider
getCertificateUtils()

Get CertificateUtils implementation.

public CertPathBuilder
public CertStore
getCertStore(CollectionCertStoreParameters collectionCertStoreParameters)

public ECDSACryptoProvider
public UserIdentityExtractorProvider
public KeyFactory
getKeyFactory(String algorithm)

public KeyPairGenerator
getKeyPairGen(String algorithm)

public KeyStore
public <T> T
getOCSPProver(Class<T> clazz)

public PemUtilsProvider
getPemUtils()

Get PEMUtils implementation.

public SecretKeyFactory
getSecretKeyFact(String keyAlgorithm)

public Signature
getSignature(String sigAlgName)

public default Stream<KeystoreUtil.KeystoreFormat>

Returns:

Keystore types/algorithms supported by this CryptoProvider
getSupportedKeyStoreTypes
()

public default String[]

Returns:

Allowed key sizes of RSA key modulus, which this cryptoProvider supports
getSupportedRsaKeySizes
()

public CertificateFactory
public SSLSocketFactory

Returns:

decorated factory
wrapFactoryForTruststore
(SSLSocketFactory
The original factory to wrap. Usually default java SSLSocketFactory
delegate
)

Wrap given SSLSocketFactory and decorate it with some additional functionality.

Method Detail

createECParamsback to summary
public ECParameterSpec createECParams(String curveName)

Create the param spec for the EC curve

getAesCbcCipherback to summary
public Cipher getAesCbcCipher() throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException
getAesGcmCipherback to summary
public Cipher getAesGcmCipher() throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException
getAlgorithmProviderback to summary
public <T> T getAlgorithmProvider(Class<T> clazz, String algorithm)

Get some algorithm provider implementation. Returned implementation can be dependent according to if we have non-fips bouncycastle or fips bouncycastle on the classpath.

Parameters
clazz:Class<T>

Returned class.

algorithm:String

Type of the algorithm, which we want to return

getBouncyCastleProviderback to summary
public Provider getBouncyCastleProvider()
Returns:Provider

BouncyCastle security provider. Can be either non-FIPS or FIPS based provider

getCertificateUtilsback to summary
public CertificateUtilsProvider getCertificateUtils()

Get CertificateUtils implementation. Returned implementation can be dependent according to if we have non-fips bouncycastle or fips bouncycastle on the classpath.

getCertPathBuilderback to summary
public CertPathBuilder getCertPathBuilder() throws NoSuchAlgorithmException, NoSuchProviderException
getCertStoreback to summary
public CertStore getCertStore(CollectionCertStoreParameters collectionCertStoreParameters) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException
getEcdsaCryptoProviderback to summary
public ECDSACryptoProvider getEcdsaCryptoProvider()
getIdentityExtractorProviderback to summary
public UserIdentityExtractorProvider getIdentityExtractorProvider()
getKeyFactoryback to summary
public KeyFactory getKeyFactory(String algorithm) throws NoSuchAlgorithmException, NoSuchProviderException
getKeyPairGenback to summary
public KeyPairGenerator getKeyPairGen(String algorithm) throws NoSuchAlgorithmException, NoSuchProviderException
getKeyStoreback to summary
public KeyStore getKeyStore(KeystoreUtil.KeystoreFormat format) throws KeyStoreException, NoSuchProviderException
getOCSPProverback to summary
public <T> T getOCSPProver(Class<T> clazz)
getPemUtilsback to summary
public PemUtilsProvider getPemUtils()

Get PEMUtils implementation. Returned implementation can be dependent according to if we have non-fips bouncycastle or fips bouncycastle on the classpath.

getSecretKeyFactback to summary
public SecretKeyFactory getSecretKeyFact(String keyAlgorithm) throws NoSuchAlgorithmException, NoSuchProviderException
getSignatureback to summary
public Signature getSignature(String sigAlgName) throws NoSuchAlgorithmException, NoSuchProviderException
getSupportedKeyStoreTypesback to summary
public default Stream<KeystoreUtil.KeystoreFormat> getSupportedKeyStoreTypes()
Returns:Stream<KeystoreUtil.KeystoreFormat>

Keystore types/algorithms supported by this CryptoProvider

getSupportedRsaKeySizesback to summary
public default String[] getSupportedRsaKeySizes()
Returns:String[]

Allowed key sizes of RSA key modulus, which this cryptoProvider supports

getX509CertFactoryback to summary
public CertificateFactory getX509CertFactory() throws CertificateException, NoSuchProviderException
wrapFactoryForTruststoreback to summary
public SSLSocketFactory wrapFactoryForTruststore(SSLSocketFactory delegate)

Wrap given SSLSocketFactory and decorate it with some additional functionality. This method is used in the context of truststore (where Keycloak is SSL client)

Parameters
delegate:SSLSocketFactory

The original factory to wrap. Usually default java SSLSocketFactory

Returns:SSLSocketFactory

decorated factory