Search in sources :

Example 11 with GluuLdapConfiguration

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

the class LDAPAuthenticationWebResource method setupVersion.

private void setupVersion(LdapConfigurationDTO ldapConfiguration, GluuLdapConfiguration result) {
    final String name = ldapConfiguration.getConfigId();
    GluuLdapConfiguration gluuLdapConfiguration = ldapConfigurationService.findLdapConfigurationByName(name);
    result.setVersion(gluuLdapConfiguration.getVersion());
}
Also used : GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

Example 12 with GluuLdapConfiguration

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

the class LDAPAuthenticationWebResource method createLdapConfiguration.

@POST
@Operation(summary = "Create a new configuration", description = "Create a new configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = LdapConfigurationDTO.class)), description = "Success") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response createLdapConfiguration(@Valid LdapConfigurationDTO ldapConfiguration) {
    log(logger, "Create a new configuration");
    try {
        if (existingLdapConfigurationValidator.isInvalid(ldapConfiguration)) {
            throw new LdapConfigurationDuplicatedException(ldapConfiguration.getConfigId());
        }
        GluuLdapConfiguration gluuLdapConfiguration = ldapConfigurationDtoAssembly.fromDto(ldapConfiguration);
        ldapConfigurationService.save(gluuLdapConfiguration);
        return Response.ok(read(ldapConfiguration.getConfigId())).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : LdapConfigurationDuplicatedException(org.gluu.oxtrust.api.server.util.LdapConfigurationDuplicatedException) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration) LdapConfigurationDuplicatedException(org.gluu.oxtrust.api.server.util.LdapConfigurationDuplicatedException) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 13 with GluuLdapConfiguration

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

the class LdapConfigurationService method remove.

public void remove(String name) {
    GluuLdapConfiguration toRemove = findLdapConfigurationByName(name);
    List<GluuLdapConfiguration> allConfiguration = new ArrayList<GluuLdapConfiguration>(findLdapConfigurations());
    List<GluuLdapConfiguration> newConfigurations = excludeFromConfigurations(allConfiguration, toRemove);
    save(newConfigurations);
}
Also used : ArrayList(java.util.ArrayList) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

Example 14 with GluuLdapConfiguration

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

the class LdapConfigurationService method oxIDPAuthConfs.

private List<OxIDPAuthConf> oxIDPAuthConfs(List<GluuLdapConfiguration> ldapConfigurations) {
    final LdapConfigurationLookup ldapConfigurationLookup = new LdapConfigurationLookup(findLdapConfigurations());
    List<OxIDPAuthConf> idpConf = new ArrayList<OxIDPAuthConf>();
    for (GluuLdapConfiguration ldapConfig : ldapConfigurations) {
        if (ldapConfigurationLookup.shouldEncryptPassword(ldapConfig)) {
            ldapConfig.setBindPassword(encrypt(ldapConfig.getBindPassword()));
        }
        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);
    }
    return idpConf;
}
Also used : ArrayList(java.util.ArrayList) OxIDPAuthConf(org.gluu.oxtrust.model.OxIDPAuthConf) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration) LdapConfigurationLookup(org.gluu.oxtrust.util.LdapConfigurationLookup)

Example 15 with GluuLdapConfiguration

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

the class LDAPAuthenticationWebResource method withVersion.

private GluuLdapConfiguration withVersion(LdapConfigurationDTO ldapConfiguration) {
    GluuLdapConfiguration result = ldapConfigurationDtoAssembly.fromDto(ldapConfiguration);
    setupVersion(ldapConfiguration, result);
    return result;
}
Also used : GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

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