use of io.swagger.v3.oas.models.responses.ApiResponse in project oxTrust by GluuFederation.
the class CasProtocolWebResource method getCasConfig.
@GET
@Operation(summary = "Get existing configuration", description = "Get the existing configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = CasProtocolDTO.class)), description = "Success") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getCasConfig() {
log(logger, "Get the existing cas configuration");
try {
CASProtocolConfiguration casProtocolConfiguration = casProtocolConfigurationProvider.get();
CasProtocolDTO casProtocolDto = casProtocolDtoAssembly.toDto(casProtocolConfiguration);
return Response.ok(casProtocolDto).build();
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of io.swagger.v3.oas.models.responses.ApiResponse in project oxTrust by GluuFederation.
the class ClientWebResource method addScopeToClient.
@POST
@Path(ApiConstants.INUM_PARAM_PATH + ApiConstants.SCOPES + ApiConstants.SCOPE_INUM_PARAM_PATH)
@Operation(summary = "Add OIDC client scopes", description = "Add scopes to OIDC 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 addScopeToClient(@PathParam(ApiConstants.INUM) @NotNull String inum, @PathParam(ApiConstants.SCOPE_INUM) @NotNull String sinum) {
log(logger, "add new 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());
String scopeBaseDn = scopeService.getDnForScope(scope.getInum());
scopes.remove(scopeBaseDn);
scopes.add(scopeBaseDn);
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();
}
}
use of io.swagger.v3.oas.models.responses.ApiResponse in project oxTrust by GluuFederation.
the class ClientWebResource method getClientByInum.
@GET
@Path(ApiConstants.INUM_PARAM_PATH)
@Operation(summary = "Get OIDC client", description = "Get a specific OIDC client")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = OxAuthClient.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getClientByInum(@PathParam(ApiConstants.INUM) @NotNull String inum) {
log(logger, "Get client " + inum);
try {
Objects.requireNonNull(inum);
OxAuthClient client = clientService.getClientByInum(inum);
if (client != null) {
return Response.ok(client).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();
}
}
use of io.swagger.v3.oas.models.responses.ApiResponse 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();
}
}
use of io.swagger.v3.oas.models.responses.ApiResponse 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();
}
}
Aggregations