mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-220: Add EMPTY_SET convenience constant to all core set interfaces.
This commit is contained in:
@@ -35,9 +35,6 @@ import org.apache.guacamole.net.auth.RelatedObjectSet;
|
|||||||
import org.apache.guacamole.net.auth.User;
|
import org.apache.guacamole.net.auth.User;
|
||||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||||
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
||||||
import org.apache.guacamole.net.auth.simple.SimpleObjectPermissionSet;
|
|
||||||
import org.apache.guacamole.net.auth.simple.SimpleRelatedObjectSet;
|
|
||||||
import org.apache.guacamole.net.auth.simple.SimpleSystemPermissionSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An immutable implementation of User which defines READ permission for each of
|
* An immutable implementation of User which defines READ permission for each of
|
||||||
@@ -122,7 +119,7 @@ public class SharedUser implements User {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SystemPermissionSet getSystemPermissions() throws GuacamoleException {
|
public SystemPermissionSet getSystemPermissions() throws GuacamoleException {
|
||||||
return new SimpleSystemPermissionSet();
|
return SystemPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -145,22 +142,22 @@ public class SharedUser implements User {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getUserGroupPermissions() throws GuacamoleException {
|
public ObjectPermissionSet getUserGroupPermissions() throws GuacamoleException {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getSharingProfilePermissions() throws GuacamoleException {
|
public ObjectPermissionSet getSharingProfilePermissions() throws GuacamoleException {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getActiveConnectionPermissions() throws GuacamoleException {
|
public ObjectPermissionSet getActiveConnectionPermissions() throws GuacamoleException {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
||||||
return new SimpleRelatedObjectSet();
|
return RelatedObjectSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -19,8 +19,10 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.net.auth;
|
package org.apache.guacamole.net.auth;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.GuacamoleSecurityException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An arbitrary set of existing objects sharing some common relation. Unlike a
|
* An arbitrary set of existing objects sharing some common relation. Unlike a
|
||||||
@@ -75,4 +77,28 @@ public interface RelatedObjectSet {
|
|||||||
*/
|
*/
|
||||||
void removeObjects(Set<String> identifiers) throws GuacamoleException;
|
void removeObjects(Set<String> identifiers) throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An immutable instance of RelatedObjectSEt which contains no objects.
|
||||||
|
*/
|
||||||
|
static final RelatedObjectSet EMPTY_SET = new RelatedObjectSet() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getObjects() throws GuacamoleException {
|
||||||
|
return Collections.<String>emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addObjects(Set<String> identifiers)
|
||||||
|
throws GuacamoleException {
|
||||||
|
throw new GuacamoleSecurityException("Permission denied.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeObjects(Set<String> identifiers)
|
||||||
|
throws GuacamoleException {
|
||||||
|
throw new GuacamoleSecurityException("Permission denied.");
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -20,8 +20,10 @@
|
|||||||
package org.apache.guacamole.net.auth.permission;
|
package org.apache.guacamole.net.auth.permission;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.GuacamoleSecurityException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,4 +128,54 @@ public interface ObjectPermissionSet extends PermissionSet<ObjectPermission> {
|
|||||||
void removePermissions(Set<ObjectPermission> permissions)
|
void removePermissions(Set<ObjectPermission> permissions)
|
||||||
throws GuacamoleException;
|
throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An immutable instance of ObjectPermissionSet which contains no
|
||||||
|
* permissions.
|
||||||
|
*/
|
||||||
|
static final ObjectPermissionSet EMPTY_SET = new ObjectPermissionSet() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(ObjectPermission.Type permission,
|
||||||
|
String identifier) throws GuacamoleException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addPermission(ObjectPermission.Type permission,
|
||||||
|
String identifier) throws GuacamoleException {
|
||||||
|
throw new GuacamoleSecurityException("Permission denied.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removePermission(ObjectPermission.Type permission,
|
||||||
|
String identifier) throws GuacamoleException {
|
||||||
|
throw new GuacamoleSecurityException("Permission denied.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> getAccessibleObjects(Collection<ObjectPermission.Type> permissions,
|
||||||
|
Collection<String> identifiers) throws GuacamoleException {
|
||||||
|
return Collections.<String>emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<ObjectPermission> getPermissions()
|
||||||
|
throws GuacamoleException {
|
||||||
|
return Collections.<ObjectPermission>emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addPermissions(Set<ObjectPermission> permissions)
|
||||||
|
throws GuacamoleException {
|
||||||
|
throw new GuacamoleSecurityException("Permission denied.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removePermissions(Set<ObjectPermission> permissions)
|
||||||
|
throws GuacamoleException {
|
||||||
|
throw new GuacamoleSecurityException("Permission denied.");
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -19,8 +19,10 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.net.auth.permission;
|
package org.apache.guacamole.net.auth.permission;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.GuacamoleSecurityException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,4 +83,48 @@ public interface SystemPermissionSet extends PermissionSet<SystemPermission> {
|
|||||||
void removePermissions(Set<SystemPermission> permissions)
|
void removePermissions(Set<SystemPermission> permissions)
|
||||||
throws GuacamoleException;
|
throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An immutable instance of SystemPermissionSet which contains no
|
||||||
|
* permissions.
|
||||||
|
*/
|
||||||
|
static final SystemPermissionSet EMPTY_SET = new SystemPermissionSet() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(SystemPermission.Type permission)
|
||||||
|
throws GuacamoleException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addPermission(SystemPermission.Type permission)
|
||||||
|
throws GuacamoleException {
|
||||||
|
throw new GuacamoleSecurityException("Permission denied.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removePermission(SystemPermission.Type permission)
|
||||||
|
throws GuacamoleException {
|
||||||
|
throw new GuacamoleSecurityException("Permission denied.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<SystemPermission> getPermissions()
|
||||||
|
throws GuacamoleException {
|
||||||
|
return Collections.<SystemPermission>emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,10 @@ public class SimpleObjectPermissionSet implements ObjectPermissionSet {
|
|||||||
private Set<ObjectPermission> permissions = Collections.<ObjectPermission>emptySet();
|
private Set<ObjectPermission> permissions = Collections.<ObjectPermission>emptySet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new empty SimpleObjectPermissionSet.
|
* Creates a new empty SimpleObjectPermissionSet. If you are not extending
|
||||||
|
* SimpleObjectPermissionSet and only need an immutable, empty
|
||||||
|
* ObjectPermissionSet, consider using {@link ObjectPermissionSet#EMPTY_SET}
|
||||||
|
* instead.
|
||||||
*/
|
*/
|
||||||
public SimpleObjectPermissionSet() {
|
public SimpleObjectPermissionSet() {
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,10 @@ public class SimpleRelatedObjectSet implements RelatedObjectSet {
|
|||||||
private Set<String> identifiers = Collections.<String>emptySet();
|
private Set<String> identifiers = Collections.<String>emptySet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new empty SimpleObjectPermissionSet.
|
* Creates a new empty SimpleRelatedObjectSet. If you are not extending
|
||||||
|
* SimpleRelatedObjectSet and only need an immutable, empty
|
||||||
|
* RelatedObjectSet, consider using {@link RelatedObjectSet#EMPTY_SET}
|
||||||
|
* instead.
|
||||||
*/
|
*/
|
||||||
public SimpleRelatedObjectSet() {
|
public SimpleRelatedObjectSet() {
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,10 @@ public class SimpleSystemPermissionSet implements SystemPermissionSet {
|
|||||||
private Set<SystemPermission> permissions = Collections.<SystemPermission>emptySet();
|
private Set<SystemPermission> permissions = Collections.<SystemPermission>emptySet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new empty SimpleSystemPermissionSet.
|
* Creates a new empty SimpleSystemPermissionSet. If you are not extending
|
||||||
|
* SimpleSystemPermissionSet and only need an immutable, empty
|
||||||
|
* SystemPermissionSet, consider using {@link SystemPermissionSet#EMPTY_SET}
|
||||||
|
* instead.
|
||||||
*/
|
*/
|
||||||
public SimpleSystemPermissionSet() {
|
public SimpleSystemPermissionSet() {
|
||||||
}
|
}
|
||||||
|
@@ -193,7 +193,7 @@ public class SimpleUser extends AbstractUser {
|
|||||||
@Override
|
@Override
|
||||||
public SystemPermissionSet getSystemPermissions()
|
public SystemPermissionSet getSystemPermissions()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return new SimpleSystemPermissionSet();
|
return SystemPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -217,23 +217,23 @@ public class SimpleUser extends AbstractUser {
|
|||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getUserGroupPermissions()
|
public ObjectPermissionSet getUserGroupPermissions()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getActiveConnectionPermissions()
|
public ObjectPermissionSet getActiveConnectionPermissions()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getSharingProfilePermissions() {
|
public ObjectPermissionSet getSharingProfilePermissions() {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
||||||
return new SimpleRelatedObjectSet();
|
return RelatedObjectSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -62,57 +62,57 @@ public class SimpleUserGroup extends AbstractIdentifiable implements UserGroup {
|
|||||||
@Override
|
@Override
|
||||||
public SystemPermissionSet getSystemPermissions()
|
public SystemPermissionSet getSystemPermissions()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return new SimpleSystemPermissionSet();
|
return SystemPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getConnectionPermissions()
|
public ObjectPermissionSet getConnectionPermissions()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getConnectionGroupPermissions()
|
public ObjectPermissionSet getConnectionGroupPermissions()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getUserPermissions()
|
public ObjectPermissionSet getUserPermissions()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getUserGroupPermissions()
|
public ObjectPermissionSet getUserGroupPermissions()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getActiveConnectionPermissions()
|
public ObjectPermissionSet getActiveConnectionPermissions()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectPermissionSet getSharingProfilePermissions() {
|
public ObjectPermissionSet getSharingProfilePermissions() {
|
||||||
return new SimpleObjectPermissionSet();
|
return ObjectPermissionSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
||||||
return new SimpleRelatedObjectSet();
|
return RelatedObjectSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelatedObjectSet getMemberUsers() throws GuacamoleException {
|
public RelatedObjectSet getMemberUsers() throws GuacamoleException {
|
||||||
return new SimpleRelatedObjectSet();
|
return RelatedObjectSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelatedObjectSet getMemberUserGroups() throws GuacamoleException {
|
public RelatedObjectSet getMemberUserGroups() throws GuacamoleException {
|
||||||
return new SimpleRelatedObjectSet();
|
return RelatedObjectSet.EMPTY_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user