Search in sources :

Example 1 with DeleteOperation

use of org.springframework.boot.actuate.endpoint.annotation.DeleteOperation 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 2 with DeleteOperation

use of org.springframework.boot.actuate.endpoint.annotation.DeleteOperation in project cas by apereo.

the class U2FRegisteredDevicesEndpoint method delete.

/**
 * Delete.
 *
 * @param username the username
 * @param id       the id
 */
@DeleteOperation
@Operation(summary = "Delete registered device for username and device")
public void delete(@Selector final String username, @Selector final Long id) {
    val registeredDevices = new ArrayList<>(u2fDeviceRepository.getObject().getRegisteredDevices(username));
    registeredDevices.stream().filter(d -> d.getId() == id).forEach(u2fDeviceRepository.getObject()::deleteRegisteredDevice);
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) Endpoint(org.springframework.boot.actuate.endpoint.annotation.Endpoint) MediaType(org.springframework.http.MediaType) Collection(java.util.Collection) lombok.val(lombok.val) U2FDeviceRegistration(org.apereo.cas.adaptors.u2f.storage.U2FDeviceRegistration) Collectors(java.util.stream.Collectors) BaseCasActuatorEndpoint(org.apereo.cas.web.BaseCasActuatorEndpoint) DeleteOperation(org.springframework.boot.actuate.endpoint.annotation.DeleteOperation) ArrayList(java.util.ArrayList) Parameter(io.swagger.v3.oas.annotations.Parameter) Operation(io.swagger.v3.oas.annotations.Operation) ObjectProvider(org.springframework.beans.factory.ObjectProvider) U2FDeviceRepository(org.apereo.cas.adaptors.u2f.storage.U2FDeviceRepository) Selector(org.springframework.boot.actuate.endpoint.annotation.Selector) 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 3 with DeleteOperation

use of org.springframework.boot.actuate.endpoint.annotation.DeleteOperation in project cas by apereo.

the class SamlRegisteredServiceCachedMetadataEndpoint method invalidate.

/**
 * Invalidate.
 *
 * @param serviceId the service id
 */
@DeleteOperation
@Operation(summary = "Invalidate SAML2 metadata cache using an entity id.", parameters = { @Parameter(name = "serviceId") })
public void invalidate(@Nullable final String serviceId) {
    if (StringUtils.isBlank(serviceId)) {
        cachingMetadataResolver.invalidate();
    } else {
        val registeredService = findRegisteredService(serviceId);
        val criteriaSet = new CriteriaSet();
        criteriaSet.add(new EntityIdCriterion(serviceId));
        criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
        cachingMetadataResolver.invalidate(registeredService, criteriaSet);
    }
}
Also used : lombok.val(lombok.val) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) EntityIdCriterion(org.opensaml.core.criterion.EntityIdCriterion) EntityRoleCriterion(org.opensaml.saml.criterion.EntityRoleCriterion) 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)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)3 lombok.val (lombok.val)3 DeleteOperation (org.springframework.boot.actuate.endpoint.annotation.DeleteOperation)3 ReadOperation (org.springframework.boot.actuate.endpoint.annotation.ReadOperation)3 ArrayList (java.util.ArrayList)2 Parameter (io.swagger.v3.oas.annotations.Parameter)1 Collection (java.util.Collection)1 Collectors (java.util.stream.Collectors)1 CriteriaSet (net.shibboleth.utilities.java.support.resolver.CriteriaSet)1 U2FDeviceRegistration (org.apereo.cas.adaptors.u2f.storage.U2FDeviceRegistration)1 U2FDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FDeviceRepository)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 BaseCasActuatorEndpoint (org.apereo.cas.web.BaseCasActuatorEndpoint)1 EntityIdCriterion (org.opensaml.core.criterion.EntityIdCriterion)1 EntityRoleCriterion (org.opensaml.saml.criterion.EntityRoleCriterion)1 ObjectProvider (org.springframework.beans.factory.ObjectProvider)1 Endpoint (org.springframework.boot.actuate.endpoint.annotation.Endpoint)1 Selector (org.springframework.boot.actuate.endpoint.annotation.Selector)1 MediaType (org.springframework.http.MediaType)1