From facea42463c9535e320a92032f3d1b2f55d61980 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 6 Jun 2017 11:09:01 -0400 Subject: [PATCH 01/61] GUACAMOLE-38: Initial implementation of QuickConnect feature --- .../guacamole-auth-quickconnect/pom.xml | 202 +++++++++++++ .../src/main/assembly/dist.xml | 53 ++++ .../QuickConnectAuthenticationProvider.java | 167 ++++++++++ ...ckConnectAuthenticationProviderModule.java | 79 +++++ .../QuickConnectConnectionGroup.java | 99 ++++++ .../quickconnect/QuickConnectDirectory.java | 103 +++++++ .../quickconnect/QuickConnectUserContext.java | 286 ++++++++++++++++++ .../auth/quickconnect/QuickConnection.java | 146 +++++++++ .../controllers/quickconnectController.js | 207 +++++++++++++ .../src/main/resources/guac-manifest.json | 27 ++ .../src/main/resources/quickconnectModule.js | 28 ++ .../main/resources/styles/quickconnect.css | 48 +++ .../templates/quickconnectField.html | 7 + pom.xml | 1 + 14 files changed, 1453 insertions(+) create mode 100644 extensions/guacamole-auth-quickconnect/pom.xml create mode 100644 extensions/guacamole-auth-quickconnect/src/main/assembly/dist.xml create mode 100644 extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java create mode 100644 extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java create mode 100644 extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java create mode 100644 extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java create mode 100644 extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java create mode 100644 extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java create mode 100644 extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js create mode 100644 extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json create mode 100644 extensions/guacamole-auth-quickconnect/src/main/resources/quickconnectModule.js create mode 100644 extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css create mode 100644 extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html diff --git a/extensions/guacamole-auth-quickconnect/pom.xml b/extensions/guacamole-auth-quickconnect/pom.xml new file mode 100644 index 000000000..9d2bcfb17 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/pom.xml @@ -0,0 +1,202 @@ + + + + + 4.0.0 + org.apache.guacamole + guacamole-auth-quickconnect + jar + 0.9.13-incubating + guacamole-auth-quickconnect + http://guacamole.incubator.apache.org/ + + + UTF-8 + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.6 + 1.6 + + -Xlint:all + -Werror + + true + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.10 + + + unpack-dependencies + prepare-package + + unpack-dependencies + + + runtime + ${project.build.directory}/classes + + + + + + + + maven-assembly-plugin + 2.5.3 + + ${project.artifactId}-${project.version} + false + + src/main/assembly/dist.xml + + + + + make-dist-archive + package + + single + + + + + + + + com.samaxes.maven + minify-maven-plugin + 1.7.5 + + + default-cli + + UTF-8 + + ${basedir}/src/main/resources + ${project.build.directory}/classes + + / + / + quickconnect.css + + + **/*.css + + + / + / + quickconnect.js + + + **/*.js + + + + + **/*.test.js + + CLOSURE + + + + OFF + OFF + + + + + minify + + + + + + + + org.apache.rat + apache-rat-plugin + 0.12 + + + + **/*.json + src/licenses/**/* + src/main/resources/templates/*.html + + + + + + + validate + validate + + check + + + + + + + + + + + + + + org.apache.guacamole + guacamole-ext + 0.9.13-incubating + provided + + + + + com.google.inject + guice + 3.0 + + + com.google.inject.extensions + guice-multibindings + 3.0 + + + + + diff --git a/extensions/guacamole-auth-quickconnect/src/main/assembly/dist.xml b/extensions/guacamole-auth-quickconnect/src/main/assembly/dist.xml new file mode 100644 index 000000000..b89fd534c --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/assembly/dist.xml @@ -0,0 +1,53 @@ + + + + + dist + ${project.artifactId}-${project.version} + + + + tar.gz + + + + + + + + + src/licenses + + + + + target + + + *.jar + + + + + + diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java new file mode 100644 index 000000000..a3add1185 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -0,0 +1,167 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.guacamole.auth.quickconnect; + +import com.google.inject.Inject; +import com.google.inject.Provider; +import java.util.HashMap; +import java.util.Map; +import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.net.auth.AuthenticatedUser; +import org.apache.guacamole.net.auth.Credentials; +import org.apache.guacamole.net.auth.simple.SimpleAuthenticationProvider; +import org.apache.guacamole.net.auth.UserContext; +import org.apache.guacamole.protocol.GuacamoleConfiguration; +import org.apache.guacamole.token.StandardTokens; +import org.apache.guacamole.token.TokenFilter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProvider { + + /** + * Logger for this class. + */ + private final Logger logger = LoggerFactory.getLogger(QuickConnectAuthenticationProvider.class); + + private Map quickConnections = new HashMap(); + + private UserContext userContext = null; + + @Inject + private Provider userContextProvider; + + @Override + public String getIdentifier() { + return "quickconnect"; + } + + + /** + * For QuickConnect, authenticateUser simply returns null because this + * extension is designed to provide only a connection directory to users + * that are already authenticated and not any actual authentication. + * + * @param credentials + * Credentials object passed in from Guacamole login. + * + * @returns + * Returns null, which causes the client to move on to the next + * module. + */ + @Override + public AuthenticatedUser authenticateUser(Credentials credentials) + throws GuacamoleException { + + logger.debug(">>>QuickConnect<<< authenticateUser NOT IMPLEMENTED."); + + GuacamoleConfiguration config = new GuacamoleConfiguration(); + + config.setProtocol("ssh"); + config.setParameter("hostname","ussalxapps005t.cotyww.com"); + config.setParameter("port","22"); + + quickConnections.put("Adhoc 1", config); + + if (userContext == null) + userContext = new QuickConnectUserContext(this, credentials.getUsername(), quickConnections); + + return null; + + } + + @Override + public Map + getAuthorizedConfigurations(Credentials credentials) + throws GuacamoleException { + + logger.debug(">>>QuickConnect<<< Retrieving configurations for user {}", credentials.getUsername()); + + GuacamoleConfiguration config = new GuacamoleConfiguration(); + + config.setProtocol("ssh"); + config.setParameter("hostname","ussalxapps005t.cotyww.com"); + config.setParameter("port","22"); + + quickConnections.put("Adhoc 1", config); + + if(userContext == null) + userContext = new QuickConnectUserContext(this, credentials.getUsername(), quickConnections); + + return quickConnections; + } + + private Map + getFilteredAuthorizedConfigurations(Credentials credentials) + throws GuacamoleException { + + logger.debug(">>>QuickConnect<<< Filtering configurations."); + + // Get configurations + Map configs = + getAuthorizedConfigurations(credentials); + + // Return as unauthorized if not authorized to retrieve configs + if (configs == null) + return null; + + // Build credential TokenFilter + TokenFilter tokenFilter = new TokenFilter(); + StandardTokens.addStandardTokens(tokenFilter, credentials); + + // Filter each configuration + for (GuacamoleConfiguration config : configs.values()) + tokenFilter.filterValues(config.getParameters()); + + return configs; + + } + + private Map + getFilteredAuthorizedConfigurations(AuthenticatedUser authenticatedUser) + throws GuacamoleException { + + // Pull using credentials + return getFilteredAuthorizedConfigurations(authenticatedUser.getCredentials()); + + } + + @Override + public UserContext getUserContext(AuthenticatedUser authenticatedUser) + throws GuacamoleException { + + logger.debug(">>>QuickConnect<<< getUserContext for {}", authenticatedUser.getCredentials().getUsername()); + + // Get configurations + // Map configs = + // getFilteredAuthorizedConfigurations(authenticatedUser); + + // Return as unauthorized if not authorized to retrieve configs + // if (configs == null) + // return null; + + // Return user context restricted to authorized configs + // return new QuickConnectUserContext(this, authenticatedUser.getIdentifier(), configs); + + return userContext; + + } + +} diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java new file mode 100644 index 000000000..54f7c4163 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.guacamole.auth.quickconnect; + +import com.google.inject.AbstractModule; +import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.environment.Environment; +import org.apache.guacamole.environment.LocalEnvironment; +import org.apache.guacamole.net.auth.AuthenticationProvider; + +/** + * Guice module to do QuickConnect injections. + */ +public class QuickConnectAuthenticationProviderModule extends AbstractModule { + + /** + * Guacamole server environment. + */ + private final Environment environment; + + /** + * QuickConnect authentication provider. + */ + private final AuthenticationProvider authProvider; + + /** + * Create a new instance of the authentication provider module + * which configures injection for the QuickConnectAuthenticationProvider + * class. + * + * @param authProvider + * The authentication provider for which injection is being + * configured. + * + * @throws GuacamoleException + * If an error occurs while retrieving the server environment. + */ + public QuickConnectAuthenticationProviderModule(AuthenticationProvider authProvider) + throws GuacamoleException { + + // Create a new local environment + this.environment = new LocalEnvironment(); + + // Initialize authProvider + this.authProvider = authProvider; + + } + + @Override + protected void configure() { + + // Bind core implementations of guacamole-ext classes + bind(AuthenticationProvider.class).toInstance(authProvider); + bind(Environment.class).toInstance(environment); + + // Bind QuickConnect-specific classes; + bind(QuickConnectDirectory.class); + bind(QuickConnectUserContext.class); + + } + +} diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java new file mode 100644 index 000000000..94d00d7c6 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.guacamole.auth.quickconnect; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.GuacamoleSecurityException; +import org.apache.guacamole.net.GuacamoleTunnel; +import org.apache.guacamole.net.auth.AbstractConnectionGroup; +import org.apache.guacamole.net.auth.ConnectionGroup; +import org.apache.guacamole.protocol.GuacamoleClientInformation; + +class QuickConnectConnectionGroup extends AbstractConnectionGroup { + + /** + * The connection identifiers for this group. + */ + private Set connectionIdentifiers; + + public QuickConnectConnectionGroup(String name, String identifier) { + + setName(name); + setIdentifier(identifier); + setType(ConnectionGroup.Type.ORGANIZATIONAL); + + this.connectionIdentifiers = new HashSet(Collections.emptyList()); + + } + + public QuickConnectConnectionGroup(String name, String identifier, + Collection connectionIdentifiers) { + + setName(name); + setIdentifier(identifier); + setType(ConnectionGroup.Type.ORGANIZATIONAL); + + this.connectionIdentifiers = new HashSet(connectionIdentifiers); + + } + + @Override + public int getActiveConnections() { + return 0; + } + + @Override + public Set getConnectionIdentifiers() { + return connectionIdentifiers; + } + + @Override + public Set getConnectionGroupIdentifiers() { + return Collections.emptySet(); + } + + @Override + public Map getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + // Do nothing - there are no attributes + } + + @Override + public GuacamoleTunnel connect(GuacamoleClientInformation info) + throws GuacamoleException { + throw new GuacamoleSecurityException("Permission denied."); + } + + public String addConnectionIdentifier(String identifier) { + if (connectionIdentifiers.add(identifier)) + return identifier; + return null; + } + +} diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java new file mode 100644 index 000000000..f77a5a78c --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.guacamole.auth.quickconnect; + +import com.google.inject.Inject; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; +import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.net.auth.ConnectionGroup; +import org.apache.guacamole.net.auth.simple.SimpleConnection; +import org.apache.guacamole.net.auth.simple.SimpleConnectionDirectory; +import org.apache.guacamole.net.auth.Connection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Implementation of the Connection Directory, stored + * completely in-memory. + */ +public class QuickConnectDirectory extends SimpleConnectionDirectory { + + /** + * Logger for this class. + */ + private final Logger logger = LoggerFactory.getLogger(QuickConnectDirectory.class); + + /** + * The unique identifier of the root connection group. + */ + private static final String ROOT_IDENTIFIER = "ROOT"; + + /** + * The root connection group for this directory. + */ + private final QuickConnectConnectionGroup rootGroup; + + /** + * The internal counter for connection IDs. + */ + private int CONNECTION_ID = 0; + + /** + * Creates a new QuickConnectDirectory which provides access to the + * connections contained within the given Map. + * + * @param connections + * A Collection of all connections that should be present in this + * connection directory. + */ + public QuickConnectDirectory(Collection connections, ConnectionGroup rootGroup) { + super(connections); + this.rootGroup = (QuickConnectConnectionGroup)rootGroup; + logger.debug(">>>QuickConnect<<< Created new directory."); + + } + + private Integer getNextConnectionID() { + return CONNECTION_ID++; + } + + @Override + public void add(Connection object) throws GuacamoleException { + logger.debug(">>>QuickConnect<<< Adding connection object."); + String connectionId = getNextConnectionID().toString(); + object.setIdentifier(connectionId); + object.setParentIdentifier(ROOT_IDENTIFIER); + /* + SimpleConnection newConn = new SimpleConnection( + object.getName(), + connectionId, + object.getConfiguration() + ); + newConn.setParentIdentifier(ROOT_IDENTIFIER); + */ + putConnection(new QuickConnection(object)); + this.rootGroup.addConnectionIdentifier(connectionId); + } + + @Override + public void update(Connection object) throws GuacamoleException { + logger.debug(">>>QuickConnect<<< Updating connection object."); + putConnection(object); + } + +} diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java new file mode 100644 index 000000000..02038604d --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -0,0 +1,286 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.guacamole.auth.quickconnect; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.UUID; +import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.form.Form; +import org.apache.guacamole.net.auth.ActiveConnection; +import org.apache.guacamole.net.auth.AuthenticationProvider; +import org.apache.guacamole.net.auth.Connection; +import org.apache.guacamole.net.auth.ConnectionGroup; +import org.apache.guacamole.net.auth.ConnectionRecordSet; +import org.apache.guacamole.net.auth.Directory; +import org.apache.guacamole.net.auth.SharingProfile; +import org.apache.guacamole.net.auth.User; +import org.apache.guacamole.net.auth.UserContext; +import org.apache.guacamole.net.auth.simple.SimpleConnection; +import org.apache.guacamole.net.auth.simple.SimpleConnectionGroup; +import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory; +import org.apache.guacamole.net.auth.simple.SimpleConnectionRecordSet; +import org.apache.guacamole.net.auth.simple.SimpleDirectory; +import org.apache.guacamole.net.auth.simple.SimpleUser; +import org.apache.guacamole.net.auth.simple.SimpleUserDirectory; +import org.apache.guacamole.protocol.GuacamoleConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * An extremely simple UserContext implementation which provides access to + * a defined and restricted set of GuacamoleConfigurations. Access to + * querying or modifying either users or permissions is denied. + */ +public class QuickConnectUserContext implements UserContext { + + /** + * Logger for this class. + */ + private final Logger logger = LoggerFactory.getLogger(QuickConnectUserContext.class); + + /** + * The unique identifier of the root connection group. + */ + private static final String ROOT_IDENTIFIER = "ROOT"; + + /** + * The AuthenticationProvider that created this UserContext. + */ + private final AuthenticationProvider authProvider; + + /** + * Reference to the user whose permissions dictate the configurations + * accessible within this UserContext. + */ + private final User self; + + /** + * The Directory with access only to the User associated with this + * UserContext. + */ + private final Directory userDirectory; + + /** + * The Directory with access only to the root group associated with this + * UserContext. + */ + private final Directory connectionGroupDirectory; + + /** + * The Directory with access to all connections within the root group + * associated with this UserContext. + */ + private final Directory connectionDirectory; + + /** + * The root connection group. + */ + private final ConnectionGroup rootGroup; + + /** + * Creates a new SimpleUserContext which provides access to only those + * configurations within the given Map. The username is assigned + * arbitrarily. + * + * @param authProvider + * The AuthenticationProvider creating this UserContext. + * + * @param configs + * A Map of all configurations for which the user associated with this + * UserContext has read access. + */ + public QuickConnectUserContext(AuthenticationProvider authProvider, + Map configs) { + this(authProvider, UUID.randomUUID().toString(), configs); + } + + /** + * Creates a new SimpleUserContext for the user with the given username + * which provides access to only those configurations within the given Map. + * + * @param authProvider + * The AuthenticationProvider creating this UserContext. + * + * @param username + * The username of the user associated with this UserContext. + * + * @param configs + * A Map of all configurations for which the user associated with + * this UserContext has read access. + */ + public QuickConnectUserContext(AuthenticationProvider authProvider, + String username, Map configs) { + + Collection connectionIdentifiers = new ArrayList(configs.size()); + Collection connectionGroupIdentifiers = Collections.singleton(ROOT_IDENTIFIER); + + // Produce collection of connections from given configs + Collection connections = new ArrayList(configs.size()); + for (Map.Entry configEntry : configs.entrySet()) { + + // Get connection identifier and configuration + String identifier = configEntry.getKey(); + GuacamoleConfiguration config = configEntry.getValue(); + + // Add as simple connection + Connection connection = new SimpleConnection(identifier, identifier, config); + connection.setParentIdentifier(ROOT_IDENTIFIER); + connections.add(connection); + + // Add identifier to overall set of identifiers + connectionIdentifiers.add(identifier); + + } + + // Add root group that contains only the given configurations + this.rootGroup = new QuickConnectConnectionGroup( + ROOT_IDENTIFIER, ROOT_IDENTIFIER, + connectionIdentifiers + ); + + // Build new user from credentials + this.self = new SimpleUser(username, connectionIdentifiers, + connectionGroupIdentifiers); + + // Create directories for new user + this.userDirectory = new SimpleUserDirectory(self); + this.connectionDirectory = new QuickConnectDirectory(connections,this.rootGroup); + this.connectionGroupDirectory = new SimpleConnectionGroupDirectory(Collections.singleton(this.rootGroup)); + + // Associate provided AuthenticationProvider + this.authProvider = authProvider; + + } + + public QuickConnectUserContext(AuthenticationProvider authProvider, + String username) { + + this.rootGroup = new QuickConnectConnectionGroup( + ROOT_IDENTIFIER, ROOT_IDENTIFIER + ); + + this.self = new SimpleUser(username, + Collections.emptyList(), + Collections.singleton(ROOT_IDENTIFIER) + ); + + this.userDirectory = new SimpleUserDirectory(self); + this.connectionDirectory = new QuickConnectDirectory(Collections.emptyList(), this.rootGroup); + this.connectionGroupDirectory = new SimpleConnectionGroupDirectory(Collections.singleton(this.rootGroup)); + + this.authProvider = authProvider; + + } + + public void setConfigs(Map configs) { + + return; + + } + + @Override + public User self() { + return self; + } + + @Override + public Object getResource() throws GuacamoleException { + return null; + } + + @Override + public AuthenticationProvider getAuthenticationProvider() { + return authProvider; + } + + @Override + public Directory getUserDirectory() + throws GuacamoleException { + return userDirectory; + } + + @Override + public Directory getConnectionDirectory() + throws GuacamoleException { + + logger.debug(">>>QuickConnect<<< Returning the entire connection directory: {}", connectionDirectory.getIdentifiers()); + + return connectionDirectory; + } + + @Override + public Directory getConnectionGroupDirectory() + throws GuacamoleException { + + logger.debug(">>>QuickConnect<<< Returning the entire group directory: {}", connectionGroupDirectory.getIdentifiers()); + + return connectionGroupDirectory; + } + + @Override + public ConnectionGroup getRootConnectionGroup() throws GuacamoleException { + + logger.debug(">>>QuickConnect<<< Returning the entire root Connection Group: {}", rootGroup); + + return rootGroup; + } + + @Override + public Directory getSharingProfileDirectory() + throws GuacamoleException { + return new SimpleDirectory(); + } + + @Override + public Directory getActiveConnectionDirectory() + throws GuacamoleException { + return new SimpleDirectory(); + } + + @Override + public ConnectionRecordSet getConnectionHistory() + throws GuacamoleException { + return new SimpleConnectionRecordSet(); + } + + @Override + public Collection
getUserAttributes() { + return Collections.emptyList(); + } + + @Override + public Collection getConnectionAttributes() { + return Collections.emptyList(); + } + + @Override + public Collection getConnectionGroupAttributes() { + return Collections.emptyList(); + } + + @Override + public Collection getSharingProfileAttributes() { + return Collections.emptyList(); + } + +} diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java new file mode 100644 index 000000000..f675057b6 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java @@ -0,0 +1,146 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.guacamole.auth.quickconnect; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.GuacamoleServerException; +import org.apache.guacamole.environment.Environment; +import org.apache.guacamole.environment.LocalEnvironment; +import org.apache.guacamole.net.GuacamoleSocket; +import org.apache.guacamole.net.GuacamoleTunnel; +import org.apache.guacamole.net.InetGuacamoleSocket; +import org.apache.guacamole.net.SSLGuacamoleSocket; +import org.apache.guacamole.net.SimpleGuacamoleTunnel; +import org.apache.guacamole.net.auth.AbstractConnection; +import org.apache.guacamole.net.auth.Connection; +import org.apache.guacamole.net.auth.ConnectionRecord; +import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration; +import org.apache.guacamole.protocol.ConfiguredGuacamoleSocket; +import org.apache.guacamole.protocol.GuacamoleClientInformation; +import org.apache.guacamole.protocol.GuacamoleConfiguration; + +public class QuickConnection extends AbstractConnection { + + /** + * Backing configuration, containing all sensitive information. + */ + private GuacamoleConfiguration config; + + /** + * Number of active connections. + */ + private int activeConnections; + + public QuickConnection() { + + } + + public QuickConnection(String name, String identifier, + GuacamoleConfiguration config) { + + setName(name); + + setIdentifier(identifier); + + setConfiguration(config); + this.config = config; + + this.activeConnections = 0; + + } + + public QuickConnection(Connection object) { + + setName(object.getName()); + setIdentifier(object.getIdentifier()); + setParentIdentifier(object.getParentIdentifier()); + setConfiguration(object.getConfiguration()); + this.config = object.getConfiguration(); + this.activeConnections = 0; + + } + + @Override + public int getActiveConnections() { + return activeConnections; + } + + @Override + public Map getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + // Do nothing - there are no attributes + } + + @Override + public GuacamoleTunnel connect(GuacamoleClientInformation info) + throws GuacamoleException { + + // Retrieve proxy configuration from environment + Environment environment = new LocalEnvironment(); + GuacamoleProxyConfiguration proxyConfig = environment.getDefaultGuacamoleProxyConfiguration(); + + // Get guacd connection parameters + String hostname = proxyConfig.getHostname(); + int port = proxyConfig.getPort(); + + GuacamoleSocket socket; + + // Determine socket type based on required encryption method + switch (proxyConfig.getEncryptionMethod()) { + + // If guacd requires SSL, use it + case SSL: + socket = new ConfiguredGuacamoleSocket( + new SSLGuacamoleSocket(hostname, port), + config, info + ); + break; + + // Connect directly via TCP if encryption is not enabled + case NONE: + socket = new ConfiguredGuacamoleSocket( + new InetGuacamoleSocket(hostname, port), + config, info + ); + break; + + // Abort if encryption method is unknown + default: + throw new GuacamoleServerException("Unimplemented encryption method."); + + } + + return new SimpleGuacamoleTunnel(socket); + + } + + @Override + public List getHistory() throws GuacamoleException { + return Collections.emptyList(); + } + +} diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js new file mode 100644 index 000000000..1a120a89a --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js @@ -0,0 +1,207 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * The controller for making ad-hoc (quick) connections + */ +angular.module('guacQuickConnect').controller('quickconnectController', ['$scope', '$injector', '$log', + function manageConnectionController($scope, $injector, $log) { + + $log.debug('In quickconnectController...'); + + // Required types + var ClientIdentifier = $injector.get('ClientIdentifier'); + var Connection = $injector.get('Connection'); + + // Required services + var $location = $injector.get('$location'); + var $routeParams = $injector.get('$routeParams'); + var guacNotification = $injector.get('guacNotification'); + var connectionService = $injector.get('connectionService'); + var schemaService = $injector.get('schemaService'); + + /** + * An action to be provided along with the object sent to showStatus which + * closes the currently-shown status dialog. + */ + var ACKNOWLEDGE_ACTION = { + name : "MANAGE_CONNECTION.ACTION_ACKNOWLEDGE", + // Handle action + callback : function acknowledgeCallback() { + guacNotification.showStatus(false); + } + }; + + $scope.uri = null; + + $scope.selectedDataSource = 'quickconnect'; + + /** + * Saves the connection, creating a new connection or updating the existing + * connection. + */ + $scope.quickConnect = function quickConnect() { + + $log.debug('Got saveConnection() call.'); + + // Construct parameters from URI... + /** + * Parse URL into the following components: + * [0] - Full URL + * [3] - Protocol + * [5] - Username + * [7] - Password + * [8] - Hostname + * [10] - Port + * [11] - Path + * [13] - Document + * [15] - Parameters + * [17] - JS Route + */ + var regexURL = /^(((rdp|ssh|telnet|vnc)?):\/)?\/?((.*?)(:(.*?)|)@)?([^:\/\s]+)(:([^\/]*))?((\/\w+\/)*)([-\w.\/]+[^#?\s]*)?(\?([^#]*))?(#(.*))?$/g; + $log.debug(regexURL); + var urlArray = regexURL.exec($scope.uri); + $log.debug($scope.uri); + $log.debug(urlArray); + + var gettingProtocols = schemaService.getProtocols('quickconnect'); + gettingProtocols.success(function checkProtocol(supportedProtocols) { + $log.debug(supportedProtocols); + if (!(urlArray[3] in supportedProtocols)) { + guacNotification.showStatus({ + 'className' : 'error', + 'title' : 'Unsupported Protocol', + 'text' : 'The ' + urlArray[3] + ' protocol is not supported by Guacamole.', + 'actions' : [ ACKNOWLEDGE_ACTION ] + }); + return; + } + var port = 0; + var urlParams = Array(); + switch(urlArray[3]) { + case 'rdp': + port = 3389; + break; + case 'ssh': + port = 22; + break; + case 'telnet': + port = 23; + break; + case 'vnc': + port = 5900; + break; + default: + port = 0; + } + + if (!isNaN(urlArray[10])) + port = parseInt(urlArray[10]); + + if (!(typeof urlArray[15] === 'undefined')) + urlParams = JSON.parse('{"' + decodeURI(urlArray[15]).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}'); + + console.log(urlParams); + + var connParams = {}; + if (!(typeof urlArray[8] === 'undefined')) + connParams['hostname'] = urlArray[8]; + else + connParams['hostname'] = 'localhost'; + if (!(typeof urlArray[5] === 'undefined')) + connParams['username'] = urlArray[5]; + if (!(typeof urlArray[7] === 'undefined')) + connParams['password'] = urlArray[7]; + connParams['port'] = port; + connParams['read-only'] = 'read-only' in urlParams ? urlParams['read-only'] : ''; + connParams['swap-red-blue'] = 'swap-red-blue' in urlParams ? urlParams['swap-red-blue'] : ''; + connParams['cursor'] = 'cursor' in urlParams ? urlParams['cursor'] : ''; + connParams['color-depth'] = 'color-depth' in urlParams ? parseInt(urlParams['color-depth']) : ''; + connParams['clipboard-encoding'] = 'clipboard-encoding' in urlParams ? urlParams['clipboard-encoding'] : ''; + connParams['dest-port'] = 'dest-port' in urlParams ? parseInt(urlParams['dest-port']) : ''; + connParams['create-recording-path'] = 'create-recording-path' in urlParams ? urlParams['create-recording-path'] : ''; + connParams['enable-sftp'] = 'enable-sftp' in urlParams ? urlParams['enable-sftp'] : false; + connParams['sftp-port'] = 'sftp-port' in urlParams ? parseInt(urlParams['sftp-port']) : 22; + connParams['enable-audio'] = 'enable-audio' in urlParams ? urlParams['enable-audio'] : false; + connParams['color-scheme'] = 'color-scheme' in urlParams ? urlParams['color-scheme'] : ''; + connParams['font-size'] = 'font-size' in urlParams ? parseInt(urlParams['font-size']) : ''; + connParams['create-typescript-path'] = 'create-typescript-path' in urlParams ? urlParams['create-typescript-path'] : ''; + connParams['private-key'] = 'private-key' in urlParams ? urlParams['private-key'] : ''; + connParams['passphrase'] = 'passphrase' in urlParams ? urlParams['passphrase'] : ''; + + var connName = urlArray[3] + '://'; + if(!(typeof connParams['username'] === 'undefined')) + connName += connParams['username'] + '@'; + connName += connParams['hostname'] + ':' + connParams['port']; + + $scope.connection = new Connection({ + name : connName, + protocol : urlArray[3], + parameters: connParams + }); + console.log($scope.connection); + + connectionService.saveConnection($scope.selectedDataSource, $scope.connection) + .success(function runConnection(newConnection) { + $log.debug('Connection saved - we should run it, now: ' + newConnection.identifier); + $location.url('/client/' + ClientIdentifier.toString({ + dataSource : $scope.selectedDataSource, + type : ClientIdentifier.Types.CONNECTION, + id : newConnection.identifier + })); + }) + .error(function saveFailed(error) { + guacNotification.showStatus({ + 'className' : 'error', + 'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR', + 'text' : error.translatableMessage, + 'actions' : [ ACKNOWLEDGE_ACTION ] + }); + }); + + }); + + + + return; + + /* + $scope.connection.parameters = $scope.parameters; + + // Save the connection + connectionService.saveConnection($scope.selectedDataSource, $scope.connection) + .success(function savedConnection(newConnection) { + $log.debug('Connection saved successfully: ' + newConnection); + // $location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections'); + }) + + // Notify of any errors + .error(function connectionSaveFailed(error) { + guacNotification.showStatus({ + 'className' : 'error', + 'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR', + 'text' : error.translatableMessage, + 'actions' : [ ACKNOWLEDGE_ACTION ] + }); + }); + */ + + }; + +}]); diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json b/extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json new file mode 100644 index 000000000..0aa96b1db --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json @@ -0,0 +1,27 @@ +{ + "guacamoleVersion" : "0.9.13-incubating", + + "name" : "Adhoc Guacamole Connections", + "namespace" : "quickconnect", + + "authProviders" : [ + "org.apache.guacamole.auth.quickconnect.QuickConnectAuthenticationProvider" + ], + + "js" : [ + "quickconnect.min.js" + ], + + "css" : [ + "quickconnect.min.css" + ], + + "html" : [ + "templates/quickconnectField.html" + ], + + "resources" : { + "templates/quickconnectField.html" : "text/html" + } + +} diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/quickconnectModule.js b/extensions/guacamole-auth-quickconnect/src/main/resources/quickconnectModule.js new file mode 100644 index 000000000..7635a1ed2 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/quickconnectModule.js @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Module which provides Adhoc connection capability + */ +angular.module('guacQuickConnect', [ + 'form' +]); + +// Ensure the guacQuickConnect module is loaded along with the rest of the app +angular.module('index').requires.push('guacQuickConnect'); diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css b/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css new file mode 100644 index 000000000..49a407b2a --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +.quickconnect-container { + margin: 0.5em 0; + width: 100%; +} + +.quickconnect-container .quickconnect-field { + background-image: url('images/protocol-icons/guac-text.png'); + background-repeat: no-repeat; + background-size: 1.75em; + background-position: 0.25em center; + background-color: transparent; + padding: 0.5em; + padding-left: 2.25em; + width: 100%; + max-width: none; + border: 0; + border-left: 1px solid rgba(0,0,0,0.125); + box-sizing: border-box; +} + +.quickconnect-field input[type="submit"] { + display: none !important; +} + +.quickconnect-button { + clear: both; + float: right; +} diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html new file mode 100644 index 000000000..0f53379f8 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html @@ -0,0 +1,7 @@ + +
+
+ +
+ +
diff --git a/pom.xml b/pom.xml index 4f7c8ed6a..e5e631fa9 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,7 @@ extensions/guacamole-auth-jdbc extensions/guacamole-auth-ldap extensions/guacamole-auth-openid + extensions/guacamole-auth-quickconnect extensions/guacamole-auth-totp From ed8ca17a955230fd2d9794591c6ed15e5917ebe2 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Fri, 21 Jul 2017 12:23:17 -0400 Subject: [PATCH 02/61] GUACAMOLE-38: Fix issue with Settings -> Users page. --- .../QuickConnectAuthenticationProvider.java | 35 +++++++------------ .../quickconnect/QuickConnectUserContext.java | 4 +++ 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java index a3add1185..e3f0bbd44 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -21,11 +21,14 @@ package org.apache.guacamole.auth.quickconnect; import com.google.inject.Inject; import com.google.inject.Provider; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.net.auth.AuthenticatedUser; import org.apache.guacamole.net.auth.Credentials; +import org.apache.guacamole.net.auth.credentials.CredentialsInfo; +import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException; import org.apache.guacamole.net.auth.simple.SimpleAuthenticationProvider; import org.apache.guacamole.net.auth.UserContext; import org.apache.guacamole.protocol.GuacamoleConfiguration; @@ -41,8 +44,6 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv */ private final Logger logger = LoggerFactory.getLogger(QuickConnectAuthenticationProvider.class); - private Map quickConnections = new HashMap(); - private UserContext userContext = null; @Inject @@ -70,18 +71,13 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv public AuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException { - logger.debug(">>>QuickConnect<<< authenticateUser NOT IMPLEMENTED."); + logger.debug(">>>QuickConnect<<< authenticateUser running for user {}.", credentials.getUsername()); - GuacamoleConfiguration config = new GuacamoleConfiguration(); + String username = credentials.getUsername(); + if(username == null || username.isEmpty()) + throw new GuacamoleInvalidCredentialsException("You must login.", CredentialsInfo.USERNAME_PASSWORD); - config.setProtocol("ssh"); - config.setParameter("hostname","ussalxapps005t.cotyww.com"); - config.setParameter("port","22"); - - quickConnections.put("Adhoc 1", config); - - if (userContext == null) - userContext = new QuickConnectUserContext(this, credentials.getUsername(), quickConnections); + userContext = new QuickConnectUserContext(this, credentials.getUsername()); return null; @@ -94,18 +90,11 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv logger.debug(">>>QuickConnect<<< Retrieving configurations for user {}", credentials.getUsername()); - GuacamoleConfiguration config = new GuacamoleConfiguration(); - - config.setProtocol("ssh"); - config.setParameter("hostname","ussalxapps005t.cotyww.com"); - config.setParameter("port","22"); - - quickConnections.put("Adhoc 1", config); - if(userContext == null) - userContext = new QuickConnectUserContext(this, credentials.getUsername(), quickConnections); + userContext = new QuickConnectUserContext(this, credentials.getUsername()); + + return Collections.emptyMap(); - return quickConnections; } private Map @@ -160,7 +149,7 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv // Return user context restricted to authorized configs // return new QuickConnectUserContext(this, authenticatedUser.getIdentifier(), configs); - return userContext; + return new QuickConnectUserContext(this, authenticatedUser.getIdentifier()); } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index 02038604d..9d12eaab2 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -112,6 +112,7 @@ public class QuickConnectUserContext implements UserContext { public QuickConnectUserContext(AuthenticationProvider authProvider, Map configs) { this(authProvider, UUID.randomUUID().toString(), configs); + logger.debug(">>>QuickConnect<<< Constructor with authProvider and configs."); } /** @@ -216,6 +217,9 @@ public class QuickConnectUserContext implements UserContext { @Override public Directory getUserDirectory() throws GuacamoleException { + + logger.debug(">>>QuickConnect<<< Returning the entire user directory: {}", userDirectory.getIdentifiers()); + return userDirectory; } From 7aaca96f10b1033d07e8a9cb076195b8cb0c54a7 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Fri, 21 Jul 2017 12:53:31 -0400 Subject: [PATCH 03/61] GUACAMOLE-38: Code cleanup - remove unneeded code, debugging, etc. Provide proper documentation. --- .../QuickConnectAuthenticationProvider.java | 73 ++---------- ...ckConnectAuthenticationProviderModule.java | 2 + .../QuickConnectConnectionGroup.java | 43 ++++--- .../quickconnect/QuickConnectDirectory.java | 27 +++-- .../quickconnect/QuickConnectUserContext.java | 106 +++--------------- .../auth/quickconnect/QuickConnection.java | 27 +++++ .../controllers/quickconnectController.js | 51 +++------ .../src/main/resources/quickconnectModule.js | 2 +- .../templates/quickconnectField.html | 4 +- 9 files changed, 115 insertions(+), 220 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java index e3f0bbd44..b431ad10e 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -37,6 +37,11 @@ import org.apache.guacamole.token.TokenFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * Class providing the necessary hooks into the Guacamole Client authentication + * process so that the QuickConnect functionality can be initialized and be used + * throughout the web client. + */ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProvider { /** @@ -44,17 +49,16 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv */ private final Logger logger = LoggerFactory.getLogger(QuickConnectAuthenticationProvider.class); - private UserContext userContext = null; - - @Inject - private Provider userContextProvider; + /** + * userContext for this authentication provider. + */ + private UserContext userContext; @Override public String getIdentifier() { return "quickconnect"; } - /** * For QuickConnect, authenticateUser simply returns null because this * extension is designed to provide only a connection directory to users @@ -71,14 +75,10 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv public AuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException { - logger.debug(">>>QuickConnect<<< authenticateUser running for user {}.", credentials.getUsername()); - String username = credentials.getUsername(); - if(username == null || username.isEmpty()) + if (username == null || username.isEmpty()) throw new GuacamoleInvalidCredentialsException("You must login.", CredentialsInfo.USERNAME_PASSWORD); - userContext = new QuickConnectUserContext(this, credentials.getUsername()); - return null; } @@ -88,67 +88,14 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv getAuthorizedConfigurations(Credentials credentials) throws GuacamoleException { - logger.debug(">>>QuickConnect<<< Retrieving configurations for user {}", credentials.getUsername()); - - if(userContext == null) - userContext = new QuickConnectUserContext(this, credentials.getUsername()); - return Collections.emptyMap(); } - private Map - getFilteredAuthorizedConfigurations(Credentials credentials) - throws GuacamoleException { - - logger.debug(">>>QuickConnect<<< Filtering configurations."); - - // Get configurations - Map configs = - getAuthorizedConfigurations(credentials); - - // Return as unauthorized if not authorized to retrieve configs - if (configs == null) - return null; - - // Build credential TokenFilter - TokenFilter tokenFilter = new TokenFilter(); - StandardTokens.addStandardTokens(tokenFilter, credentials); - - // Filter each configuration - for (GuacamoleConfiguration config : configs.values()) - tokenFilter.filterValues(config.getParameters()); - - return configs; - - } - - private Map - getFilteredAuthorizedConfigurations(AuthenticatedUser authenticatedUser) - throws GuacamoleException { - - // Pull using credentials - return getFilteredAuthorizedConfigurations(authenticatedUser.getCredentials()); - - } - @Override public UserContext getUserContext(AuthenticatedUser authenticatedUser) throws GuacamoleException { - logger.debug(">>>QuickConnect<<< getUserContext for {}", authenticatedUser.getCredentials().getUsername()); - - // Get configurations - // Map configs = - // getFilteredAuthorizedConfigurations(authenticatedUser); - - // Return as unauthorized if not authorized to retrieve configs - // if (configs == null) - // return null; - - // Return user context restricted to authorized configs - // return new QuickConnectUserContext(this, authenticatedUser.getIdentifier(), configs); - return new QuickConnectUserContext(this, authenticatedUser.getIdentifier()); } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java index 54f7c4163..397de5aa9 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java @@ -71,8 +71,10 @@ public class QuickConnectAuthenticationProviderModule extends AbstractModule { bind(Environment.class).toInstance(environment); // Bind QuickConnect-specific classes; + bind(QuickConnectConnectionGroup.class); bind(QuickConnectDirectory.class); bind(QuickConnectUserContext.class); + bind(QuickConnection.class); } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java index 94d00d7c6..df10ba13d 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java @@ -31,6 +31,11 @@ import org.apache.guacamole.net.auth.AbstractConnectionGroup; import org.apache.guacamole.net.auth.ConnectionGroup; import org.apache.guacamole.protocol.GuacamoleClientInformation; +/** + * Provides a very simple, single-level connection group used + * for temporarily storing the QuickConnections created by + * users. + */ class QuickConnectConnectionGroup extends AbstractConnectionGroup { /** @@ -38,6 +43,15 @@ class QuickConnectConnectionGroup extends AbstractConnectionGroup { */ private Set connectionIdentifiers; + /** + * Set up a QuickConnectConnectionGroup with a name and identifier, and + * an empty set of child connections. + * + * @param name + * The name of the QuickConnectConnectionGroup. + * @param identifier + * The identifier of the QuickConnectConnectionGroup. + */ public QuickConnectConnectionGroup(String name, String identifier) { setName(name); @@ -48,15 +62,20 @@ class QuickConnectConnectionGroup extends AbstractConnectionGroup { } - public QuickConnectConnectionGroup(String name, String identifier, - Collection connectionIdentifiers) { - - setName(name); - setIdentifier(identifier); - setType(ConnectionGroup.Type.ORGANIZATIONAL); - - this.connectionIdentifiers = new HashSet(connectionIdentifiers); - + /** + * Add a connection identifier to this connection group, and + * return the identifier if the add succeeds, else return null. + * + * @param identifier + * The identifier of the connection to add to the group. + * @return + * The String identifier of the connection if the add + * operation was successful; otherwise null. + */ + public String addConnectionIdentifier(String identifier) { + if (connectionIdentifiers.add(identifier)) + return identifier; + return null; } @Override @@ -90,10 +109,4 @@ class QuickConnectConnectionGroup extends AbstractConnectionGroup { throw new GuacamoleSecurityException("Permission denied."); } - public String addConnectionIdentifier(String identifier) { - if (connectionIdentifiers.add(identifier)) - return identifier; - return null; - } - } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index f77a5a78c..370961c0c 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -68,35 +68,38 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { public QuickConnectDirectory(Collection connections, ConnectionGroup rootGroup) { super(connections); this.rootGroup = (QuickConnectConnectionGroup)rootGroup; - logger.debug(">>>QuickConnect<<< Created new directory."); - } + /** + * Returns the current counter and then increments it. + * + * @returns + * An Integer representing the next available connection + * ID to get used when adding connections. + */ private Integer getNextConnectionID() { return CONNECTION_ID++; } @Override public void add(Connection object) throws GuacamoleException { - logger.debug(">>>QuickConnect<<< Adding connection object."); + + // Get the next connection ID. String connectionId = getNextConnectionID().toString(); + + // Set up identifier and parent on original object. object.setIdentifier(connectionId); object.setParentIdentifier(ROOT_IDENTIFIER); - /* - SimpleConnection newConn = new SimpleConnection( - object.getName(), - connectionId, - object.getConfiguration() - ); - newConn.setParentIdentifier(ROOT_IDENTIFIER); - */ + + // Add connection to the directory putConnection(new QuickConnection(object)); + + // Add connection to the tree this.rootGroup.addConnectionIdentifier(connectionId); } @Override public void update(Connection object) throws GuacamoleException { - logger.debug(">>>QuickConnect<<< Updating connection object."); putConnection(object); } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index 9d12eaab2..4fe4b38d2 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -47,9 +47,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * An extremely simple UserContext implementation which provides access to - * a defined and restricted set of GuacamoleConfigurations. Access to - * querying or modifying either users or permissions is denied. + * A simple implementation of UserContext to support the QuickConnect + * extension, primarily used for storing connections the user has + * created using the QuickConnect bar in the webapp. */ public class QuickConnectUserContext implements UserContext { @@ -98,107 +98,41 @@ public class QuickConnectUserContext implements UserContext { private final ConnectionGroup rootGroup; /** - * Creates a new SimpleUserContext which provides access to only those - * configurations within the given Map. The username is assigned - * arbitrarily. + * Construct a QuickConnectUserContext using the authProvider and + * the username. * * @param authProvider - * The AuthenticationProvider creating this UserContext. - * - * @param configs - * A Map of all configurations for which the user associated with this - * UserContext has read access. - */ - public QuickConnectUserContext(AuthenticationProvider authProvider, - Map configs) { - this(authProvider, UUID.randomUUID().toString(), configs); - logger.debug(">>>QuickConnect<<< Constructor with authProvider and configs."); - } - - /** - * Creates a new SimpleUserContext for the user with the given username - * which provides access to only those configurations within the given Map. - * - * @param authProvider - * The AuthenticationProvider creating this UserContext. - * + * The authentication provider module instantiating this + * this class. * @param username - * The username of the user associated with this UserContext. - * - * @param configs - * A Map of all configurations for which the user associated with - * this UserContext has read access. + * The name of the user logging in and using this class. */ - public QuickConnectUserContext(AuthenticationProvider authProvider, - String username, Map configs) { - - Collection connectionIdentifiers = new ArrayList(configs.size()); - Collection connectionGroupIdentifiers = Collections.singleton(ROOT_IDENTIFIER); - - // Produce collection of connections from given configs - Collection connections = new ArrayList(configs.size()); - for (Map.Entry configEntry : configs.entrySet()) { - - // Get connection identifier and configuration - String identifier = configEntry.getKey(); - GuacamoleConfiguration config = configEntry.getValue(); - - // Add as simple connection - Connection connection = new SimpleConnection(identifier, identifier, config); - connection.setParentIdentifier(ROOT_IDENTIFIER); - connections.add(connection); - - // Add identifier to overall set of identifiers - connectionIdentifiers.add(identifier); - - } - - // Add root group that contains only the given configurations - this.rootGroup = new QuickConnectConnectionGroup( - ROOT_IDENTIFIER, ROOT_IDENTIFIER, - connectionIdentifiers - ); - - // Build new user from credentials - this.self = new SimpleUser(username, connectionIdentifiers, - connectionGroupIdentifiers); - - // Create directories for new user - this.userDirectory = new SimpleUserDirectory(self); - this.connectionDirectory = new QuickConnectDirectory(connections,this.rootGroup); - this.connectionGroupDirectory = new SimpleConnectionGroupDirectory(Collections.singleton(this.rootGroup)); - - // Associate provided AuthenticationProvider - this.authProvider = authProvider; - - } - public QuickConnectUserContext(AuthenticationProvider authProvider, String username) { + // Initialize the rootGroup to a basic connection group with a + // single root identifier. this.rootGroup = new QuickConnectConnectionGroup( ROOT_IDENTIFIER, ROOT_IDENTIFIER ); + // Initialize the user to a SimpleUser with the username, no + // preexisting connections, and the single root group. this.self = new SimpleUser(username, Collections.emptyList(), Collections.singleton(ROOT_IDENTIFIER) ); + // Initialize each of the directories associated with the userContext. this.userDirectory = new SimpleUserDirectory(self); this.connectionDirectory = new QuickConnectDirectory(Collections.emptyList(), this.rootGroup); this.connectionGroupDirectory = new SimpleConnectionGroupDirectory(Collections.singleton(this.rootGroup)); + // Set the authProvider to the calling authProvider object. this.authProvider = authProvider; } - public void setConfigs(Map configs) { - - return; - - } - @Override public User self() { return self; @@ -217,35 +151,23 @@ public class QuickConnectUserContext implements UserContext { @Override public Directory getUserDirectory() throws GuacamoleException { - - logger.debug(">>>QuickConnect<<< Returning the entire user directory: {}", userDirectory.getIdentifiers()); - return userDirectory; } @Override public Directory getConnectionDirectory() throws GuacamoleException { - - logger.debug(">>>QuickConnect<<< Returning the entire connection directory: {}", connectionDirectory.getIdentifiers()); - return connectionDirectory; } @Override public Directory getConnectionGroupDirectory() throws GuacamoleException { - - logger.debug(">>>QuickConnect<<< Returning the entire group directory: {}", connectionGroupDirectory.getIdentifiers()); - return connectionGroupDirectory; } @Override public ConnectionGroup getRootConnectionGroup() throws GuacamoleException { - - logger.debug(">>>QuickConnect<<< Returning the entire root Connection Group: {}", rootGroup); - return rootGroup; } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java index f675057b6..cbcdd4fa0 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java @@ -39,6 +39,9 @@ import org.apache.guacamole.protocol.ConfiguredGuacamoleSocket; import org.apache.guacamole.protocol.GuacamoleClientInformation; import org.apache.guacamole.protocol.GuacamoleConfiguration; +/** + * A type of Connection specific to this authentication extension. + */ public class QuickConnection extends AbstractConnection { /** @@ -51,10 +54,26 @@ public class QuickConnection extends AbstractConnection { */ private int activeConnections; + /** + * Empty connection constructor. + */ public QuickConnection() { } + /** + * Constructor that takes a name, identifier, and GuacamoleConfiguration + * and builds a QuickConnection from it. + * + * @param name + * The name of the connection. + * @param identifier + * The unique identifier of this connection within this + * authentication module. + * @param config + * The GuacamoleConfiguration object to store in this + * QuickConnection. + */ public QuickConnection(String name, String identifier, GuacamoleConfiguration config) { @@ -69,6 +88,14 @@ public class QuickConnection extends AbstractConnection { } + /** + * Constructs a QuickConnection from a generic Connection + * object, copying over the relevant data and initializing + * the rest. + * + * @param object + * The generic Connection object to be copied. + */ public QuickConnection(Connection object) { setName(object.getName()); diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js index 1a120a89a..156a84d5e 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js @@ -23,8 +23,6 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope', '$injector', '$log', function manageConnectionController($scope, $injector, $log) { - $log.debug('In quickconnectController...'); - // Required types var ClientIdentifier = $injector.get('ClientIdentifier'); var Connection = $injector.get('Connection'); @@ -58,8 +56,6 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope */ $scope.quickConnect = function quickConnect() { - $log.debug('Got saveConnection() call.'); - // Construct parameters from URI... /** * Parse URL into the following components: @@ -75,14 +71,10 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope * [17] - JS Route */ var regexURL = /^(((rdp|ssh|telnet|vnc)?):\/)?\/?((.*?)(:(.*?)|)@)?([^:\/\s]+)(:([^\/]*))?((\/\w+\/)*)([-\w.\/]+[^#?\s]*)?(\?([^#]*))?(#(.*))?$/g; - $log.debug(regexURL); var urlArray = regexURL.exec($scope.uri); - $log.debug($scope.uri); - $log.debug(urlArray); var gettingProtocols = schemaService.getProtocols('quickconnect'); gettingProtocols.success(function checkProtocol(supportedProtocols) { - $log.debug(supportedProtocols); if (!(urlArray[3] in supportedProtocols)) { guacNotification.showStatus({ 'className' : 'error', @@ -94,6 +86,8 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope } var port = 0; var urlParams = Array(); + + // Default port assignments for various protocols. switch(urlArray[3]) { case 'rdp': port = 3389; @@ -111,23 +105,29 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope port = 0; } + // If the port is explicitly set, overwrite the default if (!isNaN(urlArray[10])) port = parseInt(urlArray[10]); + // Parse out any additional URI parameters on the connection string into an array. if (!(typeof urlArray[15] === 'undefined')) urlParams = JSON.parse('{"' + decodeURI(urlArray[15]).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}'); - console.log(urlParams); - var connParams = {}; + + // If hostname is undefined, assume localhost if (!(typeof urlArray[8] === 'undefined')) connParams['hostname'] = urlArray[8]; else connParams['hostname'] = 'localhost'; + + // Username and password if (!(typeof urlArray[5] === 'undefined')) connParams['username'] = urlArray[5]; if (!(typeof urlArray[7] === 'undefined')) connParams['password'] = urlArray[7]; + + // Additional connection parameters connParams['port'] = port; connParams['read-only'] = 'read-only' in urlParams ? urlParams['read-only'] : ''; connParams['swap-red-blue'] = 'swap-red-blue' in urlParams ? urlParams['swap-red-blue'] : ''; @@ -145,21 +145,23 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope connParams['private-key'] = 'private-key' in urlParams ? urlParams['private-key'] : ''; connParams['passphrase'] = 'passphrase' in urlParams ? urlParams['passphrase'] : ''; + // Set up the name of the connection based on various parts of the URI var connName = urlArray[3] + '://'; if(!(typeof connParams['username'] === 'undefined')) connName += connParams['username'] + '@'; connName += connParams['hostname'] + ':' + connParams['port']; - + + // Create the new connection $scope.connection = new Connection({ name : connName, protocol : urlArray[3], parameters: connParams }); - console.log($scope.connection); + // Save the new connection into the QuickConnect datasource. connectionService.saveConnection($scope.selectedDataSource, $scope.connection) .success(function runConnection(newConnection) { - $log.debug('Connection saved - we should run it, now: ' + newConnection.identifier); + // If the save succeeds, launch the new connection. $location.url('/client/' + ClientIdentifier.toString({ dataSource : $scope.selectedDataSource, type : ClientIdentifier.Types.CONNECTION, @@ -177,31 +179,8 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope }); - - return; - /* - $scope.connection.parameters = $scope.parameters; - - // Save the connection - connectionService.saveConnection($scope.selectedDataSource, $scope.connection) - .success(function savedConnection(newConnection) { - $log.debug('Connection saved successfully: ' + newConnection); - // $location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections'); - }) - - // Notify of any errors - .error(function connectionSaveFailed(error) { - guacNotification.showStatus({ - 'className' : 'error', - 'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR', - 'text' : error.translatableMessage, - 'actions' : [ ACKNOWLEDGE_ACTION ] - }); - }); - */ - }; }]); diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/quickconnectModule.js b/extensions/guacamole-auth-quickconnect/src/main/resources/quickconnectModule.js index 7635a1ed2..ed397a6ed 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/quickconnectModule.js +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/quickconnectModule.js @@ -18,7 +18,7 @@ */ /** - * Module which provides Adhoc connection capability + * Module which provides QuickConnect capability */ angular.module('guacQuickConnect', [ 'form' diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html index 0f53379f8..75daf4bf8 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html @@ -1,7 +1,9 @@
- + + +
From 2115fa90729b83ff5d1f5926ab0ef9c42b8bcc96 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 25 Jul 2017 15:49:15 -0400 Subject: [PATCH 04/61] GUACAMOLE-38: Fix issue related to submitting via Enter key. --- .../src/main/resources/templates/quickconnectField.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html index 75daf4bf8..d9b5a4d24 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html @@ -1,7 +1,7 @@
-
+
From ee539597cd6b0efccd8fcd9416b00340773939e5 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Fri, 11 Aug 2017 20:22:03 -0400 Subject: [PATCH 05/61] GUACAMOLE-38: Add licenses to QuickConnect extension. --- .../src/licenses/DISCLAIMER | 7 + .../src/licenses/LICENSE | 239 ++++++++++++++++++ .../src/licenses/NOTICE | 5 + .../src/licenses/bundled/README | 4 + .../licenses/bundled/aopalliance-1.0/LICENSE | 4 + .../src/licenses/bundled/guice-3.0/COPYING | 202 +++++++++++++++ .../bundled/javax.inject-1/LICENSE-2.0.txt | 202 +++++++++++++++ 7 files changed, 663 insertions(+) create mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/DISCLAIMER create mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/LICENSE create mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/NOTICE create mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/bundled/README create mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/bundled/aopalliance-1.0/LICENSE create mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/bundled/guice-3.0/COPYING create mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/bundled/javax.inject-1/LICENSE-2.0.txt diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/DISCLAIMER b/extensions/guacamole-auth-quickconnect/src/licenses/DISCLAIMER new file mode 100644 index 000000000..1a9c3be8d --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/licenses/DISCLAIMER @@ -0,0 +1,7 @@ +Apache Guacamole is an effort undergoing incubation at The Apache Software +Foundation (ASF). Incubation is required of all newly accepted projects until a +further review indicates that the infrastructure, communications, and decision +making process have stabilized in a manner consistent with other successful ASF +projects. While incubation status is not necessarily a reflection of the +completeness or stability of the code, it does indicate that the project has +yet to be fully endorsed by the ASF. diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/LICENSE b/extensions/guacamole-auth-quickconnect/src/licenses/LICENSE new file mode 100644 index 000000000..c6cbf77e8 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/licenses/LICENSE @@ -0,0 +1,239 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +============================================================================== + +APACHE GUACAMOLE SUBCOMPONENTS + +Apache Guacamole includes a number of subcomponents with separate copyright +notices and license terms. Your use of these subcomponents is subject to the +terms and conditions of the following licenses. + + +AOP Alliance (http://aopalliance.sourceforge.net/) +-------------------------------------------------- + + Version: 1.0 + From: 'AOP Alliance' (http://aopalliance.sourceforge.net/members.html) + License(s): + Public Domain (bundled/aopalliance-1.0/LICENSE) + + +Google Guice (https://github.com/google/guice) +---------------------------------------------- + + Version: 3.0 + From: 'Google Inc.' (http://www.google.com/) + License(s): + Apache v2.0 (bundled/guice-3.0/COPYING) + + +JSR-330 / Dependency Injection for Java (http://code.google.com/p/atinject/) +---------------------------------------------------------------------------- + + Version: 1 + From: 'JSR-330 Expert Group' (https://jcp.org/en/jsr/detail?id=330) + License(s): + Apache v2.0 (bundled/javax.inject-1/LICENSE-2.0.txt) + diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/NOTICE b/extensions/guacamole-auth-quickconnect/src/licenses/NOTICE new file mode 100644 index 000000000..47f2b4c24 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/licenses/NOTICE @@ -0,0 +1,5 @@ +Apache Guacamole +Copyright 2017 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/README b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/README new file mode 100644 index 000000000..47ba19db0 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/README @@ -0,0 +1,4 @@ +Apache Guacamole includes a number of subcomponents with separate copyright +notices and license terms. Your use of these subcomponents is subject to the +terms and conditions of their respective licenses, included within this +directory for reference. diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/aopalliance-1.0/LICENSE b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/aopalliance-1.0/LICENSE new file mode 100644 index 000000000..8e0e3786b --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/aopalliance-1.0/LICENSE @@ -0,0 +1,4 @@ +From http://aopalliance.sourceforge.net/: + + LICENCE: all the source code provided by AOP Alliance is Public Domain. + diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/guice-3.0/COPYING b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/guice-3.0/COPYING new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/guice-3.0/COPYING @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/javax.inject-1/LICENSE-2.0.txt b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/javax.inject-1/LICENSE-2.0.txt new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/javax.inject-1/LICENSE-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From 531725671b3e22498fc58b5bd92a1d4e4f4f29b6 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Fri, 11 Aug 2017 20:45:39 -0400 Subject: [PATCH 06/61] GUACAMOLE-38: Clean up unnecessary imports and tweak style issues. --- .../QuickConnectAuthenticationProvider.java | 12 ------------ .../quickconnect/QuickConnectConnectionGroup.java | 1 - .../auth/quickconnect/QuickConnectDirectory.java | 13 ++----------- .../auth/quickconnect/QuickConnectUserContext.java | 13 ------------- .../resources/controllers/quickconnectController.js | 2 +- 5 files changed, 3 insertions(+), 38 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java index b431ad10e..a94c7df46 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -19,10 +19,7 @@ package org.apache.guacamole.auth.quickconnect; -import com.google.inject.Inject; -import com.google.inject.Provider; import java.util.Collections; -import java.util.HashMap; import java.util.Map; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.net.auth.AuthenticatedUser; @@ -32,10 +29,6 @@ import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsExce import org.apache.guacamole.net.auth.simple.SimpleAuthenticationProvider; import org.apache.guacamole.net.auth.UserContext; import org.apache.guacamole.protocol.GuacamoleConfiguration; -import org.apache.guacamole.token.StandardTokens; -import org.apache.guacamole.token.TokenFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Class providing the necessary hooks into the Guacamole Client authentication @@ -44,11 +37,6 @@ import org.slf4j.LoggerFactory; */ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProvider { - /** - * Logger for this class. - */ - private final Logger logger = LoggerFactory.getLogger(QuickConnectAuthenticationProvider.class); - /** * userContext for this authentication provider. */ diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java index df10ba13d..5abf0bee3 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java @@ -19,7 +19,6 @@ package org.apache.guacamole.auth.quickconnect; -import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Map; diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index 370961c0c..c2ca355e4 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -19,17 +19,11 @@ package org.apache.guacamole.auth.quickconnect; -import com.google.inject.Inject; import java.util.Collection; -import java.util.Collections; -import java.util.Set; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.net.auth.ConnectionGroup; -import org.apache.guacamole.net.auth.simple.SimpleConnection; import org.apache.guacamole.net.auth.simple.SimpleConnectionDirectory; import org.apache.guacamole.net.auth.Connection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Implementation of the Connection Directory, stored @@ -37,11 +31,6 @@ import org.slf4j.LoggerFactory; */ public class QuickConnectDirectory extends SimpleConnectionDirectory { - /** - * Logger for this class. - */ - private final Logger logger = LoggerFactory.getLogger(QuickConnectDirectory.class); - /** * The unique identifier of the root connection group. */ @@ -64,6 +53,8 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { * @param connections * A Collection of all connections that should be present in this * connection directory. + * @param rootGroup + * A group that should be at the base of this directory. */ public QuickConnectDirectory(Collection connections, ConnectionGroup rootGroup) { super(connections); diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index 4fe4b38d2..b06464d2f 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -19,11 +19,8 @@ package org.apache.guacamole.auth.quickconnect; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Map; -import java.util.UUID; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.form.Form; import org.apache.guacamole.net.auth.ActiveConnection; @@ -35,16 +32,11 @@ import org.apache.guacamole.net.auth.Directory; import org.apache.guacamole.net.auth.SharingProfile; import org.apache.guacamole.net.auth.User; import org.apache.guacamole.net.auth.UserContext; -import org.apache.guacamole.net.auth.simple.SimpleConnection; -import org.apache.guacamole.net.auth.simple.SimpleConnectionGroup; import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory; import org.apache.guacamole.net.auth.simple.SimpleConnectionRecordSet; import org.apache.guacamole.net.auth.simple.SimpleDirectory; import org.apache.guacamole.net.auth.simple.SimpleUser; import org.apache.guacamole.net.auth.simple.SimpleUserDirectory; -import org.apache.guacamole.protocol.GuacamoleConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * A simple implementation of UserContext to support the QuickConnect @@ -53,11 +45,6 @@ import org.slf4j.LoggerFactory; */ public class QuickConnectUserContext implements UserContext { - /** - * Logger for this class. - */ - private final Logger logger = LoggerFactory.getLogger(QuickConnectUserContext.class); - /** * The unique identifier of the root connection group. */ diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js index 156a84d5e..715653a69 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js @@ -147,7 +147,7 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope // Set up the name of the connection based on various parts of the URI var connName = urlArray[3] + '://'; - if(!(typeof connParams['username'] === 'undefined')) + if (!(typeof connParams['username'] === 'undefined')) connName += connParams['username'] + '@'; connName += connParams['hostname'] + ':' + connParams['port']; From 498400ef0d587e47a00c9ddbaa6891d996db7eae Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Thu, 28 Sep 2017 10:48:43 -0400 Subject: [PATCH 07/61] GUACAMOLE-38: Fix compatibility with recent ActivityRecord changes. --- .../quickconnect/QuickConnectUserContext.java | 21 +++++++++++++++---- .../auth/quickconnect/QuickConnection.java | 6 ++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index b06464d2f..bc9754cad 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -24,16 +24,18 @@ import java.util.Collections; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.form.Form; import org.apache.guacamole.net.auth.ActiveConnection; +import org.apache.guacamole.net.auth.ActivityRecord; +import org.apache.guacamole.net.auth.ActivityRecordSet; import org.apache.guacamole.net.auth.AuthenticationProvider; import org.apache.guacamole.net.auth.Connection; import org.apache.guacamole.net.auth.ConnectionGroup; -import org.apache.guacamole.net.auth.ConnectionRecordSet; +import org.apache.guacamole.net.auth.ConnectionRecord; import org.apache.guacamole.net.auth.Directory; import org.apache.guacamole.net.auth.SharingProfile; import org.apache.guacamole.net.auth.User; import org.apache.guacamole.net.auth.UserContext; +import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet; import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory; -import org.apache.guacamole.net.auth.simple.SimpleConnectionRecordSet; import org.apache.guacamole.net.auth.simple.SimpleDirectory; import org.apache.guacamole.net.auth.simple.SimpleUser; import org.apache.guacamole.net.auth.simple.SimpleUserDirectory; @@ -130,6 +132,11 @@ public class QuickConnectUserContext implements UserContext { return null; } + @Override + public void invalidate() { + // Do nothing. + } + @Override public AuthenticationProvider getAuthenticationProvider() { return authProvider; @@ -141,6 +148,12 @@ public class QuickConnectUserContext implements UserContext { return userDirectory; } + @Override + public ActivityRecordSet getUserHistory() + throws GuacamoleException { + return new SimpleActivityRecordSet(); + } + @Override public Directory getConnectionDirectory() throws GuacamoleException { @@ -171,9 +184,9 @@ public class QuickConnectUserContext implements UserContext { } @Override - public ConnectionRecordSet getConnectionHistory() + public ActivityRecordSet getConnectionHistory() throws GuacamoleException { - return new SimpleConnectionRecordSet(); + return new SimpleActivityRecordSet(); } @Override diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java index cbcdd4fa0..1735757fe 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java @@ -20,6 +20,7 @@ package org.apache.guacamole.auth.quickconnect; import java.util.Collections; +import java.util.Date; import java.util.List; import java.util.Map; import org.apache.guacamole.GuacamoleException; @@ -170,4 +171,9 @@ public class QuickConnection extends AbstractConnection { return Collections.emptyList(); } + @Override + public Date getLastActive() { + return null; + } + } From c0a6bacad5e43833d4b78d60215bbd72210ac0a4 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 11 Oct 2017 15:55:14 -0400 Subject: [PATCH 08/61] GUACAMOLE-38: Implement extension-specific REST endpoint and utilities for parsing connection. --- .../guacamole-auth-quickconnect/pom.xml | 7 + .../quickconnect/QuickConnectDirectory.java | 71 ++++++++ .../quickconnect/QuickConnectUserContext.java | 5 +- .../quickconnect/rest/QuickConnectREST.java | 103 +++++++++++ .../auth/quickconnect/utility/QCParser.java | 169 ++++++++++++++++++ 5 files changed, 353 insertions(+), 2 deletions(-) create mode 100644 extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java create mode 100644 extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java diff --git a/extensions/guacamole-auth-quickconnect/pom.xml b/extensions/guacamole-auth-quickconnect/pom.xml index 9d2bcfb17..fdf04c75a 100644 --- a/extensions/guacamole-auth-quickconnect/pom.xml +++ b/extensions/guacamole-auth-quickconnect/pom.xml @@ -185,6 +185,13 @@ provided + + + com.sun.jersey + jersey-server + 1.17.1 + + com.google.inject diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index c2ca355e4..d56df95ad 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -21,9 +21,11 @@ package org.apache.guacamole.auth.quickconnect; import java.util.Collection; import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.auth.quickconnect.utility.QCParser; import org.apache.guacamole.net.auth.ConnectionGroup; import org.apache.guacamole.net.auth.simple.SimpleConnectionDirectory; import org.apache.guacamole.net.auth.Connection; +import org.apache.guacamole.protocol.GuacamoleConfiguration; /** * Implementation of the Connection Directory, stored @@ -89,6 +91,75 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { this.rootGroup.addConnectionIdentifier(connectionId); } + /** + * Create a connection object on the tree using an existing + * QuickConnection connection, after setting the identifier + * and parent object. + * + * @param object + * The QuickConnection object to add to the tree. + * + * @returns + * The connectionId of the object added to the directory. + * + * @throws GuacamoleException + * If an error is encountered adding the object to the + * directory. + */ + public String put(QuickConnection object) throws GuacamoleException { + + // Get the next connection ID. + String connectionId = getNextConnectionID().toString(); + + // Set up identifier and parent on object. + object.setIdentifier(connectionId); + object.setParentIdentifier(ROOT_IDENTIFIER); + + // Add connection to the directory + putConnection(object); + + // Add connection to the tree + this.rootGroup.addConnectionIdentifier(connectionId); + + return connectionId; + + } + + /** + * Create a QuickConnection object from a GuacamoleConfiguration + * and get an ID and place it on the tree. + * + * @param config + * The GuacamoleConfiguration to use to create the + * QuickConnection object. + * + * @returns + * The connectionId of the object creation in the directory. + * + * @throws GuacamoleException + * If an error occurs adding the object to the tree. + */ + public String create(GuacamoleConfiguration config) throws GuacamoleException { + + // Get the next connection ID + String connectionId = getNextConnectionID().toString(); + + // Generate a name for the configuration + String name = QCParser.getName(config); + + // Create a new connection and set parent identifier. + Connection connection = new QuickConnection(name, connectionId, config); + connection.setParentIdentifier(ROOT_IDENTIFIER); + + // Place the object in directory + putConnection(connection); + + // Add connection to the tree. + this.rootGroup.addConnectionIdentifier(connectionId); + + return connectionId; + } + @Override public void update(Connection object) throws GuacamoleException { putConnection(object); diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index bc9754cad..b1a2752ca 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -21,6 +21,7 @@ package org.apache.guacamole.auth.quickconnect; import java.util.Collection; import java.util.Collections; +import org.apache.guacamole.auth.quickconnect.rest.QuickConnectREST; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.form.Form; import org.apache.guacamole.net.auth.ActiveConnection; @@ -50,7 +51,7 @@ public class QuickConnectUserContext implements UserContext { /** * The unique identifier of the root connection group. */ - private static final String ROOT_IDENTIFIER = "ROOT"; + public static final String ROOT_IDENTIFIER = "ROOT"; /** * The AuthenticationProvider that created this UserContext. @@ -129,7 +130,7 @@ public class QuickConnectUserContext implements UserContext { @Override public Object getResource() throws GuacamoleException { - return null; + return new QuickConnectREST(this); } @Override diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java new file mode 100644 index 000000000..d494eb883 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.guacamole.auth.quickconnect.rest; + +import com.google.inject.Inject; +import java.util.List; +import javax.ws.rs.Consumes; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.POST; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.GuacamoleServerException; +import org.apache.guacamole.protocol.GuacamoleConfiguration; +import org.apache.guacamole.auth.quickconnect.QuickConnection; +import org.apache.guacamole.auth.quickconnect.QuickConnectDirectory; +import org.apache.guacamole.auth.quickconnect.QuickConnectUserContext; +import org.apache.guacamole.auth.quickconnect.utility.QCParser; +import org.apache.guacamole.net.auth.Connection; +import org.apache.guacamole.net.auth.Directory; + +/** + * A class to create and manage REST endpoints for the + * QuickConnect extension. + */ +@Produces(MediaType.APPLICATION_JSON) +public class QuickConnectREST { + + /** + * The connection directory for this REST endpoint. + */ + private QuickConnectDirectory directory; + + /** + * The UserContext object for this REST endpoint. + */ + private QuickConnectUserContext userContext; + + /** + * Construct a new QuickConnectREST class, taking in the UserContext + * object that calls this constructor. + * + * @param userContext + * The UserContext object associated with this REST endpoint + * + * @throws GuacamoleException + * If the UserContext is unavailable or the directory object + * cannot be retrieved. + */ + public QuickConnectREST(QuickConnectUserContext userContext) + throws GuacamoleException { + this.userContext = userContext; + this.directory = (QuickConnectDirectory)this.userContext.getConnectionDirectory(); + } + + /** + * Parse the URI read from the POST input, add the connection + * to the directory, and return the ID of the newly-created + * connection. + * + * @param uri + * The URI to parse into a connection. + * + * @returns + * The ID of the connection in the directory. + * + * @throws + * Throws a GuacamoleException if an error is encountered + * parsing the URI. + */ + @POST + @Path("create") + public String create(@FormParam("uri") String uri) + throws GuacamoleException { + + if (directory == null) + throw new GuacamoleServerException("No connection directory available."); + + return directory.create(QCParser.getConfiguration(uri)); + + } + + +} diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java new file mode 100644 index 000000000..afe272adb --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -0,0 +1,169 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.guacamole.auth.quickconnect.utility; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.List; +import org.apache.guacamole.GuacamoleClientException; +import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.protocol.GuacamoleConfiguration; + +public class QCParser { + + /** + * The default protocol to parse to if one is undefined. + */ + public static final String DEFAULT_URI_PROTOCOL = "ssh"; + + /** + * The default host to use if one is not defined. + */ + public static final String DEFAULT_URI_HOST = "localhost"; + + /** + * The default port to use if one is not defined. + */ + public static final Integer DEFAULT_URI_PORT = 22; + + /** + * Parse out a URI string and get a connection from that string, + * or an exception if the parsing fails. + * + * @param uri + * The string form of the URI to be parsed. + * + * @returns + * A GuacamoleConfiguration using a combination of the parsed + * URI values and default values when not specified in the + * URI. + * + * @throws GuacamoleException + * When an error occurs parsing the URI. + */ + public static GuacamoleConfiguration getConfiguration(String uri) + throws GuacamoleException { + + URI qcUri; + try { + qcUri = new URI(uri); + } + catch (URISyntaxException e) { + throw new GuacamoleClientException("Invalid URI Syntax", e); + } + String protocol = qcUri.getScheme(); + String host = qcUri.getHost(); + Integer port = qcUri.getPort(); + String userInfo = qcUri.getUserInfo(); + String query = qcUri.getQuery(); + String username = null; + String password = null; + List paramList = null; + + if (protocol == null || protocol.equals("")) + protocol = DEFAULT_URI_PROTOCOL; + + if (host == null || host.equals("")) + host = DEFAULT_URI_HOST; + + if (port == -1 || port < 1) + port = DEFAULT_URI_PORT; + + if (query != null && !query.equals("")) + paramList = Arrays.asList(query.split("&")); + + if (userInfo != null && !userInfo.equals("")) { + String[] authenticators = userInfo.split(":"); + if (authenticators[0] != null) + username = authenticators[0]; + if (authenticators[1] != null) + password = authenticators[1]; + } + + GuacamoleConfiguration qcConfig = new GuacamoleConfiguration(); + qcConfig.setProtocol(protocol); + qcConfig.setParameter("hostname",host); + qcConfig.setParameter("port", port.toString()); + + if (username != null) + qcConfig.setParameter("username", username); + + if (password != null) + qcConfig.setParameter("password", password); + + if (paramList != null) { + for (String parameter : paramList) { + String[] paramArray = parameter.split("="); + qcConfig.setParameter(paramArray[0],paramArray[1]); + } + } + + return qcConfig; + + } + + /** + * Given a GuacamoleConfiguration object, generate a name + * for the configuration based on the protocol, host, user + * and port in the configuration, and return the string value. + * + * @param config + * The GuacamoleConfiguration object to use to generate + * the name. + * + * @return + * The String value of the name that is generated, or + * null if no config is provided. + * + * @throws GuacamoleException + * If an error occurs getting items in the configuration. + */ + public static String getName(GuacamoleConfiguration config) + throws GuacamoleException { + + if (config == null) + return null; + + String protocol = config.getProtocol(); + String host = config.getParameter("hostname"); + String port = config.getParameter("port"); + String user = config.getParameter("username"); + + String name = ""; + + if (protocol != null && !protocol.equals("")) + name += protocol + "://"; + + if (user != null && !user.equals("")) + name += user + "@"; + + if (host != null && !host.equals("")) + name += host; + + if (port != null && !port.equals("")) + name += ":" + port; + + name += "/"; + + return name; + } + +} From 9946dca022017bf72dbea74b31a10ca0a35b6e5c Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 11 Oct 2017 21:42:05 -0400 Subject: [PATCH 09/61] GUACAMOLE-38: Alter AngularJS side of extensions to use new REST endpoint. --- .../controllers/quickconnectController.js | 141 ++---------------- .../resources/services/quickConnectService.js | 60 ++++++++ 2 files changed, 75 insertions(+), 126 deletions(-) create mode 100644 extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js index 715653a69..dc8c22bf9 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js @@ -25,14 +25,11 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope // Required types var ClientIdentifier = $injector.get('ClientIdentifier'); - var Connection = $injector.get('Connection'); // Required services var $location = $injector.get('$location'); - var $routeParams = $injector.get('$routeParams'); var guacNotification = $injector.get('guacNotification'); - var connectionService = $injector.get('connectionService'); - var schemaService = $injector.get('schemaService'); + var quickConnectService = $injector.get('quickConnectService'); /** * An action to be provided along with the object sent to showStatus which @@ -48,135 +45,27 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope $scope.uri = null; - $scope.selectedDataSource = 'quickconnect'; - /** * Saves the connection, creating a new connection or updating the existing * connection. */ $scope.quickConnect = function quickConnect() { - // Construct parameters from URI... - /** - * Parse URL into the following components: - * [0] - Full URL - * [3] - Protocol - * [5] - Username - * [7] - Password - * [8] - Hostname - * [10] - Port - * [11] - Path - * [13] - Document - * [15] - Parameters - * [17] - JS Route - */ - var regexURL = /^(((rdp|ssh|telnet|vnc)?):\/)?\/?((.*?)(:(.*?)|)@)?([^:\/\s]+)(:([^\/]*))?((\/\w+\/)*)([-\w.\/]+[^#?\s]*)?(\?([^#]*))?(#(.*))?$/g; - var urlArray = regexURL.exec($scope.uri); - - var gettingProtocols = schemaService.getProtocols('quickconnect'); - gettingProtocols.success(function checkProtocol(supportedProtocols) { - if (!(urlArray[3] in supportedProtocols)) { - guacNotification.showStatus({ - 'className' : 'error', - 'title' : 'Unsupported Protocol', - 'text' : 'The ' + urlArray[3] + ' protocol is not supported by Guacamole.', - 'actions' : [ ACKNOWLEDGE_ACTION ] - }); - return; - } - var port = 0; - var urlParams = Array(); - - // Default port assignments for various protocols. - switch(urlArray[3]) { - case 'rdp': - port = 3389; - break; - case 'ssh': - port = 22; - break; - case 'telnet': - port = 23; - break; - case 'vnc': - port = 5900; - break; - default: - port = 0; - } - - // If the port is explicitly set, overwrite the default - if (!isNaN(urlArray[10])) - port = parseInt(urlArray[10]); - - // Parse out any additional URI parameters on the connection string into an array. - if (!(typeof urlArray[15] === 'undefined')) - urlParams = JSON.parse('{"' + decodeURI(urlArray[15]).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}'); - - var connParams = {}; - - // If hostname is undefined, assume localhost - if (!(typeof urlArray[8] === 'undefined')) - connParams['hostname'] = urlArray[8]; - else - connParams['hostname'] = 'localhost'; - - // Username and password - if (!(typeof urlArray[5] === 'undefined')) - connParams['username'] = urlArray[5]; - if (!(typeof urlArray[7] === 'undefined')) - connParams['password'] = urlArray[7]; - - // Additional connection parameters - connParams['port'] = port; - connParams['read-only'] = 'read-only' in urlParams ? urlParams['read-only'] : ''; - connParams['swap-red-blue'] = 'swap-red-blue' in urlParams ? urlParams['swap-red-blue'] : ''; - connParams['cursor'] = 'cursor' in urlParams ? urlParams['cursor'] : ''; - connParams['color-depth'] = 'color-depth' in urlParams ? parseInt(urlParams['color-depth']) : ''; - connParams['clipboard-encoding'] = 'clipboard-encoding' in urlParams ? urlParams['clipboard-encoding'] : ''; - connParams['dest-port'] = 'dest-port' in urlParams ? parseInt(urlParams['dest-port']) : ''; - connParams['create-recording-path'] = 'create-recording-path' in urlParams ? urlParams['create-recording-path'] : ''; - connParams['enable-sftp'] = 'enable-sftp' in urlParams ? urlParams['enable-sftp'] : false; - connParams['sftp-port'] = 'sftp-port' in urlParams ? parseInt(urlParams['sftp-port']) : 22; - connParams['enable-audio'] = 'enable-audio' in urlParams ? urlParams['enable-audio'] : false; - connParams['color-scheme'] = 'color-scheme' in urlParams ? urlParams['color-scheme'] : ''; - connParams['font-size'] = 'font-size' in urlParams ? parseInt(urlParams['font-size']) : ''; - connParams['create-typescript-path'] = 'create-typescript-path' in urlParams ? urlParams['create-typescript-path'] : ''; - connParams['private-key'] = 'private-key' in urlParams ? urlParams['private-key'] : ''; - connParams['passphrase'] = 'passphrase' in urlParams ? urlParams['passphrase'] : ''; - - // Set up the name of the connection based on various parts of the URI - var connName = urlArray[3] + '://'; - if (!(typeof connParams['username'] === 'undefined')) - connName += connParams['username'] + '@'; - connName += connParams['hostname'] + ':' + connParams['port']; - - // Create the new connection - $scope.connection = new Connection({ - name : connName, - protocol : urlArray[3], - parameters: connParams + quickConnectService.createConnection(encodeURIComponent($scope.uri)) + .success(function createdConnection(connectionId) { + $location.url('/client/' + ClientIdentifier.toString({ + dataSource : 'quickconnect', + type : ClientIdentifier.Types.CONNECTION, + id : connectionId + })); + }) + .error(function createFailed(error) { + guacNotification.showStatus({ + 'className' : 'error', + 'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR', + 'text' : error.translatableMessage, + 'actions' : [ ACKNOWLEDGE_ACTION ] }); - - // Save the new connection into the QuickConnect datasource. - connectionService.saveConnection($scope.selectedDataSource, $scope.connection) - .success(function runConnection(newConnection) { - // If the save succeeds, launch the new connection. - $location.url('/client/' + ClientIdentifier.toString({ - dataSource : $scope.selectedDataSource, - type : ClientIdentifier.Types.CONNECTION, - id : newConnection.identifier - })); - }) - .error(function saveFailed(error) { - guacNotification.showStatus({ - 'className' : 'error', - 'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR', - 'text' : error.translatableMessage, - 'actions' : [ ACKNOWLEDGE_ACTION ] - }); - }); - }); return; diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js b/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js new file mode 100644 index 000000000..329b83c11 --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Service for managing quickConnect extension. + */ +angular.module('guacQuickConnect').factory('quickConnectService', ['$injector', + function quickConnectService($injector) { + + // Required services + var $http = $injector.get('$http'); + var authenticationService = $injector.get('authenticationService'); + + var service = {}; + + /** + * Makes a request to the REST API to create a connection, returning a + * promise that can be used for processing the results of the call. + * + * @param {uri} The URI of the connection to create. + * + * @returns {Promise} + * A promise for the HTTP call which will succeed if and only if the + * save operation is successful. + */ + service.createConnection = function createConnection(uri) { + + // Build HTTP parameters set + var httpParameters = { + token : authenticationService.getCurrentToken() + }; + + return $http({ + method : 'POST', + url : 'api/session/ext/quickconnect/create', + params : httpParameters, + data : $.param({uri: uri }), + headers : {'Content-Type': 'application/x-www-form-urlencoded'} + }); + + }; + + return service; +}]); From b49047cf789a39efd4a0adb97edf0bada45615c0 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 11 Oct 2017 22:50:14 -0400 Subject: [PATCH 10/61] GUACAMOLE-38: Don't try to encode URI before sending it to be parsed. --- .../apache/guacamole/auth/quickconnect/utility/QCParser.java | 4 ++-- .../src/main/resources/controllers/quickconnectController.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index afe272adb..4ada3f089 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -92,9 +92,9 @@ public class QCParser { if (userInfo != null && !userInfo.equals("")) { String[] authenticators = userInfo.split(":"); - if (authenticators[0] != null) + if (authenticators.length > 0 && authenticators[0] != null) username = authenticators[0]; - if (authenticators[1] != null) + if (authenticators.length > 1 && authenticators[1] != null) password = authenticators[1]; } diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js index dc8c22bf9..03137303a 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js @@ -51,7 +51,7 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope */ $scope.quickConnect = function quickConnect() { - quickConnectService.createConnection(encodeURIComponent($scope.uri)) + quickConnectService.createConnection($scope.uri) .success(function createdConnection(connectionId) { $location.url('/client/' + ClientIdentifier.toString({ dataSource : 'quickconnect', From 289239efc56d2a9b3c49b3d855b84aaaddda3972 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 11 Oct 2017 23:02:37 -0400 Subject: [PATCH 11/61] GUACAMOLE-38: Clear cache after creating the connection. --- .../src/main/resources/services/quickConnectService.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js b/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js index 329b83c11..946e1912a 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js @@ -26,6 +26,7 @@ angular.module('guacQuickConnect').factory('quickConnectService', ['$injector', // Required services var $http = $injector.get('$http'); var authenticationService = $injector.get('authenticationService'); + var cacheService = $injector.get('cacheService'); var service = {}; @@ -52,6 +53,11 @@ angular.module('guacQuickConnect').factory('quickConnectService', ['$injector', params : httpParameters, data : $.param({uri: uri }), headers : {'Content-Type': 'application/x-www-form-urlencoded'} + }) + .success(function connectionCreated() { + // Clear connections and users from cache. + cacheService.connections.removeAll(); + cacheService.users.removeAll(); }); }; From 74ab18beb122fccd3573c86ab30cc983386973e3 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Mon, 23 Oct 2017 12:03:42 -0400 Subject: [PATCH 12/61] GUACAMOLE-38: Add translation file for the extension. --- .../src/main/resources/guac-manifest.json | 4 ++++ .../src/main/resources/translations/en.json | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json b/extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json index 0aa96b1db..46fad88e7 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json @@ -20,6 +20,10 @@ "templates/quickconnectField.html" ], + "translations" : [ + "translations/en.json" + ], + "resources" : { "templates/quickconnectField.html" : "text/html" } diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json b/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json new file mode 100644 index 000000000..b080d4b0b --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json @@ -0,0 +1,7 @@ +{ + + "DATA_SOURCE_QUICKCONNECT" : { + "NAME" : "QuickConnect" + } + +} From fc63007e59120712ed7c3a96d17ad73b2ce8c3c0 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 28 Oct 2017 14:40:03 -0400 Subject: [PATCH 13/61] GUACAMOLE-38: Remove unnecessary code. --- .../auth/quickconnect/QuickConnectDirectory.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index d56df95ad..5c9606d31 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -77,18 +77,8 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { @Override public void add(Connection object) throws GuacamoleException { - // Get the next connection ID. - String connectionId = getNextConnectionID().toString(); + put(new QuickConnection(object)); - // Set up identifier and parent on original object. - object.setIdentifier(connectionId); - object.setParentIdentifier(ROOT_IDENTIFIER); - - // Add connection to the directory - putConnection(new QuickConnection(object)); - - // Add connection to the tree - this.rootGroup.addConnectionIdentifier(connectionId); } /** From 039c5120dfcba506141b6be0a34c154e8537ce2a Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Mon, 1 Jan 2018 16:53:31 -0500 Subject: [PATCH 14/61] GUACAMOLE-38: Update to 0.9.14 and remove incubating references. --- extensions/guacamole-auth-quickconnect/pom.xml | 6 +++--- .../guacamole-auth-quickconnect/src/licenses/DISCLAIMER | 7 ------- .../src/main/resources/guac-manifest.json | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) delete mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/DISCLAIMER diff --git a/extensions/guacamole-auth-quickconnect/pom.xml b/extensions/guacamole-auth-quickconnect/pom.xml index fdf04c75a..87ee7bd7a 100644 --- a/extensions/guacamole-auth-quickconnect/pom.xml +++ b/extensions/guacamole-auth-quickconnect/pom.xml @@ -26,9 +26,9 @@ org.apache.guacamole guacamole-auth-quickconnect jar - 0.9.13-incubating + 0.9.14 guacamole-auth-quickconnect - http://guacamole.incubator.apache.org/ + http://guacamole.apache.org/ UTF-8 @@ -181,7 +181,7 @@ org.apache.guacamole guacamole-ext - 0.9.13-incubating + 0.9.14 provided diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/DISCLAIMER b/extensions/guacamole-auth-quickconnect/src/licenses/DISCLAIMER deleted file mode 100644 index 1a9c3be8d..000000000 --- a/extensions/guacamole-auth-quickconnect/src/licenses/DISCLAIMER +++ /dev/null @@ -1,7 +0,0 @@ -Apache Guacamole is an effort undergoing incubation at The Apache Software -Foundation (ASF). Incubation is required of all newly accepted projects until a -further review indicates that the infrastructure, communications, and decision -making process have stabilized in a manner consistent with other successful ASF -projects. While incubation status is not necessarily a reflection of the -completeness or stability of the code, it does indicate that the project has -yet to be fully endorsed by the ASF. diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json b/extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json index 46fad88e7..62dd3bbfa 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/guac-manifest.json @@ -1,5 +1,5 @@ { - "guacamoleVersion" : "0.9.13-incubating", + "guacamoleVersion" : "0.9.14", "name" : "Adhoc Guacamole Connections", "namespace" : "quickconnect", From 6c235565b0d1c4c39576fad37de345669f118af8 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 18 Feb 2018 21:10:49 -0500 Subject: [PATCH 15/61] GUACAMOLE-38: Style and typo fix-ups. --- .../quickconnect/QuickConnectAuthenticationProvider.java | 2 +- .../auth/quickconnect/QuickConnectConnectionGroup.java | 2 ++ .../guacamole/auth/quickconnect/QuickConnectDirectory.java | 6 +++--- .../auth/quickconnect/QuickConnectUserContext.java | 1 + .../guacamole/auth/quickconnect/QuickConnection.java | 2 ++ .../guacamole/auth/quickconnect/rest/QuickConnectREST.java | 7 +++---- .../guacamole/auth/quickconnect/utility/QCParser.java | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java index a94c7df46..f725bdfce 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -55,7 +55,7 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv * @param credentials * Credentials object passed in from Guacamole login. * - * @returns + * @return * Returns null, which causes the client to move on to the next * module. */ diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java index 5abf0bee3..4faab1cc6 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java @@ -48,6 +48,7 @@ class QuickConnectConnectionGroup extends AbstractConnectionGroup { * * @param name * The name of the QuickConnectConnectionGroup. + * * @param identifier * The identifier of the QuickConnectConnectionGroup. */ @@ -67,6 +68,7 @@ class QuickConnectConnectionGroup extends AbstractConnectionGroup { * * @param identifier * The identifier of the connection to add to the group. + * * @return * The String identifier of the connection if the add * operation was successful; otherwise null. diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index 5c9606d31..ce1fd1f1d 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -66,7 +66,7 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { /** * Returns the current counter and then increments it. * - * @returns + * @return * An Integer representing the next available connection * ID to get used when adding connections. */ @@ -89,7 +89,7 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { * @param object * The QuickConnection object to add to the tree. * - * @returns + * @return * The connectionId of the object added to the directory. * * @throws GuacamoleException @@ -123,7 +123,7 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { * The GuacamoleConfiguration to use to create the * QuickConnection object. * - * @returns + * @return * The connectionId of the object creation in the directory. * * @throws GuacamoleException diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index b1a2752ca..d9eb3895b 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -94,6 +94,7 @@ public class QuickConnectUserContext implements UserContext { * @param authProvider * The authentication provider module instantiating this * this class. + * * @param username * The name of the user logging in and using this class. */ diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java index 1735757fe..a2f381447 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java @@ -68,9 +68,11 @@ public class QuickConnection extends AbstractConnection { * * @param name * The name of the connection. + * * @param identifier * The unique identifier of this connection within this * authentication module. + * * @param config * The GuacamoleConfiguration object to store in this * QuickConnection. diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java index d494eb883..42e53a2f8 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java @@ -80,12 +80,11 @@ public class QuickConnectREST { * @param uri * The URI to parse into a connection. * - * @returns + * @return * The ID of the connection in the directory. * - * @throws - * Throws a GuacamoleException if an error is encountered - * parsing the URI. + * @throws GuacamoleException + * If an error is encountered parsing the URI. */ @POST @Path("create") diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 4ada3f089..05b892fcc 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -51,7 +51,7 @@ public class QCParser { * @param uri * The string form of the URI to be parsed. * - * @returns + * @return * A GuacamoleConfiguration using a combination of the parsed * URI values and default values when not specified in the * URI. From 2113d1aa96cc5595108adbd30f94b59c9c023825 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Fri, 16 Mar 2018 14:37:05 -0400 Subject: [PATCH 16/61] GUACAMOLE-38: Fix parameter name to sometihng more fitting to its function. --- .../auth/quickconnect/QuickConnectDirectory.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index ce1fd1f1d..00c50443e 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -86,7 +86,7 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { * QuickConnection connection, after setting the identifier * and parent object. * - * @param object + * @param connection * The QuickConnection object to add to the tree. * * @return @@ -96,17 +96,17 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { * If an error is encountered adding the object to the * directory. */ - public String put(QuickConnection object) throws GuacamoleException { + public String put(QuickConnection connection) throws GuacamoleException { // Get the next connection ID. String connectionId = getNextConnectionID().toString(); // Set up identifier and parent on object. - object.setIdentifier(connectionId); - object.setParentIdentifier(ROOT_IDENTIFIER); + connection.setIdentifier(connectionId); + connection.setParentIdentifier(ROOT_IDENTIFIER); // Add connection to the directory - putConnection(object); + putConnection(connection); // Add connection to the tree this.rootGroup.addConnectionIdentifier(connectionId); From a3d851228eb523782ce20965be4391645d86f014 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Fri, 16 Mar 2018 14:54:05 -0400 Subject: [PATCH 17/61] GUACAMOLE-38: Extend SimpleConnection instead of copying code manually. --- .../auth/quickconnect/QuickConnection.java | 89 ++----------------- 1 file changed, 5 insertions(+), 84 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java index a2f381447..2603f176e 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java @@ -36,6 +36,7 @@ import org.apache.guacamole.net.auth.AbstractConnection; import org.apache.guacamole.net.auth.Connection; import org.apache.guacamole.net.auth.ConnectionRecord; import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration; +import org.apache.guacamole.net.auth.simple.SimpleConnection; import org.apache.guacamole.protocol.ConfiguredGuacamoleSocket; import org.apache.guacamole.protocol.GuacamoleClientInformation; import org.apache.guacamole.protocol.GuacamoleConfiguration; @@ -43,12 +44,7 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration; /** * A type of Connection specific to this authentication extension. */ -public class QuickConnection extends AbstractConnection { - - /** - * Backing configuration, containing all sensitive information. - */ - private GuacamoleConfiguration config; +public class QuickConnection extends SimpleConnection { /** * Number of active connections. @@ -80,12 +76,7 @@ public class QuickConnection extends AbstractConnection { public QuickConnection(String name, String identifier, GuacamoleConfiguration config) { - setName(name); - - setIdentifier(identifier); - - setConfiguration(config); - this.config = config; + super(name, identifier, config); this.activeConnections = 0; @@ -101,81 +92,11 @@ public class QuickConnection extends AbstractConnection { */ public QuickConnection(Connection object) { - setName(object.getName()); - setIdentifier(object.getIdentifier()); + super(object.getName(),object.getIdentifier(),object.getConfiguration()); + setParentIdentifier(object.getParentIdentifier()); - setConfiguration(object.getConfiguration()); - this.config = object.getConfiguration(); this.activeConnections = 0; } - @Override - public int getActiveConnections() { - return activeConnections; - } - - @Override - public Map getAttributes() { - return Collections.emptyMap(); - } - - @Override - public void setAttributes(Map attributes) { - // Do nothing - there are no attributes - } - - @Override - public GuacamoleTunnel connect(GuacamoleClientInformation info) - throws GuacamoleException { - - // Retrieve proxy configuration from environment - Environment environment = new LocalEnvironment(); - GuacamoleProxyConfiguration proxyConfig = environment.getDefaultGuacamoleProxyConfiguration(); - - // Get guacd connection parameters - String hostname = proxyConfig.getHostname(); - int port = proxyConfig.getPort(); - - GuacamoleSocket socket; - - // Determine socket type based on required encryption method - switch (proxyConfig.getEncryptionMethod()) { - - // If guacd requires SSL, use it - case SSL: - socket = new ConfiguredGuacamoleSocket( - new SSLGuacamoleSocket(hostname, port), - config, info - ); - break; - - // Connect directly via TCP if encryption is not enabled - case NONE: - socket = new ConfiguredGuacamoleSocket( - new InetGuacamoleSocket(hostname, port), - config, info - ); - break; - - // Abort if encryption method is unknown - default: - throw new GuacamoleServerException("Unimplemented encryption method."); - - } - - return new SimpleGuacamoleTunnel(socket); - - } - - @Override - public List getHistory() throws GuacamoleException { - return Collections.emptyList(); - } - - @Override - public Date getLastActive() { - return null; - } - } From 8fa0cea7936a5740cebf464902f8445dc30120c4 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 18 Mar 2018 20:42:37 -0400 Subject: [PATCH 18/61] GUACAMOLE-38: Make connection ID incrementing thread-safe. --- .../auth/quickconnect/QuickConnectDirectory.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index 00c50443e..2e198709b 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -20,6 +20,7 @@ package org.apache.guacamole.auth.quickconnect; import java.util.Collection; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.auth.quickconnect.utility.QCParser; import org.apache.guacamole.net.auth.ConnectionGroup; @@ -46,7 +47,7 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { /** * The internal counter for connection IDs. */ - private int CONNECTION_ID = 0; + private AtomicInteger connectionId; /** * Creates a new QuickConnectDirectory which provides access to the @@ -61,6 +62,7 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { public QuickConnectDirectory(Collection connections, ConnectionGroup rootGroup) { super(connections); this.rootGroup = (QuickConnectConnectionGroup)rootGroup; + this.connectionId = new AtomicInteger(); } /** @@ -70,8 +72,8 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { * An Integer representing the next available connection * ID to get used when adding connections. */ - private Integer getNextConnectionID() { - return CONNECTION_ID++; + private int getNextConnectionID() { + return connectionId.getAndIncrement(); } @Override @@ -99,7 +101,7 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { public String put(QuickConnection connection) throws GuacamoleException { // Get the next connection ID. - String connectionId = getNextConnectionID().toString(); + String connectionId = Integer.toString(getNextConnectionID()); // Set up identifier and parent on object. connection.setIdentifier(connectionId); @@ -132,7 +134,7 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { public String create(GuacamoleConfiguration config) throws GuacamoleException { // Get the next connection ID - String connectionId = getNextConnectionID().toString(); + String connectionId = Integer.toString(getNextConnectionID()); // Generate a name for the configuration String name = QCParser.getName(config); From 6c71f4ddb3b7863864f1081b178acccbb7e9fe0d Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 24 Mar 2018 20:37:19 -0400 Subject: [PATCH 19/61] GUACAMOLE-38: Brush up comments and removed some extra code. --- extensions/guacamole-auth-quickconnect/pom.xml | 7 ++++--- .../QuickConnectAuthenticationProvider.java | 4 ---- .../guacamole/auth/quickconnect/utility/QCParser.java | 11 ++++++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/pom.xml b/extensions/guacamole-auth-quickconnect/pom.xml index 87ee7bd7a..717f42c96 100644 --- a/extensions/guacamole-auth-quickconnect/pom.xml +++ b/extensions/guacamole-auth-quickconnect/pom.xml @@ -187,9 +187,10 @@ - com.sun.jersey - jersey-server - 1.17.1 + javax.ws.rs + jsr311-api + 1.1.1 + provided diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java index f725bdfce..c8097094a 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -63,10 +63,6 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv public AuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException { - String username = credentials.getUsername(); - if (username == null || username.isEmpty()) - throw new GuacamoleInvalidCredentialsException("You must login.", CredentialsInfo.USERNAME_PASSWORD); - return null; } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 05b892fcc..3de9e80c4 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -27,10 +27,15 @@ import org.apache.guacamole.GuacamoleClientException; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.protocol.GuacamoleConfiguration; +/** + * A utility class to parse out a URI into the settings necessary + * to create and establish a Guacamole connection. + */ public class QCParser { /** - * The default protocol to parse to if one is undefined. + * The default protocol to parse to if one is provided in + * the incoming URI.. */ public static final String DEFAULT_URI_PROTOCOL = "ssh"; @@ -71,7 +76,7 @@ public class QCParser { } String protocol = qcUri.getScheme(); String host = qcUri.getHost(); - Integer port = qcUri.getPort(); + int port = qcUri.getPort(); String userInfo = qcUri.getUserInfo(); String query = qcUri.getQuery(); String username = null; @@ -101,7 +106,7 @@ public class QCParser { GuacamoleConfiguration qcConfig = new GuacamoleConfiguration(); qcConfig.setProtocol(protocol); qcConfig.setParameter("hostname",host); - qcConfig.setParameter("port", port.toString()); + qcConfig.setParameter("port", Integer.toString(port)); if (username != null) qcConfig.setParameter("username", username); From 5c96cd63267abf184d9a689f694f0a1e4da453d5 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 24 Mar 2018 20:44:02 -0400 Subject: [PATCH 20/61] GUACAMOLE-38: Leave default port to individual protocols. --- .../auth/quickconnect/utility/QCParser.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 3de9e80c4..30121df46 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -44,11 +44,6 @@ public class QCParser { */ public static final String DEFAULT_URI_HOST = "localhost"; - /** - * The default port to use if one is not defined. - */ - public static final Integer DEFAULT_URI_PORT = 22; - /** * Parse out a URI string and get a connection from that string, * or an exception if the parsing fails. @@ -89,9 +84,6 @@ public class QCParser { if (host == null || host.equals("")) host = DEFAULT_URI_HOST; - if (port == -1 || port < 1) - port = DEFAULT_URI_PORT; - if (query != null && !query.equals("")) paramList = Arrays.asList(query.split("&")); @@ -106,7 +98,9 @@ public class QCParser { GuacamoleConfiguration qcConfig = new GuacamoleConfiguration(); qcConfig.setProtocol(protocol); qcConfig.setParameter("hostname",host); - qcConfig.setParameter("port", Integer.toString(port)); + + if (port > 0) + qcConfig.setParameter("port", Integer.toString(port)); if (username != null) qcConfig.setParameter("username", username); From fb5d2723bcc7cad1585736e644e367d802082d29 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 24 Mar 2018 21:58:19 -0400 Subject: [PATCH 21/61] GUACAMOLE-38: Implement the AuthenticationProvider instead of extending another. --- .../QuickConnectAuthenticationProvider.java | 59 +++++++++++++++---- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java index c8097094a..d638ff847 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -23,10 +23,10 @@ import java.util.Collections; import java.util.Map; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.net.auth.AuthenticatedUser; +import org.apache.guacamole.net.auth.AuthenticationProvider; import org.apache.guacamole.net.auth.Credentials; import org.apache.guacamole.net.auth.credentials.CredentialsInfo; import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException; -import org.apache.guacamole.net.auth.simple.SimpleAuthenticationProvider; import org.apache.guacamole.net.auth.UserContext; import org.apache.guacamole.protocol.GuacamoleConfiguration; @@ -35,7 +35,7 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration; * process so that the QuickConnect functionality can be initialized and be used * throughout the web client. */ -public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProvider { +public class QuickConnectAuthenticationProvider implements AuthenticationProvider { /** * userContext for this authentication provider. @@ -47,6 +47,11 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv return "quickconnect"; } + @Override + public Object getResource() throws GuacamoleException { + return null; + } + /** * For QuickConnect, authenticateUser simply returns null because this * extension is designed to provide only a connection directory to users @@ -67,15 +72,6 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv } - @Override - public Map - getAuthorizedConfigurations(Credentials credentials) - throws GuacamoleException { - - return Collections.emptyMap(); - - } - @Override public UserContext getUserContext(AuthenticatedUser authenticatedUser) throws GuacamoleException { @@ -84,4 +80,45 @@ public class QuickConnectAuthenticationProvider extends SimpleAuthenticationProv } + @Override + public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser, + Credentials credentials) throws GuacamoleException { + + // Simply return the given user, updating nothing + return authenticatedUser; + + } + + @Override + public UserContext updateUserContext(UserContext context, + AuthenticatedUser authorizedUser, Credentials credentials) + throws GuacamoleException { + + // Simply return the given context, updating nothing + return context; + + } + + @Override + public UserContext decorate(UserContext context, + AuthenticatedUser authenticatedUser, Credentials credentials) + throws GuacamoleException { + + // Simply return the given context, decorating nothing + return context; + + } + + @Override + public UserContext redecorate(UserContext decorated, UserContext context, + AuthenticatedUser authenticatedUser, Credentials credentials) + throws GuacamoleException { + return decorate(context, authenticatedUser, credentials); + } + + @Override + public void shutdown() { + // Nothing to do, here. + } + } From add78b9cdb29ecf6469dce303a7d9974a3a7e677 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 24 Mar 2018 22:02:03 -0400 Subject: [PATCH 22/61] GUACAMOLE-38: Remove unnecessary style element. --- .../src/main/resources/styles/quickconnect.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css b/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css index 49a407b2a..ee0c2f59e 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css @@ -38,10 +38,6 @@ box-sizing: border-box; } -.quickconnect-field input[type="submit"] { - display: none !important; -} - .quickconnect-button { clear: both; float: right; From 8ed356a7f2d96675a8751cc87c0e5ec06f3c8653 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 24 Mar 2018 22:06:21 -0400 Subject: [PATCH 23/61] GUACAMOLE-38: Remove unnecessary null check. --- .../guacamole/auth/quickconnect/rest/QuickConnectREST.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java index 42e53a2f8..aef5ca357 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java @@ -91,9 +91,6 @@ public class QuickConnectREST { public String create(@FormParam("uri") String uri) throws GuacamoleException { - if (directory == null) - throw new GuacamoleServerException("No connection directory available."); - return directory.create(QCParser.getConfiguration(uri)); } From da363f845e9d20be2d99c9b8355462570f0df7f9 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 24 Mar 2018 22:11:24 -0400 Subject: [PATCH 24/61] GUACAMOLE-38: Make class public for consistency with other classes. --- .../auth/quickconnect/QuickConnectConnectionGroup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java index 4faab1cc6..2f37e080c 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java @@ -35,7 +35,7 @@ import org.apache.guacamole.protocol.GuacamoleClientInformation; * for temporarily storing the QuickConnections created by * users. */ -class QuickConnectConnectionGroup extends AbstractConnectionGroup { +public class QuickConnectConnectionGroup extends AbstractConnectionGroup { /** * The connection identifiers for this group. From c50d372517167d2ed9e9386fba0807c99622b777 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 24 Mar 2018 22:18:01 -0400 Subject: [PATCH 25/61] GUACAMOLE-38: Make placeholder translatable. --- .../src/main/resources/templates/quickconnectField.html | 2 +- .../src/main/resources/translations/en.json | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html index d9b5a4d24..114f59a9e 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html @@ -2,7 +2,7 @@
- +
diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json b/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json index b080d4b0b..1f7bb3dcf 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json @@ -2,6 +2,10 @@ "DATA_SOURCE_QUICKCONNECT" : { "NAME" : "QuickConnect" + }, + + "QUICKCONNECT" : { + "FIELD_PLACEHOLDER_URI" : "Enter Connection URI" } } From 9ab50a239c818a21f3a39ddeb84576939d721fb3 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 24 Mar 2018 22:34:56 -0400 Subject: [PATCH 26/61] GUACAMOLE-38: Avoid unnuecessary type-casting. --- .../guacamole/auth/quickconnect/QuickConnectUserContext.java | 4 ++-- .../guacamole/auth/quickconnect/rest/QuickConnectREST.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index d9eb3895b..06ef630d7 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -80,7 +80,7 @@ public class QuickConnectUserContext implements UserContext { * The Directory with access to all connections within the root group * associated with this UserContext. */ - private final Directory connectionDirectory; + private final QuickConnectDirectory connectionDirectory; /** * The root connection group. @@ -157,7 +157,7 @@ public class QuickConnectUserContext implements UserContext { } @Override - public Directory getConnectionDirectory() + public QuickConnectDirectory getConnectionDirectory() throws GuacamoleException { return connectionDirectory; } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java index aef5ca357..d11bd064b 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java @@ -69,7 +69,7 @@ public class QuickConnectREST { public QuickConnectREST(QuickConnectUserContext userContext) throws GuacamoleException { this.userContext = userContext; - this.directory = (QuickConnectDirectory)this.userContext.getConnectionDirectory(); + this.directory = this.userContext.getConnectionDirectory(); } /** From 16130b32fef8a26a54af2d02015bf843a1b6266e Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 25 Mar 2018 09:09:34 -0400 Subject: [PATCH 27/61] GUACAMOLE-38: Switch to regex for parsing username and password. --- .../auth/quickconnect/utility/QCParser.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 30121df46..6bd043517 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -23,6 +23,8 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.Arrays; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.guacamole.GuacamoleClientException; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.protocol.GuacamoleConfiguration; @@ -44,6 +46,21 @@ public class QCParser { */ public static final String DEFAULT_URI_HOST = "localhost"; + /** + * The regex to use to split username and password. + */ + private static final Pattern userinfoPattern = Pattern.compile("(^[^:]+):(.*)"); + + /** + * The regex group of the username. + */ + private static final int USERNAME_GROUP = 1; + + /** + * THe regex group of the password. + */ + private static final int PASSWORD_GROUP = 2; + /** * Parse out a URI string and get a connection from that string, * or an exception if the parsing fails. @@ -88,11 +105,11 @@ public class QCParser { paramList = Arrays.asList(query.split("&")); if (userInfo != null && !userInfo.equals("")) { - String[] authenticators = userInfo.split(":"); - if (authenticators.length > 0 && authenticators[0] != null) - username = authenticators[0]; - if (authenticators.length > 1 && authenticators[1] != null) - password = authenticators[1]; + + Matcher userinfoMatcher = userinfoPattern.matcher(userInfo); + username = userinfoMatcher.group(USERNAME_GROUP); + password = userinfoMatcher.group(PASSWORD_GROUP); + } GuacamoleConfiguration qcConfig = new GuacamoleConfiguration(); @@ -102,10 +119,10 @@ public class QCParser { if (port > 0) qcConfig.setParameter("port", Integer.toString(port)); - if (username != null) + if (username != null && username.length() > 0) qcConfig.setParameter("username", username); - if (password != null) + if (password != null && password.length() > 0) qcConfig.setParameter("password", password); if (paramList != null) { From 43919e56239bfad26908d4eb257b459fe5818121 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 25 Mar 2018 15:02:16 -0400 Subject: [PATCH 28/61] GUACAMOLE-38: Tweak to regex and correct behavior of matcher. --- .../guacamole/auth/quickconnect/utility/QCParser.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 6bd043517..d67d7efc3 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -49,7 +49,7 @@ public class QCParser { /** * The regex to use to split username and password. */ - private static final Pattern userinfoPattern = Pattern.compile("(^[^:]+):(.*)"); + private static final Pattern userinfoPattern = Pattern.compile("(^[^:]+):?(.*)"); /** * The regex group of the username. @@ -107,8 +107,10 @@ public class QCParser { if (userInfo != null && !userInfo.equals("")) { Matcher userinfoMatcher = userinfoPattern.matcher(userInfo); - username = userinfoMatcher.group(USERNAME_GROUP); - password = userinfoMatcher.group(PASSWORD_GROUP); + if (userinfoMatcher.matches()) { + username = userinfoMatcher.group(USERNAME_GROUP); + password = userinfoMatcher.group(PASSWORD_GROUP); + } } From 3feb2c2de1d1d1af96e422b2050e85cb499c39ef Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 14 Apr 2018 11:22:40 -0400 Subject: [PATCH 29/61] GUACAMOLE-38: Use newly-implemented AbstractuserContext and AbstractAuthenticationProvider classes, remove deprecated classes. --- .../QuickConnectAuthenticationProvider.java | 70 +--------------- .../quickconnect/QuickConnectDirectory.java | 71 +++++----------- .../quickconnect/QuickConnectUserContext.java | 81 +++---------------- 3 files changed, 34 insertions(+), 188 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java index d638ff847..6e6f2bcf9 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -23,7 +23,7 @@ import java.util.Collections; import java.util.Map; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.net.auth.AuthenticatedUser; -import org.apache.guacamole.net.auth.AuthenticationProvider; +import org.apache.guacamole.net.auth.AbstractAuthenticationProvider; import org.apache.guacamole.net.auth.Credentials; import org.apache.guacamole.net.auth.credentials.CredentialsInfo; import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException; @@ -35,7 +35,7 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration; * process so that the QuickConnect functionality can be initialized and be used * throughout the web client. */ -public class QuickConnectAuthenticationProvider implements AuthenticationProvider { +public class QuickConnectAuthenticationProvider extends AbstractAuthenticationProvider { /** * userContext for this authentication provider. @@ -47,31 +47,6 @@ public class QuickConnectAuthenticationProvider implements AuthenticationProvide return "quickconnect"; } - @Override - public Object getResource() throws GuacamoleException { - return null; - } - - /** - * For QuickConnect, authenticateUser simply returns null because this - * extension is designed to provide only a connection directory to users - * that are already authenticated and not any actual authentication. - * - * @param credentials - * Credentials object passed in from Guacamole login. - * - * @return - * Returns null, which causes the client to move on to the next - * module. - */ - @Override - public AuthenticatedUser authenticateUser(Credentials credentials) - throws GuacamoleException { - - return null; - - } - @Override public UserContext getUserContext(AuthenticatedUser authenticatedUser) throws GuacamoleException { @@ -80,45 +55,4 @@ public class QuickConnectAuthenticationProvider implements AuthenticationProvide } - @Override - public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser, - Credentials credentials) throws GuacamoleException { - - // Simply return the given user, updating nothing - return authenticatedUser; - - } - - @Override - public UserContext updateUserContext(UserContext context, - AuthenticatedUser authorizedUser, Credentials credentials) - throws GuacamoleException { - - // Simply return the given context, updating nothing - return context; - - } - - @Override - public UserContext decorate(UserContext context, - AuthenticatedUser authenticatedUser, Credentials credentials) - throws GuacamoleException { - - // Simply return the given context, decorating nothing - return context; - - } - - @Override - public UserContext redecorate(UserContext decorated, UserContext context, - AuthenticatedUser authenticatedUser, Credentials credentials) - throws GuacamoleException { - return decorate(context, authenticatedUser, credentials); - } - - @Override - public void shutdown() { - // Nothing to do, here. - } - } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index 2e198709b..d17c25b7b 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -19,12 +19,13 @@ package org.apache.guacamole.auth.quickconnect; -import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.auth.quickconnect.utility.QCParser; import org.apache.guacamole.net.auth.ConnectionGroup; -import org.apache.guacamole.net.auth.simple.SimpleConnectionDirectory; +import org.apache.guacamole.net.auth.simple.SimpleDirectory; import org.apache.guacamole.net.auth.Connection; import org.apache.guacamole.protocol.GuacamoleConfiguration; @@ -32,13 +33,19 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration; * Implementation of the Connection Directory, stored * completely in-memory. */ -public class QuickConnectDirectory extends SimpleConnectionDirectory { +public class QuickConnectDirectory extends SimpleDirectory { /** * The unique identifier of the root connection group. */ private static final String ROOT_IDENTIFIER = "ROOT"; + /** + * The connections to store. + */ + private final Map connections = + new HashMap(); + /** * The root connection group for this directory. */ @@ -54,15 +61,15 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { * connections contained within the given Map. * * @param connections - * A Collection of all connections that should be present in this + * A Map of all connections that should be present in this * connection directory. * @param rootGroup * A group that should be at the base of this directory. */ - public QuickConnectDirectory(Collection connections, ConnectionGroup rootGroup) { - super(connections); + public QuickConnectDirectory(ConnectionGroup rootGroup) { this.rootGroup = (QuickConnectConnectionGroup)rootGroup; this.connectionId = new AtomicInteger(); + super.setObjects(this.connections); } /** @@ -77,56 +84,21 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { } @Override - public void add(Connection object) throws GuacamoleException { - - put(new QuickConnection(object)); - - } - - /** - * Create a connection object on the tree using an existing - * QuickConnection connection, after setting the identifier - * and parent object. - * - * @param connection - * The QuickConnection object to add to the tree. - * - * @return - * The connectionId of the object added to the directory. - * - * @throws GuacamoleException - * If an error is encountered adding the object to the - * directory. - */ - public String put(QuickConnection connection) throws GuacamoleException { - - // Get the next connection ID. - String connectionId = Integer.toString(getNextConnectionID()); - - // Set up identifier and parent on object. - connection.setIdentifier(connectionId); - connection.setParentIdentifier(ROOT_IDENTIFIER); - - // Add connection to the directory - putConnection(connection); - - // Add connection to the tree - this.rootGroup.addConnectionIdentifier(connectionId); - - return connectionId; - + public void add(Connection connection) throws GuacamoleException { + connections.put(connection.getIdentifier(), connection); } /** * Create a QuickConnection object from a GuacamoleConfiguration - * and get an ID and place it on the tree. + * and get an ID and place it on the tree, returning the new + * connection identifier value. * * @param config * The GuacamoleConfiguration to use to create the * QuickConnection object. * * @return - * The connectionId of the object creation in the directory. + * The identifier of the connection created in the directory. * * @throws GuacamoleException * If an error occurs adding the object to the tree. @@ -144,7 +116,7 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { connection.setParentIdentifier(ROOT_IDENTIFIER); // Place the object in directory - putConnection(connection); + add(connection); // Add connection to the tree. this.rootGroup.addConnectionIdentifier(connectionId); @@ -152,9 +124,4 @@ public class QuickConnectDirectory extends SimpleConnectionDirectory { return connectionId; } - @Override - public void update(Connection object) throws GuacamoleException { - putConnection(object); - } - } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index 06ef630d7..60f6ded22 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -24,6 +24,7 @@ import java.util.Collections; import org.apache.guacamole.auth.quickconnect.rest.QuickConnectREST; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.form.Form; +import org.apache.guacamole.net.auth.AbstractUserContext; import org.apache.guacamole.net.auth.ActiveConnection; import org.apache.guacamole.net.auth.ActivityRecord; import org.apache.guacamole.net.auth.ActivityRecordSet; @@ -36,22 +37,15 @@ import org.apache.guacamole.net.auth.SharingProfile; import org.apache.guacamole.net.auth.User; import org.apache.guacamole.net.auth.UserContext; import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet; -import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory; import org.apache.guacamole.net.auth.simple.SimpleDirectory; import org.apache.guacamole.net.auth.simple.SimpleUser; -import org.apache.guacamole.net.auth.simple.SimpleUserDirectory; /** * A simple implementation of UserContext to support the QuickConnect * extension, primarily used for storing connections the user has * created using the QuickConnect bar in the webapp. */ -public class QuickConnectUserContext implements UserContext { - - /** - * The unique identifier of the root connection group. - */ - public static final String ROOT_IDENTIFIER = "ROOT"; +public class QuickConnectUserContext extends AbstractUserContext { /** * The AuthenticationProvider that created this UserContext. @@ -104,26 +98,32 @@ public class QuickConnectUserContext implements UserContext { // Initialize the rootGroup to a basic connection group with a // single root identifier. this.rootGroup = new QuickConnectConnectionGroup( - ROOT_IDENTIFIER, ROOT_IDENTIFIER + DEFAULT_ROOT_CONNECTION_GROUP, + DEFAULT_ROOT_CONNECTION_GROUP ); // Initialize the user to a SimpleUser with the username, no // preexisting connections, and the single root group. this.self = new SimpleUser(username, Collections.emptyList(), - Collections.singleton(ROOT_IDENTIFIER) + Collections.singleton(DEFAULT_ROOT_CONNECTION_GROUP) ); // Initialize each of the directories associated with the userContext. - this.userDirectory = new SimpleUserDirectory(self); - this.connectionDirectory = new QuickConnectDirectory(Collections.emptyList(), this.rootGroup); - this.connectionGroupDirectory = new SimpleConnectionGroupDirectory(Collections.singleton(this.rootGroup)); + this.userDirectory = new SimpleDirectory(self); + this.connectionDirectory = new QuickConnectDirectory(this.rootGroup); + this.connectionGroupDirectory = new SimpleDirectory(Collections.singleton(this.rootGroup)); // Set the authProvider to the calling authProvider object. this.authProvider = authProvider; } + @Override + public QuickConnectDirectory getConnectionDirectory() { + return connectionDirectory; + } + @Override public User self() { return self; @@ -134,11 +134,6 @@ public class QuickConnectUserContext implements UserContext { return new QuickConnectREST(this); } - @Override - public void invalidate() { - // Do nothing. - } - @Override public AuthenticationProvider getAuthenticationProvider() { return authProvider; @@ -150,18 +145,6 @@ public class QuickConnectUserContext implements UserContext { return userDirectory; } - @Override - public ActivityRecordSet getUserHistory() - throws GuacamoleException { - return new SimpleActivityRecordSet(); - } - - @Override - public QuickConnectDirectory getConnectionDirectory() - throws GuacamoleException { - return connectionDirectory; - } - @Override public Directory getConnectionGroupDirectory() throws GuacamoleException { @@ -173,42 +156,4 @@ public class QuickConnectUserContext implements UserContext { return rootGroup; } - @Override - public Directory getSharingProfileDirectory() - throws GuacamoleException { - return new SimpleDirectory(); - } - - @Override - public Directory getActiveConnectionDirectory() - throws GuacamoleException { - return new SimpleDirectory(); - } - - @Override - public ActivityRecordSet getConnectionHistory() - throws GuacamoleException { - return new SimpleActivityRecordSet(); - } - - @Override - public Collection
getUserAttributes() { - return Collections.emptyList(); - } - - @Override - public Collection getConnectionAttributes() { - return Collections.emptyList(); - } - - @Override - public Collection getConnectionGroupAttributes() { - return Collections.emptyList(); - } - - @Override - public Collection getSharingProfileAttributes() { - return Collections.emptyList(); - } - } From d608643bb6c890d91edfac5fb70838c264180dde Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 15 Apr 2018 22:44:46 -0400 Subject: [PATCH 30/61] GUACAMOLE-38: Remove lots of extra imports. --- .../QuickConnectAuthenticationProvider.java | 6 ------ .../quickconnect/QuickConnectUserContext.java | 10 ---------- .../auth/quickconnect/QuickConnection.java | 17 ----------------- .../quickconnect/rest/QuickConnectREST.java | 9 --------- 4 files changed, 42 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java index 6e6f2bcf9..66c42e7d5 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -19,16 +19,10 @@ package org.apache.guacamole.auth.quickconnect; -import java.util.Collections; -import java.util.Map; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.net.auth.AuthenticatedUser; import org.apache.guacamole.net.auth.AbstractAuthenticationProvider; -import org.apache.guacamole.net.auth.Credentials; -import org.apache.guacamole.net.auth.credentials.CredentialsInfo; -import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException; import org.apache.guacamole.net.auth.UserContext; -import org.apache.guacamole.protocol.GuacamoleConfiguration; /** * Class providing the necessary hooks into the Guacamole Client authentication diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index 60f6ded22..60a05e53a 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -19,24 +19,14 @@ package org.apache.guacamole.auth.quickconnect; -import java.util.Collection; import java.util.Collections; import org.apache.guacamole.auth.quickconnect.rest.QuickConnectREST; import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.form.Form; import org.apache.guacamole.net.auth.AbstractUserContext; -import org.apache.guacamole.net.auth.ActiveConnection; -import org.apache.guacamole.net.auth.ActivityRecord; -import org.apache.guacamole.net.auth.ActivityRecordSet; import org.apache.guacamole.net.auth.AuthenticationProvider; -import org.apache.guacamole.net.auth.Connection; import org.apache.guacamole.net.auth.ConnectionGroup; -import org.apache.guacamole.net.auth.ConnectionRecord; import org.apache.guacamole.net.auth.Directory; -import org.apache.guacamole.net.auth.SharingProfile; import org.apache.guacamole.net.auth.User; -import org.apache.guacamole.net.auth.UserContext; -import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet; import org.apache.guacamole.net.auth.simple.SimpleDirectory; import org.apache.guacamole.net.auth.simple.SimpleUser; diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java index 2603f176e..37358493c 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java @@ -19,26 +19,9 @@ package org.apache.guacamole.auth.quickconnect; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.GuacamoleServerException; -import org.apache.guacamole.environment.Environment; -import org.apache.guacamole.environment.LocalEnvironment; -import org.apache.guacamole.net.GuacamoleSocket; -import org.apache.guacamole.net.GuacamoleTunnel; -import org.apache.guacamole.net.InetGuacamoleSocket; -import org.apache.guacamole.net.SSLGuacamoleSocket; -import org.apache.guacamole.net.SimpleGuacamoleTunnel; -import org.apache.guacamole.net.auth.AbstractConnection; import org.apache.guacamole.net.auth.Connection; -import org.apache.guacamole.net.auth.ConnectionRecord; -import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration; import org.apache.guacamole.net.auth.simple.SimpleConnection; -import org.apache.guacamole.protocol.ConfiguredGuacamoleSocket; -import org.apache.guacamole.protocol.GuacamoleClientInformation; import org.apache.guacamole.protocol.GuacamoleConfiguration; /** diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java index d11bd064b..48dec4c63 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java @@ -19,24 +19,15 @@ package org.apache.guacamole.auth.quickconnect.rest; -import com.google.inject.Inject; -import java.util.List; -import javax.ws.rs.Consumes; import javax.ws.rs.FormParam; -import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.POST; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.GuacamoleServerException; -import org.apache.guacamole.protocol.GuacamoleConfiguration; -import org.apache.guacamole.auth.quickconnect.QuickConnection; import org.apache.guacamole.auth.quickconnect.QuickConnectDirectory; import org.apache.guacamole.auth.quickconnect.QuickConnectUserContext; import org.apache.guacamole.auth.quickconnect.utility.QCParser; -import org.apache.guacamole.net.auth.Connection; -import org.apache.guacamole.net.auth.Directory; /** * A class to create and manage REST endpoints for the From bb127c55d2226651622c9bb2b6e1b6fb623bec46 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 15 Apr 2018 22:58:19 -0400 Subject: [PATCH 31/61] GUACAMOLE-38: Quick fix-up for userContext object in AuthenticationProvider --- .../quickconnect/QuickConnectAuthenticationProvider.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java index 66c42e7d5..522379319 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -45,7 +45,11 @@ public class QuickConnectAuthenticationProvider extends AbstractAuthenticationPr public UserContext getUserContext(AuthenticatedUser authenticatedUser) throws GuacamoleException { - return new QuickConnectUserContext(this, authenticatedUser.getIdentifier()); + if (userContext == null) + userContext = new QuickConnectUserContext(this, + authenticatedUser.getIdentifier()); + + return userContext; } From 12d92d210fb857696e890b8036baebd07ce85090 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 15 Apr 2018 23:07:57 -0400 Subject: [PATCH 32/61] GUACAMOLE-38: Fix parameter name in QuickConnection constructor. --- .../guacamole/auth/quickconnect/QuickConnection.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java index 37358493c..f3be14ed0 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java @@ -70,14 +70,16 @@ public class QuickConnection extends SimpleConnection { * object, copying over the relevant data and initializing * the rest. * - * @param object - * The generic Connection object to be copied. + * @param connection + * The generic Connection to be copied. */ - public QuickConnection(Connection object) { + public QuickConnection(Connection connection) { - super(object.getName(),object.getIdentifier(),object.getConfiguration()); + super(connection.getName(),connection.getIdentifier(), + connection.getConfiguration()); + + setParentIdentifier(connection.getParentIdentifier()); - setParentIdentifier(object.getParentIdentifier()); this.activeConnections = 0; } From 6a922a781139e157cfa7cf5889e6e2f1e688693a Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 17 Apr 2018 17:30:52 -0400 Subject: [PATCH 33/61] GUACAMOLE-38: Minor documentation tweaks. --- extensions/guacamole-auth-quickconnect/src/licenses/NOTICE | 2 +- .../apache/guacamole/auth/quickconnect/utility/QCParser.java | 3 +-- .../src/main/resources/controllers/quickconnectController.js | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/NOTICE b/extensions/guacamole-auth-quickconnect/src/licenses/NOTICE index 47f2b4c24..97e613062 100644 --- a/extensions/guacamole-auth-quickconnect/src/licenses/NOTICE +++ b/extensions/guacamole-auth-quickconnect/src/licenses/NOTICE @@ -1,5 +1,5 @@ Apache Guacamole -Copyright 2017 The Apache Software Foundation +Copyright 2018 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index d67d7efc3..be157dc13 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -148,8 +148,7 @@ public class QCParser { * the name. * * @return - * The String value of the name that is generated, or - * null if no config is provided. + * The String value of the name that is generated. * * @throws GuacamoleException * If an error occurs getting items in the configuration. diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js index 03137303a..640034f6e 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js @@ -43,6 +43,10 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope } }; + /** + * The URI that will be passed in to the extension to create + * the connection. + */ $scope.uri = null; /** From b31b09a2f5b0562cf6ed971660c319a833b735c7 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 17 Apr 2018 21:36:38 -0400 Subject: [PATCH 34/61] GUACAMOLE-38: Get rid of unnecessary userContext initialization. --- .../QuickConnectAuthenticationProvider.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java index 522379319..35fa8b71c 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -31,11 +31,6 @@ import org.apache.guacamole.net.auth.UserContext; */ public class QuickConnectAuthenticationProvider extends AbstractAuthenticationProvider { - /** - * userContext for this authentication provider. - */ - private UserContext userContext; - @Override public String getIdentifier() { return "quickconnect"; @@ -45,11 +40,8 @@ public class QuickConnectAuthenticationProvider extends AbstractAuthenticationPr public UserContext getUserContext(AuthenticatedUser authenticatedUser) throws GuacamoleException { - if (userContext == null) - userContext = new QuickConnectUserContext(this, - authenticatedUser.getIdentifier()); - - return userContext; + return new QuickConnectUserContext(this, + authenticatedUser.getIdentifier()); } From c994c5a9b429d6acec40d7f894b0a6a5749c50bd Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 17 Apr 2018 21:44:11 -0400 Subject: [PATCH 35/61] GUACAMOLE-38: Remove unnecessary GUICE/Inject stuff. --- .../guacamole-auth-quickconnect/pom.xml | 12 -- .../src/licenses/LICENSE | 18 -- .../src/licenses/bundled/guice-3.0/COPYING | 202 ------------------ .../bundled/javax.inject-1/LICENSE-2.0.txt | 202 ------------------ ...ckConnectAuthenticationProviderModule.java | 81 ------- 5 files changed, 515 deletions(-) delete mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/bundled/guice-3.0/COPYING delete mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/bundled/javax.inject-1/LICENSE-2.0.txt delete mode 100644 extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java diff --git a/extensions/guacamole-auth-quickconnect/pom.xml b/extensions/guacamole-auth-quickconnect/pom.xml index 717f42c96..e8d044072 100644 --- a/extensions/guacamole-auth-quickconnect/pom.xml +++ b/extensions/guacamole-auth-quickconnect/pom.xml @@ -193,18 +193,6 @@ provided - - - com.google.inject - guice - 3.0 - - - com.google.inject.extensions - guice-multibindings - 3.0 - - diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/LICENSE b/extensions/guacamole-auth-quickconnect/src/licenses/LICENSE index c6cbf77e8..e8788bb5e 100644 --- a/extensions/guacamole-auth-quickconnect/src/licenses/LICENSE +++ b/extensions/guacamole-auth-quickconnect/src/licenses/LICENSE @@ -219,21 +219,3 @@ AOP Alliance (http://aopalliance.sourceforge.net/) License(s): Public Domain (bundled/aopalliance-1.0/LICENSE) - -Google Guice (https://github.com/google/guice) ----------------------------------------------- - - Version: 3.0 - From: 'Google Inc.' (http://www.google.com/) - License(s): - Apache v2.0 (bundled/guice-3.0/COPYING) - - -JSR-330 / Dependency Injection for Java (http://code.google.com/p/atinject/) ----------------------------------------------------------------------------- - - Version: 1 - From: 'JSR-330 Expert Group' (https://jcp.org/en/jsr/detail?id=330) - License(s): - Apache v2.0 (bundled/javax.inject-1/LICENSE-2.0.txt) - diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/guice-3.0/COPYING b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/guice-3.0/COPYING deleted file mode 100644 index d64569567..000000000 --- a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/guice-3.0/COPYING +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/javax.inject-1/LICENSE-2.0.txt b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/javax.inject-1/LICENSE-2.0.txt deleted file mode 100644 index d64569567..000000000 --- a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/javax.inject-1/LICENSE-2.0.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java deleted file mode 100644 index 397de5aa9..000000000 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProviderModule.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.guacamole.auth.quickconnect; - -import com.google.inject.AbstractModule; -import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.environment.Environment; -import org.apache.guacamole.environment.LocalEnvironment; -import org.apache.guacamole.net.auth.AuthenticationProvider; - -/** - * Guice module to do QuickConnect injections. - */ -public class QuickConnectAuthenticationProviderModule extends AbstractModule { - - /** - * Guacamole server environment. - */ - private final Environment environment; - - /** - * QuickConnect authentication provider. - */ - private final AuthenticationProvider authProvider; - - /** - * Create a new instance of the authentication provider module - * which configures injection for the QuickConnectAuthenticationProvider - * class. - * - * @param authProvider - * The authentication provider for which injection is being - * configured. - * - * @throws GuacamoleException - * If an error occurs while retrieving the server environment. - */ - public QuickConnectAuthenticationProviderModule(AuthenticationProvider authProvider) - throws GuacamoleException { - - // Create a new local environment - this.environment = new LocalEnvironment(); - - // Initialize authProvider - this.authProvider = authProvider; - - } - - @Override - protected void configure() { - - // Bind core implementations of guacamole-ext classes - bind(AuthenticationProvider.class).toInstance(authProvider); - bind(Environment.class).toInstance(environment); - - // Bind QuickConnect-specific classes; - bind(QuickConnectConnectionGroup.class); - bind(QuickConnectDirectory.class); - bind(QuickConnectUserContext.class); - bind(QuickConnection.class); - - } - -} From 0cbf90a55df8c14eb80391bb97c831f5bb910e71 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 17 Apr 2018 22:10:25 -0400 Subject: [PATCH 36/61] GUACAMOLE-38: Clean up lots of unnecessary code. --- .../quickconnect/QuickConnectDirectory.java | 11 +-- .../quickconnect/QuickConnectUserContext.java | 15 +--- .../auth/quickconnect/QuickConnection.java | 87 ------------------- ...onGroup.java => QuickConnectionGroup.java} | 10 +-- 4 files changed, 12 insertions(+), 111 deletions(-) delete mode 100644 extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java rename extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/{QuickConnectConnectionGroup.java => QuickConnectionGroup.java} (90%) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index d17c25b7b..a321f871a 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.auth.quickconnect.utility.QCParser; import org.apache.guacamole.net.auth.ConnectionGroup; +import org.apache.guacamole.net.auth.simple.SimpleConnection; import org.apache.guacamole.net.auth.simple.SimpleDirectory; import org.apache.guacamole.net.auth.Connection; import org.apache.guacamole.protocol.GuacamoleConfiguration; @@ -49,7 +50,7 @@ public class QuickConnectDirectory extends SimpleDirectory { /** * The root connection group for this directory. */ - private final QuickConnectConnectionGroup rootGroup; + private final QuickConnectionGroup rootGroup; /** * The internal counter for connection IDs. @@ -67,7 +68,7 @@ public class QuickConnectDirectory extends SimpleDirectory { * A group that should be at the base of this directory. */ public QuickConnectDirectory(ConnectionGroup rootGroup) { - this.rootGroup = (QuickConnectConnectionGroup)rootGroup; + this.rootGroup = (QuickConnectionGroup)rootGroup; this.connectionId = new AtomicInteger(); super.setObjects(this.connections); } @@ -89,13 +90,13 @@ public class QuickConnectDirectory extends SimpleDirectory { } /** - * Create a QuickConnection object from a GuacamoleConfiguration + * Create a SimpleConnection object from a GuacamoleConfiguration * and get an ID and place it on the tree, returning the new * connection identifier value. * * @param config * The GuacamoleConfiguration to use to create the - * QuickConnection object. + * SimpleConnection object. * * @return * The identifier of the connection created in the directory. @@ -112,7 +113,7 @@ public class QuickConnectDirectory extends SimpleDirectory { String name = QCParser.getName(config); // Create a new connection and set parent identifier. - Connection connection = new QuickConnection(name, connectionId, config); + Connection connection = new SimpleConnection(name, connectionId, config); connection.setParentIdentifier(ROOT_IDENTIFIER); // Place the object in directory diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index 60a05e53a..438265977 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -54,12 +54,6 @@ public class QuickConnectUserContext extends AbstractUserContext { */ private final Directory userDirectory; - /** - * The Directory with access only to the root group associated with this - * UserContext. - */ - private final Directory connectionGroupDirectory; - /** * The Directory with access to all connections within the root group * associated with this UserContext. @@ -87,7 +81,7 @@ public class QuickConnectUserContext extends AbstractUserContext { // Initialize the rootGroup to a basic connection group with a // single root identifier. - this.rootGroup = new QuickConnectConnectionGroup( + this.rootGroup = new QuickConnectionGroup( DEFAULT_ROOT_CONNECTION_GROUP, DEFAULT_ROOT_CONNECTION_GROUP ); @@ -102,7 +96,6 @@ public class QuickConnectUserContext extends AbstractUserContext { // Initialize each of the directories associated with the userContext. this.userDirectory = new SimpleDirectory(self); this.connectionDirectory = new QuickConnectDirectory(this.rootGroup); - this.connectionGroupDirectory = new SimpleDirectory(Collections.singleton(this.rootGroup)); // Set the authProvider to the calling authProvider object. this.authProvider = authProvider; @@ -135,12 +128,6 @@ public class QuickConnectUserContext extends AbstractUserContext { return userDirectory; } - @Override - public Directory getConnectionGroupDirectory() - throws GuacamoleException { - return connectionGroupDirectory; - } - @Override public ConnectionGroup getRootConnectionGroup() throws GuacamoleException { return rootGroup; diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java deleted file mode 100644 index f3be14ed0..000000000 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.guacamole.auth.quickconnect; - -import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.net.auth.Connection; -import org.apache.guacamole.net.auth.simple.SimpleConnection; -import org.apache.guacamole.protocol.GuacamoleConfiguration; - -/** - * A type of Connection specific to this authentication extension. - */ -public class QuickConnection extends SimpleConnection { - - /** - * Number of active connections. - */ - private int activeConnections; - - /** - * Empty connection constructor. - */ - public QuickConnection() { - - } - - /** - * Constructor that takes a name, identifier, and GuacamoleConfiguration - * and builds a QuickConnection from it. - * - * @param name - * The name of the connection. - * - * @param identifier - * The unique identifier of this connection within this - * authentication module. - * - * @param config - * The GuacamoleConfiguration object to store in this - * QuickConnection. - */ - public QuickConnection(String name, String identifier, - GuacamoleConfiguration config) { - - super(name, identifier, config); - - this.activeConnections = 0; - - } - - /** - * Constructs a QuickConnection from a generic Connection - * object, copying over the relevant data and initializing - * the rest. - * - * @param connection - * The generic Connection to be copied. - */ - public QuickConnection(Connection connection) { - - super(connection.getName(),connection.getIdentifier(), - connection.getConfiguration()); - - setParentIdentifier(connection.getParentIdentifier()); - - this.activeConnections = 0; - - } - -} diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java similarity index 90% rename from extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java rename to extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java index 2f37e080c..dd3da3fe8 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java @@ -35,7 +35,7 @@ import org.apache.guacamole.protocol.GuacamoleClientInformation; * for temporarily storing the QuickConnections created by * users. */ -public class QuickConnectConnectionGroup extends AbstractConnectionGroup { +public class QuickConnectionGroup extends AbstractConnectionGroup { /** * The connection identifiers for this group. @@ -43,16 +43,16 @@ public class QuickConnectConnectionGroup extends AbstractConnectionGroup { private Set connectionIdentifiers; /** - * Set up a QuickConnectConnectionGroup with a name and identifier, and + * Set up a QuickConnectionGroup with a name and identifier, and * an empty set of child connections. * * @param name - * The name of the QuickConnectConnectionGroup. + * The name of the QuickConnectionGroup. * * @param identifier - * The identifier of the QuickConnectConnectionGroup. + * The identifier of the QuickConnectionGroup. */ - public QuickConnectConnectionGroup(String name, String identifier) { + public QuickConnectionGroup(String name, String identifier) { setName(name); setIdentifier(identifier); From cf241f041e34e64515fe185314af5ade5b716309 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 17 Apr 2018 22:29:46 -0400 Subject: [PATCH 37/61] GUACAMOLE-38: Fix up string checks in QCParser class. --- .../auth/quickconnect/utility/QCParser.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index be157dc13..ba6e3fdfe 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -95,16 +95,16 @@ public class QCParser { String password = null; List paramList = null; - if (protocol == null || protocol.equals("")) + if (protocol == null || protocol.isEmpty()) protocol = DEFAULT_URI_PROTOCOL; - if (host == null || host.equals("")) + if (host == null || host.isEmpty()) host = DEFAULT_URI_HOST; - if (query != null && !query.equals("")) + if (query != null && !query.isEmpty()) paramList = Arrays.asList(query.split("&")); - if (userInfo != null && !userInfo.equals("")) { + if (userInfo != null && !userInfo.isEmpty()) { Matcher userinfoMatcher = userinfoPattern.matcher(userInfo); if (userinfoMatcher.matches()) { @@ -121,15 +121,15 @@ public class QCParser { if (port > 0) qcConfig.setParameter("port", Integer.toString(port)); - if (username != null && username.length() > 0) + if (username != null && !username.isEmpty()) qcConfig.setParameter("username", username); - if (password != null && password.length() > 0) + if (password != null && !password.isEmpty()) qcConfig.setParameter("password", password); if (paramList != null) { for (String parameter : paramList) { - String[] paramArray = parameter.split("="); + String[] paramArray = parameter.split("=", 2); qcConfig.setParameter(paramArray[0],paramArray[1]); } } @@ -166,16 +166,16 @@ public class QCParser { String name = ""; - if (protocol != null && !protocol.equals("")) + if (protocol != null && !protocol.isEmpty()) name += protocol + "://"; - if (user != null && !user.equals("")) + if (user != null && !user.isEmpty()) name += user + "@"; - if (host != null && !host.equals("")) + if (host != null && !host.isEmpty()) name += host; - if (port != null && !port.equals("")) + if (port != null && !port.isEmpty()) name += ":" + port; name += "/"; From d4b7e2b8b608eaa8ad8e5a21eed8cd3bd92964e7 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Thu, 19 Apr 2018 05:30:51 -0400 Subject: [PATCH 38/61] GUACAMOLE-38: Use StringBuilder to gather up name. --- .../auth/quickconnect/utility/QCParser.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index ba6e3fdfe..7d5d7d422 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -19,6 +19,7 @@ package org.apache.guacamole.auth.quickconnect.utility; +import java.lang.StringBuilder; import java.net.URI; import java.net.URISyntaxException; import java.util.Arrays; @@ -164,23 +165,23 @@ public class QCParser { String port = config.getParameter("port"); String user = config.getParameter("username"); - String name = ""; + StringBuilder name = new StringBuilder(""); if (protocol != null && !protocol.isEmpty()) - name += protocol + "://"; + name.append(protocol).append("://"); if (user != null && !user.isEmpty()) - name += user + "@"; + name.append(user).append("@"); if (host != null && !host.isEmpty()) - name += host; + name.append(host); if (port != null && !port.isEmpty()) - name += ":" + port; + name.append(":").append(port); - name += "/"; + name.append("/"); - return name; + return name.toString(); } } From 963593ea27831ae772f39d8f64b3d2d2a3ac5b8f Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Thu, 19 Apr 2018 06:01:37 -0400 Subject: [PATCH 39/61] GUACAMOLE-38: Handle encoded query parameters. --- .../auth/quickconnect/utility/QCParser.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 7d5d7d422..650d56193 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -19,16 +19,21 @@ package org.apache.guacamole.auth.quickconnect.utility; +import java.io.UnsupportedEncodingException; import java.lang.StringBuilder; import java.net.URI; import java.net.URISyntaxException; +import java.net.URLDecoder; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.guacamole.GuacamoleClientException; +import org.apache.guacamole.GuacamoleServerException; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.protocol.GuacamoleConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A utility class to parse out a URI into the settings necessary @@ -36,6 +41,11 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration; */ public class QCParser { + /** + * Logger for this class. + */ + private final static Logger logger = LoggerFactory.getLogger(QCParser.class); + /** * The default protocol to parse to if one is provided in * the incoming URI.. @@ -131,7 +141,14 @@ public class QCParser { if (paramList != null) { for (String parameter : paramList) { String[] paramArray = parameter.split("=", 2); - qcConfig.setParameter(paramArray[0],paramArray[1]); + try { + qcConfig.setParameter(URLDecoder.decode(paramArray[0], "UTF-8"), + URLDecoder.decode(paramArray[1], "UTF-8")); + } + catch (UnsupportedEncodingException e) { + logger.error("Unexpected lack of UTF-8 encoding support."); + throw new GuacamoleServerException("Unexpected lack of UTF-8 encoding support.", e); + } } } From d9751f20d0427379e247af803311081f0dcc27cd Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Thu, 19 Apr 2018 06:29:06 -0400 Subject: [PATCH 40/61] GUACAMOLE-38: REST class only needs directory, not entire userContext object. --- .../quickconnect/QuickConnectUserContext.java | 2 +- .../auth/quickconnect/rest/QuickConnectREST.java | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index 438265977..d2315e514 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -114,7 +114,7 @@ public class QuickConnectUserContext extends AbstractUserContext { @Override public Object getResource() throws GuacamoleException { - return new QuickConnectREST(this); + return new QuickConnectREST(connectionDirectory); } @Override diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java index 48dec4c63..4b0b9fd1e 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java @@ -26,7 +26,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.auth.quickconnect.QuickConnectDirectory; -import org.apache.guacamole.auth.quickconnect.QuickConnectUserContext; import org.apache.guacamole.auth.quickconnect.utility.QCParser; /** @@ -41,26 +40,20 @@ public class QuickConnectREST { */ private QuickConnectDirectory directory; - /** - * The UserContext object for this REST endpoint. - */ - private QuickConnectUserContext userContext; - /** * Construct a new QuickConnectREST class, taking in the UserContext * object that calls this constructor. * - * @param userContext - * The UserContext object associated with this REST endpoint + * @param directory + * The ConnectionDirectory object associated with this REST endpoint * * @throws GuacamoleException * If the UserContext is unavailable or the directory object * cannot be retrieved. */ - public QuickConnectREST(QuickConnectUserContext userContext) + public QuickConnectREST(QuickConnectDirectory directory) throws GuacamoleException { - this.userContext = userContext; - this.directory = this.userContext.getConnectionDirectory(); + this.directory = directory; } /** From 10118450321fde8931f755362589ae532fc5cbed Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Thu, 19 Apr 2018 07:20:51 -0400 Subject: [PATCH 41/61] GUACAMOLE-38: Break query string parsing into its own method. --- .../auth/quickconnect/utility/QCParser.java | 62 ++++++++++++++----- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 650d56193..4924619f0 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -25,7 +25,9 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URLDecoder; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.guacamole.GuacamoleClientException; @@ -104,7 +106,7 @@ public class QCParser { String query = qcUri.getQuery(); String username = null; String password = null; - List paramList = null; + Map queryParams = null; if (protocol == null || protocol.isEmpty()) protocol = DEFAULT_URI_PROTOCOL; @@ -112,8 +114,14 @@ public class QCParser { if (host == null || host.isEmpty()) host = DEFAULT_URI_HOST; - if (query != null && !query.isEmpty()) - paramList = Arrays.asList(query.split("&")); + if (query != null && !query.isEmpty()) { + try { + queryParams = parseQueryString(query); + } + catch (UnsupportedEncodingException e) { + throw new GuacamoleServerException("Unexpected lack of UTF-8 encoding support.", e); + } + } if (userInfo != null && !userInfo.isEmpty()) { @@ -138,24 +146,44 @@ public class QCParser { if (password != null && !password.isEmpty()) qcConfig.setParameter("password", password); - if (paramList != null) { - for (String parameter : paramList) { - String[] paramArray = parameter.split("=", 2); - try { - qcConfig.setParameter(URLDecoder.decode(paramArray[0], "UTF-8"), - URLDecoder.decode(paramArray[1], "UTF-8")); - } - catch (UnsupportedEncodingException e) { - logger.error("Unexpected lack of UTF-8 encoding support."); - throw new GuacamoleServerException("Unexpected lack of UTF-8 encoding support.", e); - } - } - } + if (queryParams != null) + for (Map.Entry entry : queryParams.entrySet()) + qcConfig.setParameter(entry.getKey(), entry.getValue()); return qcConfig; } + /** + * Parse the given string for parameter key/value pairs and return + * a map with the parameters. + * + * @param queryStr + * The query string to parse for the values. + * + * @return + * A map with the key/value pairs. + * + * @throws UnsupportedEncodingException + * If Java lacks UTF-8 support. + */ + private static Map parseQueryString(String queryStr) + throws UnsupportedEncodingException { + + // Split the query string into the pairs + List paramList = Arrays.asList(queryStr.split("&")); + Map parameters = new HashMap(); + + // Split into key/value pairs and decode + for (String param : paramList) { + String[] paramArray = param.split("=", 2); + parameters.put(URLDecoder.decode(paramArray[0], "UTF-8"), + URLDecoder.decode(paramArray[1], "UTF-8")); + } + + return parameters; + } + /** * Given a GuacamoleConfiguration object, generate a name * for the configuration based on the protocol, host, user @@ -182,7 +210,7 @@ public class QCParser { String port = config.getParameter("port"); String user = config.getParameter("username"); - StringBuilder name = new StringBuilder(""); + StringBuilder name = new StringBuilder(); if (protocol != null && !protocol.isEmpty()) name.append(protocol).append("://"); From aabc871d7d05c4db1f4e3906e6a8c93b0fc9a30b Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Thu, 19 Apr 2018 08:55:24 -0400 Subject: [PATCH 42/61] GUACAMOLE-38: Add unit test for query string parser. --- .../guacamole-auth-quickconnect/pom.xml | 8 +++ .../auth/quickconnect/utility/QCParser.java | 2 +- .../quickconnect/utility/QCParserTest.java | 49 +++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java diff --git a/extensions/guacamole-auth-quickconnect/pom.xml b/extensions/guacamole-auth-quickconnect/pom.xml index e8d044072..b2fd92286 100644 --- a/extensions/guacamole-auth-quickconnect/pom.xml +++ b/extensions/guacamole-auth-quickconnect/pom.xml @@ -193,6 +193,14 @@ provided + + + junit + junit + 4.10 + test + + diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 4924619f0..c8e954a49 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -167,7 +167,7 @@ public class QCParser { * @throws UnsupportedEncodingException * If Java lacks UTF-8 support. */ - private static Map parseQueryString(String queryStr) + public static Map parseQueryString(String queryStr) throws UnsupportedEncodingException { // Split the query string into the pairs diff --git a/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java new file mode 100644 index 000000000..5567ea3ab --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.guacamole.auth.quickconnect.utility; + +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +/** + * Class to test methods in the QCParser utility class. + */ +public class QCParserTest { + + /** + * Verify that the parseQueryString() method functions as designed. + */ + @Test + public void testParseQueryString() throws UnsupportedEncodingException { + + final String queryString = "param1=value1¶m2=value2=3¶m3=value%3D3¶m4=value%264"; + Map queryMap = QCParser.parseQueryString(queryString); + + assertEquals("value1", queryMap.get("param1")); + assertEquals("value2=3", queryMap.get("param2")); + assertEquals("value=3", queryMap.get("param3")); + assertEquals("value&4", queryMap.get("param4")); + + } + +} From cfd16737916b18ac7e7b8f7cbc154e3a93cd2dad Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Fri, 20 Apr 2018 21:21:15 -0400 Subject: [PATCH 43/61] GUACAMOLE-38: Code cleanup; style, and grammar tweaks. --- .../QuickConnectAuthenticationProvider.java | 4 +-- .../quickconnect/QuickConnectDirectory.java | 33 +++++++++---------- .../quickconnect/QuickConnectUserContext.java | 23 +++---------- .../quickconnect/QuickConnectionGroup.java | 19 +++++------ .../quickconnect/rest/QuickConnectREST.java | 23 +++++-------- .../auth/quickconnect/utility/QCParser.java | 29 ++++++++-------- 6 files changed, 56 insertions(+), 75 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java index 35fa8b71c..090c5e7f7 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectAuthenticationProvider.java @@ -25,8 +25,8 @@ import org.apache.guacamole.net.auth.AbstractAuthenticationProvider; import org.apache.guacamole.net.auth.UserContext; /** - * Class providing the necessary hooks into the Guacamole Client authentication - * process so that the QuickConnect functionality can be initialized and be used + * This class provides the necessary hooks into the Guacamole Client authentication + * process so that the QuickConnect functionality can be initialized and used * throughout the web client. */ public class QuickConnectAuthenticationProvider extends AbstractAuthenticationProvider { diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index a321f871a..30d868330 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -31,7 +31,7 @@ import org.apache.guacamole.net.auth.Connection; import org.apache.guacamole.protocol.GuacamoleConfiguration; /** - * Implementation of the Connection Directory, stored + * Implementation of a directory to stored Connection objects * completely in-memory. */ public class QuickConnectDirectory extends SimpleDirectory { @@ -58,14 +58,12 @@ public class QuickConnectDirectory extends SimpleDirectory { private AtomicInteger connectionId; /** - * Creates a new QuickConnectDirectory which provides access to the - * connections contained within the given Map. + * Creates a new QuickConnectDirectory with the default + * empty Map for Connection objects, and the specified + * ConnectionGroup at the root of the directory. * - * @param connections - * A Map of all connections that should be present in this - * connection directory. * @param rootGroup - * A group that should be at the base of this directory. + * A group that should be at the root of this directory. */ public QuickConnectDirectory(ConnectionGroup rootGroup) { this.rootGroup = (QuickConnectionGroup)rootGroup; @@ -74,11 +72,12 @@ public class QuickConnectDirectory extends SimpleDirectory { } /** - * Returns the current counter and then increments it. + * Returns the current connection identifier counter and + * then increments it. * * @return - * An Integer representing the next available connection - * ID to get used when adding connections. + * An int representing the next available connection + * identifier to be used when adding connections. */ private int getNextConnectionID() { return connectionId.getAndIncrement(); @@ -90,9 +89,9 @@ public class QuickConnectDirectory extends SimpleDirectory { } /** - * Create a SimpleConnection object from a GuacamoleConfiguration - * and get an ID and place it on the tree, returning the new - * connection identifier value. + * Create a SimpleConnection object from a GuacamoleConfiguration, + * obtain an identifier, and place it on the tree, returning the + * identifier value of the new connection. * * @param config * The GuacamoleConfiguration to use to create the @@ -106,17 +105,17 @@ public class QuickConnectDirectory extends SimpleDirectory { */ public String create(GuacamoleConfiguration config) throws GuacamoleException { - // Get the next connection ID + // Get the next connection identifier. String connectionId = Integer.toString(getNextConnectionID()); - // Generate a name for the configuration + // Generate a name for the configuration. String name = QCParser.getName(config); - // Create a new connection and set parent identifier. + // Create a new connection and set the parent identifier. Connection connection = new SimpleConnection(name, connectionId, config); connection.setParentIdentifier(ROOT_IDENTIFIER); - // Place the object in directory + // Place the object in this directory. add(connection); // Add connection to the tree. diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index d2315e514..32f4b37d2 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -32,8 +32,8 @@ import org.apache.guacamole.net.auth.simple.SimpleUser; /** * A simple implementation of UserContext to support the QuickConnect - * extension, primarily used for storing connections the user has - * created using the QuickConnect bar in the webapp. + * extension, used for storing connections the user has created + * with the QuickConnect bar in the webapp. */ public class QuickConnectUserContext extends AbstractUserContext { @@ -48,12 +48,6 @@ public class QuickConnectUserContext extends AbstractUserContext { */ private final User self; - /** - * The Directory with access only to the User associated with this - * UserContext. - */ - private final Directory userDirectory; - /** * The Directory with access to all connections within the root group * associated with this UserContext. @@ -86,15 +80,14 @@ public class QuickConnectUserContext extends AbstractUserContext { DEFAULT_ROOT_CONNECTION_GROUP ); - // Initialize the user to a SimpleUser with the username, no - // preexisting connections, and the single root group. + // Initialize the user to a SimpleUser with the provided username, + // no connections, and the single root group. this.self = new SimpleUser(username, Collections.emptyList(), Collections.singleton(DEFAULT_ROOT_CONNECTION_GROUP) ); - // Initialize each of the directories associated with the userContext. - this.userDirectory = new SimpleDirectory(self); + // Initialize the connection directory this.connectionDirectory = new QuickConnectDirectory(this.rootGroup); // Set the authProvider to the calling authProvider object. @@ -122,12 +115,6 @@ public class QuickConnectUserContext extends AbstractUserContext { return authProvider; } - @Override - public Directory getUserDirectory() - throws GuacamoleException { - return userDirectory; - } - @Override public ConnectionGroup getRootConnectionGroup() throws GuacamoleException { return rootGroup; diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java index dd3da3fe8..8419cf022 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java @@ -31,20 +31,20 @@ import org.apache.guacamole.net.auth.ConnectionGroup; import org.apache.guacamole.protocol.GuacamoleClientInformation; /** - * Provides a very simple, single-level connection group used - * for temporarily storing the QuickConnections created by - * users. + * Provides a simple, single-level connection group used for + * temporarily storing the Connection objects created by users. */ public class QuickConnectionGroup extends AbstractConnectionGroup { /** - * The connection identifiers for this group. + * A set that will store the Connection identifiers for this group. */ - private Set connectionIdentifiers; + private Set connectionIdentifiers = + new HashSet(Collections.emptyList()); /** - * Set up a QuickConnectionGroup with a name and identifier, and - * an empty set of child connections. + * Set up a QuickConnectionGroup with the provided name and + * identifier. * * @param name * The name of the QuickConnectionGroup. @@ -58,13 +58,12 @@ public class QuickConnectionGroup extends AbstractConnectionGroup { setIdentifier(identifier); setType(ConnectionGroup.Type.ORGANIZATIONAL); - this.connectionIdentifiers = new HashSet(Collections.emptyList()); - } /** * Add a connection identifier to this connection group, and - * return the identifier if the add succeeds, else return null. + * return the identifier if the add succeeds, otheriwse + * return null. * * @param identifier * The identifier of the connection to add to the group. diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java index 4b0b9fd1e..559335b89 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java @@ -29,8 +29,8 @@ import org.apache.guacamole.auth.quickconnect.QuickConnectDirectory; import org.apache.guacamole.auth.quickconnect.utility.QCParser; /** - * A class to create and manage REST endpoints for the - * QuickConnect extension. + * A class that implements REST endpoints for the QuickConnect + * extension. */ @Produces(MediaType.APPLICATION_JSON) public class QuickConnectREST { @@ -41,31 +41,27 @@ public class QuickConnectREST { private QuickConnectDirectory directory; /** - * Construct a new QuickConnectREST class, taking in the UserContext - * object that calls this constructor. + * Construct a new QuickConnectREST class, taking in a + * QuickConnectDirectory for use with this class. * * @param directory - * The ConnectionDirectory object associated with this REST endpoint - * - * @throws GuacamoleException - * If the UserContext is unavailable or the directory object - * cannot be retrieved. + * The QuickConnectDirectory object to associate with this + * REST endpoint class. */ - public QuickConnectREST(QuickConnectDirectory directory) - throws GuacamoleException { + public QuickConnectREST(QuickConnectDirectory directory) { this.directory = directory; } /** * Parse the URI read from the POST input, add the connection - * to the directory, and return the ID of the newly-created + * to the directory, and return the identifier of the newly-created * connection. * * @param uri * The URI to parse into a connection. * * @return - * The ID of the connection in the directory. + * The identifier of the connection in the directory. * * @throws GuacamoleException * If an error is encountered parsing the URI. @@ -78,6 +74,5 @@ public class QuickConnectREST { return directory.create(QCParser.getConfiguration(uri)); } - } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index c8e954a49..1156ca5f9 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -34,23 +34,16 @@ import org.apache.guacamole.GuacamoleClientException; import org.apache.guacamole.GuacamoleServerException; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.protocol.GuacamoleConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * A utility class to parse out a URI into the settings necessary - * to create and establish a Guacamole connection. + * to generate a GuacamoleConfiguration object. */ public class QCParser { /** - * Logger for this class. - */ - private final static Logger logger = LoggerFactory.getLogger(QCParser.class); - - /** - * The default protocol to parse to if one is provided in - * the incoming URI.. + * The default protocol to use if one is not provided in + * the incoming URI. */ public static final String DEFAULT_URI_PROTOCOL = "ssh"; @@ -75,8 +68,8 @@ public class QCParser { private static final int PASSWORD_GROUP = 2; /** - * Parse out a URI string and get a connection from that string, - * or an exception if the parsing fails. + * Parse out a URI string and get a GuacamoleConfiguration + * from that string, or an exception if the parsing fails. * * @param uri * The string form of the URI to be parsed. @@ -99,21 +92,27 @@ public class QCParser { catch (URISyntaxException e) { throw new GuacamoleClientException("Invalid URI Syntax", e); } + + // Break out individual components of the URI. String protocol = qcUri.getScheme(); String host = qcUri.getHost(); int port = qcUri.getPort(); String userInfo = qcUri.getUserInfo(); String query = qcUri.getQuery(); + String username = null; String password = null; Map queryParams = null; + // Assign default protocol if one is not found in the URI. if (protocol == null || protocol.isEmpty()) protocol = DEFAULT_URI_PROTOCOL; + // Assign default host if one is not found in the URI. if (host == null || host.isEmpty()) host = DEFAULT_URI_HOST; + // Look for extra query parameters and parse them out. if (query != null && !query.isEmpty()) { try { queryParams = parseQueryString(query); @@ -123,6 +122,7 @@ public class QCParser { } } + // Look for the username and password and parse them out. if (userInfo != null && !userInfo.isEmpty()) { Matcher userinfoMatcher = userinfoPattern.matcher(userInfo); @@ -133,6 +133,7 @@ public class QCParser { } + // Generate a new GuacamoleConfiguration and set parameters. GuacamoleConfiguration qcConfig = new GuacamoleConfiguration(); qcConfig.setProtocol(protocol); qcConfig.setParameter("hostname",host); @@ -159,7 +160,7 @@ public class QCParser { * a map with the parameters. * * @param queryStr - * The query string to parse for the values. + * The query string to parse for key/value pairs. * * @return * A map with the key/value pairs. @@ -174,7 +175,7 @@ public class QCParser { List paramList = Arrays.asList(queryStr.split("&")); Map parameters = new HashMap(); - // Split into key/value pairs and decode + // Loop through key/value pairs and put them in the Map. for (String param : paramList) { String[] paramArray = param.split("=", 2); parameters.put(URLDecoder.decode(paramArray[0], "UTF-8"), From 6629451892f7ae160a0cfdea15b309b80da744fe Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 28 Apr 2018 08:28:03 -0400 Subject: [PATCH 44/61] GUACAMOLE-38: Remove bundled aopalliance license. --- .../src/licenses/LICENSE | 19 ------------------- .../src/licenses/bundled/README | 4 ---- .../licenses/bundled/aopalliance-1.0/LICENSE | 4 ---- 3 files changed, 27 deletions(-) delete mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/bundled/README delete mode 100644 extensions/guacamole-auth-quickconnect/src/licenses/bundled/aopalliance-1.0/LICENSE diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/LICENSE b/extensions/guacamole-auth-quickconnect/src/licenses/LICENSE index e8788bb5e..d64569567 100644 --- a/extensions/guacamole-auth-quickconnect/src/licenses/LICENSE +++ b/extensions/guacamole-auth-quickconnect/src/licenses/LICENSE @@ -200,22 +200,3 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - - -============================================================================== - -APACHE GUACAMOLE SUBCOMPONENTS - -Apache Guacamole includes a number of subcomponents with separate copyright -notices and license terms. Your use of these subcomponents is subject to the -terms and conditions of the following licenses. - - -AOP Alliance (http://aopalliance.sourceforge.net/) --------------------------------------------------- - - Version: 1.0 - From: 'AOP Alliance' (http://aopalliance.sourceforge.net/members.html) - License(s): - Public Domain (bundled/aopalliance-1.0/LICENSE) - diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/README b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/README deleted file mode 100644 index 47ba19db0..000000000 --- a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/README +++ /dev/null @@ -1,4 +0,0 @@ -Apache Guacamole includes a number of subcomponents with separate copyright -notices and license terms. Your use of these subcomponents is subject to the -terms and conditions of their respective licenses, included within this -directory for reference. diff --git a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/aopalliance-1.0/LICENSE b/extensions/guacamole-auth-quickconnect/src/licenses/bundled/aopalliance-1.0/LICENSE deleted file mode 100644 index 8e0e3786b..000000000 --- a/extensions/guacamole-auth-quickconnect/src/licenses/bundled/aopalliance-1.0/LICENSE +++ /dev/null @@ -1,4 +0,0 @@ -From http://aopalliance.sourceforge.net/: - - LICENCE: all the source code provided by AOP Alliance is Public Domain. - From 201fbcd5a5aeb0d6a98ddbc726f4aee775ae53f0 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Mon, 30 Apr 2018 10:32:43 -0400 Subject: [PATCH 45/61] GUACAMOLE-38: Updated AngularJS components for compatibility with 1.6.x. --- .../controllers/quickconnectController.js | 34 ++++--------------- .../resources/services/quickConnectService.js | 11 +++--- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js index 640034f6e..34c67800c 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/controllers/quickconnectController.js @@ -20,28 +20,16 @@ /** * The controller for making ad-hoc (quick) connections */ -angular.module('guacQuickConnect').controller('quickconnectController', ['$scope', '$injector', '$log', - function manageConnectionController($scope, $injector, $log) { +angular.module('guacQuickConnect').controller('quickconnectController', ['$scope', '$injector', + function manageConnectionController($scope, $injector) { // Required types var ClientIdentifier = $injector.get('ClientIdentifier'); // Required services - var $location = $injector.get('$location'); - var guacNotification = $injector.get('guacNotification'); - var quickConnectService = $injector.get('quickConnectService'); - - /** - * An action to be provided along with the object sent to showStatus which - * closes the currently-shown status dialog. - */ - var ACKNOWLEDGE_ACTION = { - name : "MANAGE_CONNECTION.ACTION_ACKNOWLEDGE", - // Handle action - callback : function acknowledgeCallback() { - guacNotification.showStatus(false); - } - }; + var $location = $injector.get('$location'); + var guacNotification = $injector.get('guacNotification'); + var quickConnectService = $injector.get('quickConnectService'); /** * The URI that will be passed in to the extension to create @@ -56,21 +44,13 @@ angular.module('guacQuickConnect').controller('quickconnectController', ['$scope $scope.quickConnect = function quickConnect() { quickConnectService.createConnection($scope.uri) - .success(function createdConnection(connectionId) { + .then(function createdConnection(connectionId) { $location.url('/client/' + ClientIdentifier.toString({ dataSource : 'quickconnect', type : ClientIdentifier.Types.CONNECTION, id : connectionId })); - }) - .error(function createFailed(error) { - guacNotification.showStatus({ - 'className' : 'error', - 'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR', - 'text' : error.translatableMessage, - 'actions' : [ ACKNOWLEDGE_ACTION ] - }); - }); + }, guacNotification.SHOW_REQUEST_ERROR); return; diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js b/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js index 946e1912a..b5f947515 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js @@ -24,9 +24,9 @@ angular.module('guacQuickConnect').factory('quickConnectService', ['$injector', function quickConnectService($injector) { // Required services - var $http = $injector.get('$http'); var authenticationService = $injector.get('authenticationService'); var cacheService = $injector.get('cacheService'); + var requestService = $injector.get('requestService'); var service = {}; @@ -47,17 +47,20 @@ angular.module('guacQuickConnect').factory('quickConnectService', ['$injector', token : authenticationService.getCurrentToken() }; - return $http({ + return requestService({ method : 'POST', url : 'api/session/ext/quickconnect/create', params : httpParameters, - data : $.param({uri: uri }), + data : $.param({uri: uri}), headers : {'Content-Type': 'application/x-www-form-urlencoded'} }) - .success(function connectionCreated() { + .then(function connectionCreated(connectionId) { // Clear connections and users from cache. cacheService.connections.removeAll(); cacheService.users.removeAll(); + + // Pass on the connection identifier + return connectionId; }); }; From 555b26ae1fd1584485ab6b85c0a55a350e035350 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 8 May 2018 15:58:58 -0400 Subject: [PATCH 46/61] GUACAMOLE-38: Use ConcurrentHashMap for threadsafety. --- .../guacamole/auth/quickconnect/QuickConnectDirectory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index 30d868330..5070ea6e7 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -19,7 +19,7 @@ package org.apache.guacamole.auth.quickconnect; -import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import org.apache.guacamole.GuacamoleException; @@ -45,7 +45,7 @@ public class QuickConnectDirectory extends SimpleDirectory { * The connections to store. */ private final Map connections = - new HashMap(); + new ConcurrentHashMap(); /** * The root connection group for this directory. From 7df88cdfbd22bd0964a634736c348b7475c5cd1b Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 8 May 2018 16:28:10 -0400 Subject: [PATCH 47/61] GUACAMOLE-38: Fix issues with root identifier and directory. --- .../quickconnect/QuickConnectDirectory.java | 7 +----- .../quickconnect/QuickConnectUserContext.java | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index 5070ea6e7..ceb8c80d9 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -36,11 +36,6 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration; */ public class QuickConnectDirectory extends SimpleDirectory { - /** - * The unique identifier of the root connection group. - */ - private static final String ROOT_IDENTIFIER = "ROOT"; - /** * The connections to store. */ @@ -113,7 +108,7 @@ public class QuickConnectDirectory extends SimpleDirectory { // Create a new connection and set the parent identifier. Connection connection = new SimpleConnection(name, connectionId, config); - connection.setParentIdentifier(ROOT_IDENTIFIER); + connection.setParentIdentifier(QuickConnectUserContext.ROOT_IDENTIFIER); // Place the object in this directory. add(connection); diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index 32f4b37d2..aa98db75e 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -37,6 +37,11 @@ import org.apache.guacamole.net.auth.simple.SimpleUser; */ public class QuickConnectUserContext extends AbstractUserContext { + /** + * The unique identifier of the root connection group. + */ + public static final String ROOT_IDENTIFIER = DEFAULT_ROOT_CONNECTION_GROUP; + /** * The AuthenticationProvider that created this UserContext. */ @@ -71,25 +76,25 @@ public class QuickConnectUserContext extends AbstractUserContext { * The name of the user logging in and using this class. */ public QuickConnectUserContext(AuthenticationProvider authProvider, - String username) { + String username) throws GuacamoleException { // Initialize the rootGroup to a basic connection group with a // single root identifier. this.rootGroup = new QuickConnectionGroup( - DEFAULT_ROOT_CONNECTION_GROUP, - DEFAULT_ROOT_CONNECTION_GROUP - ); - - // Initialize the user to a SimpleUser with the provided username, - // no connections, and the single root group. - this.self = new SimpleUser(username, - Collections.emptyList(), - Collections.singleton(DEFAULT_ROOT_CONNECTION_GROUP) + ROOT_IDENTIFIER, + ROOT_IDENTIFIER ); // Initialize the connection directory this.connectionDirectory = new QuickConnectDirectory(this.rootGroup); + // Initialize the user to a SimpleUser with the provided username, + // no connections, and the single root group. + this.self = new SimpleUser(username, + connectionDirectory.getIdentifiers(), + Collections.singleton(ROOT_IDENTIFIER) + ); + // Set the authProvider to the calling authProvider object. this.authProvider = authProvider; From 2a9c7fe0b7dee1a409a96f32b6e155c63c62e917 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 9 May 2018 08:40:55 -0400 Subject: [PATCH 48/61] GUACAMOLE-38: Rearrange logic in QCParser class. --- .../auth/quickconnect/utility/QCParser.java | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 1156ca5f9..9601e1cb3 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -85,6 +85,7 @@ public class QCParser { public static GuacamoleConfiguration getConfiguration(String uri) throws GuacamoleException { + // Parse the URI object from provided string. URI qcUri; try { qcUri = new URI(uri); @@ -100,22 +101,32 @@ public class QCParser { String userInfo = qcUri.getUserInfo(); String query = qcUri.getQuery(); - String username = null; - String password = null; - Map queryParams = null; + // Generate a new GuacamoleConfiguration + GuacamoleConfiguration qcConfig = new GuacamoleConfiguration(); - // Assign default protocol if one is not found in the URI. - if (protocol == null || protocol.isEmpty()) - protocol = DEFAULT_URI_PROTOCOL; + // Check for provided protocol or use default + if (protocol != null && !protocol.isEmpty()) + qcConfig.setProtocol(protocol); + else + qcConfig.setProtocol(DEFAULT_URI_PROTOCOL); - // Assign default host if one is not found in the URI. - if (host == null || host.isEmpty()) - host = DEFAULT_URI_HOST; + // Check for provided port number + if (port > 0) + qcConfig.setParameter("port", Integer.toString(port)); + + // Check for provided host or use default + if (host != null && !host.isEmpty()) + qcConfig.setParameter("hostname", host); + else + qcConfig.setParameter("hostname", DEFAULT_URI_HOST); // Look for extra query parameters and parse them out. if (query != null && !query.isEmpty()) { try { - queryParams = parseQueryString(query); + Map queryParams = parseQueryString(query); + if (queryParams != null) + for (Map.Entry entry: queryParams.entrySet()) + qcConfig.setParameter(entry.getKey(), entry.getValue()); } catch (UnsupportedEncodingException e) { throw new GuacamoleServerException("Unexpected lack of UTF-8 encoding support.", e); @@ -127,30 +138,18 @@ public class QCParser { Matcher userinfoMatcher = userinfoPattern.matcher(userInfo); if (userinfoMatcher.matches()) { - username = userinfoMatcher.group(USERNAME_GROUP); - password = userinfoMatcher.group(PASSWORD_GROUP); + String username = userinfoMatcher.group(USERNAME_GROUP); + String password = userinfoMatcher.group(PASSWORD_GROUP); + + if (username != null && !username.isEmpty()) + qcConfig.setParameter("username", username); + + if (password != null && !password.isEmpty()) + qcConfig.setParameter("password", password); } } - // Generate a new GuacamoleConfiguration and set parameters. - GuacamoleConfiguration qcConfig = new GuacamoleConfiguration(); - qcConfig.setProtocol(protocol); - qcConfig.setParameter("hostname",host); - - if (port > 0) - qcConfig.setParameter("port", Integer.toString(port)); - - if (username != null && !username.isEmpty()) - qcConfig.setParameter("username", username); - - if (password != null && !password.isEmpty()) - qcConfig.setParameter("password", password); - - if (queryParams != null) - for (Map.Entry entry : queryParams.entrySet()) - qcConfig.setParameter(entry.getKey(), entry.getValue()); - return qcConfig; } From 56cc11e1b991a9885454d8954c61eb254e99496a Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 9 May 2018 09:54:45 -0400 Subject: [PATCH 49/61] GUACAMOLE-38: Tweak style and translation issues. --- .../src/main/resources/styles/quickconnect.css | 11 ++++++----- .../main/resources/templates/quickconnectField.html | 4 +++- .../src/main/resources/translations/en.json | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css b/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css index ee0c2f59e..bc9209db3 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css @@ -19,26 +19,27 @@ .quickconnect-container { - margin: 0.5em 0; + margin: 0.75em 0; width: 100%; + margin-left: 0.75em; } .quickconnect-container .quickconnect-field { background-image: url('images/protocol-icons/guac-text.png'); background-repeat: no-repeat; - background-size: 1.75em; + background-size: 1.50em; background-position: 0.25em center; background-color: transparent; - padding: 0.5em; - padding-left: 2.25em; + padding: 0.25em; + padding-left: 2.50em; width: 100%; max-width: none; border: 0; - border-left: 1px solid rgba(0,0,0,0.125); box-sizing: border-box; } .quickconnect-button { clear: both; float: right; + margin-right: 0.75em; } diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html index 114f59a9e..30e8a9085 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html @@ -5,5 +5,7 @@
- +
+ +
diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json b/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json index 1f7bb3dcf..2c2dc8ef5 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json @@ -5,6 +5,7 @@ }, "QUICKCONNECT" : { + "ACTION_CONNECT" : "Connect", "FIELD_PLACEHOLDER_URI" : "Enter Connection URI" } From f563925aa7a6d7716f783497d845028227b94afa Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Thu, 10 May 2018 12:02:37 -0400 Subject: [PATCH 50/61] GUACAMOLE-38: Relocate the toolbar and restyle it. --- .../src/main/resources/styles/quickconnect.css | 12 ++++++++++-- .../main/resources/templates/quickconnectField.html | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css b/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css index bc9209db3..2f112623c 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/styles/quickconnect.css @@ -19,9 +19,9 @@ .quickconnect-container { - margin: 0.75em 0; + margin: 0.25em 0; width: 100%; - margin-left: 0.75em; + margin-left: 0.50em; } .quickconnect-container .quickconnect-field { @@ -42,4 +42,12 @@ clear: both; float: right; margin-right: 0.75em; + font-size: 0.75em; + padding: 0.25em; +} + +.quickconnect-list-item { + vertical-align: middle; + align-content: center; + display: flex } diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html index 30e8a9085..6089965c5 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/templates/quickconnectField.html @@ -1,5 +1,5 @@ - -
+ +
From 6dad254c14dcd8ee1e4781c09089668f9ddba0a3 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 12 May 2018 07:44:09 -0400 Subject: [PATCH 51/61] GUACAMOLE-38: Fix use of superclass methods. --- .../guacamole/auth/quickconnect/QuickConnectionGroup.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java index 8419cf022..b087c35c3 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java @@ -54,9 +54,10 @@ public class QuickConnectionGroup extends AbstractConnectionGroup { */ public QuickConnectionGroup(String name, String identifier) { - setName(name); - setIdentifier(identifier); - setType(ConnectionGroup.Type.ORGANIZATIONAL); + super(); + super.setName(name); + super.setIdentifier(identifier); + super.setType(ConnectionGroup.Type.ORGANIZATIONAL); } From aafc4359c812c1cf90b4c5d373c56cd4ceb2e5f6 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Mon, 14 May 2018 10:12:17 -0400 Subject: [PATCH 52/61] GUACAMOLE-38: Break userInfo parsing into its own function, and properly decode username and password. --- .../auth/quickconnect/utility/QCParser.java | 55 ++++++++++++++++--- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 9601e1cb3..2c0b6dc71 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -136,18 +136,18 @@ public class QCParser { // Look for the username and password and parse them out. if (userInfo != null && !userInfo.isEmpty()) { - Matcher userinfoMatcher = userinfoPattern.matcher(userInfo); - if (userinfoMatcher.matches()) { - String username = userinfoMatcher.group(USERNAME_GROUP); - String password = userinfoMatcher.group(PASSWORD_GROUP); + try { + Map userInfoParams = parseUserInfo(userInfo); - if (username != null && !username.isEmpty()) - qcConfig.setParameter("username", username); + if (userInfoParams.containsKey("username")) + qcConfig.setParameter("username", userInfoParams.get("username")); - if (password != null && !password.isEmpty()) - qcConfig.setParameter("password", password); + if (userInfoParams.containsKey("password")) + qcConfig.setParameter("password", userInfoParams.get("password")); + } + catch (UnsupportedEncodingException e) { + throw new GuacamoleServerException("Unexpected lack of UTF-8 encoding support.", e); } - } return qcConfig; @@ -184,6 +184,43 @@ public class QCParser { return parameters; } + /** + * Parse the given string for username and password values, + * and return a map containing the username, password + * or both. + * + * @param userInfo + * The string to parse for username/password values. + * + * @return + * A map with the username, password, or both. + * + * @throws UnsupportedEncodingException + * If Java lacks UTF-8 support. + */ + public static Map parseUserInfo(String userInfo) + throws UnsupportedEncodingException { + + Map userInfoMap = new HashMap(); + Matcher userinfoMatcher = userinfoPattern.matcher(userInfo); + + if (userinfoMatcher.matches()) { + String username = URLDecoder.decode( + userinfoMatcher.group(USERNAME_GROUP), "UTF-8"); + String password = URLDecoder.decode( + userinfoMatcher.group(PASSWORD_GROUP), "UTF-8"); + + if (username != null && !username.isEmpty()) + userInfoMap.put("username", username); + + if (password != null && !password.isEmpty()) + userInfoMap.put("password", password); + } + + return userInfoMap; + + } + /** * Given a GuacamoleConfiguration object, generate a name * for the configuration based on the protocol, host, user From 27f4ad01f5525b695ed9fbc651f04e8205b8d8b6 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Mon, 14 May 2018 10:46:49 -0400 Subject: [PATCH 53/61] GUACAMOLE-38: Add unit tests for the userInfo parser and the getConfiguration method. --- .../quickconnect/utility/QCParserTest.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java index 5567ea3ab..8a4ed1b28 100644 --- a/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java +++ b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java @@ -22,8 +22,11 @@ package org.apache.guacamole.auth.quickconnect.utility; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; +import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.protocol.GuacamoleConfiguration; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; /** * Class to test methods in the QCParser utility class. @@ -46,4 +49,63 @@ public class QCParserTest { } + /** + * Verify that the parseUserInfo() method functions as designed. + */ + @Test + public void testParseUserInfo() throws UnsupportedEncodingException { + + Map userInfoMap; + + userInfoMap = QCParser.parseUserInfo("guacuser:secretpw"); + assertEquals("guacuser", userInfoMap.get("username")); + assertEquals("secretpw", userInfoMap.get("password")); + + + userInfoMap = QCParser.parseUserInfo("guacuser"); + assertEquals("guacuser", userInfoMap.get("username")); + assertFalse(userInfoMap.containsKey("password")); + + userInfoMap = QCParser.parseUserInfo("guacuser:P%40ssw0rd%21"); + assertEquals("guacuser", userInfoMap.get("username")); + assertEquals("P@ssw0rd!", userInfoMap.get("password")); + + userInfoMap = QCParser.parseUserInfo("domain%5cguacuser:domain%2fpassword"); + assertEquals("domain\\guacuser", userInfoMap.get("username")); + assertEquals("domain/password", userInfoMap.get("password")); + + } + + /** + * Verify that the getConfiguration() method returns the expected + * GuacamoleConfiguration object. + */ + @Test + public void testGetConfiguration() throws GuacamoleException { + + String uri1 = "ssh://guacuser:guacpassword@hostname1.domain.local/?param1=value1¶m2=value2"; + GuacamoleConfiguration config1 = QCParser.getConfiguration(uri1); + assertEquals("ssh", config1.getProtocol()); + assertEquals("hostname1.domain.local", config1.getParameter("hostname")); + assertEquals("guacuser", config1.getParameter("username")); + assertEquals("guacpassword", config1.getParameter("password")); + assertEquals("value1", config1.getParameter("param1")); + assertEquals("value2", config1.getParameter("param2")); + + String uri2 = "rdp://domain%5cguacuser:adPassword123@windows1.domain.tld/?enable-sftp=true"; + GuacamoleConfiguration config2 = QCParser.getConfiguration(uri2); + assertEquals("rdp", config2.getProtocol()); + assertEquals("windows1.domain.tld", config2.getParameter("hostname")); + assertEquals("domain\\guacuser", config2.getParameter("username")); + assertEquals("adPassword123", config2.getParameter("password")); + assertEquals("true", config2.getParameter("enable-sftp")); + + String uri3 = "vnc://mirror1.example.com:5910/"; + GuacamoleConfiguration config3 = QCParser.getConfiguration(uri3); + assertEquals("vnc", config3.getProtocol()); + assertEquals("mirror1.example.com", config3.getParameter("hostname")); + assertEquals("5910", config3.getParameter("port")); + + } + } From aaada49dfefdb7aab794ebc6054976686fc57970 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Mon, 14 May 2018 14:00:50 -0400 Subject: [PATCH 54/61] GUACAMOLE-38: Clean up minor code issues. --- .../auth/quickconnect/QuickConnectDirectory.java | 2 +- .../auth/quickconnect/QuickConnectUserContext.java | 2 -- .../auth/quickconnect/QuickConnectionGroup.java | 2 +- .../auth/quickconnect/rest/QuickConnectREST.java | 2 +- .../auth/quickconnect/utility/QCParserTest.java | 10 +++++++++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index ceb8c80d9..88419440b 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -50,7 +50,7 @@ public class QuickConnectDirectory extends SimpleDirectory { /** * The internal counter for connection IDs. */ - private AtomicInteger connectionId; + private final AtomicInteger connectionId; /** * Creates a new QuickConnectDirectory with the default diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index aa98db75e..36a5a8fb0 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -25,9 +25,7 @@ import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.net.auth.AbstractUserContext; import org.apache.guacamole.net.auth.AuthenticationProvider; import org.apache.guacamole.net.auth.ConnectionGroup; -import org.apache.guacamole.net.auth.Directory; import org.apache.guacamole.net.auth.User; -import org.apache.guacamole.net.auth.simple.SimpleDirectory; import org.apache.guacamole.net.auth.simple.SimpleUser; /** diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java index b087c35c3..dfb60d14f 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java @@ -39,7 +39,7 @@ public class QuickConnectionGroup extends AbstractConnectionGroup { /** * A set that will store the Connection identifiers for this group. */ - private Set connectionIdentifiers = + private final Set connectionIdentifiers = new HashSet(Collections.emptyList()); /** diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java index 559335b89..cee759141 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java @@ -38,7 +38,7 @@ public class QuickConnectREST { /** * The connection directory for this REST endpoint. */ - private QuickConnectDirectory directory; + private final QuickConnectDirectory directory; /** * Construct a new QuickConnectREST class, taking in a diff --git a/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java index 8a4ed1b28..d63a52191 100644 --- a/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java +++ b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java @@ -20,7 +20,6 @@ package org.apache.guacamole.auth.quickconnect.utility; import java.io.UnsupportedEncodingException; -import java.util.HashMap; import java.util.Map; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.protocol.GuacamoleConfiguration; @@ -35,6 +34,9 @@ public class QCParserTest { /** * Verify that the parseQueryString() method functions as designed. + * + * @throws UnsupportedEncodingException + * If Java lacks UTF-8 support. */ @Test public void testParseQueryString() throws UnsupportedEncodingException { @@ -51,6 +53,9 @@ public class QCParserTest { /** * Verify that the parseUserInfo() method functions as designed. + * + * @throws UnsupportedEncodingException + * If Java lacks UTF-8 support. */ @Test public void testParseUserInfo() throws UnsupportedEncodingException { @@ -79,6 +84,9 @@ public class QCParserTest { /** * Verify that the getConfiguration() method returns the expected * GuacamoleConfiguration object. + * + * @throws GuacamoleException + * If the configuration cannot be parsed from the given URI. */ @Test public void testGetConfiguration() throws GuacamoleException { From 84e71a029c9a664d4dafa9638511ff468525d115 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Thu, 17 May 2018 19:58:12 -0400 Subject: [PATCH 55/61] GUACAMOLE-38: Put userInfo directly into configuration. --- .../auth/quickconnect/utility/QCParser.java | 37 ++++++++----------- .../quickconnect/utility/QCParserTest.java | 31 +++++++++------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 2c0b6dc71..60b4b9cb0 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -137,13 +137,7 @@ public class QCParser { if (userInfo != null && !userInfo.isEmpty()) { try { - Map userInfoParams = parseUserInfo(userInfo); - - if (userInfoParams.containsKey("username")) - qcConfig.setParameter("username", userInfoParams.get("username")); - - if (userInfoParams.containsKey("password")) - qcConfig.setParameter("password", userInfoParams.get("password")); + parseUserInfo(userInfo, qcConfig); } catch (UnsupportedEncodingException e) { throw new GuacamoleServerException("Unexpected lack of UTF-8 encoding support.", e); @@ -186,39 +180,38 @@ public class QCParser { /** * Parse the given string for username and password values, - * and return a map containing the username, password - * or both. + * and, if values are present, decode them and set them in + * the provided GuacamoleConfiguration object. * * @param userInfo * The string to parse for username/password values. - * - * @return - * A map with the username, password, or both. + * + * @param config + * The GuacamoleConfiguration object to store the username + * and password in. * * @throws UnsupportedEncodingException * If Java lacks UTF-8 support. */ - public static Map parseUserInfo(String userInfo) + public static void parseUserInfo(String userInfo, + GuacamoleConfiguration config) throws UnsupportedEncodingException { - Map userInfoMap = new HashMap(); Matcher userinfoMatcher = userinfoPattern.matcher(userInfo); if (userinfoMatcher.matches()) { - String username = URLDecoder.decode( - userinfoMatcher.group(USERNAME_GROUP), "UTF-8"); - String password = URLDecoder.decode( - userinfoMatcher.group(PASSWORD_GROUP), "UTF-8"); + String username = userinfoMatcher.group(USERNAME_GROUP); + String password = userinfoMatcher.group(PASSWORD_GROUP); if (username != null && !username.isEmpty()) - userInfoMap.put("username", username); + config.setParameter("username", + URLDecoder.decode(username, "UTF-8")); if (password != null && !password.isEmpty()) - userInfoMap.put("password", password); + config.setParameter("password", + URLDecoder.decode(password, "UTF-8")); } - return userInfoMap; - } /** diff --git a/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java index d63a52191..50ad7d6f2 100644 --- a/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java +++ b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java @@ -25,7 +25,7 @@ import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.protocol.GuacamoleConfiguration; import org.junit.Test; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; /** * Class to test methods in the QCParser utility class. @@ -62,22 +62,25 @@ public class QCParserTest { Map userInfoMap; - userInfoMap = QCParser.parseUserInfo("guacuser:secretpw"); - assertEquals("guacuser", userInfoMap.get("username")); - assertEquals("secretpw", userInfoMap.get("password")); + GuacamoleConfiguration config1 = new GuacamoleConfiguration(); + QCParser.parseUserInfo("guacuser:secretpw", config1); + assertEquals("guacuser", config1.getParameter("username")); + assertEquals("secretpw", config1.getParameter("password")); + GuacamoleConfiguration config2 = new GuacamoleConfiguration(); + QCParser.parseUserInfo("guacuser", config2); + assertEquals("guacuser", config2.getParameter("username")); + assertNull(config2.getParameter("password")); - userInfoMap = QCParser.parseUserInfo("guacuser"); - assertEquals("guacuser", userInfoMap.get("username")); - assertFalse(userInfoMap.containsKey("password")); + GuacamoleConfiguration config3 = new GuacamoleConfiguration(); + QCParser.parseUserInfo("guacuser:P%40ssw0rd%21", config3); + assertEquals("guacuser", config3.getParameter("username")); + assertEquals("P@ssw0rd!", config3.getParameter("password")); - userInfoMap = QCParser.parseUserInfo("guacuser:P%40ssw0rd%21"); - assertEquals("guacuser", userInfoMap.get("username")); - assertEquals("P@ssw0rd!", userInfoMap.get("password")); - - userInfoMap = QCParser.parseUserInfo("domain%5cguacuser:domain%2fpassword"); - assertEquals("domain\\guacuser", userInfoMap.get("username")); - assertEquals("domain/password", userInfoMap.get("password")); + GuacamoleConfiguration config4 = new GuacamoleConfiguration(); + QCParser.parseUserInfo("domain%5cguacuser:domain%2fpassword", config4); + assertEquals("domain\\guacuser", config4.getParameter("username")); + assertEquals("domain/password", config4.getParameter("password")); } From 8c130215f49c862819b3dfca219403db296a3a18 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Mon, 21 May 2018 09:56:50 -0400 Subject: [PATCH 56/61] GUACAMOLE-38: Remove default protocol and port, throw errors if not specified. --- .../auth/quickconnect/utility/QCParser.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 60b4b9cb0..2810f1d8b 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -41,17 +41,6 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration; */ public class QCParser { - /** - * The default protocol to use if one is not provided in - * the incoming URI. - */ - public static final String DEFAULT_URI_PROTOCOL = "ssh"; - - /** - * The default host to use if one is not defined. - */ - public static final String DEFAULT_URI_HOST = "localhost"; - /** * The regex to use to split username and password. */ @@ -89,6 +78,8 @@ public class QCParser { URI qcUri; try { qcUri = new URI(uri); + if (!qcUri.isAbsolute()) + throw new GuacamoleClientException("URI must be absolute."); } catch (URISyntaxException e) { throw new GuacamoleClientException("Invalid URI Syntax", e); @@ -108,7 +99,7 @@ public class QCParser { if (protocol != null && !protocol.isEmpty()) qcConfig.setProtocol(protocol); else - qcConfig.setProtocol(DEFAULT_URI_PROTOCOL); + throw new GuacamoleClientException("No protocol specified."); // Check for provided port number if (port > 0) @@ -118,7 +109,7 @@ public class QCParser { if (host != null && !host.isEmpty()) qcConfig.setParameter("hostname", host); else - qcConfig.setParameter("hostname", DEFAULT_URI_HOST); + throw new GuacamoleClientException("No host specified."); // Look for extra query parameters and parse them out. if (query != null && !query.isEmpty()) { From 730201358edb26ee27ab90f808fa72f146e0454b Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Mon, 21 May 2018 10:54:14 -0400 Subject: [PATCH 57/61] GUACAMOLE-38: Implement QuickConnectException for providing exceptions to the user. --- .../quickconnect/QuickConnectException.java | 86 +++++++++++++++++++ .../auth/quickconnect/utility/QCParser.java | 13 ++- .../src/main/resources/translations/en.json | 6 ++ 3 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectException.java diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectException.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectException.java new file mode 100644 index 000000000..6e4d5b94c --- /dev/null +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectException.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.guacamole.auth.quickconnect; + +import org.apache.guacamole.GuacamoleClientException; +import org.apache.guacamole.language.Translatable; +import org.apache.guacamole.language.TranslatableMessage; + +/** + * An exception that is thrown by this extension when an error occurs + * attempting to create and establish a connection with a user-provided + * URI. + */ +public class QuickConnectException extends GuacamoleClientException + implements Translatable { + + /** + * A message that can be passed through the translation service + * to provide information about the error that occurred. + */ + private final TranslatableMessage translatableMessage; + + /** + * Create a QuickConnectException with the given message and translationKey. + * The message will not be passed through the translation system; the + * translationKey will be passed through the translation system. Both should + * describe the error. + * + * @param message + * A string describing the error that occurred when trying to create + * or establish the connection. This will not be passed through the + * translation system. + * + * @param translationKey + * A key known to the translation system describing the error that + * occurred when trying to create or establish the connection. + * This will be passed through the translation system to provide + * a localized version of the message. + */ + public QuickConnectException(String message, String translationKey) { + super(message); + this.translatableMessage = new TranslatableMessage(translationKey); + } + + /** + * Create a new QuickConnectException given the human-readable message, + * which will not be passed through the translation system, and the + * translatableMessage, which will be passed through the translation system. + * Both parameters should describe the error preventing the connection + * from being created or established. + * + * @param message + * The human-readable message describing the error, which will not + * be passed through the translation system. + * + * @param translatableMessage + * The human-readable message describing the error, which will be + * passed through the translation system. + */ + public QuickConnectException(String message, TranslatableMessage translatableMessage) { + super(message); + this.translatableMessage = translatableMessage; + } + + @Override + public TranslatableMessage getTranslatableMessage() { + return translatableMessage; + } + +} diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 2810f1d8b..f61f51089 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -33,6 +33,7 @@ import java.util.regex.Pattern; import org.apache.guacamole.GuacamoleClientException; import org.apache.guacamole.GuacamoleServerException; import org.apache.guacamole.GuacamoleException; +import org.apache.guacamole.auth.quickconnect.QuickConnectException; import org.apache.guacamole.protocol.GuacamoleConfiguration; /** @@ -79,10 +80,12 @@ public class QCParser { try { qcUri = new URI(uri); if (!qcUri.isAbsolute()) - throw new GuacamoleClientException("URI must be absolute."); + throw new QuickConnectException("URI must be absolute.", + "QUICKCONNECT.ERROR_NOT_ABSOLUTE_URI"); } catch (URISyntaxException e) { - throw new GuacamoleClientException("Invalid URI Syntax", e); + throw new QuickConnectException("Invalid URI Syntax", + "QUICKCONNECT.ERROR_INVALID_URI"); } // Break out individual components of the URI. @@ -99,7 +102,8 @@ public class QCParser { if (protocol != null && !protocol.isEmpty()) qcConfig.setProtocol(protocol); else - throw new GuacamoleClientException("No protocol specified."); + throw new QuickConnectException("No protocol specified.", + "QUICKCONNECT.ERROR_NO_PROTOCOL"); // Check for provided port number if (port > 0) @@ -109,7 +113,8 @@ public class QCParser { if (host != null && !host.isEmpty()) qcConfig.setParameter("hostname", host); else - throw new GuacamoleClientException("No host specified."); + throw new QuickConnectException("No host specified.", + "QUICKCONNECT.ERROR_NO_HOST"); // Look for extra query parameters and parse them out. if (query != null && !query.isEmpty()) { diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json b/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json index 2c2dc8ef5..50ffb2dff 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/translations/en.json @@ -6,6 +6,12 @@ "QUICKCONNECT" : { "ACTION_CONNECT" : "Connect", + + "ERROR_INVALID_URI" : "Invalid URI Specified", + "ERROR_NO_HOST" : "No host specified", + "ERROR_NO_PROTOCOL" : "No protocol specified", + "ERROR_NOT_ABSOLUTE_URI" : "URI is not absolute", + "FIELD_PLACEHOLDER_URI" : "Enter Connection URI" } From b283adc73a8296ce53296ea1992c5e88af4ceb46 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 22 May 2018 22:15:58 -0400 Subject: [PATCH 58/61] GUACAMOLE-38: REST service should return proper JSON. --- .../guacamole/auth/quickconnect/rest/QuickConnectREST.java | 7 +++++-- .../src/main/resources/services/quickConnectService.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java index cee759141..275e1a423 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java @@ -19,6 +19,8 @@ package org.apache.guacamole.auth.quickconnect.rest; +import java.util.Collections; +import java.util.Map; import javax.ws.rs.FormParam; import javax.ws.rs.Path; import javax.ws.rs.POST; @@ -68,10 +70,11 @@ public class QuickConnectREST { */ @POST @Path("create") - public String create(@FormParam("uri") String uri) + public Map create(@FormParam("uri") String uri) throws GuacamoleException { - return directory.create(QCParser.getConfiguration(uri)); + return Collections.singletonMap("identifier", + directory.create(QCParser.getConfiguration(uri))); } diff --git a/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js b/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js index b5f947515..0da298087 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js +++ b/extensions/guacamole-auth-quickconnect/src/main/resources/services/quickConnectService.js @@ -60,7 +60,7 @@ angular.module('guacQuickConnect').factory('quickConnectService', ['$injector', cacheService.users.removeAll(); // Pass on the connection identifier - return connectionId; + return connectionId.identifier; }); }; From 6d0b6d649462c59de67257091cadb1485c8aeb92 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 22 May 2018 22:35:56 -0400 Subject: [PATCH 59/61] GUACAMOLE-38: Update comments to match recent changes in return type of REST create method. --- .../guacamole/auth/quickconnect/rest/QuickConnectREST.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java index 275e1a423..4cced071c 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/rest/QuickConnectREST.java @@ -56,14 +56,15 @@ public class QuickConnectREST { /** * Parse the URI read from the POST input, add the connection - * to the directory, and return the identifier of the newly-created - * connection. + * to the directory, and return a Map containing a single key, + * identifier, and the identifier of the new connection. * * @param uri * The URI to parse into a connection. * * @return - * The identifier of the connection in the directory. + * A Map containing a single key, identifier, and the + * identifier of the new connection. * * @throws GuacamoleException * If an error is encountered parsing the URI. From 97d2d3a2c95403784bc3b0324194ef8be4333e13 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 30 May 2018 11:23:00 -0400 Subject: [PATCH 60/61] GUACAMOLE-38: Clean up comments and make a couple of methods private. --- .../quickconnect/QuickConnectDirectory.java | 16 ++++++++-------- .../quickconnect/QuickConnectUserContext.java | 11 ++++++++--- .../quickconnect/QuickConnectionGroup.java | 6 +++++- .../auth/quickconnect/utility/QCParser.java | 18 ++++++++---------- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java index 88419440b..37b07ba33 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java @@ -31,8 +31,8 @@ import org.apache.guacamole.net.auth.Connection; import org.apache.guacamole.protocol.GuacamoleConfiguration; /** - * Implementation of a directory to stored Connection objects - * completely in-memory. + * Implementation of a directory to store Connection objects + * completely in memory. */ public class QuickConnectDirectory extends SimpleDirectory { @@ -89,7 +89,7 @@ public class QuickConnectDirectory extends SimpleDirectory { * identifier value of the new connection. * * @param config - * The GuacamoleConfiguration to use to create the + * The GuacamoleConfiguration object to use to create the * SimpleConnection object. * * @return @@ -100,23 +100,23 @@ public class QuickConnectDirectory extends SimpleDirectory { */ public String create(GuacamoleConfiguration config) throws GuacamoleException { - // Get the next connection identifier. - String connectionId = Integer.toString(getNextConnectionID()); + // Get the next available connection identifier. + String newConnectionId = Integer.toString(getNextConnectionID()); // Generate a name for the configuration. String name = QCParser.getName(config); // Create a new connection and set the parent identifier. - Connection connection = new SimpleConnection(name, connectionId, config); + Connection connection = new SimpleConnection(name, newConnectionId, config); connection.setParentIdentifier(QuickConnectUserContext.ROOT_IDENTIFIER); // Place the object in this directory. add(connection); // Add connection to the tree. - this.rootGroup.addConnectionIdentifier(connectionId); + rootGroup.addConnectionIdentifier(newConnectionId); - return connectionId; + return newConnectionId; } } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java index 36a5a8fb0..d7e23edb4 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java @@ -29,7 +29,7 @@ import org.apache.guacamole.net.auth.User; import org.apache.guacamole.net.auth.simple.SimpleUser; /** - * A simple implementation of UserContext to support the QuickConnect + * A simple implementation of UserContext to support this * extension, used for storing connections the user has created * with the QuickConnect bar in the webapp. */ @@ -71,12 +71,17 @@ public class QuickConnectUserContext extends AbstractUserContext { * this class. * * @param username - * The name of the user logging in and using this class. + * The name of the user logging in that will be associated + * with this UserContext. + * + * @throws GuacamoleException + * If errors occur initializing the ConnectionGroup, + * ConnectionDirectory, or User. */ public QuickConnectUserContext(AuthenticationProvider authProvider, String username) throws GuacamoleException { - // Initialize the rootGroup to a basic connection group with a + // Initialize the rootGroup to a QuickConnectionGroup with a // single root identifier. this.rootGroup = new QuickConnectionGroup( ROOT_IDENTIFIER, diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java index dfb60d14f..cbce37976 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java @@ -63,7 +63,7 @@ public class QuickConnectionGroup extends AbstractConnectionGroup { /** * Add a connection identifier to this connection group, and - * return the identifier if the add succeeds, otheriwse + * return the identifier if the add succeeds, otherwise * return null. * * @param identifier @@ -81,6 +81,7 @@ public class QuickConnectionGroup extends AbstractConnectionGroup { @Override public int getActiveConnections() { + // This group does not track active connections. return 0; } @@ -91,11 +92,13 @@ public class QuickConnectionGroup extends AbstractConnectionGroup { @Override public Set getConnectionGroupIdentifiers() { + // This group contains only connections, not other groups. return Collections.emptySet(); } @Override public Map getAttributes() { + // There are no attributes associated with this group. return Collections.emptyMap(); } @@ -107,6 +110,7 @@ public class QuickConnectionGroup extends AbstractConnectionGroup { @Override public GuacamoleTunnel connect(GuacamoleClientInformation info) throws GuacamoleException { + // This group does not support connections throw new GuacamoleSecurityException("Permission denied."); } diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index f61f51089..2924c0d95 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.guacamole.GuacamoleClientException; import org.apache.guacamole.GuacamoleServerException; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.auth.quickconnect.QuickConnectException; @@ -65,17 +64,16 @@ public class QCParser { * The string form of the URI to be parsed. * * @return - * A GuacamoleConfiguration using a combination of the parsed - * URI values and default values when not specified in the - * URI. + * A GuacamoleConfiguration generated using the information + * provided by the user in the URI. * * @throws GuacamoleException - * When an error occurs parsing the URI. + * If an error occurs parsing the URI. */ public static GuacamoleConfiguration getConfiguration(String uri) throws GuacamoleException { - // Parse the URI object from provided string. + // Parse the provided String into a URI object. URI qcUri; try { qcUri = new URI(uri); @@ -98,7 +96,7 @@ public class QCParser { // Generate a new GuacamoleConfiguration GuacamoleConfiguration qcConfig = new GuacamoleConfiguration(); - // Check for provided protocol or use default + // Check for protocol and set it, or throw an error if not present if (protocol != null && !protocol.isEmpty()) qcConfig.setProtocol(protocol); else @@ -109,7 +107,7 @@ public class QCParser { if (port > 0) qcConfig.setParameter("port", Integer.toString(port)); - // Check for provided host or use default + // Check for provided host, or throw an error if not present if (host != null && !host.isEmpty()) qcConfig.setParameter("hostname", host); else @@ -157,7 +155,7 @@ public class QCParser { * @throws UnsupportedEncodingException * If Java lacks UTF-8 support. */ - public static Map parseQueryString(String queryStr) + private static Map parseQueryString(String queryStr) throws UnsupportedEncodingException { // Split the query string into the pairs @@ -189,7 +187,7 @@ public class QCParser { * @throws UnsupportedEncodingException * If Java lacks UTF-8 support. */ - public static void parseUserInfo(String userInfo, + private static void parseUserInfo(String userInfo, GuacamoleConfiguration config) throws UnsupportedEncodingException { From 1438a5117b40b359e629f22aa04338560c3e4da7 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 30 May 2018 11:31:41 -0400 Subject: [PATCH 61/61] GUACAMOLE-38: Methods being tested need to be public. --- .../apache/guacamole/auth/quickconnect/utility/QCParser.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java index 2924c0d95..3e2e5e5ab 100644 --- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java +++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java @@ -155,7 +155,7 @@ public class QCParser { * @throws UnsupportedEncodingException * If Java lacks UTF-8 support. */ - private static Map parseQueryString(String queryStr) + public static Map parseQueryString(String queryStr) throws UnsupportedEncodingException { // Split the query string into the pairs @@ -187,7 +187,7 @@ public class QCParser { * @throws UnsupportedEncodingException * If Java lacks UTF-8 support. */ - private static void parseUserInfo(String userInfo, + public static void parseUserInfo(String userInfo, GuacamoleConfiguration config) throws UnsupportedEncodingException {