Search in sources :

Example 1 with SchemaExtensionHolder

use of org.gluu.oxtrust.model.scim2.schema.SchemaExtensionHolder in project oxTrust by GluuFederation.

the class ResourceTypeWS method getResourceTypeUser.

@Path("User")
@GET
@Produces(Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8")
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
public Response getResourceTypeUser(@HeaderParam("Authorization") String authorization) throws Exception {
    ResourceType userResourceType = new ResourceType();
    userResourceType.setDescription(Constants.USER_CORE_SCHEMA_DESCRIPTION);
    userResourceType.setEndpoint("/v2/Users");
    userResourceType.setName(Constants.USER_CORE_SCHEMA_NAME);
    userResourceType.setId(Constants.USER_CORE_SCHEMA_NAME);
    userResourceType.setSchema(Constants.USER_CORE_SCHEMA_ID);
    Meta userMeta = new Meta();
    userMeta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes/User");
    userMeta.setResourceType("ResourceType");
    userResourceType.setMeta(userMeta);
    List<SchemaExtensionHolder> schemaExtensions = new ArrayList<SchemaExtensionHolder>();
    SchemaExtensionHolder userExtensionSchema = new SchemaExtensionHolder();
    userExtensionSchema.setSchema(Constants.USER_EXT_SCHEMA_ID);
    userExtensionSchema.setRequired(false);
    schemaExtensions.add(userExtensionSchema);
    userResourceType.setSchemaExtensions(schemaExtensions);
    // ResourceType[] resourceTypes = new ResourceType[]{userResourceType};
    URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes/User");
    // return Response.ok(resourceTypes).location(location).build();
    return Response.ok(userResourceType).location(location).build();
}
Also used : Meta(org.gluu.oxtrust.model.scim2.Meta) SchemaExtensionHolder(org.gluu.oxtrust.model.scim2.schema.SchemaExtensionHolder) ArrayList(java.util.ArrayList) 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 2 with SchemaExtensionHolder

use of org.gluu.oxtrust.model.scim2.schema.SchemaExtensionHolder in project oxTrust by GluuFederation.

the class ResourceTypeWS method listResources.

@GET
@Produces(Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8")
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
public Response listResources(@HeaderParam("Authorization") String authorization) throws Exception {
    ListResponse listResponse = new ListResponse();
    List<String> schemas = new ArrayList<String>();
    schemas.add(Constants.LIST_RESPONSE_SCHEMA_ID);
    listResponse.setSchemas(schemas);
    // START: User
    ResourceType userResourceType = new ResourceType();
    userResourceType.setDescription(Constants.USER_CORE_SCHEMA_DESCRIPTION);
    userResourceType.setEndpoint("/v2/Users");
    userResourceType.setName(Constants.USER_CORE_SCHEMA_NAME);
    userResourceType.setId(Constants.USER_CORE_SCHEMA_NAME);
    userResourceType.setSchema(Constants.USER_CORE_SCHEMA_ID);
    Meta userMeta = new Meta();
    userMeta.setLocation(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes/User");
    userMeta.setResourceType("ResourceType");
    userResourceType.setMeta(userMeta);
    List<SchemaExtensionHolder> schemaExtensions = new ArrayList<SchemaExtensionHolder>();
    SchemaExtensionHolder userExtensionSchema = new SchemaExtensionHolder();
    userExtensionSchema.setSchema(Constants.USER_EXT_SCHEMA_ID);
    userExtensionSchema.setRequired(false);
    schemaExtensions.add(userExtensionSchema);
    userResourceType.setSchemaExtensions(schemaExtensions);
    // START: Group
    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);
    // START: FidoDevice
    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);
    // ResourceType[] resourceTypes = new ResourceType[]{userResourceType, groupResourceType};
    List<Resource> resourceTypes = new ArrayList<Resource>();
    resourceTypes.add(userResourceType);
    resourceTypes.add(groupResourceType);
    resourceTypes.add(fidoDeviceResourceType);
    listResponse.setResources(resourceTypes);
    listResponse.setTotalResults(resourceTypes.size());
    listResponse.setItemsPerPage(10);
    listResponse.setStartIndex(1);
    URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/ResourceTypes");
    // return Response.ok(resourceTypes).location(location).build();
    return Response.ok(listResponse).location(location).build();
}
Also used : Meta(org.gluu.oxtrust.model.scim2.Meta) SchemaExtensionHolder(org.gluu.oxtrust.model.scim2.schema.SchemaExtensionHolder) ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) ArrayList(java.util.ArrayList) Resource(org.gluu.oxtrust.model.scim2.Resource) ResourceType(org.gluu.oxtrust.model.scim2.provider.ResourceType) URI(java.net.URI) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with SchemaExtensionHolder

