use of com.wordnik.swagger.annotations.ApiOperation in project oxAuth by GluuFederation.
the class UmaConfigurationWS method getConfiguration.
@GET
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
@ApiOperation(value = "Provides configuration data as json document. It contains options and endpoints supported by the authorization server.", response = UmaConfiguration.class)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Failed to build Uma configuration json object.") })
public Response getConfiguration() {
try {
final String baseEndpointUri = appConfiguration.getBaseEndpoint();
final UmaConfiguration c = new UmaConfiguration();
c.setVersion("1.0");
c.setIssuer(appConfiguration.getIssuer());
c.setPatProfilesSupported(new String[] { TokenType.BEARER.getName() });
c.setAatProfilesSupported(new String[] { TokenType.BEARER.getName() });
c.setRptProfilesSupported(new String[] { RptProfiles.BEARER.getIdentifyingUri() });
c.setPatGrantTypesSupported(new String[] { GrantType.AUTHORIZATION_CODE.getValue(), GrantType.IMPLICIT.getValue(), GrantType.CLIENT_CREDENTIALS.getValue() });
c.setAatGrantTypesSupported(new String[] { GrantType.AUTHORIZATION_CODE.getValue(), GrantType.IMPLICIT.getValue(), GrantType.CLIENT_CREDENTIALS.getValue() });
c.setClaimTokenProfilesSupported(new String[] { "openid" });
c.setUmaProfilesSupported(new String[0]);
c.setDynamicClientEndpoint(baseEndpointUri + "/oxauth/register");
c.setTokenEndpoint(baseEndpointUri + "/oxauth/token");
c.setAuthorizationEndpoint(baseEndpointUri + "/requester/perm");
c.setRequestingPartyClaimsEndpoint("");
c.setIntrospectionEndpoint(baseEndpointUri + "/rpt/status");
c.setResourceSetRegistrationEndpoint(baseEndpointUri + "/host/rsrc/resource_set");
c.setPermissionRegistrationEndpoint(baseEndpointUri + "/host/rsrc_pr");
c.setRptEndpoint(baseEndpointUri + "/requester/rpt");
c.setGatEndpoint(baseEndpointUri + "/requester/gat");
c.setScopeEndpoint(baseEndpointUri + UMA_SCOPES_SUFFIX);
c.setRptAsJwt(appConfiguration.getUmaRptAsJwt());
// convert manually to avoid possible conflicts between resteasy providers, e.g. jettison, jackson
final String entity = ServerUtil.asPrettyJson(c);
log.trace("Uma 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(UmaErrorResponseType.SERVER_ERROR)).build());
}
}
use of com.wordnik.swagger.annotations.ApiOperation 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());
}
}
use of com.wordnik.swagger.annotations.ApiOperation in project oxAuth by GluuFederation.
the class CreateRptWS method getGat.
@Path("gat")
@POST
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
@ApiOperation(value = "The endpoint at which the requester asks the AM to issue an GAT", produces = UmaConstants.JSON_MEDIA_TYPE, notes = "The endpoint at which the requester asks the AM to issue an GAT")
@ApiResponses(value = { @ApiResponse(code = 401, message = "Unauthorized") })
public Response getGat(@HeaderParam("Authorization") String authorization, @HeaderParam("Host") String amHost, GatRequest request, @Context HttpServletRequest httpRequest) {
try {
umaValidationService.assertHasAuthorizationScope(authorization);
String validatedAmHost = umaValidationService.validateAmHost(amHost);
UmaRPT rpt = rptManager.createRPT(authorization, validatedAmHost, true);
authorizeGat(request, rpt, authorization, httpRequest);
String rptResponse = rpt.getCode();
final Boolean umaRptAsJwt = appConfiguration.getUmaRptAsJwt();
if (umaRptAsJwt != null && umaRptAsJwt) {
rptResponse = createJwr(rpt, authorization, request.getScopes()).asString();
}
return Response.status(Response.Status.CREATED).entity(ServerUtil.asJson(new RPTResponse(rptResponse))).build();
} catch (Exception ex) {
log.error("Exception happened", ex);
if (ex instanceof WebApplicationException) {
throw (WebApplicationException) ex;
}
throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.SERVER_ERROR)).build());
}
}
use of com.wordnik.swagger.annotations.ApiOperation in project oxAuth by GluuFederation.
the class CreateRptWS method getRpt.
@Path("rpt")
@POST
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
@ApiOperation(value = "The endpoint at which the requester asks the AM to issue an RPT", produces = UmaConstants.JSON_MEDIA_TYPE, notes = "The endpoint at which the requester asks the AM to issue an RPT")
@ApiResponses(value = { @ApiResponse(code = 401, message = "Unauthorized") })
public Response getRpt(@HeaderParam("Authorization") String authorization, @HeaderParam("Host") String amHost) {
try {
umaValidationService.assertHasAuthorizationScope(authorization);
String validatedAmHost = umaValidationService.validateAmHost(amHost);
UmaRPT rpt = rptManager.createRPT(authorization, validatedAmHost, false);
String rptResponse = rpt.getCode();
final Boolean umaRptAsJwt = appConfiguration.getUmaRptAsJwt();
if (umaRptAsJwt != null && umaRptAsJwt) {
rptResponse = createJwr(rpt, authorization, Lists.<String>newArrayList()).asString();
}
return Response.status(Response.Status.CREATED).entity(ServerUtil.asJson(new RPTResponse(rptResponse))).build();
} catch (Exception ex) {
log.error("Exception happened", ex);
if (ex instanceof WebApplicationException) {
throw (WebApplicationException) ex;
}
throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.SERVER_ERROR)).build());
}
}
use of com.wordnik.swagger.annotations.ApiOperation in project oxAuth by GluuFederation.
the class PermissionRegistrationWS method registerResourceSetPermission.
@POST
@Consumes({ UmaConstants.JSON_MEDIA_TYPE })
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
@ApiOperation(value = "Registers permission using the POST method", consumes = UmaConstants.JSON_MEDIA_TYPE, produces = UmaConstants.JSON_MEDIA_TYPE, notes = "The resource server uses the POST method at the endpoint. The body of the HTTP request message contains a JSON object providing the requested permission, using a format derived from the scope description format specified in [OAuth-resource-reg], as follows. The object has the following properties:")
@ApiResponses(value = { @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 400, message = "Bad Request") })
public Response registerResourceSetPermission(@Context HttpServletRequest request, @HeaderParam("Authorization") String authorization, @HeaderParam("Host") String amHost, @ApiParam(value = "The identifier for a resource set to which this client is seeking access. The identifier MUST correspond to a resource set that was previously registered.", required = true) UmaPermission resourceSetPermissionRequest) {
try {
umaValidationService.assertHasProtectionScope(authorization);
String validatedAmHost = umaValidationService.validateAmHost(amHost);
umaValidationService.validateResourceSet(resourceSetPermissionRequest);
final ResourceSetPermission resourceSetPermissions = resourceSetPermissionManager.createResourceSetPermission(validatedAmHost, resourceSetPermissionRequest, umaRsPermissionService.rptExpirationDate());
resourceSetPermissionManager.addResourceSetPermission(resourceSetPermissions, tokenService.getClientDn(authorization));
return Response.status(Response.Status.CREATED).entity(new PermissionTicket(resourceSetPermissions.getTicket())).build();
} catch (Exception ex) {
if (ex instanceof WebApplicationException) {
throw (WebApplicationException) ex;
}
log.error("Exception happened", ex);
throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.SERVER_ERROR)).build());
}
}
Aggregations