diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/permission/ObjectPermissionSet.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/permission/ObjectPermissionSet.java index 490c5697d..fd8af692a 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/permission/ObjectPermissionSet.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/permission/ObjectPermissionSet.java @@ -23,6 +23,7 @@ package org.glyptodon.guacamole.net.auth.permission; import java.util.Collection; +import java.util.Set; import org.glyptodon.guacamole.GuacamoleException; @@ -121,4 +122,48 @@ public interface ObjectPermissionSet { Collection permissions, Collection 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> 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> 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> permissions) + throws GuacamoleException; + } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/permission/SystemPermissionSet.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/permission/SystemPermissionSet.java index e106cbc08..8acefff8d 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/permission/SystemPermissionSet.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/permission/SystemPermissionSet.java @@ -22,6 +22,7 @@ package org.glyptodon.guacamole.net.auth.permission; +import java.util.Set; import org.glyptodon.guacamole.GuacamoleException; @@ -74,4 +75,49 @@ public interface SystemPermissionSet { void removePermission(SystemPermission.Type permission) 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 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 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 permissions) + throws GuacamoleException; + + } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleObjectPermissionSet.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleObjectPermissionSet.java index d0132780c..96a98b46a 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleObjectPermissionSet.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleObjectPermissionSet.java @@ -78,20 +78,11 @@ public class SimpleObjectPermissionSet this.permissions = permissions; } - /** - * Returns the Set which currently backs this SimpleObjectPermissionSet. - * Changes to this Set will affect future function calls on this - * SimpleObjectPermissionSet. - * - * @return - * The Set of permissions this SimpleObjectPermissionSet currently - * contains. - */ - protected Set> getPermissions() { + @Override + public Set> getPermissions() { return permissions; } - @Override public boolean hasPermission(ObjectPermission.Type permission, IdentifierType identifier) throws GuacamoleException { @@ -140,4 +131,16 @@ public class SimpleObjectPermissionSet } + @Override + public void addPermissions(Set> permissions) + throws GuacamoleException { + throw new GuacamoleSecurityException("Permission denied."); + } + + @Override + public void removePermissions(Set> permissions) + throws GuacamoleException { + throw new GuacamoleSecurityException("Permission denied."); + } + } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleSystemPermissionSet.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleSystemPermissionSet.java index 5b027e5a9..bd6a5c2e0 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleSystemPermissionSet.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleSystemPermissionSet.java @@ -72,16 +72,8 @@ public class SimpleSystemPermissionSet implements SystemPermissionSet { this.permissions = permissions; } - /** - * Returns the Set which currently backs this SimpleSystemPermissionSet. - * Changes to this Set will affect future function calls on this - * SimpleSystemPermissionSet. - * - * @return - * The Set of permissions this SimpleSystemPermissionSet currently - * contains. - */ - protected Set getPermissions() { + @Override + public Set getPermissions() { return permissions; } @@ -106,4 +98,16 @@ public class SimpleSystemPermissionSet implements SystemPermissionSet { throw new GuacamoleSecurityException("Permission denied."); } + @Override + public void addPermissions(Set permissions) + throws GuacamoleException { + throw new GuacamoleSecurityException("Permission denied."); + } + + @Override + public void removePermissions(Set permissions) + throws GuacamoleException { + throw new GuacamoleSecurityException("Permission denied."); + } + }