Skip to content

Commit

Permalink
Add generated Key provider to add the required algorithm for FC+
Browse files Browse the repository at this point in the history
Signed-off-by: Cédric Couralet <[email protected]>
  • Loading branch information
micedre committed Nov 7, 2021
1 parent 1c2d96f commit 5308f4a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 <a href="mailto:[email protected]">Stian Thorgersen</a>
*/
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<ProviderConfigProperty> CONFIG_PROPERTIES = AbstractRsaKeyProviderFactory.configurationBuilder()
.property(Attributes.KEY_SIZE_PROPERTY)
.property(Attributes.KEY_USE_PROPERTY)
.build();

@Override
public String getId() {
return ID;
}

@Override
public List<ProviderConfigProperty> getConfigProperties() {
CONFIG_PROPERTIES.removeIf(p -> p.getName().equals("algorithm"));
CONFIG_PROPERTIES.add(RS_ALGORITHM_PROPERTY);
return CONFIG_PROPERTIES;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fr.insee.keycloak.keys.GeneratedRsaKeyFCProviderFactory

0 comments on commit 5308f4a

Please sign in to comment.