Search in sources :

Example 1 with AfterPermissionRevokedEvent

use of org.alien4cloud.alm.events.AfterPermissionRevokedEvent in project alien4cloud by alien4cloud.

the class ResourcePermissionService method revokePermission.

/**
 * Revoke admin permission from the given resource from the given subjects.
 *
 * @param resource the resource to revoke
 * @param saver a callback to save the resource after modification
 * @param subjectType the type of the subject
 * @param subjects the subjects from which the permissions are revoked
 */
public void revokePermission(ISecurityEnabledResource resource, IResourceSaver saver, Subject subjectType, String... subjects) {
    publisher.publishEvent(new BeforePermissionRevokedEvent(this, new BeforePermissionRevokedEvent.OnResource(resource.getClass(), resource.getId()), subjectType, subjects));
    Arrays.stream(subjects).forEach(subject -> resource.removePermissions(subjectType, subject, Sets.newHashSet(Permission.ADMIN)));
    if (saver != null) {
        saver.save(resource);
    }
    publisher.publishEvent(new AfterPermissionRevokedEvent(this, new BeforePermissionRevokedEvent.OnResource(resource.getClass(), resource.getId()), subjectType, subjects));
}
Also used : AfterPermissionRevokedEvent(org.alien4cloud.alm.events.AfterPermissionRevokedEvent) BeforePermissionRevokedEvent(org.alien4cloud.alm.events.BeforePermissionRevokedEvent)

Aggregations

AfterPermissionRevokedEvent (org.alien4cloud.alm.events.AfterPermissionRevokedEvent)1 BeforePermissionRevokedEvent (org.alien4cloud.alm.events.BeforePermissionRevokedEvent)1