GUAC-1100: Add batch add/remove to permission sets.

This commit is contained in:
Michael Jumper
2015-02-11 15:04:48 -08:00
parent a22299466b
commit 7c353007f6
4 changed files with 119 additions and 21 deletions

View File

@@ -23,6 +23,7 @@
package org.glyptodon.guacamole.net.auth.permission; package org.glyptodon.guacamole.net.auth.permission;
import java.util.Collection; import java.util.Collection;
import java.util.Set;
import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleException;
@@ -121,4 +122,48 @@ public interface ObjectPermissionSet<IdentifierType> {
Collection<ObjectPermission.Type> permissions, Collection<ObjectPermission.Type> permissions,
Collection<IdentifierType> identifiers) throws GuacamoleException; Collection<IdentifierType> identifiers) throws GuacamoleException;
/**
* Returns a Set which contains all permissions granted within this
* permission set.
*
* @return
* A Set containing all permissions granted within this permission set.
*
* @throws GuacamoleException
* If an error occurs while retrieving permissions, or if permissions
* cannot be retrieved due to lack of permissions to do so.
*/
Set<ObjectPermission<IdentifierType>> getPermissions()
throws GuacamoleException;
/**
* Adds the specified permissions, if not already granted. If a specified
* permission is already granted, no operation is performed regarding that
* permission.
*
* @param permissions
* The permissions to add.
*
* @throws GuacamoleException
* If an error occurs while adding the permissions, or if permission to
* add permissions is denied.
*/
void addPermissions(Set<ObjectPermission<IdentifierType>> permissions)
throws GuacamoleException;
/**
* Removes each of the specified permissions, if granted. If a specified
* permission is not granted, no operation is performed regarding that
* permission.
*
* @param permissions
* The permissions to remove.
*
* @throws GuacamoleException
* If an error occurs while removing the permissions, or if permission
* to remove permissions is denied.
*/
void removePermissions(Set<ObjectPermission<IdentifierType>> permissions)
throws GuacamoleException;
} }

View File

@@ -22,6 +22,7 @@
package org.glyptodon.guacamole.net.auth.permission; package org.glyptodon.guacamole.net.auth.permission;
import java.util.Set;
import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleException;
@@ -74,4 +75,49 @@ public interface SystemPermissionSet {
void removePermission(SystemPermission.Type permission) void removePermission(SystemPermission.Type permission)
throws GuacamoleException; throws GuacamoleException;
/**
* Returns a Set which contains all system-level permissions granted within
* this permission set.
*
* @return
* A Set containing all system-level permissions granted within this
* permission set.
*
* @throws GuacamoleException
* If an error occurs while retrieving permissions, or if permissions
* cannot be retrieved due to lack of permissions to do so.
*/
Set<SystemPermission> getPermissions() throws GuacamoleException;
/**
* Adds the specified permissions, if not already granted. If a specified
* permission is already granted, no operation is performed regarding that
* permission.
*
* @param permissions
* The permissions to add.
*
* @throws GuacamoleException
* If an error occurs while adding the permissions, or if permission to
* add permissions is denied.
*/
void addPermissions(Set<SystemPermission> permissions)
throws GuacamoleException;
/**
* Removes each of the specified permissions, if granted. If a specified
* permission is not granted, no operation is performed regarding that
* permission.
*
* @param permissions
* The permissions to remove.
*
* @throws GuacamoleException
* If an error occurs while removing the permissions, or if permission
* to remove permissions is denied.
*/
void removePermissions(Set<SystemPermission> permissions)
throws GuacamoleException;
} }

View File

@@ -78,20 +78,11 @@ public class SimpleObjectPermissionSet<IdentifierType>
this.permissions = permissions; this.permissions = permissions;
} }
/** @Override
* Returns the Set which currently backs this SimpleObjectPermissionSet. public Set<ObjectPermission<IdentifierType>> getPermissions() {
* Changes to this Set will affect future function calls on this
* SimpleObjectPermissionSet.
*
* @return
* The Set of permissions this SimpleObjectPermissionSet currently
* contains.
*/
protected Set<ObjectPermission<IdentifierType>> getPermissions() {
return permissions; return permissions;
} }
@Override @Override
public boolean hasPermission(ObjectPermission.Type permission, public boolean hasPermission(ObjectPermission.Type permission,
IdentifierType identifier) throws GuacamoleException { IdentifierType identifier) throws GuacamoleException {
@@ -140,4 +131,16 @@ public class SimpleObjectPermissionSet<IdentifierType>
} }
@Override
public void addPermissions(Set<ObjectPermission<IdentifierType>> permissions)
throws GuacamoleException {
throw new GuacamoleSecurityException("Permission denied.");
}
@Override
public void removePermissions(Set<ObjectPermission<IdentifierType>> permissions)
throws GuacamoleException {
throw new GuacamoleSecurityException("Permission denied.");
}
} }

View File

@@ -72,16 +72,8 @@ public class SimpleSystemPermissionSet implements SystemPermissionSet {
this.permissions = permissions; this.permissions = permissions;
} }
/** @Override
* Returns the Set which currently backs this SimpleSystemPermissionSet. public Set<SystemPermission> getPermissions() {
* Changes to this Set will affect future function calls on this
* SimpleSystemPermissionSet.
*
* @return
* The Set of permissions this SimpleSystemPermissionSet currently
* contains.
*/
protected Set<SystemPermission> getPermissions() {
return permissions; return permissions;
} }
@@ -106,4 +98,16 @@ public class SimpleSystemPermissionSet implements SystemPermissionSet {
throw new GuacamoleSecurityException("Permission denied."); throw new GuacamoleSecurityException("Permission denied.");
} }
@Override
public void addPermissions(Set<SystemPermission> permissions)
throws GuacamoleException {
throw new GuacamoleSecurityException("Permission denied.");
}
@Override
public void removePermissions(Set<SystemPermission> permissions)
throws GuacamoleException {
throw new GuacamoleSecurityException("Permission denied.");
}
} }