use of org.gluu.oxtrust.model.scim2.provider.resourcetypes.ResourceType 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();
}
use of org.gluu.oxtrust.model.scim2.provider.resourcetypes.ResourceType 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();
}
use of org.gluu.oxtrust.model.scim2.provider.resourcetypes.ResourceType 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);
}
use of org.gluu.oxtrust.model.scim2.provider.resourcetypes.ResourceType in project oxTrust by GluuFederation.
the class ResourceTypeWS method getGroupResourceType.
private ResourceType getGroupResourceType() {
ResourceType grRT = new ResourceType();
fillResourceType(grRT, ScimResourceUtil.getSchemaAnnotation(GroupResource.class), groupService.getEndpointUrl(), getResourceLocation(GROUP_SUFFIX), null);
return grRT;
}
use of org.gluu.oxtrust.model.scim2.provider.resourcetypes.ResourceType 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;
}
Aggregations