Search in sources :

Example 11 with MEDIA_TYPE_SCIM_JSON

use of io.jans.scim.model.scim2.Constants.MEDIA_TYPE_SCIM_JSON in project jans by JanssenProject.

the class FidoDeviceWebService method getDeviceById.

@Path("{id}")
@GET
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi(scopes = { "https://jans.io/scim/fido.read" })
@RefAdjusted
public Response getDeviceById(@PathParam("id") String id, @QueryParam("userId") String userId, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList) {
    Response response;
    try {
        log.debug("Executing web service method. getDeviceById");
        GluuCustomFidoDevice device = fidoDeviceService.getGluuCustomFidoDeviceById(userId, id);
        if (device == null)
            return notFoundResponse(id, fidoResourceType);
        response = externalConstraintsService.applyEntityCheck(device, null, httpHeaders, uriInfo, HttpMethod.GET, fidoResourceType);
        if (response != null)
            return response;
        FidoDeviceResource fidoResource = new FidoDeviceResource();
        transferAttributesToFidoResource(device, fidoResource, endpointUrl, userPersistenceHelper.getUserInumFromDN(device.getDn()));
        String json = resourceSerializer.serialize(fidoResource, attrsList, excludedAttrsList);
        response = Response.ok(new URI(fidoResource.getMeta().getLocation())).entity(json).build();
    } catch (Exception e) {
        log.error("Failure at getDeviceById method", e);
        response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) GluuCustomFidoDevice(io.jans.scim.model.fido.GluuCustomFidoDevice) FidoDeviceResource(io.jans.scim.model.scim2.fido.FidoDeviceResource) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) SCIMException(io.jans.scim.model.exception.SCIMException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) Path(javax.ws.rs.Path) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) RefAdjusted(io.jans.scim.service.scim2.interceptor.RefAdjusted) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ProtectedApi(io.jans.scim.service.filter.ProtectedApi)

Example 12 with MEDIA_TYPE_SCIM_JSON

use of io.jans.scim.model.scim2.Constants.MEDIA_TYPE_SCIM_JSON in project jans by JanssenProject.

the class Fido2DeviceWebService method getF2DeviceById.

@Path("{id}")
@GET
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi(scopes = { "https://jans.io/scim/fido2.read" })
@RefAdjusted
public Response getF2DeviceById(@PathParam("id") String id, @QueryParam("userId") String userId, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList) {
    Response response;
    try {
        log.debug("Executing web service method. getF2DeviceById");
        GluuFido2Device device = fidoDeviceService.getFido2DeviceById(userId, id);
        if (device == null)
            return notFoundResponse(id, fido2ResourceType);
        response = externalConstraintsService.applyEntityCheck(device, null, httpHeaders, uriInfo, HttpMethod.GET, fido2ResourceType);
        if (response != null)
            return response;
        Fido2DeviceResource fidoResource = new Fido2DeviceResource();
        transferAttributesToFido2Resource(device, fidoResource, endpointUrl, userPersistenceHelper.getUserInumFromDN(device.getDn()));
        String json = resourceSerializer.serialize(fidoResource, attrsList, excludedAttrsList);
        response = Response.ok(new URI(fidoResource.getMeta().getLocation())).entity(json).build();
    } catch (Exception e) {
        log.error("Failure at getF2DeviceById method", e);
        response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) Fido2DeviceResource(io.jans.scim.model.scim2.fido.Fido2DeviceResource) URI(java.net.URI) GluuFido2Device(io.jans.scim.model.GluuFido2Device) URISyntaxException(java.net.URISyntaxException) SCIMException(io.jans.scim.model.exception.SCIMException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) Path(javax.ws.rs.Path) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) RefAdjusted(io.jans.scim.service.scim2.interceptor.RefAdjusted) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ProtectedApi(io.jans.scim.service.filter.ProtectedApi)

Example 13 with MEDIA_TYPE_SCIM_JSON

use of io.jans.scim.model.scim2.Constants.MEDIA_TYPE_SCIM_JSON in project jans by JanssenProject.

the class SchemaWebService method serve.

