Enhancement: Add support for RSA encryption key imports in JavaKeystoreKeyProvider (#29853)
closes #29852 Signed-off-by: Francis Pouatcha <francis.pouatcha@adorsys.com>
This commit is contained in:
parent
694ffaf289
commit
583054b929
2 changed files with 7 additions and 2 deletions
|
@ -93,7 +93,8 @@ public class JavaKeystoreKeyProvider implements KeyProvider {
|
||||||
String keyAlias = model.get(JavaKeystoreKeyProviderFactory.KEY_ALIAS_KEY);
|
String keyAlias = model.get(JavaKeystoreKeyProviderFactory.KEY_ALIAS_KEY);
|
||||||
|
|
||||||
return switch (algorithm) {
|
return switch (algorithm) {
|
||||||
case Algorithm.PS256, Algorithm.PS384, Algorithm.PS512, Algorithm.RS256, Algorithm.RS384, Algorithm.RS512 ->
|
case Algorithm.PS256, Algorithm.PS384, Algorithm.PS512, Algorithm.RS256, Algorithm.RS384, Algorithm.RS512,
|
||||||
|
Algorithm.RSA_OAEP, Algorithm.RSA1_5, Algorithm.RSA_OAEP_256 ->
|
||||||
loadRSAKey(realm, model, keyStore, keyAlias);
|
loadRSAKey(realm, model, keyStore, keyAlias);
|
||||||
case Algorithm.ES256, Algorithm.ES384, Algorithm.ES512 -> loadECKey(realm, model, keyStore, keyAlias);
|
case Algorithm.ES256, Algorithm.ES384, Algorithm.ES512 -> loadECKey(realm, model, keyStore, keyAlias);
|
||||||
default ->
|
default ->
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.keycloak.provider.ConfigurationValidationHelper;
|
||||||
import org.keycloak.provider.ProviderConfigProperty;
|
import org.keycloak.provider.ProviderConfigProperty;
|
||||||
import org.keycloak.provider.ProviderConfigurationBuilder;
|
import org.keycloak.provider.ProviderConfigurationBuilder;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@ -118,7 +119,10 @@ public class JavaKeystoreKeyProviderFactory implements KeyProviderFactory {
|
||||||
// merge the algorithms supported for RSA and EC keys and provide them as one configuration property
|
// merge the algorithms supported for RSA and EC keys and provide them as one configuration property
|
||||||
private static ProviderConfigProperty mergedAlgorithmProperties() {
|
private static ProviderConfigProperty mergedAlgorithmProperties() {
|
||||||
List<String> ecAlgorithms = List.of(Algorithm.ES256, Algorithm.ES384, Algorithm.ES512);
|
List<String> ecAlgorithms = List.of(Algorithm.ES256, Algorithm.ES384, Algorithm.ES512);
|
||||||
List<String> algorithms = Stream.concat(Attributes.RS_ALGORITHM_PROPERTY.getOptions().stream(), ecAlgorithms.stream()).toList();
|
List<String> algorithms = Stream.of(Attributes.RS_ALGORITHM_PROPERTY.getOptions(),
|
||||||
|
ecAlgorithms, Attributes.RS_ENC_ALGORITHM_PROPERTY.getOptions())
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.toList();
|
||||||
return new ProviderConfigProperty(Attributes.RS_ALGORITHM_PROPERTY.getName(), Attributes.RS_ALGORITHM_PROPERTY.getLabel(),
|
return new ProviderConfigProperty(Attributes.RS_ALGORITHM_PROPERTY.getName(), Attributes.RS_ALGORITHM_PROPERTY.getLabel(),
|
||||||
Attributes.RS_ALGORITHM_PROPERTY.getHelpText(), Attributes.RS_ALGORITHM_PROPERTY.getType(),
|
Attributes.RS_ALGORITHM_PROPERTY.getHelpText(), Attributes.RS_ALGORITHM_PROPERTY.getType(),
|
||||||
Attributes.RS_ALGORITHM_PROPERTY.getDefaultValue(), algorithms.toArray(String[]::new));
|
Attributes.RS_ALGORITHM_PROPERTY.getDefaultValue(), algorithms.toArray(String[]::new));
|
||||||
|
|
Loading…
Reference in a new issue