From 137e5cb91f34c627c8d64e794c8e7e597956e514 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 27 Jan 2013 02:37:37 -0800 Subject: [PATCH] Add user role concept, stub permissions (#267). --- .../guacamole/net/auth/AbstractUser.java | 25 ++++++-- .../sourceforge/guacamole/net/auth/Role.java | 64 +++++++++++++++++++ .../sourceforge/guacamole/net/auth/User.java | 29 ++++++--- 3 files changed, 102 insertions(+), 16 deletions(-) create mode 100644 guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/Role.java diff --git a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/AbstractUser.java b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/AbstractUser.java index b97a6a35b..43c0219a7 100644 --- a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/AbstractUser.java +++ b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/AbstractUser.java @@ -37,8 +37,6 @@ package net.sourceforge.guacamole.net.auth; * * ***** END LICENSE BLOCK ***** */ -import net.sourceforge.guacamole.GuacamoleException; - /** * Basic implementation of a Guacamole user which uses the username to @@ -60,26 +58,41 @@ public abstract class AbstractUser implements User, Comparable { */ private String password; + /** + * This user's role. + */ + private Role role; + @Override - public String getUsername() throws GuacamoleException { + public String getUsername() { return username; } @Override - public void setUsername(String username) throws GuacamoleException { + public void setUsername(String username) { this.username = username; } @Override - public String getPassword() throws GuacamoleException { + public String getPassword() { return password; } @Override - public void setPassword(String password) throws GuacamoleException { + public void setPassword(String password) { this.password = password; } + @Override + public Role getRole() { + return role; + } + + @Override + public void setRole(Role role) { + this.role = role; + } + @Override public int hashCode() { diff --git a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/Role.java b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/Role.java new file mode 100644 index 000000000..6a18ed162 --- /dev/null +++ b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/Role.java @@ -0,0 +1,64 @@ +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 ***** */ + + +/** + * The role of a particular user, defining the access levels of that user. + * + * @author Michael Jumper + */ +public interface Role { + + /* FIXME: STUB */ + + /* + * POSSIBLE PERMISSIONS: + * + * UserManagementPermission(ADD/UPDATE/DELETE/VIEW, user or ANY) + * ConfigurationPermission(ADD/UPDATE/DELETE/VIEW, config or ANY) + * AdministrationPermission(ADD/REMOVE, permission or ANY) + * + * Each can be used with: + * + * add(Permission) + * remove(Permission) + * has(Permission) + * + */ + +} diff --git a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/User.java b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/User.java index 12546feea..35a9f3dea 100644 --- a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/User.java +++ b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/User.java @@ -37,8 +37,6 @@ package net.sourceforge.guacamole.net.auth; * * ***** END LICENSE BLOCK ***** */ -import net.sourceforge.guacamole.GuacamoleException; - /** * A user of the Guacamole web application. @@ -51,26 +49,23 @@ public interface User { * Returns the name of this user, which must be unique across all users. * * @return The name of this user. - * @throws GuacamoleException If an error occurs retrieving the username. */ - public String getUsername() throws GuacamoleException; + public String getUsername(); /** * Sets the name of this user, which must be unique across all users. * * @param username The name of this user. - * @throws GuacamoleException If an error occurs setting the username. */ - public void setUsername(String username) throws GuacamoleException; + public void setUsername(String username); /** * Returns this user's password. Note that the password returned may be * hashed or completely arbitrary. * * @return A String which may (or may not) be the user's password. - * @throws GuacamoleException If an error occurs retrieving the password. */ - public String getPassword() throws GuacamoleException; + public String getPassword(); /** * Sets this user's password. Note that while this function is guaranteed @@ -78,8 +73,22 @@ public interface User { * getPassword() will return the value given to setPassword(). * * @param password The password to set. - * @throws GuacamoleException If an error occurs setting the password. */ - public void setPassword(String password) throws GuacamoleException; + public void setPassword(String password); + /** + * Returns the role of this User. The role defines exactly which permissions + * a particular user has. + * + * @return The role of this User. + */ + public Role getRole(); + + /** + * Sets the role of this User to the given Role. + * + * @param role The role which this User should have. + */ + public void setRole(Role role); + }