@GET
@Produces(MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT)
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@RejectFilterParam
public Response serve() {
    Response response;
    try {
        int total = resourceSchemas.size();
        ListResponse listResponse = new ListResponse(1, total, total);
        for (String urn : resourceSchemas.keySet()) {
            listResponse.addResource(getSchemaInstance(resourceSchemas.get(urn), urn));
        }
        String json = resourceSerializer.getListResponseMapper().writeValueAsString(listResponse);
        response = Response.ok(json).location(new URI(endpointUrl)).build();
    } catch (Exception e) {
        log.error("Failure at serve method", e);
        response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) ListResponse(io.jans.scim.model.scim2.ListResponse) URI(java.net.URI) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) RejectFilterParam(io.jans.scim.service.scim2.interceptor.RejectFilterParam)

Example 14 with MEDIA_TYPE_SCIM_JSON

use of io.jans.scim.model.scim2.Constants.MEDIA_TYPE_SCIM_JSON in project jans by JanssenProject.

the class SchemaWebService method getSchemaById.

@GET
@Path("{schemaUrn}")
@Produces(MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT)
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@RejectFilterParam
public Response getSchemaById(@PathParam("schemaUrn") String urn) {
    Response response;
    try {
        Class<? extends BaseScimResource> cls = resourceSchemas.get(urn);
        if (cls == null) {
            log.info("Schema urn {} not recognized", urn);
            response = Response.status(Response.Status.NOT_FOUND).build();
        } else {
            String json = resourceSerializer.serialize(getSchemaInstance(cls, urn));
            URI location = new URI(endpointUrl + "/" + urn);
            response = Response.ok(json).location(location).build();
        }
    } catch (Exception e) {
        log.error("Failure at getSchemaById method", e);
        response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) URI(java.net.URI) Path(javax.ws.rs.Path) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) RejectFilterParam(io.jans.scim.service.scim2.interceptor.RejectFilterParam)

Example 15 with MEDIA_TYPE_SCIM_JSON

use of io.jans.scim.model.scim2.Constants.MEDIA_TYPE_SCIM_JSON in project jans by JanssenProject.

the class ResourceTypeWS method serve.

@GET
@Produces(MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT)
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@RejectFilterParam
public Response serve() {
    try {
        ListResponse listResponse = new ListResponse(1, 4, 4);
        listResponse.addResource(getUserResourceType());
        listResponse.addResource(getGroupResourceType());
        listResponse.addResource(getFidoDeviceResourceType());
        listResponse.addResource(getFido2DeviceResourceType());
        String json = resourceSerializer.getListResponseMapper().writeValueAsString(listResponse);
        return Response.ok(json).location(new URI(endpointUrl)).build();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        return getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
    }
}
Also used : ListResponse(io.jans.scim.model.scim2.ListResponse) URI(java.net.URI) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) RejectFilterParam(io.jans.scim.service.scim2.interceptor.RejectFilterParam)

Aggregations

DefaultValue (javax.ws.rs.DefaultValue)16 HeaderParam (javax.ws.rs.HeaderParam)16 Produces (javax.ws.rs.Produces)16 URI (java.net.URI)14 Response (javax.ws.rs.core.Response)14 ProtectedApi (io.jans.scim.service.filter.ProtectedApi)12 RefAdjusted (io.jans.scim.service.scim2.interceptor.RefAdjusted)11 Path (javax.ws.rs.Path)11 SCIMException (io.jans.scim.model.exception.SCIMException)10 URISyntaxException (java.net.URISyntaxException)10 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)10 GET (javax.ws.rs.GET)9 Consumes (javax.ws.rs.Consumes)8 DuplicateEntryException (io.jans.orm.exception.operation.DuplicateEntryException)6 PUT (javax.ws.rs.PUT)5 GluuGroup (io.jans.scim.model.GluuGroup)3 ScimCustomPerson (io.jans.scim.model.scim.ScimCustomPerson)3 ListResponse (io.jans.scim.model.scim2.ListResponse)3 GroupResource (io.jans.scim.model.scim2.group.GroupResource)3 UserResource (io.jans.scim.model.scim2.user.UserResource)3