use of org.alien4cloud.alm.events.BeforePermissionRevokedEvent 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));
}
Aggregations