Search in sources :

Example 1 with OxIDPAuthConf

use of org.gluu.oxtrust.model.OxIDPAuthConf 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 OxIDPAuthConf

use of org.gluu.oxtrust.model.OxIDPAuthConf in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method save.

public String save() {
    try {
        // Reload entry to include latest changes
        GluuAppliance appliance = applianceService.getAppliance();
        boolean updateAuthenticationMode = false;
        boolean updateOxTrustAuthenticationMode = false;
        OxIDPAuthConf idpConf = getIDPAuthConfOrNull(appliance);
        if (idpConf != null && idpConf.getName() != null) {
            if (idpConf.getName().equals(this.authenticationMode)) {
                updateAuthenticationMode = true;
            }
            if (idpConf.getName().equals(this.oxTrustAuthenticationMode)) {
                updateOxTrustAuthenticationMode = true;
            }
        }
        this.ldapConfig.updateStringsLists();
        updateAuthConf(appliance);
        String updatedAuthMode = updateAuthenticationMode ? this.ldapConfig.getConfigId() : this.authenticationMode;
        String updatedOxTrustAuthMode = updateOxTrustAuthenticationMode ? this.ldapConfig.getConfigId() : this.oxTrustAuthenticationMode;
        appliance.setAuthenticationMode(updatedAuthMode);
        appliance.setOxTrustAuthenticationMode(updatedOxTrustAuthMode);
        appliance.setPassportEnabled(passportEnable);
        applianceService.updateAppliance(appliance);
        ldapOxPassportConfiguration.setPassportConfigurations(ldapPassportConfigurations);
        passportService.updateLdapOxPassportConfiguration(ldapOxPassportConfiguration);
    } catch (LdapMappingException ex) {
        log.error("Failed to update appliance configuration", ex);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update appliance");
        return OxTrustConstants.RESULT_FAILURE;
    }
    reset();
    return modify();
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) OxIDPAuthConf(org.gluu.oxtrust.model.OxIDPAuthConf)

Example 3 with OxIDPAuthConf

use of org.gluu.oxtrust.model.OxIDPAuthConf in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method updateAuthConf.

public boolean updateAuthConf(GluuAppliance appliance) {
    try {
        List<OxIDPAuthConf> idpConf = new ArrayList<OxIDPAuthConf>();
        if (this.existLdapConfigIdpAuthConf) {
            if (this.ldapConfig.isUseAnonymousBind()) {
                this.ldapConfig.setBindDN(null);
            }
            OxIDPAuthConf ldapConfigIdpAuthConf = new OxIDPAuthConf();
            ldapConfigIdpAuthConf.setType("auth");
            ldapConfigIdpAuthConf.setVersion(ldapConfigIdpAuthConf.getVersion() + 1);
            ldapConfigIdpAuthConf.setName(this.ldapConfig.getConfigId());
            ldapConfigIdpAuthConf.setEnabled(this.ldapConfig.isEnabled());
            ldapConfigIdpAuthConf.setConfig(objectToJson(this.ldapConfig));
            idpConf.add(ldapConfigIdpAuthConf);
        }
        appliance.setOxIDPAuthentication(idpConf);
    } catch (Exception ex) {
        log.error("An Error occured ", ex);
        return false;
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) OxIDPAuthConf(org.gluu.oxtrust.model.OxIDPAuthConf) 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)

Aggregations

OxIDPAuthConf (org.gluu.oxtrust.model.OxIDPAuthConf)3 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)3 IOException (java.io.IOException)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 EncryptionException (org.xdi.util.security.StringEncrypter.EncryptionException)2 ArrayList (java.util.ArrayList)1 LdapOxPassportConfiguration (org.xdi.config.oxtrust.LdapOxPassportConfiguration)1 GluuLdapConfiguration (org.xdi.model.ldap.GluuLdapConfiguration)1