Search in sources :

Example 31 with DefaultValue

use of javax.ws.rs.DefaultValue in project oxTrust by GluuFederation.

the class ResourceTypeWS method getResourceTypeGroup.

@Path("Group")
@GET
@Produces(Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8")
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
public Response getResourceTypeGroup(@HeaderParam("Authorization") String authorization) throws Exception {
    ResourceType groupResourceType = new ResourceType();
    groupResourceType.setDescription(Constants.GROUP_CORE_SCHEMA_DESCRIPTION);
    groupResourceType.setEndpoint("/v2/Groups");
    groupResourceType.setName(Constants.GROUP_CORE_SCHEMA_NAME);
    groupResourceType.setId(Constants.GROUP_CORE_SCHEMA_NAME);
    groupResourceType.setSchema(Constants.GROUP_CORE_SCHEMA_ID);
    Meta groupMeta = new Meta();
    groupMeta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes/Group");
    groupMeta.setResourceType("ResourceType");
    groupResourceType.setMeta(groupMeta);
    // ResourceType[] resourceTypes = new ResourceType[]{groupResourceType};
    URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes/Group");
    // return Response.ok(resourceTypes).location(location).build();
    return Response.ok(groupResourceType).location(location).build();
}
Also used : Meta(org.gluu.oxtrust.model.scim2.Meta) ResourceType(org.gluu.oxtrust.model.scim2.provider.ResourceType) 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)

Example 32 with DefaultValue

use of javax.ws.rs.DefaultValue in project oxTrust by GluuFederation.

the class ResourceTypeWS method getResourceTypeFidoDevice.

@Path("FidoDevice")
@GET
@Produces(Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8")
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
public Response getResourceTypeFidoDevice(@HeaderParam("Authorization") String authorization) throws Exception {
    ResourceType fidoDeviceResourceType = new ResourceType();
    fidoDeviceResourceType.setDescription(Constants.FIDO_DEVICES_CORE_SCHEMA_DESCRIPTION);
    fidoDeviceResourceType.setEndpoint("/v2/FidoDevices");
    fidoDeviceResourceType.setName(Constants.FIDO_DEVICES_CORE_SCHEMA_NAME);
    fidoDeviceResourceType.setId(Constants.FIDO_DEVICES_CORE_SCHEMA_NAME);
    fidoDeviceResourceType.setSchema(Constants.FIDO_DEVICES_CORE_SCHEMA_ID);
    Meta fidoDeviceMeta = new Meta();
    fidoDeviceMeta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes/FidoDevice");
    fidoDeviceMeta.setResourceType("ResourceType");
    fidoDeviceResourceType.setMeta(fidoDeviceMeta);
    URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes/FidoDevice");
    return Response.ok(fidoDeviceResourceType).location(location).build();
}
Also used : Meta(org.gluu.oxtrust.model.scim2.Meta) ResourceType(org.gluu.oxtrust.model.scim2.provider.ResourceType) 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)

Example 33 with DefaultValue

use of javax.ws.rs.DefaultValue in project oxTrust by GluuFederation.

the class SchemaWebService method getSchemaById.

/**
     * Retrieves a schema via its id/urn.
     *
     * @param authorization
     * @param id
     * @return
     * @throws Exception
     */
@GET
@Path("{id}")
@Produces(Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8")
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
public Response getSchemaById(@HeaderParam("Authorization") String authorization, @PathParam("id") String id) throws Exception {
    log.info(" getSchemaById(), id = '" + id + "'");
    SchemaTypeLoadingFactory factory = new SchemaTypeLoadingFactory();
    SchemaType schemaType = factory.load(appConfiguration, id);
    if (schemaType == null) {
        log.info(" NOT FOUND: schema with id = '" + id + "'");
        return Response.status(Response.Status.NOT_FOUND).build();
    }
    URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/Schemas/" + id);
    // Serialize to JSON
    String json = serialize(schemaType);
    return Response.ok(json).location(location).build();
}
Also used : SchemaTypeLoadingFactory(org.gluu.oxtrust.service.scim2.schema.SchemaTypeLoadingFactory) URI(java.net.URI) SchemaType(org.gluu.oxtrust.model.scim2.schema.SchemaType) 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)

