use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.
the class GluuRadiusClientWebResource method updateRadiusClient.
@PUT
@Operation(summary = "Update existing radius client", description = "Update existing radius client")
@ApiResponses({ @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = RadiusClient.class)), description = "Success"), @ApiResponse(responseCode = "400", description = "Malformed Request. Missing parameter"), @ApiResponse(responseCode = "403", description = "Gluu Radius is not installed"), @ApiResponse(responseCode = "404", description = "Radius client not found"), @ApiResponse(responseCode = "500", description = "Internal server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateRadiusClient(RadiusClient client) {
try {
if (ProductInstallationChecker.isGluuRadiusInstalled() == false)
return Response.status(Response.Status.FORBIDDEN).build();
Objects.requireNonNull(client);
if (client.getInum() == null)
return Response.status(Response.Status.BAD_REQUEST).entity("Missing radius client inum").build();
String inum = client.getInum();
RadiusClient existingclient = gluuRadiusClientService.getRadiusClientByInum(inum);
if (existingclient == null)
return Response.status(Response.Status.NOT_FOUND).build();
if (client.getIpAddress() != null)
existingclient.setIpAddress(client.getIpAddress());
if (client.getName() != null)
existingclient.setName(client.getName());
if (client.getPriority() != null)
existingclient.setPriority(client.getPriority());
if (client.getSecret() != null && !StringUtils.equals(client.getSecret(), existingclient.getSecret())) {
String encryptedsecret = encryptionService.encrypt(client.getSecret());
existingclient.setSecret(encryptedsecret);
}
gluuRadiusClientService.updateRadiusClient(existingclient);
return Response.ok(gluuRadiusClientService.getRadiusClientByInum(inum)).build();
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.
the class GluuRadiusClientWebResource method deleteRadiusClient.
@DELETE
@Operation(summary = "Delete radius client", description = "Deletes a radius client")
@Path(ApiConstants.INUM_PARAM_PATH)
@ApiResponses({ @ApiResponse(responseCode = "204", description = "Success"), @ApiResponse(responseCode = "403", description = "Gluu Radius is not installed"), @ApiResponse(responseCode = "404", description = "Radius client not found"), @ApiResponse(responseCode = "500", description = "Internal server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response deleteRadiusClient(@PathParam(ApiConstants.INUM) @NotNull String inum) {
try {
if (ProductInstallationChecker.isGluuRadiusInstalled() == false)
return Response.status(Response.Status.FORBIDDEN).build();
RadiusClient client = gluuRadiusClientService.getRadiusClientByInum(inum);
if (client == null)
return Response.status(Response.Status.NOT_FOUND).build();
gluuRadiusClientService.deleteRadiusClient(client);
return Response.status(Response.Status.NO_CONTENT).build();
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.
the class BaseUmaProtectionService method getRequestedScopes.
public List<String> getRequestedScopes(ResourceInfo resourceInfo) {
Class<?> resourceClass = resourceInfo.getResourceClass();
ProtectedApi typeAnnotation = resourceClass.getAnnotation(ProtectedApi.class);
List<String> scopes = new ArrayList<String>();
if (typeAnnotation == null) {
addMethodScopes(resourceInfo, scopes);
} else {
scopes.addAll(Stream.of(typeAnnotation.scopes()).collect(Collectors.toList()));
addMethodScopes(resourceInfo, scopes);
}
return scopes;
}
use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.
the class AttributeWebResource method deleteAttribute.
@DELETE
@Path(ApiConstants.INUM_PARAM_PATH)
@Operation(summary = "Delete gluu attribute", description = "Deletes a gluu attribute")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response deleteAttribute(@PathParam(ApiConstants.INUM) @NotNull String inum) {
log(logger, "Processing deleteAttribute()");
try {
Preconditions.checkNotNull(inum);
GluuAttribute gluuAttribute = attributeService.getAttributeByInum(inum);
if (gluuAttribute != null) {
attributeService.removeAttribute(gluuAttribute);
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 org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.
the class AttributeWebResource method updateAttribute.
@PUT
@Operation(summary = "Update new attribute", description = "Updates a gluu attribute")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuAttribute.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateAttribute(GluuAttribute gluuAttribute) {
log(logger, "Processing updateAttribute()");
try {
Preconditions.checkNotNull(gluuAttribute, "Attempt to update null attribute");
String inum = gluuAttribute.getInum();
GluuAttribute existingAttribute = attributeService.getAttributeByInum(inum);
if (existingAttribute != null) {
gluuAttribute.setInum(existingAttribute.getInum());
attributeService.updateAttribute(gluuAttribute);
return Response.ok(attributeService.getAttributeByInum(existingAttribute.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