use of org.gluu.model.custom.script.conf.CustomScriptConfiguration in project oxAuth by GluuFederation.
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 org.gluu.model.custom.script.conf.CustomScriptConfiguration in project oxAuth by GluuFederation.
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);
}
return map;
}
use of org.gluu.model.custom.script.conf.CustomScriptConfiguration in project oxAuth by GluuFederation.
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 org.gluu.model.custom.script.conf.CustomScriptConfiguration in project oxAuth by GluuFederation.
the class ExternalDynamicScopeService method getScriptsToExecute.
private Set<CustomScriptConfiguration> getScriptsToExecute(DynamicScopeExternalContext context) {
Set<String> allowedScripts = Sets.newHashSet();
for (org.oxauth.persistence.model.Scope scope : context.getScopes()) {
List<String> scopeScripts = scope.getDynamicScopeScripts();
if (scopeScripts != null) {
allowedScripts.addAll(scopeScripts);
}
}
Set<CustomScriptConfiguration> result = Sets.newHashSet();
if (this.customScriptConfigurations != null) {
for (CustomScriptConfiguration script : this.customScriptConfigurations) {
if (allowedScripts.contains(script.getCustomScript().getDn())) {
result.add(script);
}
}
}
return result;
}
use of org.gluu.model.custom.script.conf.CustomScriptConfiguration in project oxAuth by GluuFederation.
the class ExternalPostAuthnService method externalForceAuthorization.
public boolean externalForceAuthorization(Client client, ExternalPostAuthnContext context) {
final List<CustomScriptConfiguration> scripts = getCustomScriptConfigurationsByDns(client.getAttributes().getPostAuthnScripts());
if (scripts.isEmpty()) {
return false;
}
log.trace("Found {} post-authn scripts.", scripts.size());
for (CustomScriptConfiguration script : scripts) {
if (!externalForceAuthorization(script, context)) {
return false;
}
}
log.debug("Forcing authorization via post-authn script.");
return true;
}
Aggregations