Search in sources :

Example 1 with UmaScopeDescription

use of io.jans.as.model.uma.UmaScopeDescription in project jans by JanssenProject.

the class ScopeHttpTest method scopePresence.

@Test
@Parameters({ "umaMetaDataUrl" })
public void scopePresence(final String umaMetaDataUrl) {
    final UmaMetadata metadata = UmaClientFactory.instance().createMetadataService(umaMetaDataUrl).getMetadata();
    final UmaScopeService scopeService = UmaClientFactory.instance().createScopeService(metadata.getScopeEndpoint());
    final UmaScopeDescription modifyScope = scopeService.getScope("modify");
    UmaTestUtil.assertIt(modifyScope);
}
Also used : UmaMetadata(io.jans.as.model.uma.UmaMetadata) UmaScopeDescription(io.jans.as.model.uma.UmaScopeDescription) UmaScopeService(io.jans.as.client.uma.UmaScopeService) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 2 with UmaScopeDescription

use of io.jans.as.model.uma.UmaScopeDescription in project jans by JanssenProject.

the class UmaScopeWSTest method scopePresence.

@Parameters({ "umaScopePath" })
@Test
public void scopePresence(final String umaScopePath) throws Exception {
    String path = umaScopePath + "/" + "modify";
    System.out.println("Path: " + path);
    Builder request = ResteasyClientBuilder.newClient().target(url.toString() + path).request();
    request.header("Accept", UmaConstants.JSON_MEDIA_TYPE);
    Response response = request.get();
    String entity = response.readEntity(String.class);
    BaseTest.showResponse("UMA : UmaScopeWSTest.scopePresence() : ", response, entity);
    assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), "Unexpected response code.");
    final UmaScopeDescription scope = TUma.readJsonValue(entity, UmaScopeDescription.class);
    UmaTestUtil.assertIt(scope);
}
Also used : Response(javax.ws.rs.core.Response) UmaScopeDescription(io.jans.as.model.uma.UmaScopeDescription) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Builder(javax.ws.rs.client.Invocation.Builder) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BaseTest(io.jans.as.server.BaseTest)

Example 3 with UmaScopeDescription

use of io.jans.as.model.uma.UmaScopeDescription in project jans by JanssenProject.

the class UmaScopeWS method getScopeDescription.

@GET
@Path("{id}")
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
public Response getScopeDescription(@PathParam("id") String id) {
    log.trace("UMA - get scope description: id: {}", id);
    errorResponseFactory.validateComponentEnabled(ComponentType.UMA);
    try {
        if (StringUtils.isNotBlank(id)) {
            final Scope scope = umaScopeService.getScope(id);
            if (scope != null) {
                final UmaScopeDescription jsonScope = new UmaScopeDescription();
                jsonScope.setIconUri(scope.getIconUrl());
                jsonScope.setName(scope.getId());
                jsonScope.setDescription(scope.getDescription());
                return Response.status(Response.Status.OK).entity(ServerUtil.asJson(jsonScope)).build();
            }
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw errorResponseFactory.createWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR, UmaErrorResponseType.SERVER_ERROR, "Internal error.");
    }
    throw errorResponseFactory.createWebApplicationException(Response.Status.NOT_FOUND, UmaErrorResponseType.NOT_FOUND, "Not found.");
}
Also used : Scope(io.jans.as.persistence.model.Scope) UmaScopeDescription(io.jans.as.model.uma.UmaScopeDescription) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

UmaScopeDescription (io.jans.as.model.uma.UmaScopeDescription)3 Parameters (org.testng.annotations.Parameters)2 Test (org.testng.annotations.Test)2 UmaScopeService (io.jans.as.client.uma.UmaScopeService)1 UmaMetadata (io.jans.as.model.uma.UmaMetadata)1 Scope (io.jans.as.persistence.model.Scope)1 BaseTest (io.jans.as.server.BaseTest)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Builder (javax.ws.rs.client.Invocation.Builder)1 Response (javax.ws.rs.core.Response)1 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)1