You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2018/06/03 19:06:29 UTC
[13/50] guacamole-client git commit: GUACAMOLE-38: Clean up lots of
unnecessary code.
GUACAMOLE-38: Clean up lots of unnecessary code.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/0cbf90a5
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/0cbf90a5
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/0cbf90a5
Branch: refs/heads/master
Commit: 0cbf90a55df8c14eb80391bb97c831f5bb910e71
Parents: c994c5a
Author: Nick Couchman <vn...@apache.org>
Authored: Tue Apr 17 22:10:25 2018 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Fri Jun 1 13:40:51 2018 -0400
----------------------------------------------------------------------
.../QuickConnectConnectionGroup.java | 113 -------------------
.../quickconnect/QuickConnectDirectory.java | 11 +-
.../quickconnect/QuickConnectUserContext.java | 15 +--
.../auth/quickconnect/QuickConnection.java | 87 --------------
.../auth/quickconnect/QuickConnectionGroup.java | 113 +++++++++++++++++++
5 files changed, 120 insertions(+), 219 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/0cbf90a5/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java
----------------------------------------------------------------------
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
deleted file mode 100644
index 2f37e08..0000000
--- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectConnectionGroup.java
+++ /dev/null
@@ -1,113 +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 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;
-
-/**
- * Provides a very simple, single-level connection group used
- * for temporarily storing the QuickConnections created by
- * users.
- */
-public class QuickConnectConnectionGroup extends AbstractConnectionGroup {
-
- /**
- * The connection identifiers for this group.
- */
- private Set<String> 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);
- setIdentifier(identifier);
- setType(ConnectionGroup.Type.ORGANIZATIONAL);
-
- this.connectionIdentifiers = new HashSet<String>(Collections.<String>emptyList());
-
- }
-
- /**
- * 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
- public int getActiveConnections() {
- return 0;
- }
-
- @Override
- public Set<String> getConnectionIdentifiers() {
- return connectionIdentifiers;
- }
-
- @Override
- public Set<String> getConnectionGroupIdentifiers() {
- return Collections.<String>emptySet();
- }
-
- @Override
- public Map<String, String> getAttributes() {
- return Collections.<String, String>emptyMap();
- }
-
- @Override
- public void setAttributes(Map<String, String> attributes) {
- // Do nothing - there are no attributes
- }
-
- @Override
- public GuacamoleTunnel connect(GuacamoleClientInformation info)
- throws GuacamoleException {
- throw new GuacamoleSecurityException("Permission denied.");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/0cbf90a5/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectDirectory.java
----------------------------------------------------------------------
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 d17c25b..a321f87 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<Connection> {
/**
* 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<Connection> {
* 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<Connection> {
}
/**
- * 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<Connection> {
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
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/0cbf90a5/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectUserContext.java
----------------------------------------------------------------------
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 60a05e5..4382659 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
@@ -55,12 +55,6 @@ public class QuickConnectUserContext extends AbstractUserContext {
private final Directory<User> userDirectory;
/**
- * The Directory with access only to the root group associated with this
- * UserContext.
- */
- private final Directory<ConnectionGroup> 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<User>(self);
this.connectionDirectory = new QuickConnectDirectory(this.rootGroup);
- this.connectionGroupDirectory = new SimpleDirectory<ConnectionGroup>(Collections.singleton(this.rootGroup));
// Set the authProvider to the calling authProvider object.
this.authProvider = authProvider;
@@ -136,12 +129,6 @@ public class QuickConnectUserContext extends AbstractUserContext {
}
@Override
- public Directory<ConnectionGroup> getConnectionGroupDirectory()
- throws GuacamoleException {
- return connectionGroupDirectory;
- }
-
- @Override
public ConnectionGroup getRootConnectionGroup() throws GuacamoleException {
return rootGroup;
}
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/0cbf90a5/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnection.java
----------------------------------------------------------------------
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 f3be14e..0000000
--- 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;
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/0cbf90a5/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..dd3da3f
--- /dev/null
+++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/QuickConnectionGroup.java
@@ -0,0 +1,113 @@
+/*
+ * 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.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;
+
+/**
+ * Provides a very simple, single-level connection group used
+ * for temporarily storing the QuickConnections created by
+ * users.
+ */
+public class QuickConnectionGroup extends AbstractConnectionGroup {
+
+ /**
+ * The connection identifiers for this group.
+ */
+ private Set<String> connectionIdentifiers;
+
+ /**
+ * Set up a QuickConnectionGroup with a name and identifier, and
+ * an empty set of child connections.
+ *
+ * @param name
+ * The name of the QuickConnectionGroup.
+ *
+ * @param identifier
+ * The identifier of the QuickConnectionGroup.
+ */
+ public QuickConnectionGroup(String name, String identifier) {
+
+ setName(name);
+ setIdentifier(identifier);
+ setType(ConnectionGroup.Type.ORGANIZATIONAL);
+
+ this.connectionIdentifiers = new HashSet<String>(Collections.<String>emptyList());
+
+ }
+
+ /**
+ * 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
+ public int getActiveConnections() {
+ return 0;
+ }
+
+ @Override
+ public Set<String> getConnectionIdentifiers() {
+ return connectionIdentifiers;
+ }
+
+ @Override
+ public Set<String> getConnectionGroupIdentifiers() {
+ return Collections.<String>emptySet();
+ }
+
+ @Override
+ public Map<String, String> getAttributes() {
+ return Collections.<String, String>emptyMap();
+ }
+
+ @Override
+ public void setAttributes(Map<String, String> attributes) {
+ // Do nothing - there are no attributes
+ }
+
+ @Override
+ public GuacamoleTunnel connect(GuacamoleClientInformation info)
+ throws GuacamoleException {
+ throw new GuacamoleSecurityException("Permission denied.");
+ }
+
+}