Return-Path: X-Original-To: apmail-guacamole-commits-archive@minotaur.apache.org Delivered-To: apmail-guacamole-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4D6451911C for ; Tue, 29 Mar 2016 04:20:28 +0000 (UTC) Received: (qmail 37946 invoked by uid 500); 29 Mar 2016 04:20:28 -0000 Delivered-To: apmail-guacamole-commits-archive@guacamole.apache.org Received: (qmail 37931 invoked by uid 500); 29 Mar 2016 04:20:28 -0000 Mailing-List: contact commits-help@guacamole.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@guacamole.incubator.apache.org Delivered-To: mailing list commits@guacamole.incubator.apache.org Received: (qmail 37916 invoked by uid 99); 29 Mar 2016 04:20:28 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Mar 2016 04:20:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id A2E621A112F for ; Tue, 29 Mar 2016 04:20:27 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.221 X-Spam-Level: X-Spam-Status: No, score=-3.221 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id WGxXEAIXFk9u for ; Tue, 29 Mar 2016 04:20:18 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id BE2115FAFA for ; Tue, 29 Mar 2016 04:20:11 +0000 (UTC) Received: (qmail 37418 invoked by uid 99); 29 Mar 2016 04:20:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Mar 2016 04:20:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7E018E976E; Tue, 29 Mar 2016 04:20:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jmuehlner@apache.org To: commits@guacamole.incubator.apache.org Date: Tue, 29 Mar 2016 04:20:16 -0000 Message-Id: <4b1545080cbe4faaba8ff411ad221c11@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [07/51] [abbrv] incubator-guacamole-client git commit: GUACAMOLE-1: Remove useless .net.basic subpackage, now that everything is being renamed. http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/permission/APIPermissionSet.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/permission/APIPermissionSet.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/permission/APIPermissionSet.java deleted file mode 100644 index 2965bfc..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/permission/APIPermissionSet.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright (C) 2014 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.apache.guacamole.net.basic.rest.permission; - -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.net.auth.User; -import org.apache.guacamole.net.auth.permission.ObjectPermission; -import org.apache.guacamole.net.auth.permission.ObjectPermissionSet; -import org.apache.guacamole.net.auth.permission.SystemPermission; -import org.apache.guacamole.net.auth.permission.SystemPermissionSet; - -/** - * The set of permissions which are granted to a specific user, organized by - * object type and, if applicable, identifier. This object can be constructed - * with arbitrary permissions present, or manipulated after creation through - * the manipulation or replacement of its collections of permissions, but is - * otherwise not intended for internal use as a data structure for permissions. - * Its primary purpose is as a hierarchical format for exchanging granted - * permissions with REST clients. - */ -public class APIPermissionSet { - - /** - * Map of connection ID to the set of granted permissions. - */ - private Map> connectionPermissions = - new HashMap>(); - - /** - * Map of connection group ID to the set of granted permissions. - */ - private Map> connectionGroupPermissions = - new HashMap>(); - - /** - * Map of active connection ID to the set of granted permissions. - */ - private Map> activeConnectionPermissions = - new HashMap>(); - - /** - * Map of user ID to the set of granted permissions. - */ - private Map> userPermissions = - new HashMap>(); - - /** - * Set of all granted system-level permissions. - */ - private Set systemPermissions = - EnumSet.noneOf(SystemPermission.Type.class); - - /** - * Creates a new permission set which contains no granted permissions. Any - * permissions must be added by manipulating or replacing the applicable - * permission collection. - */ - public APIPermissionSet() { - } - - /** - * Adds the system permissions from the given SystemPermissionSet to the - * Set of system permissions provided. - * - * @param permissions - * The Set to add system permissions to. - * - * @param permSet - * The SystemPermissionSet containing the system permissions to add. - * - * @throws GuacamoleException - * If an error occurs while retrieving system permissions from the - * SystemPermissionSet. - */ - private void addSystemPermissions(Set permissions, - SystemPermissionSet permSet) throws GuacamoleException { - - // Add all provided system permissions - for (SystemPermission permission : permSet.getPermissions()) - permissions.add(permission.getType()); - - } - - /** - * Adds the object permissions from the given ObjectPermissionSet to the - * Map of object permissions provided. - * - * @param permissions - * The Map to add object permissions to. - * - * @param permSet - * The ObjectPermissionSet containing the object permissions to add. - * - * @throws GuacamoleException - * If an error occurs while retrieving object permissions from the - * ObjectPermissionSet. - */ - private void addObjectPermissions(Map> permissions, - ObjectPermissionSet permSet) throws GuacamoleException { - - // Add all provided object permissions - for (ObjectPermission permission : permSet.getPermissions()) { - - // Get associated set of permissions - String identifier = permission.getObjectIdentifier(); - Set objectPermissions = permissions.get(identifier); - - // Create new set if none yet exists - if (objectPermissions == null) - permissions.put(identifier, EnumSet.of(permission.getType())); - - // Otherwise add to existing set - else - objectPermissions.add(permission.getType()); - - } - - } - - /** - * Creates a new permission set containing all permissions currently - * granted to the given user. - * - * @param user - * The user whose permissions should be stored within this permission - * set. - * - * @throws GuacamoleException - * If an error occurs while retrieving the user's permissions. - */ - public APIPermissionSet(User user) throws GuacamoleException { - - // Add all permissions from the provided user - addSystemPermissions(systemPermissions, user.getSystemPermissions()); - addObjectPermissions(connectionPermissions, user.getConnectionPermissions()); - addObjectPermissions(connectionGroupPermissions, user.getConnectionGroupPermissions()); - addObjectPermissions(activeConnectionPermissions, user.getActiveConnectionPermissions()); - addObjectPermissions(userPermissions, user.getUserPermissions()); - - } - - /** - * Returns a map of connection IDs to the set of permissions granted for - * that connection. If no permissions are granted to a particular - * connection, its ID will not be present as a key in the map. This map is - * mutable, and changes to this map will affect the permission set - * directly. - * - * @return - * A map of connection IDs to the set of permissions granted for that - * connection. - */ - public Map> getConnectionPermissions() { - return connectionPermissions; - } - - /** - * Returns a map of connection group IDs to the set of permissions granted - * for that connection group. If no permissions are granted to a particular - * connection group, its ID will not be present as a key in the map. This - * map is mutable, and changes to this map will affect the permission set - * directly. - * - * @return - * A map of connection group IDs to the set of permissions granted for - * that connection group. - */ - public Map> getConnectionGroupPermissions() { - return connectionGroupPermissions; - } - - /** - * Returns a map of active connection IDs to the set of permissions granted - * for that active connection. If no permissions are granted to a particular - * active connection, its ID will not be present as a key in the map. This - * map is mutable, and changes to this map will affect the permission set - * directly. - * - * @return - * A map of active connection IDs to the set of permissions granted for - * that active connection. - */ - public Map> getActiveConnectionPermissions() { - return activeConnectionPermissions; - } - - /** - * Returns a map of user IDs to the set of permissions granted for that - * user. If no permissions are granted to a particular user, its ID will - * not be present as a key in the map. This map is mutable, and changes to - * to this map will affect the permission set directly. - * - * @return - * A map of user IDs to the set of permissions granted for that user. - */ - public Map> getUserPermissions() { - return userPermissions; - } - - /** - * Returns the set of granted system-level permissions. If no permissions - * are granted at the system level, this will be an empty set. This set is - * mutable, and changes to this set will affect the permission set - * directly. - * - * @return - * The set of granted system-level permissions. - */ - public Set getSystemPermissions() { - return systemPermissions; - } - - /** - * Replaces the current map of connection permissions with the given map, - * which must map connection ID to its corresponding set of granted - * permissions. If a connection has no permissions, its ID must not be - * present as a key in the map. - * - * @param connectionPermissions - * The map which must replace the currently-stored map of permissions. - */ - public void setConnectionPermissions(Map> connectionPermissions) { - this.connectionPermissions = connectionPermissions; - } - - /** - * Replaces the current map of connection group permissions with the given - * map, which must map connection group ID to its corresponding set of - * granted permissions. If a connection group has no permissions, its ID - * must not be present as a key in the map. - * - * @param connectionGroupPermissions - * The map which must replace the currently-stored map of permissions. - */ - public void setConnectionGroupPermissions(Map> connectionGroupPermissions) { - this.connectionGroupPermissions = connectionGroupPermissions; - } - - /** - * Replaces the current map of active connection permissions with the give - * map, which must map active connection ID to its corresponding set of - * granted permissions. If an active connection has no permissions, its ID - * must not be present as a key in the map. - * - * @param activeConnectionPermissions - * The map which must replace the currently-stored map of permissions. - */ - public void setActiveConnectionPermissions(Map> activeConnectionPermissions) { - this.activeConnectionPermissions = activeConnectionPermissions; - } - - /** - * Replaces the current map of user permissions with the given map, which - * must map user ID to its corresponding set of granted permissions. If a - * user has no permissions, its ID must not be present as a key in the map. - * - * @param userPermissions - * The map which must replace the currently-stored map of permissions. - */ - public void setUserPermissions(Map> userPermissions) { - this.userPermissions = userPermissions; - } - - /** - * Replaces the current set of system-level permissions with the given set. - * If no system-level permissions are granted, the empty set must be - * specified. - * - * @param systemPermissions - * The set which must replace the currently-stored set of permissions. - */ - public void setSystemPermissions(Set systemPermissions) { - this.systemPermissions = systemPermissions; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/permission/package-info.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/permission/package-info.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/permission/package-info.java deleted file mode 100644 index 8312852..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/permission/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2014 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/** - * Classes related to the permission manipulation aspect of the Guacamole REST API. - */ -package org.apache.guacamole.net.basic.rest.permission; - http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/schema/SchemaRESTService.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/schema/SchemaRESTService.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/schema/SchemaRESTService.java deleted file mode 100644 index dfd9298..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/schema/SchemaRESTService.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (C) 2015 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.apache.guacamole.net.basic.rest.schema; - -import com.google.inject.Inject; -import java.util.Collection; -import java.util.Map; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.environment.Environment; -import org.apache.guacamole.environment.LocalEnvironment; -import org.apache.guacamole.form.Form; -import org.apache.guacamole.net.auth.UserContext; -import org.apache.guacamole.net.basic.GuacamoleSession; -import org.apache.guacamole.net.basic.rest.ObjectRetrievalService; -import org.apache.guacamole.net.basic.rest.auth.AuthenticationService; -import org.apache.guacamole.protocols.ProtocolInfo; - -/** - * A REST service which provides access to descriptions of the properties, - * attributes, etc. of objects used within the Guacamole REST API. - * - * @author Michael Jumper - */ -@Path("/schema/{dataSource}") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class SchemaRESTService { - - /** - * A service for authenticating users from auth tokens. - */ - @Inject - private AuthenticationService authenticationService; - - /** - * Service for convenient retrieval of objects. - */ - @Inject - private ObjectRetrievalService retrievalService; - - /** - * Retrieves the possible attributes of a user object. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext dictating the available user attributes. - * - * @return - * A collection of forms which describe the possible attributes of a - * user object. - * - * @throws GuacamoleException - * If an error occurs while retrieving the possible attributes. - */ - @GET - @Path("/users/attributes") - public Collection
getUserAttributes(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier) - throws GuacamoleException { - - // Retrieve all possible user attributes - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier); - return userContext.getUserAttributes(); - - } - - /** - * Retrieves the possible attributes of a connection object. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext dictating the available connection attributes. - * - * @return - * A collection of forms which describe the possible attributes of a - * connection object. - * - * @throws GuacamoleException - * If an error occurs while retrieving the possible attributes. - */ - @GET - @Path("/connections/attributes") - public Collection getConnectionAttributes(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier) - throws GuacamoleException { - - // Retrieve all possible connection attributes - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier); - return userContext.getConnectionAttributes(); - - } - - /** - * Retrieves the possible attributes of a connection group object. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext dictating the available connection group - * attributes. - * - * @return - * A collection of forms which describe the possible attributes of a - * connection group object. - * - * @throws GuacamoleException - * If an error occurs while retrieving the possible attributes. - */ - @GET - @Path("/connectionGroups/attributes") - public Collection getConnectionGroupAttributes(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier) - throws GuacamoleException { - - // Retrieve all possible connection group attributes - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier); - return userContext.getConnectionGroupAttributes(); - - } - - /** - * Gets a map of protocols defined in the system - protocol name to protocol. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext dictating the protocols available. Currently, the - * UserContext actually does not dictate this, the the same set of - * protocols will be retrieved for all users, though the identifier - * given here will be validated. - * - * @return - * A map of protocol information, where each key is the unique name - * associated with that protocol. - * - * @throws GuacamoleException - * If an error occurs while retrieving the available protocols. - */ - @GET - @Path("/protocols") - public Map getProtocols(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier) - throws GuacamoleException { - - // Verify the given auth token and auth provider identifier are valid - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - retrievalService.retrieveUserContext(session, authProviderIdentifier); - - // Get and return a map of all protocols. - Environment env = new LocalEnvironment(); - return env.getProtocols(); - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/schema/package-info.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/schema/package-info.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/schema/package-info.java deleted file mode 100644 index a005d7e..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/schema/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2015 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/** - * Classes related to the self-description of the Guacamole REST API, such as - * the attributes or parameters applicable to specific objects. - */ -package org.apache.guacamole.net.basic.rest.schema; http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUser.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUser.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUser.java deleted file mode 100644 index bcbbf7e..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUser.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2014 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.apache.guacamole.net.basic.rest.user; - -import java.util.Map; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.apache.guacamole.net.auth.User; - -/** - * A simple User to expose through the REST endpoints. - * - * @author James Muehlner - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) -public class APIUser { - - /** - * The username of this user. - */ - private String username; - - /** - * The password of this user. - */ - private String password; - - /** - * Map of all associated attributes by attribute identifier. - */ - private Map attributes; - - /** - * Construct a new empty APIUser. - */ - public APIUser() {} - - /** - * Construct a new APIUser from the provided User. - * @param user The User to construct the APIUser from. - */ - public APIUser(User user) { - - // Set user information - this.username = user.getIdentifier(); - this.password = user.getPassword(); - - // Associate any attributes - this.attributes = user.getAttributes(); - - } - - /** - * Returns the username for this user. - * @return The username for this user. - */ - public String getUsername() { - return username; - } - - /** - * Set the username for this user. - * @param username The username for this user. - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * Returns the password for this user. - * @return The password for this user. - */ - public String getPassword() { - return password; - } - - /** - * Set the password for this user. - * @param password The password for this user. - */ - public void setPassword(String password) { - this.password = password; - } - - /** - * Returns a map of all attributes associated with this user. Each entry - * key is the attribute identifier, while each value is the attribute - * value itself. - * - * @return - * The attribute map for this user. - */ - public Map getAttributes() { - return attributes; - } - - /** - * Sets the map of all attributes associated with this user. Each entry key - * is the attribute identifier, while each value is the attribute value - * itself. - * - * @param attributes - * The attribute map for this user. - */ - public void setAttributes(Map attributes) { - this.attributes = attributes; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUserPasswordUpdate.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUserPasswordUpdate.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUserPasswordUpdate.java deleted file mode 100644 index 483a141..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUserPasswordUpdate.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2015 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.apache.guacamole.net.basic.rest.user; - -/** - * All the information necessary for the password update operation on a user. - * - * @author James Muehlner - */ -public class APIUserPasswordUpdate { - - /** - * The old (current) password of this user. - */ - private String oldPassword; - - /** - * The new password of this user. - */ - private String newPassword; - - /** - * Returns the old password for this user. This password must match the - * user's current password for the password update operation to succeed. - * - * @return - * The old password for this user. - */ - public String getOldPassword() { - return oldPassword; - } - - /** - * Set the old password for this user. This password must match the - * user's current password for the password update operation to succeed. - * - * @param oldPassword - * The old password for this user. - */ - public void setOldPassword(String oldPassword) { - this.oldPassword = oldPassword; - } - - /** - * Returns the new password that will be assigned to this user. - * - * @return - * The new password for this user. - */ - public String getNewPassword() { - return newPassword; - } - - /** - * Set the new password that will be assigned to this user. - * - * @param newPassword - * The new password for this user. - */ - public void setNewPassword(String newPassword) { - this.newPassword = newPassword; - } -} http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUserWrapper.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUserWrapper.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUserWrapper.java deleted file mode 100644 index 68931e0..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/APIUserWrapper.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2014 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.apache.guacamole.net.basic.rest.user; - -import java.util.Map; -import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.GuacamoleUnsupportedException; -import org.apache.guacamole.net.auth.User; -import org.apache.guacamole.net.auth.permission.ObjectPermissionSet; -import org.apache.guacamole.net.auth.permission.SystemPermissionSet; - -/** - * A wrapper to make an APIUser look like a User. Useful where an - * org.apache.guacamole.net.auth.User is required. As a simple wrapper for - * APIUser, access to permissions is not provided. Any attempt to access or - * manipulate permissions on an APIUserWrapper will result in an exception. - * - * @author James Muehlner - */ -public class APIUserWrapper implements User { - - /** - * The wrapped APIUser. - */ - private final APIUser apiUser; - - /** - * Wrap a given APIUser to expose as a User. - * @param apiUser The APIUser to wrap. - */ - public APIUserWrapper(APIUser apiUser) { - this.apiUser = apiUser; - } - - @Override - public String getIdentifier() { - return apiUser.getUsername(); - } - - @Override - public void setIdentifier(String username) { - apiUser.setUsername(username); - } - - @Override - public String getPassword() { - return apiUser.getPassword(); - } - - @Override - public void setPassword(String password) { - apiUser.setPassword(password); - } - - @Override - public Map getAttributes() { - return apiUser.getAttributes(); - } - - @Override - public void setAttributes(Map attributes) { - apiUser.setAttributes(attributes); - } - - @Override - public SystemPermissionSet getSystemPermissions() - throws GuacamoleException { - throw new GuacamoleUnsupportedException("APIUserWrapper does not provide permission access."); - } - - @Override - public ObjectPermissionSet getConnectionPermissions() - throws GuacamoleException { - throw new GuacamoleUnsupportedException("APIUserWrapper does not provide permission access."); - } - - @Override - public ObjectPermissionSet getConnectionGroupPermissions() - throws GuacamoleException { - throw new GuacamoleUnsupportedException("APIUserWrapper does not provide permission access."); - } - - @Override - public ObjectPermissionSet getUserPermissions() - throws GuacamoleException { - throw new GuacamoleUnsupportedException("APIUserWrapper does not provide permission access."); - } - - @Override - public ObjectPermissionSet getActiveConnectionPermissions() - throws GuacamoleException { - throw new GuacamoleUnsupportedException("APIUserWrapper does not provide permission access."); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/PermissionSetPatch.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/PermissionSetPatch.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/PermissionSetPatch.java deleted file mode 100644 index a398388..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/PermissionSetPatch.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2015 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.apache.guacamole.net.basic.rest.user; - -import java.util.HashSet; -import java.util.Set; -import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.net.auth.permission.Permission; -import org.apache.guacamole.net.auth.permission.PermissionSet; - -/** - * A set of changes to be applied to a PermissionSet, describing the set of - * permissions being added and removed. - * - * @author Michael Jumper - * @param - * The type of permissions being added and removed. - */ -public class PermissionSetPatch { - - /** - * The set of all permissions being added. - */ - private final Set addedPermissions = - new HashSet(); - - /** - * The set of all permissions being removed. - */ - private final Set removedPermissions = - new HashSet(); - - /** - * Queues the given permission to be added. The add operation will be - * performed only when apply() is called. - * - * @param permission - * The permission to add. - */ - public void addPermission(PermissionType permission) { - addedPermissions.add(permission); - } - - /** - * Queues the given permission to be removed. The remove operation will be - * performed only when apply() is called. - * - * @param permission - * The permission to remove. - */ - public void removePermission(PermissionType permission) { - removedPermissions.add(permission); - } - - /** - * Applies all queued changes to the given permission set. - * - * @param permissionSet - * The permission set to add and remove permissions from. - * - * @throws GuacamoleException - * If an error occurs while manipulating the permissions of the given - * permission set. - */ - public void apply(PermissionSet permissionSet) - throws GuacamoleException { - - // Add any added permissions - if (!addedPermissions.isEmpty()) - permissionSet.addPermissions(addedPermissions); - - // Remove any removed permissions - if (!removedPermissions.isEmpty()) - permissionSet.removePermissions(removedPermissions); - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/UserRESTService.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/UserRESTService.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/UserRESTService.java deleted file mode 100644 index 9c79eef..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/UserRESTService.java +++ /dev/null @@ -1,647 +0,0 @@ -/* - * Copyright (C) 2015 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.apache.guacamole.net.basic.rest.user; - -import com.google.inject.Inject; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.UUID; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import org.apache.guacamole.GuacamoleClientException; -import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.GuacamoleResourceNotFoundException; -import org.apache.guacamole.GuacamoleSecurityException; -import org.apache.guacamole.net.auth.AuthenticationProvider; -import org.apache.guacamole.net.auth.Credentials; -import org.apache.guacamole.net.auth.Directory; -import org.apache.guacamole.net.auth.User; -import org.apache.guacamole.net.auth.UserContext; -import org.apache.guacamole.net.auth.credentials.GuacamoleCredentialsException; -import org.apache.guacamole.net.auth.permission.ObjectPermission; -import org.apache.guacamole.net.auth.permission.ObjectPermissionSet; -import org.apache.guacamole.net.auth.permission.Permission; -import org.apache.guacamole.net.auth.permission.SystemPermission; -import org.apache.guacamole.net.auth.permission.SystemPermissionSet; -import org.apache.guacamole.net.basic.GuacamoleSession; -import org.apache.guacamole.net.basic.rest.APIPatch; -import static org.apache.guacamole.net.basic.rest.APIPatch.Operation.add; -import static org.apache.guacamole.net.basic.rest.APIPatch.Operation.remove; -import org.apache.guacamole.net.basic.rest.ObjectRetrievalService; -import org.apache.guacamole.net.basic.rest.PATCH; -import org.apache.guacamole.net.basic.rest.auth.AuthenticationService; -import org.apache.guacamole.net.basic.rest.permission.APIPermissionSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A REST Service for handling user CRUD operations. - * - * @author James Muehlner - * @author Michael Jumper - */ -@Path("/data/{dataSource}/users") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class UserRESTService { - - /** - * Logger for this class. - */ - private static final Logger logger = LoggerFactory.getLogger(UserRESTService.class); - - /** - * The prefix of any path within an operation of a JSON patch which - * modifies the permissions of a user regarding a specific connection. - */ - private static final String CONNECTION_PERMISSION_PATCH_PATH_PREFIX = "/connectionPermissions/"; - - /** - * The prefix of any path within an operation of a JSON patch which - * modifies the permissions of a user regarding a specific connection group. - */ - private static final String CONNECTION_GROUP_PERMISSION_PATCH_PATH_PREFIX = "/connectionGroupPermissions/"; - - /** - * The prefix of any path within an operation of a JSON patch which - * modifies the permissions of a user regarding a specific active connection. - */ - private static final String ACTIVE_CONNECTION_PERMISSION_PATCH_PATH_PREFIX = "/activeConnectionPermissions/"; - - /** - * The prefix of any path within an operation of a JSON patch which - * modifies the permissions of a user regarding another, specific user. - */ - private static final String USER_PERMISSION_PATCH_PATH_PREFIX = "/userPermissions/"; - - /** - * The path of any operation within a JSON patch which modifies the - * permissions of a user regarding the entire system. - */ - private static final String SYSTEM_PERMISSION_PATCH_PATH = "/systemPermissions"; - - /** - * A service for authenticating users from auth tokens. - */ - @Inject - private AuthenticationService authenticationService; - - /** - * Service for convenient retrieval of objects. - */ - @Inject - private ObjectRetrievalService retrievalService; - - /** - * Gets a list of users in the given data source (UserContext), filtering - * the returned list by the given permission, if specified. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext from which the users are to be retrieved. - * - * @param permissions - * The set of permissions to filter with. A user must have one or more - * of these permissions for a user to appear in the result. - * If null, no filtering will be performed. - * - * @return - * A list of all visible users. If a permission was specified, this - * list will contain only those users for whom the current user has - * that permission. - * - * @throws GuacamoleException - * If an error is encountered while retrieving users. - */ - @GET - public List getUsers(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier, - @QueryParam("permission") List permissions) - throws GuacamoleException { - - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier); - - // An admin user has access to any user - User self = userContext.self(); - SystemPermissionSet systemPermissions = self.getSystemPermissions(); - boolean isAdmin = systemPermissions.hasPermission(SystemPermission.Type.ADMINISTER); - - // Get the directory - Directory userDirectory = userContext.getUserDirectory(); - - // Filter users, if requested - Collection userIdentifiers = userDirectory.getIdentifiers(); - if (!isAdmin && permissions != null && !permissions.isEmpty()) { - ObjectPermissionSet userPermissions = self.getUserPermissions(); - userIdentifiers = userPermissions.getAccessibleObjects(permissions, userIdentifiers); - } - - // Retrieve all users, converting to API users - List apiUsers = new ArrayList(); - for (User user : userDirectory.getAll(userIdentifiers)) - apiUsers.add(new APIUser(user)); - - return apiUsers; - - } - - /** - * Retrieves an individual user. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext from which the requested user is to be retrieved. - * - * @param username - * The username of the user to retrieve. - * - * @return user - * The user having the given username. - * - * @throws GuacamoleException - * If an error occurs while retrieving the user. - */ - @GET - @Path("/{username}") - public APIUser getUser(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier, - @PathParam("username") String username) - throws GuacamoleException { - - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - - // Retrieve the requested user - User user = retrievalService.retrieveUser(session, authProviderIdentifier, username); - return new APIUser(user); - - } - - /** - * Creates a new user and returns the user that was created. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext in which the requested user is to be created. - * - * @param user - * The new user to create. - * - * @throws GuacamoleException - * If a problem is encountered while creating the user. - * - * @return - * The newly created user. - */ - @POST - public APIUser createUser(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier, APIUser user) - throws GuacamoleException { - - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier); - - // Get the directory - Directory userDirectory = userContext.getUserDirectory(); - - // Randomly set the password if it wasn't provided - if (user.getPassword() == null) - user.setPassword(UUID.randomUUID().toString()); - - // Create the user - userDirectory.add(new APIUserWrapper(user)); - - return user; - - } - - /** - * Updates an individual existing user. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext in which the requested user is to be updated. - * - * @param username - * The username of the user to update. - * - * @param user - * The data to update the user with. - * - * @throws GuacamoleException - * If an error occurs while updating the user. - */ - @PUT - @Path("/{username}") - public void updateUser(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier, - @PathParam("username") String username, APIUser user) - throws GuacamoleException { - - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier); - - // Get the directory - Directory userDirectory = userContext.getUserDirectory(); - - // Validate data and path are sane - if (!user.getUsername().equals(username)) - throw new GuacamoleClientException("Username in path does not match username provided JSON data."); - - // A user may not use this endpoint to modify himself - if (userContext.self().getIdentifier().equals(user.getUsername())) - throw new GuacamoleSecurityException("Permission denied."); - - // Get the user - User existingUser = retrievalService.retrieveUser(userContext, username); - - // Do not update the user password if no password was provided - if (user.getPassword() != null) - existingUser.setPassword(user.getPassword()); - - // Update user attributes - existingUser.setAttributes(user.getAttributes()); - - // Update the user - userDirectory.update(existingUser); - - } - - /** - * Updates the password for an individual existing user. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext in which the requested user is to be updated. - * - * @param username - * The username of the user to update. - * - * @param userPasswordUpdate - * The object containing the old password for the user, as well as the - * new password to set for that user. - * - * @param request - * The HttpServletRequest associated with the password update attempt. - * - * @throws GuacamoleException - * If an error occurs while updating the user's password. - */ - @PUT - @Path("/{username}/password") - public void updatePassword(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier, - @PathParam("username") String username, - APIUserPasswordUpdate userPasswordUpdate, - @Context HttpServletRequest request) throws GuacamoleException { - - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier); - - // Build credentials - Credentials credentials = new Credentials(); - credentials.setUsername(username); - credentials.setPassword(userPasswordUpdate.getOldPassword()); - credentials.setRequest(request); - credentials.setSession(request.getSession(true)); - - // Verify that the old password was correct - try { - AuthenticationProvider authProvider = userContext.getAuthenticationProvider(); - if (authProvider.authenticateUser(credentials) == null) - throw new GuacamoleSecurityException("Permission denied."); - } - - // Pass through any credentials exceptions as simple permission denied - catch (GuacamoleCredentialsException e) { - throw new GuacamoleSecurityException("Permission denied."); - } - - // Get the user directory - Directory userDirectory = userContext.getUserDirectory(); - - // Get the user that we want to updates - User user = retrievalService.retrieveUser(userContext, username); - - // Set password to the newly provided one - user.setPassword(userPasswordUpdate.getNewPassword()); - - // Update the user - userDirectory.update(user); - - } - - /** - * Deletes an individual existing user. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext from which the requested user is to be deleted. - * - * @param username - * The username of the user to delete. - * - * @throws GuacamoleException - * If an error occurs while deleting the user. - */ - @DELETE - @Path("/{username}") - public void deleteUser(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier, - @PathParam("username") String username) - throws GuacamoleException { - - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier); - - // Get the directory - Directory userDirectory = userContext.getUserDirectory(); - - // Get the user - User existingUser = userDirectory.get(username); - if (existingUser == null) - throw new GuacamoleResourceNotFoundException("No such user: \"" + username + "\""); - - // Delete the user - userDirectory.remove(username); - - } - - /** - * Gets a list of permissions for the user with the given username. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext in which the requested user is to be found. - * - * @param username - * The username of the user to retrieve permissions for. - * - * @return - * A list of all permissions granted to the specified user. - * - * @throws GuacamoleException - * If an error occurs while retrieving permissions. - */ - @GET - @Path("/{username}/permissions") - public APIPermissionSet getPermissions(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier, - @PathParam("username") String username) - throws GuacamoleException { - - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier); - - User user; - - // If username is own username, just use self - might not have query permissions - if (userContext.self().getIdentifier().equals(username)) - user = userContext.self(); - - // If not self, query corresponding user from directory - else { - user = userContext.getUserDirectory().get(username); - if (user == null) - throw new GuacamoleResourceNotFoundException("No such user: \"" + username + "\""); - } - - return new APIPermissionSet(user); - - } - - /** - * Updates the given permission set patch by queuing an add or remove - * operation for the given permission based on the given patch operation. - * - * @param - * The type of permission stored within the permission set. - * - * @param operation - * The patch operation to perform. - * - * @param permissionSetPatch - * The permission set patch being modified. - * - * @param permission - * The permission being added or removed from the set. - * - * @throws GuacamoleException - * If the requested patch operation is not supported. - */ - private void updatePermissionSet( - APIPatch.Operation operation, - PermissionSetPatch permissionSetPatch, - PermissionType permission) throws GuacamoleException { - - // Add or remove permission based on operation - switch (operation) { - - // Add permission - case add: - permissionSetPatch.addPermission(permission); - break; - - // Remove permission - case remove: - permissionSetPatch.removePermission(permission); - break; - - // Unsupported patch operation - default: - throw new GuacamoleClientException("Unsupported patch operation: \"" + operation + "\""); - - } - - } - - /** - * Applies a given list of permission patches. Each patch specifies either - * an "add" or a "remove" operation for a permission type, represented by - * a string. Valid permission types depend on the path of each patch - * operation, as the path dictates the permission being modified, such as - * "/connectionPermissions/42" or "/systemPermissions". - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @param authProviderIdentifier - * The unique identifier of the AuthenticationProvider associated with - * the UserContext in which the requested user is to be found. - * - * @param username - * The username of the user to modify the permissions of. - * - * @param patches - * The permission patches to apply for this request. - * - * @throws GuacamoleException - * If a problem is encountered while modifying permissions. - */ - @PATCH - @Path("/{username}/permissions") - public void patchPermissions(@QueryParam("token") String authToken, - @PathParam("dataSource") String authProviderIdentifier, - @PathParam("username") String username, - List> patches) throws GuacamoleException { - - GuacamoleSession session = authenticationService.getGuacamoleSession(authToken); - UserContext userContext = retrievalService.retrieveUserContext(session, authProviderIdentifier); - - // Get the user - User user = userContext.getUserDirectory().get(username); - if (user == null) - throw new GuacamoleResourceNotFoundException("No such user: \"" + username + "\""); - - // Permission patches for all types of permissions - PermissionSetPatch connectionPermissionPatch = new PermissionSetPatch(); - PermissionSetPatch connectionGroupPermissionPatch = new PermissionSetPatch(); - PermissionSetPatch activeConnectionPermissionPatch = new PermissionSetPatch(); - PermissionSetPatch userPermissionPatch = new PermissionSetPatch(); - PermissionSetPatch systemPermissionPatch = new PermissionSetPatch(); - - // Apply all patch operations individually - for (APIPatch patch : patches) { - - String path = patch.getPath(); - - // Create connection permission if path has connection prefix - if (path.startsWith(CONNECTION_PERMISSION_PATCH_PATH_PREFIX)) { - - // Get identifier and type from patch operation - String identifier = path.substring(CONNECTION_PERMISSION_PATCH_PATH_PREFIX.length()); - ObjectPermission.Type type = ObjectPermission.Type.valueOf(patch.getValue()); - - // Create and update corresponding permission - ObjectPermission permission = new ObjectPermission(type, identifier); - updatePermissionSet(patch.getOp(), connectionPermissionPatch, permission); - - } - - // Create connection group permission if path has connection group prefix - else if (path.startsWith(CONNECTION_GROUP_PERMISSION_PATCH_PATH_PREFIX)) { - - // Get identifier and type from patch operation - String identifier = path.substring(CONNECTION_GROUP_PERMISSION_PATCH_PATH_PREFIX.length()); - ObjectPermission.Type type = ObjectPermission.Type.valueOf(patch.getValue()); - - // Create and update corresponding permission - ObjectPermission permission = new ObjectPermission(type, identifier); - updatePermissionSet(patch.getOp(), connectionGroupPermissionPatch, permission); - - } - - // Create active connection permission if path has active connection prefix - else if (path.startsWith(ACTIVE_CONNECTION_PERMISSION_PATCH_PATH_PREFIX)) { - - // Get identifier and type from patch operation - String identifier = path.substring(ACTIVE_CONNECTION_PERMISSION_PATCH_PATH_PREFIX.length()); - ObjectPermission.Type type = ObjectPermission.Type.valueOf(patch.getValue()); - - // Create and update corresponding permission - ObjectPermission permission = new ObjectPermission(type, identifier); - updatePermissionSet(patch.getOp(), activeConnectionPermissionPatch, permission); - - } - - // Create user permission if path has user prefix - else if (path.startsWith(USER_PERMISSION_PATCH_PATH_PREFIX)) { - - // Get identifier and type from patch operation - String identifier = path.substring(USER_PERMISSION_PATCH_PATH_PREFIX.length()); - ObjectPermission.Type type = ObjectPermission.Type.valueOf(patch.getValue()); - - // Create and update corresponding permission - ObjectPermission permission = new ObjectPermission(type, identifier); - updatePermissionSet(patch.getOp(), userPermissionPatch, permission); - - } - - // Create system permission if path is system path - else if (path.equals(SYSTEM_PERMISSION_PATCH_PATH)) { - - // Get identifier and type from patch operation - SystemPermission.Type type = SystemPermission.Type.valueOf(patch.getValue()); - - // Create and update corresponding permission - SystemPermission permission = new SystemPermission(type); - updatePermissionSet(patch.getOp(), systemPermissionPatch, permission); - - } - - // Otherwise, the path is not supported - else - throw new GuacamoleClientException("Unsupported patch path: \"" + path + "\""); - - } // end for each patch operation - - // Save the permission changes - connectionPermissionPatch.apply(user.getConnectionPermissions()); - connectionGroupPermissionPatch.apply(user.getConnectionGroupPermissions()); - activeConnectionPermissionPatch.apply(user.getActiveConnectionPermissions()); - userPermissionPatch.apply(user.getUserPermissions()); - systemPermissionPatch.apply(user.getSystemPermissions()); - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/package-info.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/package-info.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/package-info.java deleted file mode 100644 index dfa6d91..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/rest/user/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2014 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/** - * Classes related to the user manipulation aspect of the Guacamole REST API. - */ -package org.apache.guacamole.net.basic.rest.user; - http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/BasicGuacamoleWebSocketTunnelEndpoint.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/BasicGuacamoleWebSocketTunnelEndpoint.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/BasicGuacamoleWebSocketTunnelEndpoint.java deleted file mode 100644 index 981c383..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/BasicGuacamoleWebSocketTunnelEndpoint.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2014 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.apache.guacamole.net.basic.websocket; - -import com.google.inject.Provider; -import java.util.Map; -import javax.websocket.EndpointConfig; -import javax.websocket.HandshakeResponse; -import javax.websocket.Session; -import javax.websocket.server.HandshakeRequest; -import javax.websocket.server.ServerEndpointConfig; -import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.net.GuacamoleTunnel; -import org.apache.guacamole.net.basic.TunnelRequest; -import org.apache.guacamole.net.basic.TunnelRequestService; -import org.apache.guacamole.websocket.GuacamoleWebSocketTunnelEndpoint; - -/** - * Tunnel implementation which uses WebSocket as a tunnel backend, rather than - * HTTP, properly parsing connection IDs included in the connection request. - */ -public class BasicGuacamoleWebSocketTunnelEndpoint extends GuacamoleWebSocketTunnelEndpoint { - - /** - * Unique string which shall be used to store the TunnelRequest - * associated with a WebSocket connection. - */ - private static final String TUNNEL_REQUEST_PROPERTY = "WS_GUAC_TUNNEL_REQUEST"; - - /** - * Unique string which shall be used to store the TunnelRequestService to - * be used for processing TunnelRequests. - */ - private static final String TUNNEL_REQUEST_SERVICE_PROPERTY = "WS_GUAC_TUNNEL_REQUEST_SERVICE"; - - /** - * Configurator implementation which stores the requested GuacamoleTunnel - * within the user properties. The GuacamoleTunnel will be later retrieved - * during the connection process. - */ - public static class Configurator extends ServerEndpointConfig.Configurator { - - /** - * Provider which provides instances of a service for handling - * tunnel requests. - */ - private final Provider tunnelRequestServiceProvider; - - /** - * Creates a new Configurator which uses the given tunnel request - * service provider to retrieve the necessary service to handle new - * connections requests. - * - * @param tunnelRequestServiceProvider - * The tunnel request service provider to use for all new - * connections. - */ - public Configurator(Provider tunnelRequestServiceProvider) { - this.tunnelRequestServiceProvider = tunnelRequestServiceProvider; - } - - @Override - public void modifyHandshake(ServerEndpointConfig config, - HandshakeRequest request, HandshakeResponse response) { - - super.modifyHandshake(config, request, response); - - // Store tunnel request and tunnel request service for retrieval - // upon WebSocket open - Map userProperties = config.getUserProperties(); - userProperties.clear(); - userProperties.put(TUNNEL_REQUEST_PROPERTY, new WebSocketTunnelRequest(request)); - userProperties.put(TUNNEL_REQUEST_SERVICE_PROPERTY, tunnelRequestServiceProvider.get()); - - } - - } - - @Override - protected GuacamoleTunnel createTunnel(Session session, - EndpointConfig config) throws GuacamoleException { - - Map userProperties = config.getUserProperties(); - - // Get original tunnel request - TunnelRequest tunnelRequest = (TunnelRequest) userProperties.get(TUNNEL_REQUEST_PROPERTY); - if (tunnelRequest == null) - return null; - - // Get tunnel request service - TunnelRequestService tunnelRequestService = (TunnelRequestService) userProperties.get(TUNNEL_REQUEST_SERVICE_PROPERTY); - if (tunnelRequestService == null) - return null; - - // Create and return tunnel - return tunnelRequestService.createTunnel(tunnelRequest); - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/WebSocketTunnelModule.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/WebSocketTunnelModule.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/WebSocketTunnelModule.java deleted file mode 100644 index d3118b4..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/WebSocketTunnelModule.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2014 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.apache.guacamole.net.basic.websocket; - -import com.google.inject.Provider; -import com.google.inject.servlet.ServletModule; -import java.util.Arrays; -import javax.websocket.DeploymentException; -import javax.websocket.server.ServerContainer; -import javax.websocket.server.ServerEndpointConfig; -import org.apache.guacamole.net.basic.TunnelLoader; -import org.apache.guacamole.net.basic.TunnelRequestService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Loads the JSR-356 WebSocket tunnel implementation. - * - * @author Michael Jumper - */ -public class WebSocketTunnelModule extends ServletModule implements TunnelLoader { - - /** - * Logger for this class. - */ - private final Logger logger = LoggerFactory.getLogger(WebSocketTunnelModule.class); - - @Override - public boolean isSupported() { - - try { - - // Attempt to find WebSocket servlet - Class.forName("javax.websocket.Endpoint"); - - // Support found - return true; - - } - - // If no such servlet class, this particular WebSocket support - // is not present - catch (ClassNotFoundException e) {} - catch (NoClassDefFoundError e) {} - - // Support not found - return false; - - } - - @Override - public void configureServlets() { - - logger.info("Loading JSR-356 WebSocket support..."); - - // Get container - ServerContainer container = (ServerContainer) getServletContext().getAttribute("javax.websocket.server.ServerContainer"); - if (container == null) { - logger.warn("ServerContainer attribute required by JSR-356 is missing. Cannot load JSR-356 WebSocket support."); - return; - } - - Provider tunnelRequestServiceProvider = getProvider(TunnelRequestService.class); - - // Build configuration for WebSocket tunnel - ServerEndpointConfig config = - ServerEndpointConfig.Builder.create(BasicGuacamoleWebSocketTunnelEndpoint.class, "/websocket-tunnel") - .configurator(new BasicGuacamoleWebSocketTunnelEndpoint.Configurator(tunnelRequestServiceProvider)) - .subprotocols(Arrays.asList(new String[]{"guacamole"})) - .build(); - - try { - - // Add configuration to container - container.addEndpoint(config); - - } - catch (DeploymentException e) { - logger.error("Unable to deploy WebSocket tunnel.", e); - } - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/WebSocketTunnelRequest.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/WebSocketTunnelRequest.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/WebSocketTunnelRequest.java deleted file mode 100644 index 7c2b844..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/WebSocketTunnelRequest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2014 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.apache.guacamole.net.basic.websocket; - -import java.util.List; -import java.util.Map; -import javax.websocket.server.HandshakeRequest; -import org.apache.guacamole.net.basic.TunnelRequest; - -/** - * WebSocket-specific implementation of TunnelRequest. - * - * @author Michael Jumper - */ -public class WebSocketTunnelRequest extends TunnelRequest { - - /** - * All parameters passed via HTTP to the WebSocket handshake. - */ - private final Map> handshakeParameters; - - /** - * Creates a TunnelRequest implementation which delegates parameter and - * session retrieval to the given HandshakeRequest. - * - * @param request The HandshakeRequest to wrap. - */ - public WebSocketTunnelRequest(HandshakeRequest request) { - this.handshakeParameters = request.getParameterMap(); - } - - @Override - public String getParameter(String name) { - - // Pull list of values, if present - List values = getParameterValues(name); - if (values == null || values.isEmpty()) - return null; - - // Return first parameter value arbitrarily - return values.get(0); - - } - - @Override - public List getParameterValues(String name) { - return handshakeParameters.get(name); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/648a6c96/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/jetty8/BasicGuacamoleWebSocketTunnelServlet.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/jetty8/BasicGuacamoleWebSocketTunnelServlet.java b/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/jetty8/BasicGuacamoleWebSocketTunnelServlet.java deleted file mode 100644 index 6d12b2b..0000000 --- a/guacamole/src/main/java/org/apache/guacamole/net/basic/websocket/jetty8/BasicGuacamoleWebSocketTunnelServlet.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2013 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.apache.guacamole.net.basic.websocket.jetty8; - -import com.google.inject.Inject; -import com.google.inject.Singleton; -import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.net.GuacamoleTunnel; -import org.apache.guacamole.net.basic.TunnelRequestService; -import org.apache.guacamole.net.basic.TunnelRequest; - -/** - * Tunnel servlet implementation which uses WebSocket as a tunnel backend, - * rather than HTTP, properly parsing connection IDs included in the connection - * request. - */ -@Singleton -public class BasicGuacamoleWebSocketTunnelServlet extends GuacamoleWebSocketTunnelServlet { - - /** - * Service for handling tunnel requests. - */ - @Inject - private TunnelRequestService tunnelRequestService; - - @Override - protected GuacamoleTunnel doConnect(TunnelRequest request) - throws GuacamoleException { - return tunnelRequestService.createTunnel(request); - } - -}