From 5308f4a99911076df403bf8c81c85f3e66c6b32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Couralet?= Date: Sat, 6 Nov 2021 06:28:35 +0100 Subject: [PATCH] Add generated Key provider to add the required algorithm for FC+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédric Couralet --- .../GeneratedRsaKeyFCProviderFactory.java | 42 +++++++++++++++++++ .../org.keycloak.keys.KeyProviderFactory | 1 + 2 files changed, 43 insertions(+) create mode 100644 src/main/java/fr/insee/keycloak/keys/GeneratedRsaKeyFCProviderFactory.java create mode 100644 src/main/resources/META-INF/services/org.keycloak.keys.KeyProviderFactory diff --git a/src/main/java/fr/insee/keycloak/keys/GeneratedRsaKeyFCProviderFactory.java b/src/main/java/fr/insee/keycloak/keys/GeneratedRsaKeyFCProviderFactory.java new file mode 100644 index 0000000..5e8a1be --- /dev/null +++ b/src/main/java/fr/insee/keycloak/keys/GeneratedRsaKeyFCProviderFactory.java @@ -0,0 +1,42 @@ +package fr.insee.keycloak.keys; + +import java.util.List; + + +import org.keycloak.crypto.Algorithm; +import org.keycloak.keys.AbstractRsaKeyProviderFactory; +import org.keycloak.keys.Attributes; +import org.keycloak.keys.GeneratedRsaKeyProviderFactory; +import org.keycloak.provider.ProviderConfigProperty; + +/** + * @author Stian Thorgersen + */ +public class GeneratedRsaKeyFCProviderFactory extends GeneratedRsaKeyProviderFactory { + + public static final String ID = "rsa-generated-fc+"; + + + + + private static ProviderConfigProperty RS_ALGORITHM_PROPERTY = new ProviderConfigProperty("algorithm", "Algorithm", + "Intended algorithm for the key", ProviderConfigProperty.LIST_TYPE, "RSA-OAEP", "RSA-OAEP"); + + private static final List CONFIG_PROPERTIES = AbstractRsaKeyProviderFactory.configurationBuilder() + .property(Attributes.KEY_SIZE_PROPERTY) + .property(Attributes.KEY_USE_PROPERTY) + .build(); + + @Override + public String getId() { + return ID; + } + + @Override + public List getConfigProperties() { + CONFIG_PROPERTIES.removeIf(p -> p.getName().equals("algorithm")); + CONFIG_PROPERTIES.add(RS_ALGORITHM_PROPERTY); + return CONFIG_PROPERTIES; + } + +} diff --git a/src/main/resources/META-INF/services/org.keycloak.keys.KeyProviderFactory b/src/main/resources/META-INF/services/org.keycloak.keys.KeyProviderFactory new file mode 100644 index 0000000..273026f --- /dev/null +++ b/src/main/resources/META-INF/services/org.keycloak.keys.KeyProviderFactory @@ -0,0 +1 @@ +fr.insee.keycloak.keys.GeneratedRsaKeyFCProviderFactory \ No newline at end of file