Search in sources :

Example 21 with ProtectedApi

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()));
    }
}
Also used : ProtectedApi(io.jans.configapi.core.rest.ProtectedApi) Method(java.lang.reflect.Method)

Example 22 with ProtectedApi

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;
}
Also used : ArrayList(java.util.ArrayList) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 23 with ProtectedApi

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();
    }
}
Also used : LicenseResponse(io.jans.ca.plugin.adminui.model.auth.LicenseResponse) ApplicationException(io.jans.ca.plugin.adminui.model.exception.ApplicationException) ApplicationException(io.jans.ca.plugin.adminui.model.exception.ApplicationException) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 24 with ProtectedApi

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();
}
Also used : GluuOrganization(io.jans.as.persistence.model.GluuOrganization) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Example 25 with ProtectedApi

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();
}
Also used : SqlConnectionConfiguration(io.jans.orm.sql.model.SqlConnectionConfiguration) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Aggregations

ProtectedApi (io.jans.configapi.core.rest.ProtectedApi)52 Client (io.jans.as.common.model.registration.Client)6 Conf (io.jans.as.model.config.Conf)6 Scope (io.jans.as.persistence.model.Scope)5 GluuConfiguration (io.jans.as.persistence.model.configuration.GluuConfiguration)5 GluuAttribute (io.jans.model.GluuAttribute)5 WebKeysConfiguration (io.jans.as.model.config.WebKeysConfiguration)4 UmaResource (io.jans.as.model.uma.persistence.UmaResource)3 SmtpConfiguration (io.jans.model.SmtpConfiguration)3 CustomScript (io.jans.model.custom.script.model.CustomScript)3 AppConfiguration (io.jans.as.model.configuration.AppConfiguration)2 JSONWebKey (io.jans.as.model.jwk.JSONWebKey)2 LicenseResponse (io.jans.ca.plugin.adminui.model.auth.LicenseResponse)2 ApplicationException (io.jans.ca.plugin.adminui.model.exception.ApplicationException)2 ScimAppConfiguration (io.jans.configapi.plugin.scim.model.config.ScimAppConfiguration)2 Properties (java.util.Properties)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 GluuOrganization (io.jans.as.persistence.model.GluuOrganization)1 OAuth2ConfigResponse (io.jans.ca.plugin.adminui.model.auth.OAuth2ConfigResponse)1 AUIConfiguration (io.jans.ca.plugin.adminui.model.config.AUIConfiguration)1