Widening cast for BCProvider for existing provider (#14202)

Closes #14210
This commit is contained in:
nehachopra27 2022-09-06 18:40:58 +01:00 committed by GitHub
parent 19d69169b1
commit 68a07465a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,13 +22,13 @@ import org.keycloak.common.crypto.UserIdentityExtractorProvider;
*/ */
public class DefaultCryptoProvider implements CryptoProvider { public class DefaultCryptoProvider implements CryptoProvider {
private final BouncyCastleProvider bcProvider; private final Provider bcProvider;
private Map<String, Object> providers = new ConcurrentHashMap<>(); private Map<String, Object> providers = new ConcurrentHashMap<>();
public DefaultCryptoProvider() { public DefaultCryptoProvider() {
// Make sure to instantiate this only once due it is expensive. And skip registration if already available in Java security providers (EG. due explicitly configured in java security file) // Make sure to instantiate this only once due it is expensive. And skip registration if already available in Java security providers (EG. due explicitly configured in java security file)
BouncyCastleProvider existingBc = (BouncyCastleProvider) Security.getProvider(CryptoConstants.BC_PROVIDER_ID); Provider existingBc = Security.getProvider(CryptoConstants.BC_PROVIDER_ID);
this.bcProvider = existingBc == null ? new BouncyCastleProvider() : existingBc; this.bcProvider = existingBc == null ? new BouncyCastleProvider() : existingBc;
providers.put(CryptoConstants.A128KW, new AesKeyWrapAlgorithmProvider()); providers.put(CryptoConstants.A128KW, new AesKeyWrapAlgorithmProvider());