Search in sources :

Example 1 with GluuConfiguration

use of org.xdi.oxauth.model.gluu.GluuConfiguration in project oxAuth by GluuFederation.

the class GluuConfigurationWSTest method getConfigurationTest.

@RunAsClient
@Parameters({ "gluuConfigurationPath", "webTarget" })
@Consumes(MediaType.APPLICATION_JSON)
@Test
public void getConfigurationTest(String gluuConfigurationPath, @Optional @ArquillianResteasyResource("seam/resource") final WebTarget webTarget) throws Exception {
    Response response = webTarget.path(gluuConfigurationPath).request().get();
    String entity = response.readEntity(String.class);
    BaseTest.showResponse("UMA : TConfiguration.configuration", response, entity);
    assertEquals(response.getStatus(), 200, "Unexpected response code.");
    try {
        GluuConfiguration appConfiguration = ServerUtil.createJsonMapper().readValue(entity, GluuConfiguration.class);
        System.err.println(appConfiguration.getIdGenerationEndpoint());
        assertNotNull(appConfiguration, "Meta data configuration is null");
        assertNotNull(appConfiguration.getIdGenerationEndpoint());
        assertNotNull(appConfiguration.getIntrospectionEndpoint());
        assertNotNull(appConfiguration.getAuthLevelMapping());
        assertNotNull(appConfiguration.getScopeToClaimsMapping());
    } catch (IOException e) {
        e.printStackTrace();
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) IOException(java.io.IOException) GluuConfiguration(org.xdi.oxauth.model.gluu.GluuConfiguration) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Parameters(org.testng.annotations.Parameters) Consumes(javax.ws.rs.Consumes) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 2 with GluuConfiguration

use of org.xdi.oxauth.model.gluu.GluuConfiguration in project oxAuth by GluuFederation.

the class GluuConfigurationWS method getConfiguration.

@GET
@Produces({ "application/json" })
@ApiOperation(value = "Provides configuration data as json document. It contains non-standard OpenID Connect discovery metadata supported by the Gluu server.", response = GluuConfiguration.class)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Failed to build gluu configuration json object.") })
public Response getConfiguration() {
    try {
        final GluuConfiguration conf = new GluuConfiguration();
        conf.setIdGenerationEndpoint(appConfiguration.getIdGenerationEndpoint());
        conf.setIntrospectionEndpoint(appConfiguration.getIntrospectionEndpoint());
        conf.setAuthLevelMapping(createAuthLevelMapping());
        conf.setScopeToClaimsMapping(createScopeToClaimsMapping());
        // convert manually to avoid possible conflicts between resteasy
        // providers, e.g. jettison, jackson
        final String entity = ServerUtil.asPrettyJson(conf);
        log.trace("Gluu configuration: {}", entity);
        return Response.ok(entity).build();
    } catch (Throwable ex) {
        log.error(ex.getMessage(), ex);
        throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponseFactory.getErrorResponse(GluuErrorResponseType.SERVER_ERROR)).build());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) GluuConfiguration(org.xdi.oxauth.model.gluu.GluuConfiguration) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Aggregations

GluuConfiguration (org.xdi.oxauth.model.gluu.GluuConfiguration)2 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 ApiResponses (com.wordnik.swagger.annotations.ApiResponses)1 IOException (java.io.IOException)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Response (javax.ws.rs.core.Response)1 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)1 Parameters (org.testng.annotations.Parameters)1 Test (org.testng.annotations.Test)1 BaseTest (org.xdi.oxauth.BaseTest)1