use of io.swagger.v3.oas.models.parameters.Parameter in project cas by apereo.
the class CasConfigurationMetadataServerEndpoint method search.
/**
* Search for property.
*
* @param name the name
* @return the response entity
*/
@ReadOperation
@Operation(summary = "Get all properties from the repository that match the name", parameters = { @Parameter(name = "name", required = true) })
public List<ConfigurationMetadataSearchResult> search(@Selector final String name) {
val allProps = repository.getRepository().getAllProperties();
if (StringUtils.isNotBlank(name) && RegexUtils.isValidRegex(name)) {
val names = StreamSupport.stream(RelaxedPropertyNames.forCamelCase(name).spliterator(), false).map(Object::toString).collect(Collectors.joining("|"));
val pattern = RegexUtils.createPattern(names);
return allProps.entrySet().stream().filter(propEntry -> RegexUtils.find(pattern, propEntry.getKey())).map(propEntry -> new ConfigurationMetadataSearchResult(propEntry.getValue(), repository)).sorted().collect(Collectors.toList());
}
return new ArrayList<>(0);
}
use of io.swagger.v3.oas.models.parameters.Parameter 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.Parameter in project cas by apereo.
the class SamlValidateEndpoint method handle.
/**
* Handle validation request and produce saml1 payload.
*
* @param username the username
* @param password the password
* @param service the service
* @return the map
*/
@ReadOperation
@Operation(summary = "Handle validation request and produce saml1 payload.", parameters = { @Parameter(name = "username", required = true), @Parameter(name = "password", required = true), @Parameter(name = "service", required = true) })
public Map<String, Object> handle(final String username, final String password, final String service) {
val credential = new UsernamePasswordCredential(username, password);
val selectedService = this.serviceFactory.createService(service);
val result = this.authenticationSystemSupport.finalizeAuthenticationTransaction(selectedService, credential);
val authentication = result.getAuthentication();
val registeredService = this.servicesManager.findServiceBy(selectedService);
val audit = AuditableContext.builder().service(selectedService).authentication(authentication).registeredService(registeredService).build();
val accessResult = registeredServiceAccessStrategyEnforcer.execute(audit);
accessResult.throwExceptionIfNeeded();
val principal = authentication.getPrincipal();
val context = RegisteredServiceAttributeReleasePolicyContext.builder().registeredService(registeredService).service(selectedService).principal(principal).build();
val attributesToRelease = registeredService.getAttributeReleasePolicy().getAttributes(context);
val principalId = registeredService.getUsernameAttributeProvider().resolveUsername(principal, selectedService, registeredService);
val modifiedPrincipal = this.principalFactory.createPrincipal(principalId, attributesToRelease);
val builder = DefaultAuthenticationBuilder.newInstance(authentication);
builder.setPrincipal(modifiedPrincipal);
val finalAuthentication = builder.build();
val samlResponse = this.samlResponseBuilder.createResponse(selectedService.getId(), selectedService);
samlResponseBuilder.prepareSuccessfulResponse(samlResponse, selectedService, finalAuthentication, principal, finalAuthentication.getAttributes(), principal.getAttributes());
val resValidation = new LinkedHashMap<String, Object>();
val encoded = SamlUtils.transformSamlObject(this.openSamlConfigBean, samlResponse).toString();
resValidation.put(CasViewConstants.MODEL_ATTRIBUTE_NAME_ASSERTION, encoded);
resValidation.put(CasViewConstants.MODEL_ATTRIBUTE_NAME_SERVICE, selectedService);
resValidation.put("registeredService", registeredService);
return resValidation;
}
use of io.swagger.v3.oas.models.parameters.Parameter in project oxTrust by GluuFederation.
the class GluuRadiusClientWebResource method updateRadiusClient.
@PUT
@Operation(summary = "Update existing radius client", description = "Update existing radius client")
@ApiResponses({ @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = RadiusClient.class)), description = "Success"), @ApiResponse(responseCode = "400", description = "Malformed Request. Missing parameter"), @ApiResponse(responseCode = "403", description = "Gluu Radius is not installed"), @ApiResponse(responseCode = "404", description = "Radius client not found"), @ApiResponse(responseCode = "500", description = "Internal server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateRadiusClient(RadiusClient client) {
try {
if (ProductInstallationChecker.isGluuRadiusInstalled() == false)
return Response.status(Response.Status.FORBIDDEN).build();
Objects.requireNonNull(client);
if (client.getInum() == null)
return Response.status(Response.Status.BAD_REQUEST).entity("Missing radius client inum").build();
String inum = client.getInum();
RadiusClient existingclient = gluuRadiusClientService.getRadiusClientByInum(inum);
if (existingclient == null)
return Response.status(Response.Status.NOT_FOUND).build();
if (client.getIpAddress() != null)
existingclient.setIpAddress(client.getIpAddress());
if (client.getName() != null)
existingclient.setName(client.getName());
if (client.getPriority() != null)
existingclient.setPriority(client.getPriority());
if (client.getSecret() != null && !StringUtils.equals(client.getSecret(), existingclient.getSecret())) {
String encryptedsecret = encryptionService.encrypt(client.getSecret());
existingclient.setSecret(encryptedsecret);
}
gluuRadiusClientService.updateRadiusClient(existingclient);
return Response.ok(gluuRadiusClientService.getRadiusClientByInum(inum)).build();
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
Aggregations