Search in sources :

Example 1 with CustomAuthenticationConfiguration

use of org.xdi.model.config.CustomAuthenticationConfiguration in project oxAuth by GluuFederation.

the class LdapCustomAuthenticationConfigurationService method mapCustomAuthentication.

private CustomAuthenticationConfiguration mapCustomAuthentication(oxIDPAuthConf oneConf) {
    CustomAuthenticationConfiguration customAuthenticationConfig = new CustomAuthenticationConfiguration();
    customAuthenticationConfig.setName(oneConf.getName());
    customAuthenticationConfig.setLevel(oneConf.getLevel());
    customAuthenticationConfig.setPriority(oneConf.getPriority());
    customAuthenticationConfig.setEnabled(oneConf.getEnabled());
    customAuthenticationConfig.setVersion(oneConf.getVersion());
    for (CustomProperty customProperty : oneConf.getFields()) {
        if ((customProperty.getValues() == null) || (customProperty.getValues().size() == 0)) {
            continue;
        }
        String attrName = StringHelper.toLowerCase(customProperty.getName());
        if (StringHelper.isEmpty(attrName)) {
            continue;
        }
        String value = customProperty.getValues().get(0);
        if (attrName.startsWith(CUSTOM_AUTHENTICATION_PROPERTY_PREFIX)) {
            String key = customProperty.getName().substring(CUSTOM_AUTHENTICATION_PROPERTY_PREFIX.length());
            SimpleCustomProperty property = new SimpleCustomProperty(key, value);
            customAuthenticationConfig.getCustomAuthenticationAttributes().add(property);
        } else if (StringHelper.equalsIgnoreCase(attrName, CUSTOM_AUTHENTICATION_SCRIPT_PROPERTY_NAME)) {
            customAuthenticationConfig.setCustomAuthenticationScript(value);
        } else if (StringHelper.equalsIgnoreCase(attrName, CUSTOM_AUTHENTICATION_SCRIPT_USAGE_TYPE)) {
            if (StringHelper.isNotEmpty(value)) {
                AuthenticationScriptUsageType authenticationScriptUsageType = AuthenticationScriptUsageType.getByValue(value);
                customAuthenticationConfig.setUsageType(authenticationScriptUsageType);
            }
        }
    }
    return customAuthenticationConfig;
}
Also used : CustomAuthenticationConfiguration(org.xdi.model.config.CustomAuthenticationConfiguration) SimpleCustomProperty(org.xdi.model.SimpleCustomProperty) CustomProperty(org.xdi.oxauth.model.config.CustomProperty) SimpleCustomProperty(org.xdi.model.SimpleCustomProperty) AuthenticationScriptUsageType(org.xdi.model.AuthenticationScriptUsageType)

Example 2 with CustomAuthenticationConfiguration

use of org.xdi.model.config.CustomAuthenticationConfiguration in project oxAuth by GluuFederation.

the class LdapCustomAuthenticationConfigurationService method getCustomAuthenticationConfigurations.

public List<CustomAuthenticationConfiguration> getCustomAuthenticationConfigurations() {
    GluuAppliance gluuAppliance = applianceService.getAppliance();
    List<String> configurationJsons = gluuAppliance.getOxIDPAuthentication();
    List<CustomAuthenticationConfiguration> customAuthenticationConfigurations = new ArrayList<CustomAuthenticationConfiguration>();
    if (configurationJsons == null) {
        return customAuthenticationConfigurations;
    }
    for (String configurationJson : configurationJsons) {
        oxIDPAuthConf configuration;
        try {
            configuration = (oxIDPAuthConf) jsonToObject(configurationJson, oxIDPAuthConf.class);
            if (configuration.getEnabled() && configuration.getType().equalsIgnoreCase("customAuthentication")) {
                CustomAuthenticationConfiguration customAuthenticationConfiguration = mapCustomAuthentication(configuration);
                customAuthenticationConfigurations.add(customAuthenticationConfiguration);
            }
        } catch (Exception ex) {
            log.error("Failed to create object by json: '{}'", ex, configurationJson);
        }
    }
    return customAuthenticationConfigurations;
}
Also used : GluuAppliance(org.xdi.oxauth.model.appliance.GluuAppliance) ArrayList(java.util.ArrayList) CustomAuthenticationConfiguration(org.xdi.model.config.CustomAuthenticationConfiguration) org.xdi.oxauth.model.config.oxIDPAuthConf(org.xdi.oxauth.model.config.oxIDPAuthConf)

Aggregations

CustomAuthenticationConfiguration (org.xdi.model.config.CustomAuthenticationConfiguration)2 ArrayList (java.util.ArrayList)1 AuthenticationScriptUsageType (org.xdi.model.AuthenticationScriptUsageType)1 SimpleCustomProperty (org.xdi.model.SimpleCustomProperty)1 GluuAppliance (org.xdi.oxauth.model.appliance.GluuAppliance)1 CustomProperty (org.xdi.oxauth.model.config.CustomProperty)1 org.xdi.oxauth.model.config.oxIDPAuthConf (org.xdi.oxauth.model.config.oxIDPAuthConf)1