Search in sources :

Example 6 with GluuLdapConfiguration

use of org.gluu.model.ldap.GluuLdapConfiguration in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method modifyImpl.

public String modifyImpl() {
    if (this.initialized) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    try {
        GluuConfiguration configuration = configurationService.getConfiguration();
        if (configuration == null) {
            return OxTrustConstants.RESULT_FAILURE;
        }
        this.passportEnable = configuration.isPassportEnabled();
        this.customScripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.PERSON_AUTHENTICATION), "displayName", "oxLevel", "oxEnabled");
        List<OxIDPAuthConf> list = getIDPAuthConfOrNull(configuration);
        this.sourceConfigs = new ArrayList<GluuLdapConfiguration>();
        if (list != null) {
            for (OxIDPAuthConf oxIDPAuthConf : list) {
                GluuLdapConfiguration oxldapConfig = oxIDPAuthConf.getConfig();
                this.sourceConfigs.add(oxldapConfig);
            }
        }
        getAuthenticationRecaptcha();
        this.authenticationMode = configuration.getAuthenticationMode();
        this.oxTrustAuthenticationMode = configuration.getOxTrustAuthenticationMode();
    } catch (Exception ex) {
        log.error("Failed to load configuration configuration", ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
    this.initialized = true;
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : OxIDPAuthConf(org.gluu.oxtrust.model.OxIDPAuthConf) GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException) IOException(java.io.IOException)

Example 7 with GluuLdapConfiguration

use of org.gluu.model.ldap.GluuLdapConfiguration in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method addLdapConfig.

@Override
public void addLdapConfig(List<GluuLdapConfiguration> ldapConfigList) {
    GluuLdapConfiguration ldapConfiguration = new GluuLdapConfiguration();
    ldapConfiguration.setBindPassword("");
    ldapConfigList.add(ldapConfiguration);
}
Also used : GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

Example 8 with GluuLdapConfiguration

use of org.gluu.model.ldap.GluuLdapConfiguration in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method getPersonAuthenticationConfigurationNames.

public List<String> getPersonAuthenticationConfigurationNames() {
    if (this.customAuthenticationConfigNames == null) {
        this.customAuthenticationConfigNames = new ArrayList<String>();
        for (CustomScript customScript : this.customScripts) {
            if (customScript.isEnabled()) {
                String name = customScript.getName();
                if (StringHelper.isEmpty(name)) {
                    continue;
                }
                this.customAuthenticationConfigNames.add(customScript.getName());
            }
        }
        boolean internalServerName = true;
        for (GluuLdapConfiguration ldapConfig : this.sourceConfigs) {
            if ((ldapConfig != null) && StringHelper.isNotEmpty(ldapConfig.getConfigId()) && ldapConfig.isEnabled()) {
                this.customAuthenticationConfigNames.add(ldapConfig.getConfigId());
                internalServerName = false;
            }
        }
        if (internalServerName) {
            this.customAuthenticationConfigNames.add(OxConstants.SCRIPT_TYPE_INTERNAL_RESERVED_NAME);
        }
        if (shouldEnableSimplePasswordAuth() && !this.customAuthenticationConfigNames.contains(SIMPLE_PASSWORD_AUTH)) {
            this.customAuthenticationConfigNames.add(SIMPLE_PASSWORD_AUTH);
        }
    }
    return this.customAuthenticationConfigNames;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

Example 9 with GluuLdapConfiguration

use of org.gluu.model.ldap.GluuLdapConfiguration in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method updateAuthConf.

public boolean updateAuthConf(GluuConfiguration configuration) {
    try {
        List<OxIDPAuthConf> idpConf = new ArrayList<OxIDPAuthConf>();
        for (GluuLdapConfiguration ldapConfig : this.sourceConfigs) {
            if (ldapConfig.isUseAnonymousBind()) {
                ldapConfig.setBindDN(null);
            }
            OxIDPAuthConf ldapConfigIdpAuthConf = new OxIDPAuthConf();
            ldapConfig.updateStringsLists();
            ldapConfigIdpAuthConf.setType("auth");
            ldapConfigIdpAuthConf.setVersion(ldapConfigIdpAuthConf.getVersion() + 1);
            ldapConfigIdpAuthConf.setName(ldapConfig.getConfigId());
            ldapConfigIdpAuthConf.setEnabled(ldapConfig.isEnabled());
            ldapConfigIdpAuthConf.setConfig(ldapConfig);
            idpConf.add(ldapConfigIdpAuthConf);
        }
        configuration.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) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException) IOException(java.io.IOException)

Example 10 with GluuLdapConfiguration

use of org.gluu.model.ldap.GluuLdapConfiguration in project oxTrust by GluuFederation.

the class CacheRefreshTimer method processImpl.

private void processImpl(CacheRefreshConfiguration cacheRefreshConfiguration, GluuConfiguration currentConfiguration) throws SearchException {
    CacheRefreshUpdateMethod updateMethod = getUpdateMethod(cacheRefreshConfiguration);
    // Prepare and check connections to LDAP servers
    LdapServerConnection[] sourceServerConnections = prepareLdapServerConnections(cacheRefreshConfiguration, cacheRefreshConfiguration.getSourceConfigs());
    LdapServerConnection inumDbServerConnection;
    if (cacheRefreshConfiguration.isDefaultInumServer()) {
        GluuLdapConfiguration ldapInumConfiguration = new GluuLdapConfiguration();
        ldapInumConfiguration.setConfigId("local_inum");
        ldapInumConfiguration.setBaseDNsStringsList(Arrays.asList(new String[] { OxTrustConstants.CACHE_REFRESH_DEFAULT_BASE_DN }));
        inumDbServerConnection = prepareLdapServerConnection(cacheRefreshConfiguration, ldapInumConfiguration, true);
    } else {
        inumDbServerConnection = prepareLdapServerConnection(cacheRefreshConfiguration, cacheRefreshConfiguration.getInumConfig());
    }
    boolean isVdsUpdate = CacheRefreshUpdateMethod.VDS.equals(updateMethod);
    LdapServerConnection targetServerConnection = null;
    if (isVdsUpdate) {
        targetServerConnection = prepareLdapServerConnection(cacheRefreshConfiguration, cacheRefreshConfiguration.getTargetConfig());
    }
    try {
        if ((sourceServerConnections == null) || (inumDbServerConnection == null) || (isVdsUpdate && (targetServerConnection == null))) {
            log.error("Skipping cache refresh due to invalid server configuration");
        } else {
            detectChangedEntries(cacheRefreshConfiguration, currentConfiguration, sourceServerConnections, inumDbServerConnection, targetServerConnection, updateMethod);
        }
    } finally {
        // Close connections to LDAP servers
        try {
            closeLdapServerConnection(sourceServerConnections);
        } catch (Exception e) {
        // Nothing can be done
        }
        if (!cacheRefreshConfiguration.isDefaultInumServer()) {
            try {
                closeLdapServerConnection(inumDbServerConnection);
            } catch (Exception e) {
            // Nothing can be done
            }
        }
        try {
            if (isVdsUpdate) {
                closeLdapServerConnection(targetServerConnection);
            }
        } catch (Exception e) {
        // Nothing can be done
        }
    }
    return;
}
Also used : GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration) EntryPersistenceException(org.gluu.persist.exception.EntryPersistenceException) SearchException(org.gluu.persist.exception.operation.SearchException) SocketException(java.net.SocketException) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException)

