Skip to content

Commit

Permalink
Move getConfigProperties() static methods in the factory classes
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Meunier <lme@atolcd.com>
  • Loading branch information
lme-atolcd authored and clement-dufaure committed Apr 10, 2024
1 parent 9ec22bb commit d3f5d10
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package fr.insee.keycloak.providers.agentconnect;

import fr.insee.keycloak.providers.common.AbstractBaseProviderConfig;
import fr.insee.keycloak.providers.common.EidasLevel;
import org.keycloak.models.IdentityProviderMapperModel;
import org.keycloak.models.IdentityProviderModel;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.provider.ProviderConfigurationBuilder;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static fr.insee.keycloak.providers.agentconnect.AgentConnectIdentityProviderFactory.AC_PROVIDER_MAPPERS;
import static fr.insee.keycloak.providers.agentconnect.AgentConnectIdentityProviderFactory.DEFAULT_AC_ENVIRONMENT;
Expand Down Expand Up @@ -39,31 +34,4 @@ protected String getEnvironmentProperty(String key) {
protected List<IdentityProviderMapperModel> getDefaultMappers() {
return AC_PROVIDER_MAPPERS;
}

public static List<ProviderConfigProperty> getConfigProperties() {
List<String> environments = Stream.of(ACEnvironment.values())
.map(Enum::name)
.collect(Collectors.toList());

List<String> eidasLevels = Stream.of(EidasLevel.values())
.map(Enum::name)
.collect(Collectors.toList());

return ProviderConfigurationBuilder.create()
.property().name(ACEnvironment.ENVIRONMENT_PROPERTY_NAME)
.label("Environnement AgentConnect")
.helpText("Permet de choisir l'environnement AgentConnect. Effet : change les urls vers AgentConnect.")
.type(ProviderConfigProperty.LIST_TYPE)
.options(environments)
.defaultValue(DEFAULT_AC_ENVIRONMENT)
.add()
.property().name(EidasLevel.EIDAS_LEVEL_PROPERTY_NAME)
.label("Niveau de garantie eIDAS")
.helpText("Permet de fixer le niveau de garantie du compte utilisateur souhaité. Effet : désactive des fournisseurs d'identités (FI) sur la page de login AgentConnect.")
.type(ProviderConfigProperty.LIST_TYPE)
.options(eidasLevels)
.defaultValue(EidasLevel.EIDAS1)
.add()
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package fr.insee.keycloak.providers.agentconnect;

import fr.insee.keycloak.providers.common.EidasLevel;
import org.keycloak.broker.provider.AbstractIdentityProviderFactory;
import org.keycloak.broker.social.SocialIdentityProviderFactory;
import org.keycloak.models.IdentityProviderMapperModel;
import org.keycloak.models.IdentityProviderModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.provider.ProviderConfigurationBuilder;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static fr.insee.keycloak.providers.common.Utils.createHardcodedAttributeMapper;
import static fr.insee.keycloak.providers.common.Utils.createUserAttributeMapper;
Expand Down Expand Up @@ -50,6 +54,29 @@ public AgentConnectIdentityProviderConfig createConfig() {

@Override
public List<ProviderConfigProperty> getConfigProperties() {
return AgentConnectIdentityProviderConfig.getConfigProperties();
List<String> environments = Stream.of(ACEnvironment.values())
.map(Enum::name)
.collect(Collectors.toList());

List<String> eidasLevels = Stream.of(EidasLevel.values())
.map(Enum::name)
.collect(Collectors.toList());

return ProviderConfigurationBuilder.create()
.property().name(ACEnvironment.ENVIRONMENT_PROPERTY_NAME)
.label("Environnement AgentConnect")
.helpText("Permet de choisir l'environnement AgentConnect. Effet : change les urls vers AgentConnect.")
.type(ProviderConfigProperty.LIST_TYPE)
.options(environments)
.defaultValue(DEFAULT_AC_ENVIRONMENT)
.add()
.property().name(EidasLevel.EIDAS_LEVEL_PROPERTY_NAME)
.label("Niveau de garantie eIDAS")
.helpText("Permet de fixer le niveau de garantie du compte utilisateur souhaité. Effet : désactive des fournisseurs d'identités (FI) sur la page de login AgentConnect.")
.type(ProviderConfigProperty.LIST_TYPE)
.options(eidasLevels)
.defaultValue(EidasLevel.EIDAS1)
.add()
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@

import fr.insee.keycloak.providers.common.AbstractBaseProviderConfig;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import fr.insee.keycloak.providers.common.EidasLevel;
import org.keycloak.models.IdentityProviderMapperModel;
import org.keycloak.models.IdentityProviderModel;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.provider.ProviderConfigurationBuilder;

final class FranceConnectIdentityProviderConfig extends AbstractBaseProviderConfig {

Expand All @@ -37,31 +32,4 @@ protected String getEnvironmentProperty(String key) {
protected List<IdentityProviderMapperModel> getDefaultMappers() {
return FC_PROVIDER_MAPPERS;
}

public static List<ProviderConfigProperty> getConfigProperties() {
List<String> environments = Stream.of(FCEnvironment.values())
.map(Enum::name)
.collect(Collectors.toList());

List<String> eidasLevels = Stream.of(EidasLevel.values())
.map(Enum::name)
.collect(Collectors.toList());

return ProviderConfigurationBuilder.create()
.property().name(FCEnvironment.ENVIRONMENT_PROPERTY_NAME)
.label("Environnement FranceConnect")
.helpText("Permet de choisir l'environnement FranceConnect. Effet : change les urls vers FranceConnect.")
.type(ProviderConfigProperty.LIST_TYPE)
.options(environments)
.defaultValue(DEFAULT_FC_ENVIRONMENT)
.add()
.property().name(EidasLevel.EIDAS_LEVEL_PROPERTY_NAME)
.label("Niveau de garantie eIDAS")
.helpText("Permet de fixer le niveau de garantie du compte utilisateur souhaité. Effet : désactive des fournisseurs d'identités (FI) sur la page de login FranceConnect.")
.type(ProviderConfigProperty.LIST_TYPE)
.options(eidasLevels)
.defaultValue(EidasLevel.EIDAS1)
.add()
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package fr.insee.keycloak.providers.franceconnect;

import fr.insee.keycloak.providers.common.EidasLevel;
import org.keycloak.broker.provider.AbstractIdentityProviderFactory;
import org.keycloak.broker.social.SocialIdentityProviderFactory;
import org.keycloak.models.IdentityProviderMapperModel;
import org.keycloak.models.IdentityProviderModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.provider.ProviderConfigurationBuilder;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static fr.insee.keycloak.providers.common.Utils.createHardcodedAttributeMapper;
import static fr.insee.keycloak.providers.common.Utils.createUserAttributeMapper;
Expand Down Expand Up @@ -50,6 +54,29 @@ public FranceConnectIdentityProviderConfig createConfig() {

@Override
public List<ProviderConfigProperty> getConfigProperties() {
return FranceConnectIdentityProviderConfig.getConfigProperties();
List<String> environments = Stream.of(FCEnvironment.values())
.map(Enum::name)
.collect(Collectors.toList());

List<String> eidasLevels = Stream.of(EidasLevel.values())
.map(Enum::name)
.collect(Collectors.toList());

return ProviderConfigurationBuilder.create()
.property().name(FCEnvironment.ENVIRONMENT_PROPERTY_NAME)
.label("Environnement FranceConnect")
.helpText("Permet de choisir l'environnement FranceConnect. Effet : change les urls vers FranceConnect.")
.type(ProviderConfigProperty.LIST_TYPE)
.options(environments)
.defaultValue(DEFAULT_FC_ENVIRONMENT)
.add()
.property().name(EidasLevel.EIDAS_LEVEL_PROPERTY_NAME)
.label("Niveau de garantie eIDAS")
.helpText("Permet de fixer le niveau de garantie du compte utilisateur souhaité. Effet : désactive des fournisseurs d'identités (FI) sur la page de login FranceConnect.")
.type(ProviderConfigProperty.LIST_TYPE)
.options(eidasLevels)
.defaultValue(EidasLevel.EIDAS1)
.add()
.build();
}
}

0 comments on commit d3f5d10

Please sign in to comment.