Example 34 with DefaultValue

use of javax.ws.rs.DefaultValue in project oxTrust by GluuFederation.

the class UserWebService method searchUsersPost.

@Path("/.search")
@POST
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "Search users POST /.search", notes = "Returns a list of users (https://tools.ietf.org/html/rfc7644#section-3.4.3)", response = ListResponse.class)
public Response searchUsersPost(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @ApiParam(value = "SearchRequest", required = true) SearchRequest searchRequest) throws Exception {
    try {
        log.info("IN UserWebService.searchUsersPost()...");
        // Authorization check is done in searchUsers()
        Response response = searchUsers(authorization, token, searchRequest.getFilter(), searchRequest.getStartIndex(), searchRequest.getCount(), searchRequest.getSortBy(), searchRequest.getSortOrder(), searchRequest.getAttributesArray());
        URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/Users/.search");
        log.info("LEAVING UserWebService.searchUsersPost()...");
        return Response.fromResponse(response).location(location).build();
    } catch (EntryPersistenceException ex) {
        log.error("Error in searchUsersPost", ex);
        ex.printStackTrace();
        return getErrorResponse(Response.Status.NOT_FOUND, ErrorScimType.INVALID_VALUE, "Resource not found");
    } catch (Exception ex) {
        log.error("Error in searchUsersPost", ex);
        ex.printStackTrace();
        return getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_FILTER, INTERNAL_SERVER_ERROR_MESSAGE);
    }
}
Also used : ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) VirtualListViewResponse(org.xdi.ldap.model.VirtualListViewResponse) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) URI(java.net.URI) PersonRequiredFieldsException(org.gluu.oxtrust.exception.PersonRequiredFieldsException) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) DuplicateEntryException(org.gluu.site.ldap.exception.DuplicateEntryException) Path(javax.ws.rs.Path) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation)

Example 35 with DefaultValue

use of javax.ws.rs.DefaultValue in project oxTrust by GluuFederation.

the class UserWebService method updateUserPatch.

@Path("{id}")
@PATCH
@Consumes({ Constants.MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON })
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
public Response updateUserPatch(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @PathParam("id") String id, ScimPersonPatch person) throws Exception {
    Response authorizationResponse;
    if (jsonConfigurationService.getOxTrustappConfiguration().isScimTestMode()) {
        log.info(" ##### SCIM Test Mode is ACTIVE");
        authorizationResponse = processTestModeAuthorization(token);
    } else {
        authorizationResponse = processAuthorization(authorization);
    }
    if (authorizationResponse != null) {
        return authorizationResponse;
    }
    return null;
}
Also used : ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) VirtualListViewResponse(org.xdi.ldap.model.VirtualListViewResponse) Path(javax.ws.rs.Path) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PATCH(org.gluu.oxtrust.ws.rs.scim.PATCH)

Aggregations

DefaultValue (javax.ws.rs.DefaultValue)35 Produces (javax.ws.rs.Produces)33 HeaderParam (javax.ws.rs.HeaderParam)31 URI (java.net.URI)26 Response (javax.ws.rs.core.Response)25 Path (javax.ws.rs.Path)22 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)21 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)21 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)21 VirtualListViewResponse (org.xdi.ldap.model.VirtualListViewResponse)21 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)19 GET (javax.ws.rs.GET)18 Consumes (javax.ws.rs.Consumes)11 ArrayList (java.util.ArrayList)10 PersonRequiredFieldsException (org.gluu.oxtrust.exception.PersonRequiredFieldsException)9 POST (javax.ws.rs.POST)8 PUT (javax.ws.rs.PUT)6 QueryParam (javax.ws.rs.QueryParam)5 GluuGroup (org.gluu.oxtrust.model.GluuGroup)5 Meta (org.gluu.oxtrust.model.scim2.Meta)5