Aggregations

GluuLdapConfiguration (org.gluu.model.ldap.GluuLdapConfiguration)23 ArrayList (java.util.ArrayList)6 Operation (io.swagger.v3.oas.annotations.Operation)3 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)3 LdapConfigurationDuplicatedException (org.gluu.oxtrust.api.server.util.LdapConfigurationDuplicatedException)3 OxIDPAuthConf (org.gluu.oxtrust.model.OxIDPAuthConf)3 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)3 PersistenceEntryManager (org.gluu.persist.PersistenceEntryManager)3 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)3 IOException (java.io.IOException)2 EncryptionException (org.gluu.util.security.StringEncrypter.EncryptionException)2 SocketException (java.net.SocketException)1 List (java.util.List)1 Properties (java.util.Properties)1 CacheRefreshAttributeMapping (org.gluu.config.oxtrust.CacheRefreshAttributeMapping)1 CacheRefreshConfiguration (org.gluu.config.oxtrust.CacheRefreshConfiguration)1 CustomScript (org.gluu.model.custom.script.model.CustomScript)1 ConnectionStatusDTO (org.gluu.oxtrust.api.server.model.ConnectionStatusDTO)1 GluuConfiguration (org.gluu.oxtrust.model.GluuConfiguration)1 LdapConfigurationLookup (org.gluu.oxtrust.util.LdapConfigurationLookup)1