Search in sources :

Example 1 with ResourceType

use of org.apache.syncope.ext.scimv2.api.data.ResourceType in project syncope by apache.

the class SCIMLogic method resourceTypes.

@PreAuthorize("isAuthenticated()")
public List<ResourceType> resourceTypes(final UriBuilder uriBuilder) {
    synchronized (MONITOR) {
        if (USER == null) {
            USER = new ResourceType("User", "User", "/Users", "User Account", Resource.User.schema(), new Meta(Resource.ResourceType, null, null, null, uriBuilder.path("User").build().toASCIIString()));
            USER.getSchemaExtensions().add(new SchemaExtension(Resource.EnterpriseUser.schema(), true));
        }
        if (GROUP == null) {
            GROUP = new ResourceType("Group", "Group", "/Groups", "Group", Resource.Group.schema(), new Meta(Resource.ResourceType, null, null, null, uriBuilder.path("Group").build().toASCIIString()));
        }
    }
    return Arrays.asList(USER, GROUP);
}
Also used : Meta(org.apache.syncope.ext.scimv2.api.data.Meta) SchemaExtension(org.apache.syncope.ext.scimv2.api.data.SchemaExtension) ResourceType(org.apache.syncope.ext.scimv2.api.data.ResourceType) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 2 with ResourceType

use of org.apache.syncope.ext.scimv2.api.data.ResourceType in project syncope by apache.

the class SCIMITCase method resourceTypes.

@Test
public void resourceTypes() {
    assumeTrue(SCIMDetector.isSCIMAvailable(webClient()));
    Response response = webClient().path("ResourceTypes").get();
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    assertEquals(SCIMConstants.APPLICATION_SCIM_JSON, StringUtils.substringBefore(response.getHeaderString(HttpHeaders.CONTENT_TYPE), ";"));
    List<ResourceType> resourceTypes = response.readEntity(new GenericType<List<ResourceType>>() {
    });
    assertNotNull(resourceTypes);
    assertEquals(2, resourceTypes.size());
    response = webClient().path("ResourceTypes").path("User").get();
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    ResourceType user = response.readEntity(ResourceType.class);
    assertNotNull(user);
    assertEquals(Resource.User.schema(), user.getSchema());
    assertFalse(user.getSchemaExtensions().isEmpty());
}
Also used : ListResponse(org.apache.syncope.ext.scimv2.api.data.ListResponse) Response(javax.ws.rs.core.Response) ResourceType(org.apache.syncope.ext.scimv2.api.data.ResourceType) List(java.util.List) Test(org.junit.jupiter.api.Test)

Aggregations

ResourceType (org.apache.syncope.ext.scimv2.api.data.ResourceType)2 List (java.util.List)1 Response (javax.ws.rs.core.Response)1 ListResponse (org.apache.syncope.ext.scimv2.api.data.ListResponse)1 Meta (org.apache.syncope.ext.scimv2.api.data.Meta)1 SchemaExtension (org.apache.syncope.ext.scimv2.api.data.SchemaExtension)1 Test (org.junit.jupiter.api.Test)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1