use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class AuthUtil method addMethodScopes.
private void addMethodScopes(ResourceInfo resourceInfo, List<String> scopes) {
Method resourceMethod = resourceInfo.getResourceMethod();
ProtectedApi methodAnnotation = resourceMethod.getAnnotation(ProtectedApi.class);
if (methodAnnotation != null) {
scopes.addAll(Stream.of(methodAnnotation.scopes()).collect(Collectors.toList()));
}
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class AuthUtil method getRequestedScopes.
public List<String> getRequestedScopes(ResourceInfo resourceInfo) {
log.trace("Requested scopes for resourceInfo:{} ", resourceInfo);
Class<?> resourceClass = resourceInfo.getResourceClass();
ProtectedApi typeAnnotation = resourceClass.getAnnotation(ProtectedApi.class);
List<String> scopes = new ArrayList<>();
if (typeAnnotation == null) {
addMethodScopes(resourceInfo, scopes);
} else {
scopes.addAll(Stream.of(typeAnnotation.scopes()).collect(Collectors.toList()));
addMethodScopes(resourceInfo, scopes);
}
log.trace("Requested scopes:{} for resourceInfo:{} ", scopes, resourceInfo);
return scopes;
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class LicenseResource method updateLicenseDetails.
@PUT
@Path(LICENSE_DETAILS)
@ProtectedApi(scopes = { SCOPE_LICENSE_WRITE })
@Produces(MediaType.APPLICATION_JSON)
public Response updateLicenseDetails(@Valid @NotNull LicenseRequest licenseRequest) {
try {
log.info("Trying to update license details.");
LicenseResponse licenseResponse = licenseDetailsService.updateLicenseDetails(licenseRequest);
return Response.ok(licenseResponse).build();
} catch (ApplicationException e) {
log.error(ErrorResponse.UPDATE_LICENSE_DETAILS_ERROR.getDescription(), e);
return Response.status(e.getErrorCode()).entity(e.getMessage()).build();
} catch (Exception e) {
log.error(ErrorResponse.UPDATE_LICENSE_DETAILS_ERROR.getDescription(), e);
return Response.serverError().entity(ErrorResponse.UPDATE_LICENSE_DETAILS_ERROR.getDescription()).build();
}
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class OrganizationResource method patchOrganization.
@PATCH
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
@ProtectedApi(scopes = { ApiAccessConstants.ORG_CONFIG_WRITE_ACCESS })
public Response patchOrganization(@NotNull String pathString) throws JsonPatchException, IOException {
log.trace("Organization patch request - pathString:{} ", pathString);
GluuOrganization organization = organizationService.getOrganization();
organization = Jackson.applyPatch(pathString, organization);
organizationService.updateOrganization(organization);
return Response.ok(organizationService.getOrganization()).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class SqlConfigurationResource method patch.
@PATCH
@Path(ApiConstants.NAME_PARAM_PATH)
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
@ProtectedApi(scopes = { ApiAccessConstants.DATABASE_SQL_WRITE_ACCESS })
public Response patch(@PathParam(ApiConstants.NAME) String name, @NotNull String requestString) throws Exception {
log.debug("SQL to be patched - name = " + name + " , requestString = " + requestString);
SqlConnectionConfiguration conf = findByName(name);
log.info("Patch configuration by name " + name);
conf = Jackson.applyPatch(requestString, conf);
sqlConfService.save(conf);
return Response.ok(conf).build();
}
Aggregations