Search in sources :

Example 1 with LdapOxPassportConfiguration

use of org.xdi.config.oxtrust.LdapOxPassportConfiguration in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method modify.

public String modify() {
    if (this.initialized) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    try {
        GluuAppliance appliance = applianceService.getAppliance();
        if (appliance == null) {
            return OxTrustConstants.RESULT_FAILURE;
        }
        passportEnable = appliance.getPassportEnabled();
        log.info("passport enabled value  : '{}'", passportEnable);
        this.customScripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.PERSON_AUTHENTICATION), "displayName", "oxLevel", "gluuStatus");
        OxIDPAuthConf idpConf = getIDPAuthConfOrNull(appliance);
        if (idpConf != null) {
            this.ldapConfig = mapLdapConfig(idpConf.getConfig());
        }
        this.existLdapConfigIdpAuthConf = this.ldapConfig != null;
        if (this.ldapConfig == null) {
            this.ldapConfig = new GluuLdapConfiguration();
        }
        this.authenticationMode = appliance.getAuthenticationMode();
        this.oxTrustAuthenticationMode = appliance.getOxTrustAuthenticationMode();
        ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
        if (ldapOxPassportConfiguration == null) {
            ldapOxPassportConfiguration = new LdapOxPassportConfiguration();
        }
        this.ldapPassportConfigurations = ldapOxPassportConfiguration.getPassportConfigurations();
    } catch (Exception ex) {
        log.error("Failed to load appliance configuration", ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
    this.initialized = true;
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : LdapOxPassportConfiguration(org.xdi.config.oxtrust.LdapOxPassportConfiguration) GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) OxIDPAuthConf(org.gluu.oxtrust.model.OxIDPAuthConf) GluuLdapConfiguration(org.xdi.model.ldap.GluuLdapConfiguration) EncryptionException(org.xdi.util.security.StringEncrypter.EncryptionException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 2 with LdapOxPassportConfiguration

use of org.xdi.config.oxtrust.LdapOxPassportConfiguration in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method modifyImpl.

public String modifyImpl() {
    if (this.initialized) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    try {
        GluuAppliance appliance = applianceService.getAppliance();
        if (appliance == null) {
            return OxTrustConstants.RESULT_FAILURE;
        }
        passportEnable = appliance.getPassportEnabled();
        log.info("passport enabled value  : '{}'", passportEnable);
        this.customScripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.PERSON_AUTHENTICATION), "displayName", "oxLevel", "gluuStatus");
        List<OxIDPAuthConf> list = getIDPAuthConfOrNull(appliance);
        this.sourceConfigs = new ArrayList<GluuLdapConfiguration>();
        if (list != null) {
            for (OxIDPAuthConf oxIDPAuthConf : list) {
                GluuLdapConfiguration oxldapConfig = mapLdapConfig(oxIDPAuthConf.getConfig());
                this.sourceConfigs.add(oxldapConfig);
            }
        }
        this.authenticationMode = appliance.getAuthenticationMode();
        this.oxTrustAuthenticationMode = appliance.getOxTrustAuthenticationMode();
        ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
        if (ldapOxPassportConfiguration == null) {
            ldapOxPassportConfiguration = new LdapOxPassportConfiguration();
        }
        this.ldapPassportConfigurations = ldapOxPassportConfiguration.getPassportConfigurations();
    } catch (Exception ex) {
        log.error("Failed to load appliance configuration", ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
    this.initialized = true;
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : LdapOxPassportConfiguration(org.xdi.config.oxtrust.LdapOxPassportConfiguration) GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) OxIDPAuthConf(org.gluu.oxtrust.model.OxIDPAuthConf) GluuLdapConfiguration(org.xdi.model.ldap.GluuLdapConfiguration) EncryptionException(org.xdi.util.security.StringEncrypter.EncryptionException) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 3 with LdapOxPassportConfiguration

use of org.xdi.config.oxtrust.LdapOxPassportConfiguration in project oxTrust by GluuFederation.

the class PassportRestWebService method getPassportConfig.

@GET
@Produces({ MediaType.APPLICATION_JSON })
public Response getPassportConfig(@HeaderParam("Authorization") String authorization) {
    Response authorizationResponse = processAuthorization(authorization);
    if (authorizationResponse != null) {
        return authorizationResponse;
    }
    PassportConfigResponse passportConfigResponse = new PassportConfigResponse();
    Map<String, Map> strategies = new HashMap<String, Map>();
    LdapOxPassportConfiguration ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
    if (ldapOxPassportConfiguration != null) {
        for (org.xdi.model.passport.PassportConfiguration passportConfiguration : ldapOxPassportConfiguration.getPassportConfigurations()) {
            if (passportConfiguration != null) {
                Map<String, String> map = new HashMap();
                List<FieldSet> passList = passportConfiguration.getFieldset();
                for (FieldSet fieldset : passList) {
                    map.put(fieldset.getKey(), fieldset.getValue());
                }
                strategies.put(passportConfiguration.getStrategy(), map);
            }
        }
    }
    passportConfigResponse.setPassportStrategies(strategies);
    String passportConfigResponseJson;
    try {
        passportConfigResponseJson = jsonService.objectToPerttyJson(passportConfigResponse);
    } catch (IOException ex) {
        return getErrorResponse(Response.Status.FORBIDDEN, "Failed to prepare configuration");
    }
    return Response.status(Response.Status.OK).entity(passportConfigResponseJson).build();
}
Also used : LdapOxPassportConfiguration(org.xdi.config.oxtrust.LdapOxPassportConfiguration) HashMap(java.util.HashMap) IOException(java.io.IOException) PassportConfigResponse(org.gluu.oxtrust.model.passport.PassportConfigResponse) Response(javax.ws.rs.core.Response) FieldSet(org.xdi.model.passport.FieldSet) PassportConfigResponse(org.gluu.oxtrust.model.passport.PassportConfigResponse) HashMap(java.util.HashMap) Map(java.util.Map) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with LdapOxPassportConfiguration

use of org.xdi.config.oxtrust.LdapOxPassportConfiguration in project oxTrust by GluuFederation.

the class PassportRestWebService method getPassportConfig.

@GET
@Produces({ MediaType.APPLICATION_JSON })
@ProtectedApi
public Response getPassportConfig() {
    PassportConfigResponse passportConfigResponse = new PassportConfigResponse();
    Map<String, Map> strategies = new HashMap<String, Map>();
    LdapOxPassportConfiguration ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
    if (ldapOxPassportConfiguration != null) {
        for (org.xdi.model.passport.PassportConfiguration passportConfiguration : ldapOxPassportConfiguration.getPassportConfigurations()) {
            if (passportConfiguration != null) {
                Map<String, String> map = new HashMap<String, String>();
                List<SimpleExtendedCustomProperty> passList = passportConfiguration.getFieldset();
                if (passList != null) {
                    for (SimpleExtendedCustomProperty fieldset : passList) {
                        map.put(fieldset.getValue1(), fieldset.getValue2());
                    }
                }
                strategies.put(passportConfiguration.getStrategy(), map);
            }
        }
    }
    passportConfigResponse.setPassportStrategies(strategies);
    String passportConfigResponseJson;
    try {
        passportConfigResponseJson = jsonService.objectToPerttyJson(passportConfigResponse);
    } catch (IOException ex) {
        return getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Failed to prepare configuration");
    }
    return Response.status(Response.Status.OK).entity(passportConfigResponseJson).build();
}
Also used : LdapOxPassportConfiguration(org.xdi.config.oxtrust.LdapOxPassportConfiguration) HashMap(java.util.HashMap) IOException(java.io.IOException) SimpleExtendedCustomProperty(org.xdi.model.SimpleExtendedCustomProperty) PassportConfigResponse(org.gluu.oxtrust.model.passport.PassportConfigResponse) HashMap(java.util.HashMap) Map(java.util.Map) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi)

Aggregations

IOException (java.io.IOException)4 LdapOxPassportConfiguration (org.xdi.config.oxtrust.LdapOxPassportConfiguration)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)2 JsonParseException (org.codehaus.jackson.JsonParseException)2 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)2 GluuAppliance (org.gluu.oxtrust.model.GluuAppliance)2 OxIDPAuthConf (org.gluu.oxtrust.model.OxIDPAuthConf)2 PassportConfigResponse (org.gluu.oxtrust.model.passport.PassportConfigResponse)2 GluuLdapConfiguration (org.xdi.model.ldap.GluuLdapConfiguration)2 EncryptionException (org.xdi.util.security.StringEncrypter.EncryptionException)2 Response (javax.ws.rs.core.Response)1 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)1 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)1 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)1 SimpleExtendedCustomProperty (org.xdi.model.SimpleExtendedCustomProperty)1 FieldSet (org.xdi.model.passport.FieldSet)1