Search in sources :

Example 1 with U2fConfiguration

use of org.xdi.oxauth.model.fido.u2f.U2fConfiguration in project oxAuth by GluuFederation.

the class U2fConfigurationWS method getConfiguration.

@GET
@Produces({ "application/json" })
@ApiOperation(value = "Provides configuration data as json document. It contains options and endpoints supported by the FIDO U2F server.", response = U2fConfiguration.class)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Failed to build FIDO U2F configuration json object.") })
public Response getConfiguration() {
    try {
        final String baseEndpointUri = appConfiguration.getBaseEndpoint();
        final U2fConfiguration conf = new U2fConfiguration();
        conf.setVersion("2.0");
        conf.setIssuer(appConfiguration.getIssuer());
        conf.setRegistrationEndpoint(baseEndpointUri + "/fido/u2f/registration");
        conf.setAuthenticationEndpoint(baseEndpointUri + "/fido/u2f/authentication");
        // convert manually to avoid possible conflicts between resteasy
        // providers, e.g. jettison, jackson
        final String entity = ServerUtil.asPrettyJson(conf);
        log.trace("FIDO U2F 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.getUmaJsonErrorResponse(U2fErrorResponseType.SERVER_ERROR)).build());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) U2fConfiguration(org.xdi.oxauth.model.fido.u2f.U2fConfiguration) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Aggregations

ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 ApiResponses (com.wordnik.swagger.annotations.ApiResponses)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 U2fConfiguration (org.xdi.oxauth.model.fido.u2f.U2fConfiguration)1