use of org.gluu.oxtrust.model.scim2.schema.SchemaExtensionHolder in project oxTrust by GluuFederation.

the class ResourceTypeWS method fillResourceType.

private void fillResourceType(ResourceType rt, Schema schemaAnnot, String endpointUrl, String location, List<SchemaExtensionHolder> schemaExtensions) {
    rt.setId(schemaAnnot.name());
    rt.setName(schemaAnnot.name());
    rt.setDescription(schemaAnnot.description());
    rt.setEndpoint(endpointUrl.substring(appConfiguration.getBaseEndpoint().length()));
    rt.setSchema(schemaAnnot.id());
    rt.setSchemaExtensions(schemaExtensions);
    Meta rtMeta = new Meta();
    rtMeta.setLocation(location);
    rtMeta.setResourceType("ResourceType");
    rt.setMeta(rtMeta);
}
Also used : Meta(org.gluu.oxtrust.model.scim2.Meta)

Example 4 with SchemaExtensionHolder

use of org.gluu.oxtrust.model.scim2.schema.SchemaExtensionHolder in project oxTrust by GluuFederation.

the class ResourceTypeWS method getUserResourceType.

private ResourceType getUserResourceType() {
    Class<? extends BaseScimResource> cls = UserResource.class;
    List<Extension> usrExtensions = extService.getResourceExtensions(cls);
    List<SchemaExtensionHolder> schemaExtensions = new ArrayList<SchemaExtensionHolder>();
    for (Extension extension : usrExtensions) {
        SchemaExtensionHolder userExtensionSchema = new SchemaExtensionHolder();
        userExtensionSchema.setSchema(extension.getUrn());
        userExtensionSchema.setRequired(false);
        schemaExtensions.add(userExtensionSchema);
    }
    ResourceType usrRT = new ResourceType();
    fillResourceType(usrRT, ScimResourceUtil.getSchemaAnnotation(cls), userService.getEndpointUrl(), getResourceLocation(USER_SUFFIX), schemaExtensions);
    return usrRT;
}
Also used : Extension(org.gluu.oxtrust.model.scim2.extensions.Extension) SchemaExtensionHolder(org.gluu.oxtrust.model.scim2.provider.resourcetypes.SchemaExtensionHolder) UserResource(org.gluu.oxtrust.model.scim2.user.UserResource) ArrayList(java.util.ArrayList) ResourceType(org.gluu.oxtrust.model.scim2.provider.resourcetypes.ResourceType)

Aggregations

ArrayList (java.util.ArrayList)3 Meta (org.gluu.oxtrust.model.scim2.Meta)3 URI (java.net.URI)2 DefaultValue (javax.ws.rs.DefaultValue)2 GET (javax.ws.rs.GET)2 HeaderParam (javax.ws.rs.HeaderParam)2 Produces (javax.ws.rs.Produces)2 ResourceType (org.gluu.oxtrust.model.scim2.provider.ResourceType)2 SchemaExtensionHolder (org.gluu.oxtrust.model.scim2.schema.SchemaExtensionHolder)2 Path (javax.ws.rs.Path)1 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)1 Resource (org.gluu.oxtrust.model.scim2.Resource)1 Extension (org.gluu.oxtrust.model.scim2.extensions.Extension)1 ResourceType (org.gluu.oxtrust.model.scim2.provider.resourcetypes.ResourceType)1 SchemaExtensionHolder (org.gluu.oxtrust.model.scim2.provider.resourcetypes.SchemaExtensionHolder)1 UserResource (org.gluu.oxtrust.model.scim2.user.UserResource)1