Search in sources :

Example 1 with RejectFilterParam

use of org.gluu.oxtrust.service.scim2.interceptor.RejectFilterParam in project oxTrust by GluuFederation.

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, 3, 3);
        listResponse.addResource(getUserResourceType());
        listResponse.addResource(getGroupResourceType());
        listResponse.addResource(getFidoDeviceResourceType());
        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(org.gluu.oxtrust.model.scim2.ListResponse) URI(java.net.URI) RejectFilterParam(org.gluu.oxtrust.service.scim2.interceptor.RejectFilterParam)

Example 2 with RejectFilterParam

use of org.gluu.oxtrust.service.scim2.interceptor.RejectFilterParam in project oxTrust by GluuFederation.

the class ServiceProviderConfigWS method serve.

@GET
@Produces(MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT)
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@RejectFilterParam
public Response serve() {
    try {
        ServiceProviderConfig serviceProviderConfig = new ServiceProviderConfig();
        serviceProviderConfig.getFilter().setMaxResults(appConfiguration.getScimProperties().getMaxCount());
        Meta meta = new Meta();
        meta.setLocation(endpointUrl);
        meta.setResourceType(ScimResourceUtil.getType(serviceProviderConfig.getClass()));
        serviceProviderConfig.setMeta(meta);
        boolean onTestMode = appConfiguration.isScimTestMode();
        serviceProviderConfig.setAuthenticationSchemes(Arrays.asList(AuthenticationScheme.createOAuth2(onTestMode), AuthenticationScheme.createUma(!onTestMode)));
        return Response.ok(resourceSerializer.serialize(serviceProviderConfig)).build();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        return getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
    }
}
Also used : ServiceProviderConfig(org.gluu.oxtrust.model.scim2.provider.config.ServiceProviderConfig) Meta(org.gluu.oxtrust.model.scim2.Meta) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) RejectFilterParam(org.gluu.oxtrust.service.scim2.interceptor.RejectFilterParam)

Example 3 with RejectFilterParam

use of org.gluu.oxtrust.service.scim2.interceptor.RejectFilterParam in project oxTrust by GluuFederation.

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 : ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) URI(java.net.URI) RejectFilterParam(org.gluu.oxtrust.service.scim2.interceptor.RejectFilterParam)

Example 4 with RejectFilterParam

use of org.gluu.oxtrust.service.scim2.interceptor.RejectFilterParam in project oxTrust by GluuFederation.

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 : ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) URI(java.net.URI) RejectFilterParam(org.gluu.oxtrust.service.scim2.interceptor.RejectFilterParam)

Aggregations

RejectFilterParam (org.gluu.oxtrust.service.scim2.interceptor.RejectFilterParam)4 URI (java.net.URI)3 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)3 Response (javax.ws.rs.core.Response)2 DefaultValue (javax.ws.rs.DefaultValue)1 GET (javax.ws.rs.GET)1 HeaderParam (javax.ws.rs.HeaderParam)1 Produces (javax.ws.rs.Produces)1 Meta (org.gluu.oxtrust.model.scim2.Meta)1 ServiceProviderConfig (org.gluu.oxtrust.model.scim2.provider.config.ServiceProviderConfig)1