use of io.jans.model.custom.script.conf.CustomScriptConfiguration in project jans by JanssenProject.
the class IdTokenFactory method setAmrClaim.
private void setAmrClaim(JsonWebResponse jwt, String acrValues) {
List<String> amrList = Lists.newArrayList();
CustomScriptConfiguration script = externalAuthenticationService.getCustomScriptConfigurationByName(acrValues);
if (script != null) {
amrList.add(Integer.toString(script.getLevel()));
PersonAuthenticationType externalAuthenticator = (PersonAuthenticationType) script.getExternalType();
int apiVersion = externalAuthenticator.getApiVersion();
if (apiVersion > 3) {
Map<String, String> authenticationMethodClaimsOrNull = externalAuthenticator.getAuthenticationMethodClaims(script.getConfigurationAttributes());
if (authenticationMethodClaimsOrNull != null) {
for (String key : authenticationMethodClaimsOrNull.keySet()) {
amrList.add(key + ":" + authenticationMethodClaimsOrNull.get(key));
}
}
}
}
jwt.getClaims().setClaim(JwtClaimName.AUTHENTICATION_METHOD_REFERENCES, amrList);
}
use of io.jans.model.custom.script.conf.CustomScriptConfiguration in project jans by JanssenProject.
the class ExternalAuthenticationService method groupCustomScriptConfigurationsMapByUsageType.
private Map<AuthenticationScriptUsageType, List<CustomScriptConfiguration>> groupCustomScriptConfigurationsMapByUsageType(Map<String, CustomScriptConfiguration> customScriptConfigurationsMap) {
Map<AuthenticationScriptUsageType, List<CustomScriptConfiguration>> newCustomScriptConfigurationsMapByUsageType = new HashMap<AuthenticationScriptUsageType, List<CustomScriptConfiguration>>();
for (AuthenticationScriptUsageType usageType : AuthenticationScriptUsageType.values()) {
List<CustomScriptConfiguration> currCustomScriptConfigurationsMapByUsageType = new ArrayList<CustomScriptConfiguration>();
for (CustomScriptConfiguration customScriptConfiguration : customScriptConfigurationsMap.values()) {
if (!isValidateUsageType(usageType, customScriptConfiguration)) {
continue;
}
currCustomScriptConfigurationsMapByUsageType.add(customScriptConfiguration);
}
newCustomScriptConfigurationsMapByUsageType.put(usageType, currCustomScriptConfigurationsMapByUsageType);
}
return newCustomScriptConfigurationsMapByUsageType;
}
use of io.jans.model.custom.script.conf.CustomScriptConfiguration in project jans by JanssenProject.
the class ExternalAuthenticationService method getInternalCustomScriptConfiguration.
private CustomScriptConfiguration getInternalCustomScriptConfiguration(GluuLdapConfiguration ldapAuthConfig) {
CustomScriptConfiguration customScriptConfiguration = getInternalCustomScriptConfiguration();
customScriptConfiguration.getCustomScript().setName(ldapAuthConfig.getConfigId());
return customScriptConfiguration;
}
use of io.jans.model.custom.script.conf.CustomScriptConfiguration in project jans by JanssenProject.
the class ExternalAuthenticationService method getAuthModesByAcrValues.
public List<String> getAuthModesByAcrValues(List<String> acrValues) {
List<String> authModes = new ArrayList<String>();
for (String acrValue : acrValues) {
if (StringHelper.isNotEmpty(acrValue)) {
String customScriptName = StringHelper.toLowerCase(scriptName(acrValue));
if (customScriptConfigurationsNameMap.containsKey(customScriptName)) {
CustomScriptConfiguration customScriptConfiguration = customScriptConfigurationsNameMap.get(customScriptName);
CustomScript customScript = customScriptConfiguration.getCustomScript();
// Handle internal authentication method
if (customScript.isInternal()) {
authModes.add(scriptName(acrValue));
continue;
}
CustomScriptType customScriptType = customScriptConfiguration.getCustomScript().getScriptType();
BaseExternalType defaultImplementation = customScriptType.getDefaultImplementation();
BaseExternalType pythonImplementation = customScriptConfiguration.getExternalType();
if ((pythonImplementation != null) && (defaultImplementation != pythonImplementation)) {
authModes.add(scriptName(acrValue));
}
}
}
}
return authModes;
}
use of io.jans.model.custom.script.conf.CustomScriptConfiguration in project jans by JanssenProject.
the class ExternalAuthenticationService method levelToAcrMapping.
public Map<Integer, Set<String>> levelToAcrMapping() {
Map<Integer, Set<String>> map = Maps.newHashMap();
for (CustomScriptConfiguration script : getCustomScriptConfigurationsMap()) {
int level = script.getLevel();
String acr = script.getName();
Set<String> acrs = map.get(level);
if (acrs == null) {
acrs = Sets.newHashSet();
map.put(level, acrs);
}
acrs.add(acr);
// Also publish alias configuration
if (script.getCustomScript() != null && script.getCustomScript().getAliases() != null) {
for (String alias : script.getCustomScript().getAliases()) {
if (StringUtils.isNotBlank(alias)) {
acrs.add(alias);
}
}
}
}
return map;
}
Aggregations