Search in sources :

Example 81 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.

the class ClientWebResource method removeScopeToClient.

@DELETE
@Path(ApiConstants.INUM_PARAM_PATH + ApiConstants.SCOPES + ApiConstants.SCOPE_INUM_PARAM_PATH)
@Operation(summary = "Remove OIDC client scope", description = "Remove an existing scope from client")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Scope[].class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response removeScopeToClient(@PathParam(ApiConstants.INUM) @NotNull String inum, @PathParam(ApiConstants.SCOPE_INUM) @NotNull String sinum) {
    log(logger, "remove scope to client");
    try {
        OxAuthClient client = clientService.getClientByInum(inum);
        Scope scope = scopeService.getScopeByInum(sinum);
        Objects.requireNonNull(client);
        Objects.requireNonNull(scope);
        if (client != null && scope != null) {
            List<String> scopes = new ArrayList<String>(client.getOxAuthScopes());
            scopes.remove(scopeService.getDnForScope(scope.getInum()));
            client.setOxAuthScopes(scopes);
            clientService.updateClient(client);
            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) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) ArrayList(java.util.ArrayList) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 82 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.

the class CustomScriptWebResource method updateCustomScript.

@PUT
@Operation(summary = "Update custom script", description = "Update custom script")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = CustomScript.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateCustomScript(CustomScript customScript) {
    try {
        Objects.requireNonNull(customScript, "Attempt to update null custom script");
        String inum = customScript.getInum();
        log(logger, "Update custom script " + inum);
        CustomScript existingScript = customScriptService.getScriptByInum(customScript.getInum());
        if (existingScript != null) {
            customScript.setInum(existingScript.getInum());
            customScriptService.update(customScript);
            return Response.ok().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 : CustomScript(org.gluu.model.custom.script.model.CustomScript) 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 83 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses 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 84 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses 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 85 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses 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)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)99 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)99 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)48 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)47 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)47 Operation (io.swagger.v3.oas.models.Operation)39 PathItem (io.swagger.v3.oas.models.PathItem)35 OpenAPI (io.swagger.v3.oas.models.OpenAPI)34 Test (org.testng.annotations.Test)31 ArrayList (java.util.ArrayList)23 Schema (io.swagger.v3.oas.models.media.Schema)22 Content (io.swagger.v3.oas.models.media.Content)21 StringSchema (io.swagger.v3.oas.models.media.StringSchema)21 MediaType (io.swagger.v3.oas.models.media.MediaType)20 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)19 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)17 Path (javax.ws.rs.Path)17 Produces (javax.ws.rs.Produces)17 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)16 Components (io.swagger.v3.oas.models.Components)10