Search in sources :

Example 76 with Operation

use of io.swagger.v3.oas.models.Operation in project cas by apereo.

the class CasResolveAttributesReportEndpoint method resolvePrincipalAttributes.

/**
 * Resolve principal attributes map.
 *
 * @param uid the uid
 * @return the map
 */
@ReadOperation
@Operation(summary = "Resolve principal attributes for user", parameters = { @Parameter(name = "uid", required = true) })
public Map<String, Object> resolvePrincipalAttributes(@Selector final String uid) {
    val p = defaultPrincipalResolver.getObject().resolve(new BasicIdentifiableCredential(uid));
    val map = new HashMap<String, Object>();
    map.put("uid", p.getId());
    map.put("attributes", p.getAttributes());
    return map;
}
Also used : lombok.val(lombok.val) HashMap(java.util.HashMap) BasicIdentifiableCredential(org.apereo.cas.authentication.credential.BasicIdentifiableCredential) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) Operation(io.swagger.v3.oas.annotations.Operation)

Example 77 with Operation

use of io.swagger.v3.oas.models.Operation in project cas by apereo.

the class U2FRegisteredDevicesEndpoint method delete.

/**
 * Delete.
 *
 * @param username the username
 */
@DeleteOperation
@Operation(summary = "Delete all registered devices", parameters = { @Parameter(name = "username", required = true) })
public void delete(@Selector final String username) {
    val registeredDevices = new ArrayList<>(u2fDeviceRepository.getObject().getRegisteredDevices(username));
    registeredDevices.forEach(u2fDeviceRepository.getObject()::deleteRegisteredDevice);
}
Also used : lombok.val(lombok.val) ArrayList(java.util.ArrayList) DeleteOperation(org.springframework.boot.actuate.endpoint.annotation.DeleteOperation) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) DeleteOperation(org.springframework.boot.actuate.endpoint.annotation.DeleteOperation) Operation(io.swagger.v3.oas.annotations.Operation)

Example 78 with Operation

use of io.swagger.v3.oas.models.Operation in project cas by apereo.

the class SSOSamlIdPPostProfileHandlerEndpoint method produceGet.

/**
 * Produce response entity.
 *
 * @param request  the request
 * @param response the response
 * @return the response entity
 */
@GetMapping(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> produceGet(final HttpServletRequest request, final HttpServletResponse response) {
    val username = request.getParameter("username");
    val password = request.getParameter("password");
    val entityId = request.getParameter(SamlProtocolConstants.PARAMETER_ENTITY_ID);
    val encrypt = Boolean.parseBoolean(request.getParameter("encrypt"));
    return produce(request, response, username, password, entityId, encrypt);
}
Also used : lombok.val(lombok.val) GetMapping(org.springframework.web.bind.annotation.GetMapping) Operation(io.swagger.v3.oas.annotations.Operation) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 79 with Operation

use of io.swagger.v3.oas.models.Operation in project cas by apereo.

the class YubiKeyAccountRegistryEndpoint method export.

/**
 * Export.
 *
 * @return the response entity
 */
@GetMapping(path = "/export", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ResponseBody
@Operation(summary = "Export all Yubikey accounts as a zip file")
public ResponseEntity<Resource> export() {
    val accounts = registry.getObject().getAccounts();
    val resource = CompressionUtils.toZipFile(accounts.stream(), Unchecked.function(entry -> {
        val acct = (YubiKeyAccount) entry;
        val fileName = String.format("%s-%s", acct.getUsername(), acct.getId());
        val sourceFile = File.createTempFile(fileName, ".json");
        MAPPER.writeValue(sourceFile, acct);
        return sourceFile;
    }), "yubikeybaccts");
    val headers = new HttpHeaders();
    headers.setContentDisposition(ContentDisposition.attachment().filename(Objects.requireNonNull(resource.getFilename())).build());
    return new ResponseEntity<>(resource, headers, HttpStatus.OK);
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) PathVariable(org.springframework.web.bind.annotation.PathVariable) Operation(io.swagger.v3.oas.annotations.Operation) ObjectProvider(org.springframework.beans.factory.ObjectProvider) HttpServletRequest(javax.servlet.http.HttpServletRequest) ContentDisposition(org.springframework.http.ContentDisposition) GetMapping(org.springframework.web.bind.annotation.GetMapping) YubiKeyAccount(org.apereo.cas.adaptors.yubikey.YubiKeyAccount) TypeReference(com.fasterxml.jackson.core.type.TypeReference) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) Resource(org.springframework.core.io.Resource) YubiKeyAccountRegistry(org.apereo.cas.adaptors.yubikey.YubiKeyAccountRegistry) PostMapping(org.springframework.web.bind.annotation.PostMapping) Unchecked(org.jooq.lambda.Unchecked) HttpHeaders(org.springframework.http.HttpHeaders) MediaType(org.springframework.http.MediaType) Collection(java.util.Collection) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) lombok.val(lombok.val) CompressionUtils(org.apereo.cas.util.CompressionUtils) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) BaseCasActuatorEndpoint(org.apereo.cas.web.BaseCasActuatorEndpoint) Parameter(io.swagger.v3.oas.annotations.Parameter) RestControllerEndpoint(org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint) Objects(java.util.Objects) IOUtils(org.apache.commons.io.IOUtils) HttpStatus(org.springframework.http.HttpStatus) Slf4j(lombok.extern.slf4j.Slf4j) JacksonObjectMapperFactory(org.apereo.cas.util.serialization.JacksonObjectMapperFactory) ResponseEntity(org.springframework.http.ResponseEntity) HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) GetMapping(org.springframework.web.bind.annotation.GetMapping) Operation(io.swagger.v3.oas.annotations.Operation) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 80 with Operation

use of io.swagger.v3.oas.models.Operation in project cas by apereo.

the class YubiKeyAccountRegistryEndpoint method importAccount.

/**
 * Import account.
 *
 * @param request the request
 * @return the http status
 * @throws Exception the exception
 */
@Operation(summary = "Import a Yubikey account as a JSON document")
@PostMapping(path = "/import", consumes = MediaType.APPLICATION_JSON_VALUE)
public HttpStatus importAccount(final HttpServletRequest request) throws Exception {
    val requestBody = IOUtils.toString(request.getInputStream(), StandardCharsets.UTF_8);
    LOGGER.trace("Submitted account: [{}]", requestBody);
    val account = MAPPER.readValue(requestBody, new TypeReference<YubiKeyAccount>() {
    });
    LOGGER.trace("Storing account: [{}]", account);
    registry.getObject().save(account);
    return HttpStatus.CREATED;
}
Also used : lombok.val(lombok.val) YubiKeyAccount(org.apereo.cas.adaptors.yubikey.YubiKeyAccount) PostMapping(org.springframework.web.bind.annotation.PostMapping) Operation(io.swagger.v3.oas.annotations.Operation)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)177 Operation (io.swagger.v3.oas.models.Operation)174 OpenAPI (io.swagger.v3.oas.models.OpenAPI)141 Test (org.testng.annotations.Test)129 PathItem (io.swagger.v3.oas.models.PathItem)108 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)99 Schema (io.swagger.v3.oas.models.media.Schema)68 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)62 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)59 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)55 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)51 ArrayList (java.util.ArrayList)51 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)50 StringSchema (io.swagger.v3.oas.models.media.StringSchema)48 MediaType (io.swagger.v3.oas.models.media.MediaType)44 Path (javax.ws.rs.Path)44 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)43 Content (io.swagger.v3.oas.models.media.Content)42 lombok.val (lombok.val)42 Parameter (io.swagger.v3.oas.models.parameters.Parameter)39