mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Refactor operations into separate directories.
This commit is contained in:
committed by
Michael Jumper
parent
d907f7758b
commit
942f375490
@@ -0,0 +1,102 @@
|
|||||||
|
|
||||||
|
package net.sourceforge.guacamole.net.auth;
|
||||||
|
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is guacamole-ext.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Michael Jumper.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
|
import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to a collection of all configurations, and allows
|
||||||
|
* configuration manipulation and removal.
|
||||||
|
*
|
||||||
|
* @author Michael Jumper
|
||||||
|
*/
|
||||||
|
public interface GuacamoleConfigurationDirectory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a Map containing all GuacamoleConfigurations. The keys of this
|
||||||
|
* Map are Strings which uniquely identify each configuration.
|
||||||
|
*
|
||||||
|
* @return A Map of all configurations visible.
|
||||||
|
* @throws GuacamoleException If an error occurs while retrieving
|
||||||
|
* configurations.
|
||||||
|
*/
|
||||||
|
Map<String, GuacamoleConfiguration> getConfigurations()
|
||||||
|
throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given GuacamoleConfiguration to the overall set of available
|
||||||
|
* GuacamoleConfigurations, using the given unique identifier.
|
||||||
|
*
|
||||||
|
* @param identifier The identifier to assign to the configuration.
|
||||||
|
* @param config The configuration to add.
|
||||||
|
* @throws GuacamoleException If an error occurs while adding the
|
||||||
|
* configuration, or if adding the configuration
|
||||||
|
* is not allowed.
|
||||||
|
*/
|
||||||
|
void addConfiguration(String identifier, GuacamoleConfiguration config)
|
||||||
|
throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the GuacamoleConfiguration having the given unique identifier
|
||||||
|
* with the data contained in the given GuacamoleConfiguration.
|
||||||
|
*
|
||||||
|
* @param identifier The identifier to use when locating the configuration
|
||||||
|
* to update.
|
||||||
|
* @param config The configuration to use when updating the stored
|
||||||
|
* configuration.
|
||||||
|
* @throws GuacamoleException If an error occurs while updating the
|
||||||
|
* configuration, or if updating the
|
||||||
|
* configuration is not allowed.
|
||||||
|
*/
|
||||||
|
void updateConfiguration(String identifier, GuacamoleConfiguration config)
|
||||||
|
throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the GuacamoleConfiguration having the given unique identifier.
|
||||||
|
*
|
||||||
|
* @param identifier The identifier of the configuration to remove.
|
||||||
|
* @throws GuacamoleException If an error occurs while removing the
|
||||||
|
* configuration, or if removing the
|
||||||
|
* configuration is not allowed.
|
||||||
|
*/
|
||||||
|
void removeConfiguration(String identifier) throws GuacamoleException;
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,92 @@
|
|||||||
|
package net.sourceforge.guacamole.net.auth;
|
||||||
|
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is guacamole-ext.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Michael Jumper.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
|
import net.sourceforge.guacamole.net.auth.permission.Permission;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to a collection of all permissions, and allows permission
|
||||||
|
* manipulation and removal.
|
||||||
|
*
|
||||||
|
* @author Michael Jumper
|
||||||
|
*/
|
||||||
|
public interface PermissionDirectory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether the specified user has the specified permission.
|
||||||
|
*
|
||||||
|
* @param user The user to check permissions for.
|
||||||
|
* @param permission The permission to check.
|
||||||
|
* @return true if the permission is granted to the user specified, false
|
||||||
|
* otherwise.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException If an error occurs while checking permissions,
|
||||||
|
* or if permissions cannot be checked due to
|
||||||
|
* lack of permissions to do so.
|
||||||
|
*/
|
||||||
|
boolean hasPermission(User user, Permission permission)
|
||||||
|
throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the specified permission to the specified user.
|
||||||
|
*
|
||||||
|
* @param user The user to add the permission to.
|
||||||
|
* @param permission The permission to add.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException If an error occurs while adding the
|
||||||
|
* permission. or if permission to add
|
||||||
|
* permissions is denied.
|
||||||
|
*/
|
||||||
|
void addPermission(User user, Permission permission)
|
||||||
|
throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the specified permission from the specified user.
|
||||||
|
*
|
||||||
|
* @param user The user to remove the permission from.
|
||||||
|
* @param permission The permission to remove.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException If an error occurs while removing the
|
||||||
|
* permission. or if permission to remove
|
||||||
|
* permissions is denied.
|
||||||
|
*/
|
||||||
|
void removePermission(User user, Permission permission)
|
||||||
|
throws GuacamoleException;
|
||||||
|
|
||||||
|
}
|
@@ -37,10 +37,7 @@ package net.sourceforge.guacamole.net.auth;
|
|||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The context of an active user. The functions of this class enforce all
|
* The context of an active user. The functions of this class enforce all
|
||||||
@@ -50,20 +47,6 @@ import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
|
|||||||
*/
|
*/
|
||||||
public interface UserContext {
|
public interface UserContext {
|
||||||
|
|
||||||
/**
|
|
||||||
* All possible permissions for user within a UserContext.
|
|
||||||
*
|
|
||||||
* Absolutely ALL possible operations that can possibly fail due to
|
|
||||||
* security issues within a UserContext must have a means of querying
|
|
||||||
* beforehand whether the operation will fail, and thus must have an
|
|
||||||
* associated permission value.
|
|
||||||
*/
|
|
||||||
public enum Permission {
|
|
||||||
|
|
||||||
/* STUB */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the User whose access rights control the operations of this
|
* Returns the User whose access rights control the operations of this
|
||||||
* UserContext.
|
* UserContext.
|
||||||
@@ -73,98 +56,44 @@ public interface UserContext {
|
|||||||
*/
|
*/
|
||||||
User self();
|
User self();
|
||||||
|
|
||||||
/*
|
|
||||||
* USER FUNCTIONS
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Set containing all Users visible within this UserContext.
|
* Retrieves a UserDirectory which can be used to view and manipulate other
|
||||||
*
|
* users, but only as allowed by the permissions given to the user of this
|
||||||
* @return A Set of all users visible.
|
* UserContext.
|
||||||
* @throws GuacamoleException If an error occurs while retrieving
|
|
||||||
* users.
|
|
||||||
*/
|
|
||||||
Set<User> getUsers() throws GuacamoleException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the given User to the overall set of available Users.
|
|
||||||
*
|
*
|
||||||
* @param user The user to add.
|
* @return A UserDirectory whose operations are bound by the restrictions
|
||||||
* @throws GuacamoleException If an error occurs while adding the user, or
|
* of this UserContext.
|
||||||
* if adding the user is not allowed.
|
|
||||||
*/
|
|
||||||
void addUser(User user) throws GuacamoleException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the User with the data contained in the given User. The user to
|
|
||||||
* update is identified using the username of the User given.
|
|
||||||
*
|
*
|
||||||
* @param user The user to use when updating the stored user.
|
* @throws GuacamoleException If an error occurs while creating the
|
||||||
* @throws GuacamoleException If an error occurs while updating the user,
|
* UserDirectory.
|
||||||
* or if updating the user is not allowed.
|
|
||||||
*/
|
*/
|
||||||
void updateUser(User user) throws GuacamoleException;
|
UserDirectory getUserDirectory() throws GuacamoleException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the given User from the overall set of available Users.
|
|
||||||
*
|
|
||||||
* @throws GuacamoleException If an error occurs while removing the user,
|
|
||||||
* or if removing user is not allowed.
|
|
||||||
*/
|
|
||||||
void removeUser(User user) throws GuacamoleException;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* CONFIGURATION FUNCTIONS
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Map containing all GuacamoleConfigurations visible within this
|
* Retrieves a GuacamoleConfigurationDirectory which can be used to view
|
||||||
* UserContext. The keys of this Map are Strings which uniquely identify
|
* and manipulate configurations, but only as allowed by the permissions
|
||||||
* each configuration.
|
* given to the user of this UserContext.
|
||||||
*
|
*
|
||||||
* @return A Map of all configurations visible.
|
* @return A GuacamoleConfigurationdirectory whose operations are bound by
|
||||||
* @throws GuacamoleException If an error occurs while retrieving
|
* the restrictions of this UserContext.
|
||||||
* configurations.
|
*
|
||||||
*/
|
* @throws GuacamoleException If an error occurs while creating the
|
||||||
Map<String, GuacamoleConfiguration> getConfigurations()
|
* GuacamoleConfigurationDirectory.
|
||||||
|
*/
|
||||||
|
GuacamoleConfigurationDirectory getGuacamoleConfigurationDirectory()
|
||||||
throws GuacamoleException;
|
throws GuacamoleException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given GuacamoleConfiguration to the overall set of available
|
* Retrieves a PermissionDirectory which can be used to view and manipulate
|
||||||
* GuacamoleConfigurations, using the given unique identifier.
|
* permissions, but only as allowed by the permissions given to the user of
|
||||||
|
* this UserContext.
|
||||||
*
|
*
|
||||||
* @param identifier The identifier to assign to the configuration.
|
* @return A PermissionDirectory whose operations are bound by the
|
||||||
* @param config The configuration to add.
|
* restrictions of this UserContext.
|
||||||
* @throws GuacamoleException If an error occurs while adding the
|
*
|
||||||
* configuration, or if adding the configuration
|
* @throws GuacamoleException If an error occurs while creating the
|
||||||
* is not allowed.
|
* PermissionDirectory.
|
||||||
*/
|
*/
|
||||||
void addConfiguration(String identifier, GuacamoleConfiguration config)
|
PermissionDirectory getPermissionDirectory() throws GuacamoleException;
|
||||||
throws GuacamoleException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the GuacamoleConfiguration having the given unique identifier
|
|
||||||
* with the data contained in the given GuacamoleConfiguration.
|
|
||||||
*
|
|
||||||
* @param identifier The identifier to use when locating the configuration
|
|
||||||
* to update.
|
|
||||||
* @param config The configuration to use when updating the stored
|
|
||||||
* configuration.
|
|
||||||
* @throws GuacamoleException If an error occurs while updating the
|
|
||||||
* configuration, or if updating the
|
|
||||||
* configuration is not allowed.
|
|
||||||
*/
|
|
||||||
void updateConfiguration(String identifier, GuacamoleConfiguration config)
|
|
||||||
throws GuacamoleException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the GuacamoleConfiguration having the given unique identifier.
|
|
||||||
*
|
|
||||||
* @param identifier The identifier of the configuration to remove.
|
|
||||||
* @throws GuacamoleException If an error occurs while removing the
|
|
||||||
* configuration, or if removing the
|
|
||||||
* configuration is not allowed.
|
|
||||||
*/
|
|
||||||
void removeConfiguration(String identifier) throws GuacamoleException;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,87 @@
|
|||||||
|
package net.sourceforge.guacamole.net.auth;
|
||||||
|
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is guacamole-ext.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Michael Jumper.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to a collection of all users, and allows user manipulation
|
||||||
|
* and removal.
|
||||||
|
*
|
||||||
|
* @author Michael Jumper
|
||||||
|
*/
|
||||||
|
public interface UserDirectory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a Set containing all Users.
|
||||||
|
*
|
||||||
|
* @return A Set of all users.
|
||||||
|
* @throws GuacamoleException If an error occurs while retrieving
|
||||||
|
* users.
|
||||||
|
*/
|
||||||
|
Set<User> getUsers() throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given User to the overall set of available Users.
|
||||||
|
*
|
||||||
|
* @param user The user to add.
|
||||||
|
* @throws GuacamoleException If an error occurs while adding the user, or
|
||||||
|
* if adding the user is not allowed.
|
||||||
|
*/
|
||||||
|
void addUser(User user) throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the User with the data contained in the given User. The user to
|
||||||
|
* update is identified using the username of the User given.
|
||||||
|
*
|
||||||
|
* @param user The user to use when updating the stored user.
|
||||||
|
* @throws GuacamoleException If an error occurs while updating the user,
|
||||||
|
* or if updating the user is not allowed.
|
||||||
|
*/
|
||||||
|
void updateUser(User user) throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the given User from the overall set of available Users.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException If an error occurs while removing the user,
|
||||||
|
* or if removing user is not allowed.
|
||||||
|
*/
|
||||||
|
void removeUser(User user) throws GuacamoleException;
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user