use of io.swagger.v3.oas.models.parameters.RequestBody in project Singularity by HubSpot.
the class PriorityResource method createPriorityFreeze.
@POST
@Path("/freeze")
@Operation(summary = "Stop scheduling tasks below a certain priority level", responses = { @ApiResponse(responseCode = "200", description = "The priority freeze request was accepted"), @ApiResponse(responseCode = "400", description = "There was a validation error with the priority freeze request") })
public SingularityPriorityFreezeParent createPriorityFreeze(@Parameter(hidden = true) @Auth SingularityUser user, @RequestBody(description = "the new priority freeze to create") SingularityPriorityFreeze priorityFreezeRequest) {
authorizationHelper.checkAdminAuthorization(user);
priorityFreezeRequest = singularityValidator.checkSingularityPriorityFreeze(priorityFreezeRequest);
final SingularityPriorityFreezeParent priorityFreezeRequestParent = new SingularityPriorityFreezeParent(priorityFreezeRequest, System.currentTimeMillis(), user.getEmail());
priorityManager.createPriorityFreeze(priorityFreezeRequestParent);
if (priorityFreezeRequest.isKillTasks()) {
priorityManager.setPriorityKill();
}
return priorityFreezeRequestParent;
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project cas by apereo.
the class SSOSamlIdPPostProfileHandlerEndpoint method producePost.
/**
* Produce response entity.
*
* @param request the request
* @param response the response
* @param map the RequestBody
* @return the response entity
*/
@PostMapping(produces = MediaType.APPLICATION_XML_VALUE)
@ResponseBody
@Operation(summary = "Produce SAML2 response entity", parameters = { @Parameter(name = "username", required = true), @Parameter(name = "password", required = true), @Parameter(name = SamlProtocolConstants.PARAMETER_ENTITY_ID, required = true), @Parameter(name = "encrypt") })
public ResponseEntity<Object> producePost(final HttpServletRequest request, final HttpServletResponse response, @RequestBody final Map<String, String> map) {
val username = map.get("username");
val password = map.get("password");
val entityId = map.get(SamlProtocolConstants.PARAMETER_ENTITY_ID);
val encrypt = Boolean.parseBoolean(map.get("encrypt"));
return produce(request, response, username, password, entityId, encrypt);
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project cas by apereo.
the class AmazonSecurityTokenServiceEndpoint method fetchCredentials.
/**
* Fetch credentials.
*
* @param duration the duration
* @param tokenCode the token code
* @param profile the profile
* @param serialNumber the serial number
* @param roleArn the role arn
* @param requestBody the request body
* @param request the request
* @param response the response
* @return the map
*/
@PostMapping
@Operation(summary = "Fetch temporary credentials from Amazon Security Token Service", parameters = { @Parameter(name = "duration"), @Parameter(name = "tokenCode"), @Parameter(name = "profile"), @Parameter(name = "serialNumber"), @Parameter(name = "roleArn"), @Parameter(name = "requestBody"), @Parameter(name = "request"), @Parameter(name = "response") })
public ResponseEntity<String> fetchCredentials(@RequestParam(required = false, defaultValue = "PT1H") final String duration, @RequestParam(value = "token", required = false) final String tokenCode, @RequestParam(required = false) final String profile, @RequestParam(required = false) final String serialNumber, @RequestParam(required = false) final String roleArn, @RequestBody final MultiValueMap<String, String> requestBody, final HttpServletRequest request, final HttpServletResponse response) {
var authenticationResult = (AuthenticationResult) null;
try {
authenticationResult = restAuthenticationService.authenticate(requestBody, request, response).orElseThrow(AuthenticationException::new);
} catch (final Exception e) {
LoggingUtils.error(LOGGER, e);
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Authentication failed");
}
val amz = casProperties.getAmazonSts();
val principal = authenticationResult.getAuthentication().getPrincipal();
LOGGER.debug("Authenticated principal: [{}]", principal);
val authz = authorizePrincipal(amz, principal);
if (authz.isPresent()) {
return authz.get();
}
val credentials = ChainingAWSCredentialsProvider.getInstance(amz.getCredentialAccessKey(), amz.getCredentialSecretKey(), amz.getProfilePath(), StringUtils.defaultString(profile, amz.getProfileName()));
val builder = StsClient.builder();
AmazonClientConfigurationBuilder.prepareClientBuilder(builder, credentials, amz);
val client = builder.build();
if (amz.isRbacEnabled()) {
val attributeValues = principal.getAttributes().get(amz.getPrincipalAttributeName());
LOGGER.debug("Found roles [{}]", attributeValues);
if (attributeValues.size() > 1) {
if (StringUtils.isBlank(roleArn)) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Found multiple roles and none is specified. Current roles: " + attributeValues);
}
if (attributeValues.stream().noneMatch(value -> RegexUtils.find(roleArn, value.toString()))) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Specified role is not allowed. Current roles:" + attributeValues);
}
}
val role = StringUtils.defaultString(roleArn, attributeValues.get(0).toString());
LOGGER.debug("Using role [{}]", role);
val roleRequest = AssumeRoleRequest.builder().durationSeconds(Long.valueOf(Beans.newDuration(duration).toSeconds()).intValue()).roleArn(role).roleSessionName(UUID.randomUUID().toString()).serialNumber(serialNumber).tokenCode(tokenCode).build();
val sessionResult = client.assumeRole(roleRequest);
val stsCredentials = sessionResult.credentials();
return createOutputResponse(amz, stsCredentials);
}
val sessionTokenRequest = GetSessionTokenRequest.builder().durationSeconds(Long.valueOf(Beans.newDuration(duration).toSeconds()).intValue()).serialNumber(serialNumber).tokenCode(tokenCode).build();
val sessionResult = client.getSessionToken(sessionTokenRequest);
val stsCredentials = sessionResult.credentials();
return createOutputResponse(amz, stsCredentials);
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project cas by apereo.
the class GoogleAuthenticatorTokenCredentialRepositoryEndpoint method importAccount.
/**
* Import account.
*
* @param request the request
* @return the http status
* @throws Exception the exception
*/
@PostMapping(path = "/import", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Import account as a JSON document", parameters = { @Parameter(name = "request") })
public HttpStatus importAccount(final HttpServletRequest request) throws Exception {
val requestBody = IOUtils.toString(request.getInputStream(), StandardCharsets.UTF_8);
LOGGER.trace("Submitted account: [{}]", requestBody);
val serializer = new GoogleAuthenticatorAccountSerializer();
val account = serializer.from(requestBody);
LOGGER.trace("Storing account: [{}]", account);
repository.getObject().save(account);
return HttpStatus.CREATED;
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project carbon-apimgt by wso2.
the class OASParserUtil method setReferenceObjectDefinitions.
private static void setReferenceObjectDefinitions(final OpenAPI destOpenAPI, SwaggerUpdateContext context) {
processReferenceObjectMap(context);
Components components = destOpenAPI.getComponents();
Set<Components> aggregatedComponents = context.getAggregatedComponents();
for (Components sourceComponents : aggregatedComponents) {
Map<String, Set<String>> referenceObjectMap = context.getReferenceObjectMapping();
for (Map.Entry<String, Set<String>> refCategoryEntry : referenceObjectMap.entrySet()) {
String category = refCategoryEntry.getKey();
if (REQUEST_BODIES.equalsIgnoreCase(category)) {
Map<String, RequestBody> sourceRequestBodies = sourceComponents.getRequestBodies();
if (sourceRequestBodies != null) {
for (String refKey : refCategoryEntry.getValue()) {
RequestBody requestBody = sourceRequestBodies.get(refKey);
if (requestBody != null) {
components.addRequestBodies(refKey, requestBody);
}
}
}
}
if (SCHEMAS.equalsIgnoreCase(category)) {
Map<String, Schema> sourceSchemas = sourceComponents.getSchemas();
if (sourceSchemas != null) {
for (String refKey : refCategoryEntry.getValue()) {
Schema schema = sourceSchemas.get(refKey);
if (schema != null) {
components.addSchemas(refKey, schema);
}
}
}
}
if (PARAMETERS.equalsIgnoreCase(category)) {
Map<String, Parameter> parameters = sourceComponents.getParameters();
if (parameters != null) {
for (String refKey : refCategoryEntry.getValue()) {
Parameter parameter = parameters.get(refKey);
if (parameter != null) {
components.addParameters(refKey, parameter);
}
}
}
}
if (RESPONSES.equalsIgnoreCase(category)) {
Map<String, ApiResponse> responses = sourceComponents.getResponses();
if (responses != null) {
for (String refKey : refCategoryEntry.getValue()) {
ApiResponse response = responses.get(refKey);
if (response != null) {
components.addResponses(refKey, response);
}
}
}
}
if (HEADERS.equalsIgnoreCase(category)) {
Map<String, Header> headers = sourceComponents.getHeaders();
if (headers != null) {
for (String refKey : refCategoryEntry.getValue()) {
Header header = headers.get(refKey);
if (header != null) {
components.addHeaders(refKey, header);
}
}
}
}
}
}
}
Aggregations