use of com.wordnik.swagger.annotations.ApiResponses in project ma-modules-public by infiniteautomation.
the class SessionExceptionRestV2Controller method getLatest.
@ApiOperation(value = "Get Last Exception for your session", notes = "")
@ApiResponses({ @ApiResponse(code = 401, message = "Unauthorized user access", response = ResponseEntity.class), @ApiResponse(code = 404, message = "No Exception exists", response = ResponseEntity.class), @ApiResponse(code = 500, message = "Error processing request", response = ResponseEntity.class) })
@RequestMapping(method = { RequestMethod.GET }, value = { "/latest" }, produces = { "application/json" })
public ResponseEntity<Map<String, Exception>> getLatest(HttpServletRequest request) {
RestProcessResult<Map<String, Exception>> result = new RestProcessResult<>(HttpStatus.OK);
// Get latest Session Exception
HttpSession session = request.getSession(false);
if (session == null)
throw new ServerErrorException(new TranslatableMessage("rest.error.noSession"));
Map<String, Exception> exceptionMap = new HashMap<String, Exception>();
for (String key : exceptionKeys) {
exceptionMap.put(key, (Exception) session.getAttribute(key));
}
return result.createResponseEntity(exceptionMap);
}
use of com.wordnik.swagger.annotations.ApiResponses in project ma-modules-public by infiniteautomation.
the class SystemActionRestV2Controller method cancel.
@ApiOperation(value = "Cancel Action", notes = "No Guarantees that the cancel will work, this is task dependent.")
@ApiResponses({ @ApiResponse(code = 401, message = "Unauthorized user access", response = ResponseEntity.class), @ApiResponse(code = 404, message = "No resource exists with given id", response = ResponseEntity.class), @ApiResponse(code = 500, message = "Error processing request", response = ResponseEntity.class) })
@RequestMapping(method = { RequestMethod.PUT }, value = { "/cancel/{resourceId}" })
public ResponseEntity<SystemActionTemporaryResource> cancel(HttpServletRequest request, @ApiParam(value = "Resource id", required = true, allowMultiple = false) @PathVariable String resourceId, @AuthenticationPrincipal User user) {
SystemActionTemporaryResource resource = resources.get(resourceId);
resource.cancel();
return new ResponseEntity<>(resource, HttpStatus.OK);
}
use of com.wordnik.swagger.annotations.ApiResponses in project ma-modules-public by infiniteautomation.
the class SystemActionRestV2Controller method performAction.
@ApiOperation(value = "Perform an Action", notes = "Kicks off action and returns temporary URL for status")
@ApiResponses({ @ApiResponse(code = 500, message = "Internal error", response = ResponseEntity.class), @ApiResponse(code = 404, message = "Not Found", response = ResponseEntity.class) })
@RequestMapping(method = RequestMethod.PUT, value = "/trigger/{action}")
public ResponseEntity<SystemActionTemporaryResource> performAction(@ApiParam(value = "Valid System Action", required = true, allowMultiple = false) @PathVariable String action, @ApiParam(value = "Input for task", required = false, allowMultiple = false) @RequestBody(required = false) JsonNode input, @AuthenticationPrincipal User user, UriComponentsBuilder builder) {
// Kick off action
SystemActionDefinition def = ModuleRegistry.getSystemActionDefinition(action);
if (def == null)
throw new NotFoundRestException();
String resourceId = resources.generateResourceId();
SystemActionTemporaryResource resource = new SystemActionTemporaryResource(resourceId, def.getTask(user, input), resources, new Date(System.currentTimeMillis() + 600000));
// Resource can live for up to 10 minutes (TODO Configurable?)
resources.put(resourceId, resource);
URI location = builder.path("/v2/actions/status/{resourceId}").buildAndExpand(resourceId).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(resource, headers, HttpStatus.OK);
}
use of com.wordnik.swagger.annotations.ApiResponses 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.ApiResponses 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());
}
}
Aggregations