Search in sources :

Example 31 with ApiResponses

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

the class ClientWebResource method deleteClient.

@DELETE
@Path(ApiConstants.INUM_PARAM_PATH)
@Operation(summary = "Delete OIDC client ", description = "Delete an openidconnect client")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = OxAuthClient[].class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response deleteClient(@PathParam(ApiConstants.INUM) @NotNull String inum) {
    log(logger, "Delete client " + inum);
    try {
        Objects.requireNonNull(inum);
        OxAuthClient client = clientService.getClientByInum(inum);
        if (client != null) {
            clientService.removeClient(client);
            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 : OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 32 with ApiResponses

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

the class ClientWebResource method updateClient.

@PUT
@Operation(summary = "Update OIDC client", description = "Update openidconnect client")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = OxAuthClient.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateClient(OxAuthClient client) {
    try {
        Objects.requireNonNull(client, "Attempt to update null client");
        String inum = client.getInum();
        log(logger, "Update client " + inum);
        OxAuthClient existingClient = clientService.getClientByInum(inum);
        if (existingClient != null) {
            client.setInum(existingClient.getInum());
            client.setBaseDn(clientService.getDnForClient(inum));
            client.setDeletable(client.getExp() != null);
            clientService.updateClient(client);
            return Response.ok(clientService.getClientByInum(existingClient.getInum())).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) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 33 with ApiResponses

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

the class AuthenticationMethodWebResource method getCurrentAuthentication.

@GET
@Operation(summary = "Get current authentication methods", description = "Get current 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 = { READ_ACCESS })
public Response getCurrentAuthentication() {
    log(logger, "Processing getCurrentAuthentication()");
    try {
        GluuConfiguration configuration = configurationService.getConfiguration();
        AuthenticationMethod method = new AuthenticationMethod();
        method.setDefaultAcr(configuration.getAuthenticationMode());
        method.setOxtrustAcr(configuration.getOxTrustAuthenticationMode());
        return Response.ok(method).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : AuthenticationMethod(org.gluu.oxtrust.api.server.model.AuthenticationMethod) GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) GET(javax.ws.rs.GET) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 34 with ApiResponses

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

the class GroupWebResource method getGroupMembers.

@GET
@Path(ApiConstants.INUM_PARAM_PATH + ApiConstants.GROUP_MEMBERS)
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuPersonApi[].class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@Operation(summary = "Get group members", description = "Get a group members")
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response getGroupMembers(@PathParam(ApiConstants.INUM) @NotNull String inum) {
    log("Get members of group " + inum);
    inum = inum.equalsIgnoreCase("") ? null : inum;
    try {
        Objects.requireNonNull(inum, "inum should not be null");
        GluuGroup group = groupService.getGroupByInum(inum);
        List<String> members = new ArrayList<String>();
        if (group != null) {
            GluuGroupApi gluuGroupApi = convert(Arrays.asList(group)).get(0);
            members = gluuGroupApi.getMembers();
            return Response.ok(computeMembers(members)).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 : GluuGroupApi(org.gluu.oxtrust.api.server.model.GluuGroupApi) ArrayList(java.util.ArrayList) 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)

Example 35 with ApiResponses

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

the class GroupWebResource method deleteGroup.

@DELETE
@Path(ApiConstants.INUM_PARAM_PATH)
@Operation(summary = "Delete group", description = "Delete a group")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response deleteGroup(@PathParam(ApiConstants.INUM) @NotNull String inum) {
    log("Delete group having inum " + inum);
    try {
        Objects.requireNonNull(inum, "inum should not be null");
        GluuGroup group = groupService.getGroupByInum(inum);
        if (group != null) {
            groupService.removeGroup(group);
            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 : 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

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