Search in sources :

Example 6 with UmaScopeDescription

use of org.gluu.oxauth.model.uma.UmaScopeDescription in project oxAuth by GluuFederation.

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);
    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(org.oxauth.persistence.model.Scope) UmaScopeDescription(org.gluu.oxauth.model.uma.UmaScopeDescription) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 7 with UmaScopeDescription

use of org.gluu.oxauth.model.uma.UmaScopeDescription in project oxAuth by GluuFederation.

the class UmaScopeWSTest method scopePresence.

// private MetadataConfiguration m_configuration;
// 
// @Parameters({"umaConfigurationPath"})
// @Test
// public void init(final String umaConfigurationPath) {
// m_configuration = TUma.requestConfiguration(this, umaConfigurationPath);
// UmaTestUtil.assert_(m_configuration);
// }
@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.assert_(scope);
}
Also used : Response(javax.ws.rs.core.Response) UmaScopeDescription(org.gluu.oxauth.model.uma.UmaScopeDescription) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Builder(javax.ws.rs.client.Invocation.Builder) Parameters(org.testng.annotations.Parameters) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Aggregations

UmaScopeDescription (org.gluu.oxauth.model.uma.UmaScopeDescription)7 IOException (java.io.IOException)4 HttpEntity (org.apache.http.HttpEntity)4 HttpResponse (org.apache.http.HttpResponse)4 ParseException (org.apache.http.ParseException)4 HttpGet (org.apache.http.client.methods.HttpGet)4 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)4 Test (org.junit.Test)4 Parameters (org.testng.annotations.Parameters)2 Test (org.testng.annotations.Test)2 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 BaseTest (org.gluu.oxauth.BaseTest)1 UmaScopeService (org.gluu.oxauth.client.uma.UmaScopeService)1 UmaMetadata (org.gluu.oxauth.model.uma.UmaMetadata)1 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)1 Scope (org.oxauth.persistence.model.Scope)1