Search in sources :

Example 51 with ProtectedApi

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

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

the class PeopleWebResource method createPerson.

@POST
@Operation(summary = "Add person", description = "Add a person")
@ApiResponses(value = { @ApiResponse(responseCode = "201", content = @Content(schema = @Schema(implementation = GluuPersonApi.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response createPerson(GluuPersonApi person) {
    log(logger, "Adding person " + person.getDisplayName());
    try {
        Objects.requireNonNull(person, "Attempt to create null person");
        GluuCustomPerson gluuPerson = copyAttributes(person);
        String inum = person.getInum();
        if (StringHelper.isEmpty(inum)) {
            inum = personService.generateInumForNewPerson();
        }
        gluuPerson.setDn(personService.getDnForPerson(inum));
        gluuPerson.setInum(inum);
        personService.addPerson(gluuPerson);
        return Response.status(Response.Status.CREATED).entity(convert(Arrays.asList(personService.getPersonByInum(inum))).get(0)).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 53 with ProtectedApi

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

the class PeopleWebResource method updatePerson.

@PUT
@Operation(summary = "Update person", description = "Update a person")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuPersonApi.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updatePerson(GluuPersonApi person) {
    String inum = person.getInum();
    log(logger, "Update group " + inum);
    try {
        Objects.requireNonNull(inum, "inum should not be null");
        Objects.requireNonNull(person, "Attempt to update null person");
        GluuCustomPerson existingPerson = personService.getPersonByInum(inum);
        if (existingPerson != null) {
            person.setInum(existingPerson.getInum());
            person.setPassword(existingPerson.getUserPassword());
            GluuCustomPerson personToUpdate = updateValues(existingPerson, person);
            personToUpdate.setDn(personService.getDnForPerson(inum));
            personService.updatePerson(personToUpdate);
            return Response.ok(convert(Arrays.asList(personService.getPersonByInum(inum))).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 54 with ProtectedApi

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

the class AuthenticationMethodWebResource method updateAuthenticationMethod.

@PUT
@Operation(summary = "Update authentication methods", description = "Update authentication methods")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = AuthenticationMethod.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateAuthenticationMethod(AuthenticationMethod method) {
    log(logger, "Processing updateAuthenticationMethod()");
    try {
        Preconditions.checkNotNull(method, "Attempt to update null method");
        GluuConfiguration configuration = configurationService.getConfiguration();
        if (method.getDefaultAcr() != null || method.getOxtrustAcr() != null) {
            configuration.setAuthenticationMode(method.getDefaultAcr());
            configuration.setOxTrustAuthenticationMode(method.getOxtrustAcr());
            configurationService.updateConfiguration(configuration);
            configuration = configurationService.getConfiguration();
            method.setDefaultAcr(configuration.getAuthenticationMode());
            method.setOxtrustAcr(configuration.getOxTrustAuthenticationMode());
            return Response.ok(method).build();
        } else {
            return Response.status(Response.Status.PRECONDITION_FAILED).build();
        }
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 55 with ProtectedApi

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

the class GroupWebResource method updateGroup.

@PUT
@Operation(summary = "Update group", description = "Update a group")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuGroupApi.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateGroup(GluuGroupApi group) {
    String inum = group.getInum();
    inum = inum.equalsIgnoreCase("") ? null : inum;
    log("Update group " + inum);
    try {
        Objects.requireNonNull(inum, "inum should not be null");
        Objects.requireNonNull(group, "Attempt to update null group");
        GluuGroup existingGroup = groupService.getGroupByInum(inum);
        if (existingGroup != null) {
            group.setInum(existingGroup.getInum());
            GluuGroup groupToUpdate = updateValues(existingGroup, group);
            groupToUpdate.setDn(groupService.getDnForGroup(inum));
            groupService.updateGroup(groupToUpdate);
            return Response.ok(convert(Arrays.asList(groupService.getGroupByInum(inum))).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 : GluuGroup(org.gluu.oxtrust.model.GluuGroup) 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