Search in sources :

Example 26 with ProtectedApi

use of org.gluu.oxtrust.service.filter.ProtectedApi 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 27 with ProtectedApi

use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.

the class OxTrustJsonSettingWebResource method getOxtrustJsonSettings.

@GET
@Operation(summary = "Get json oxtrust settings", description = "Get json oxtrust settings")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = OxTrustJsonSetting.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getOxtrustJsonSettings() {
    try {
        log(logger, "Processing oxtrust json settings retrival");
        this.oxTrustappConfiguration = jsonConfigurationService.getOxTrustappConfiguration();
        OxTrustJsonSetting setting = new OxTrustJsonSetting();
        setting.setOrgName(this.oxTrustappConfiguration.getOrganizationName());
        setting.setSupportEmail(this.oxTrustappConfiguration.getOrgSupportEmail());
        setting.setAuthenticationRecaptchaEnabled(this.oxTrustappConfiguration.isAuthenticationRecaptchaEnabled());
        setting.setCleanServiceInterval(this.oxTrustappConfiguration.getCleanServiceInterval());
        setting.setEnforceEmailUniqueness(this.oxTrustappConfiguration.getEnforceEmailUniqueness());
        setting.setPasswordResetRequestExpirationTime(this.oxTrustappConfiguration.getPasswordResetRequestExpirationTime());
        setting.setLoggingLevel(this.oxTrustappConfiguration.getLoggingLevel());
        return Response.ok(setting).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : OxTrustJsonSetting(org.gluu.oxtrust.api.server.model.OxTrustJsonSetting) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 28 with ProtectedApi

use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.

the class PeopleWebResource method getPersonByInum.

@GET
@Path(ApiConstants.INUM_PARAM_PATH)
@Operation(summary = "Get person by inum", description = "Get a person by inum")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuPersonApi.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getPersonByInum(@PathParam(ApiConstants.INUM) @NotNull String inum) {
    log(logger, "Get person " + inum);
    try {
        Objects.requireNonNull(inum, "inum should not be null");
        GluuCustomPerson person = personService.getPersonByInum(inum);
        if (person != null) {
            return Response.ok(convert(Arrays.asList(person)).get(0)).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 29 with ProtectedApi

use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.

the class UmaResourceWebResource method getUmaResourceScopes.

@GET
@Path(ApiConstants.ID_PARAM_PATH + ApiConstants.SCOPES)
@Operation(summary = "Get UMA resource scopes", description = "Get scopes of uma resource")
@ProtectedApi(scopes = { READ_ACCESS })
public Response getUmaResourceScopes(@PathParam(ApiConstants.ID) @NotNull String id) {
    try {
        log(logger, "Get scopes of uma resource having id " + id);
        Objects.requireNonNull(id, "id should not be null");
        List<UmaResource> resources = umaResourcesService.findResourcesById(id);
        if (resources != null && !resources.isEmpty()) {
            UmaResource resource = resources.get(0);
            List<String> scopesDn = resource.getScopes();
            List<Scope> scopes = new ArrayList<Scope>();
            if (scopesDn != null) {
                for (String scopeDn : scopesDn) {
                    scopes.add(scopeDescriptionService.getUmaScopeByDn(scopeDn));
                }
            }
            return Response.ok(scopes).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : Scope(org.oxauth.persistence.model.Scope) ArrayList(java.util.ArrayList) UmaResource(org.gluu.oxauth.model.uma.persistence.UmaResource) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation)

Example 30 with ProtectedApi

use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.

the class UmaResourceWebResource method addClientToUmaResource.

@POST
@Operation(summary = "Add UMA resource client", description = "add client to uma resource")
@ApiResponses(value = { @ApiResponse(responseCode = "201", content = @Content(schema = @Schema(implementation = UmaResource.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@Path(ApiConstants.ID_PARAM_PATH + ApiConstants.CLIENTS + ApiConstants.INUM_PARAM_PATH)
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response addClientToUmaResource(@PathParam(ApiConstants.ID) @NotNull String id, @PathParam(ApiConstants.INUM) @NotNull String clientInum) {
    try {
        log(logger, "Add client " + clientInum + " to uma resource " + id);
        Objects.requireNonNull(id, "Uma id should not be null");
        Objects.requireNonNull(clientInum, "Client inum should not be null");
        List<UmaResource> resources = umaResourcesService.findResourcesById(id);
        OxAuthClient client = clientService.getClientByInum(clientInum);
        if (resources != null && !resources.isEmpty() && client != null) {
            UmaResource umaResource = resources.get(0);
            List<String> clientsDn = new ArrayList<String>();
            if (umaResource.getClients() != null) {
                clientsDn.addAll(umaResource.getClients());
            }
            clientsDn.add(clientService.getDnForClient(clientInum));
            umaResource.setClients(clientsDn);
            umaResourcesService.updateResource(umaResource);
            return Response.status(Response.Status.CREATED).entity(umaResourcesService.findResourcesById(id).get(0)).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) ArrayList(java.util.ArrayList) UmaResource(org.gluu.oxauth.model.uma.persistence.UmaResource) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)75 Operation (io.swagger.v3.oas.annotations.Operation)50 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)47 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)21 Produces (javax.ws.rs.Produces)21 Response (javax.ws.rs.core.Response)21 ArrayList (java.util.ArrayList)20 DefaultValue (javax.ws.rs.DefaultValue)20 HeaderParam (javax.ws.rs.HeaderParam)20 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)20 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)19 SCIMException (org.gluu.oxtrust.model.exception.SCIMException)19 ListViewResponse (org.gluu.persist.model.ListViewResponse)19 URI (java.net.URI)17 RefAdjusted (org.gluu.oxtrust.service.scim2.interceptor.RefAdjusted)17 Path (javax.ws.rs.Path)16 Consumes (javax.ws.rs.Consumes)11 GluuGroup (org.gluu.oxtrust.model.GluuGroup)10 OxAuthClient (org.gluu.oxtrust.model.OxAuthClient)10 Scope (org.oxauth.persistence.model.Scope)10