Search in sources :

Example 16 with GluuLdapConfiguration

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

the class LDAPAuthenticationWebResource method updateLdapConfiguration.

@PUT
@Operation(summary = "Update existing configuration", description = "Update an existing configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = LdapConfigurationDTO.class)), description = "Success"), @ApiResponse(responseCode = "404", description = "Not found") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateLdapConfiguration(@Valid LdapConfigurationDTO ldapConfiguration) {
    log(logger, "Update an existing configuration");
    try {
        GluuLdapConfiguration gluuLdapConfiguration = withVersion(ldapConfiguration);
        ldapConfigurationService.update(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 : 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 17 with GluuLdapConfiguration

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

the class LDAPAuthenticationWebResource method getLdapConfigurationStatusByName.

@GET
@Path(ApiConstants.NAME_PARAM_PATH + ApiConstants.STATUS)
@Operation(summary = "Check the status of an existing configuration", description = "Check the status of an existing configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = ConnectionStatusDTO.class)), description = "Success") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getLdapConfigurationStatusByName(@PathParam("name") String name) {
    log(logger, "Check the status of an existing configuration");
    try {
        GluuLdapConfiguration ldapConfiguration = ldapConfigurationService.findLdapConfigurationByName(name);
        org.gluu.oxtrust.util.LdapConnectionData ldapConnectionData = LdapConnectionData.from(ldapConfiguration);
        ConnectionStatusDTO connectionStatus = ConnectionStatusDTO.from(this.connectionStatus.isUp(ldapConnectionData));
        return Response.ok(connectionStatus).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : LdapConnectionData(org.gluu.oxtrust.util.LdapConnectionData) ConnectionStatusDTO(org.gluu.oxtrust.api.server.model.ConnectionStatusDTO) 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 18 with GluuLdapConfiguration

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

the class LdapConfigurationDtoAssembly method fromDto.

public GluuLdapConfiguration fromDto(org.gluu.oxtrust.api.server.model.LdapConfigurationDTO ldapConfiguration) {
    GluuLdapConfiguration gluuLdapConfiguration = new GluuLdapConfiguration();
    gluuLdapConfiguration.setLevel(ldapConfiguration.getLevel());
    gluuLdapConfiguration.setConfigId(ldapConfiguration.getConfigId());
    gluuLdapConfiguration.setBindDN(ldapConfiguration.getBindDN());
    gluuLdapConfiguration.setBindPassword(ldapConfiguration.getBindPassword());
    gluuLdapConfiguration.setServersStringsList(ldapConfiguration.getServers());
    gluuLdapConfiguration.setMaxConnections(ldapConfiguration.getMaxConnections());
    gluuLdapConfiguration.setUseSSL(ldapConfiguration.isUseSSL());
    gluuLdapConfiguration.setBaseDNsStringsList(ldapConfiguration.getBaseDNs());
    gluuLdapConfiguration.setPrimaryKey(ldapConfiguration.getPrimaryKey());
    gluuLdapConfiguration.setLocalPrimaryKey(ldapConfiguration.getLocalPrimaryKey());
    gluuLdapConfiguration.setUseAnonymousBind(ldapConfiguration.isUseAnonymousBind());
    gluuLdapConfiguration.setEnabled(ldapConfiguration.isEnabled());
    return gluuLdapConfiguration;
}
Also used : GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

Example 19 with GluuLdapConfiguration

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

the class LdapConfigurationDtoAssembly method fromDto.

public GluuLdapConfiguration fromDto(LdapConfigurationDTO ldapConfiguration) {
    GluuLdapConfiguration gluuLdapConfiguration = new GluuLdapConfiguration();
    gluuLdapConfiguration.setLevel(ldapConfiguration.getLevel());
    gluuLdapConfiguration.setConfigId(ldapConfiguration.getConfigId());
    gluuLdapConfiguration.setBindDN(ldapConfiguration.getBindDN());
    gluuLdapConfiguration.setBindPassword(ldapConfiguration.getBindPassword());
    gluuLdapConfiguration.setServersStringsList(ldapConfiguration.getServers());
    gluuLdapConfiguration.setMaxConnections(ldapConfiguration.getMaxConnections());
    gluuLdapConfiguration.setUseSSL(ldapConfiguration.isUseSSL());
    gluuLdapConfiguration.setBaseDNsStringsList(ldapConfiguration.getBaseDNs());
    gluuLdapConfiguration.setPrimaryKey(ldapConfiguration.getPrimaryKey());
    gluuLdapConfiguration.setLocalPrimaryKey(ldapConfiguration.getLocalPrimaryKey());
    gluuLdapConfiguration.setUseAnonymousBind(ldapConfiguration.isUseAnonymousBind());
    gluuLdapConfiguration.setEnabled(ldapConfiguration.isEnabled());
    return gluuLdapConfiguration;
}
Also used : GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

Example 20 with GluuLdapConfiguration

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

the class LdapConfigurationLookup method shouldEncryptPassword.

public boolean shouldEncryptPassword(GluuLdapConfiguration ldapConfiguration) {
    try {
        GluuLdapConfiguration oldConfiguration = findByName(ldapConfiguration.getConfigId());
        String encryptedOldPassword = oldConfiguration.getBindPassword();
        return !StringUtils.equals(encryptedOldPassword, ldapConfiguration.getBindPassword());
    } catch (LdapConfigurationNotFoundException e) {
        return true;
    }
}
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