GUACAMOLE-38: Clean up comments and make a couple of methods private.

This commit is contained in:
Nick Couchman
2018-05-30 11:23:00 -04:00
committed by Nick Couchman
parent 6d0b6d6494
commit 97d2d3a2c9
4 changed files with 29 additions and 22 deletions

View File

@@ -31,8 +31,8 @@ import org.apache.guacamole.net.auth.Connection;
import org.apache.guacamole.protocol.GuacamoleConfiguration; import org.apache.guacamole.protocol.GuacamoleConfiguration;
/** /**
* Implementation of a directory to stored Connection objects * Implementation of a directory to store Connection objects
* completely in-memory. * completely in memory.
*/ */
public class QuickConnectDirectory extends SimpleDirectory<Connection> { public class QuickConnectDirectory extends SimpleDirectory<Connection> {
@@ -89,7 +89,7 @@ public class QuickConnectDirectory extends SimpleDirectory<Connection> {
* identifier value of the new connection. * identifier value of the new connection.
* *
* @param config * @param config
* The GuacamoleConfiguration to use to create the * The GuacamoleConfiguration object to use to create the
* SimpleConnection object. * SimpleConnection object.
* *
* @return * @return
@@ -100,23 +100,23 @@ public class QuickConnectDirectory extends SimpleDirectory<Connection> {
*/ */
public String create(GuacamoleConfiguration config) throws GuacamoleException { public String create(GuacamoleConfiguration config) throws GuacamoleException {
// Get the next connection identifier. // Get the next available connection identifier.
String connectionId = Integer.toString(getNextConnectionID()); String newConnectionId = Integer.toString(getNextConnectionID());
// Generate a name for the configuration. // Generate a name for the configuration.
String name = QCParser.getName(config); String name = QCParser.getName(config);
// Create a new connection and set the parent identifier. // 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); connection.setParentIdentifier(QuickConnectUserContext.ROOT_IDENTIFIER);
// Place the object in this directory. // Place the object in this directory.
add(connection); add(connection);
// Add connection to the tree. // Add connection to the tree.
this.rootGroup.addConnectionIdentifier(connectionId); rootGroup.addConnectionIdentifier(newConnectionId);
return connectionId; return newConnectionId;
} }
} }

View File

@@ -29,7 +29,7 @@ import org.apache.guacamole.net.auth.User;
import org.apache.guacamole.net.auth.simple.SimpleUser; 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 * extension, used for storing connections the user has created
* with the QuickConnect bar in the webapp. * with the QuickConnect bar in the webapp.
*/ */
@@ -71,12 +71,17 @@ public class QuickConnectUserContext extends AbstractUserContext {
* this class. * this class.
* *
* @param username * @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, public QuickConnectUserContext(AuthenticationProvider authProvider,
String username) throws GuacamoleException { 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. // single root identifier.
this.rootGroup = new QuickConnectionGroup( this.rootGroup = new QuickConnectionGroup(
ROOT_IDENTIFIER, ROOT_IDENTIFIER,

View File

@@ -63,7 +63,7 @@ public class QuickConnectionGroup extends AbstractConnectionGroup {
/** /**
* Add a connection identifier to this connection group, and * 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. * return null.
* *
* @param identifier * @param identifier
@@ -81,6 +81,7 @@ public class QuickConnectionGroup extends AbstractConnectionGroup {
@Override @Override
public int getActiveConnections() { public int getActiveConnections() {
// This group does not track active connections.
return 0; return 0;
} }
@@ -91,11 +92,13 @@ public class QuickConnectionGroup extends AbstractConnectionGroup {
@Override @Override
public Set<String> getConnectionGroupIdentifiers() { public Set<String> getConnectionGroupIdentifiers() {
// This group contains only connections, not other groups.
return Collections.<String>emptySet(); return Collections.<String>emptySet();
} }
@Override @Override
public Map<String, String> getAttributes() { public Map<String, String> getAttributes() {
// There are no attributes associated with this group.
return Collections.<String, String>emptyMap(); return Collections.<String, String>emptyMap();
} }
@@ -107,6 +110,7 @@ public class QuickConnectionGroup extends AbstractConnectionGroup {
@Override @Override
public GuacamoleTunnel connect(GuacamoleClientInformation info) public GuacamoleTunnel connect(GuacamoleClientInformation info)
throws GuacamoleException { throws GuacamoleException {
// This group does not support connections
throw new GuacamoleSecurityException("Permission denied."); throw new GuacamoleSecurityException("Permission denied.");
} }

View File

@@ -30,7 +30,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.guacamole.GuacamoleClientException;
import org.apache.guacamole.GuacamoleServerException; import org.apache.guacamole.GuacamoleServerException;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.auth.quickconnect.QuickConnectException; import org.apache.guacamole.auth.quickconnect.QuickConnectException;
@@ -65,17 +64,16 @@ public class QCParser {
* The string form of the URI to be parsed. * The string form of the URI to be parsed.
* *
* @return * @return
* A GuacamoleConfiguration using a combination of the parsed * A GuacamoleConfiguration generated using the information
* URI values and default values when not specified in the * provided by the user in the URI.
* URI.
* *
* @throws GuacamoleException * @throws GuacamoleException
* When an error occurs parsing the URI. * If an error occurs parsing the URI.
*/ */
public static GuacamoleConfiguration getConfiguration(String uri) public static GuacamoleConfiguration getConfiguration(String uri)
throws GuacamoleException { throws GuacamoleException {
// Parse the URI object from provided string. // Parse the provided String into a URI object.
URI qcUri; URI qcUri;
try { try {
qcUri = new URI(uri); qcUri = new URI(uri);
@@ -98,7 +96,7 @@ public class QCParser {
// Generate a new GuacamoleConfiguration // Generate a new GuacamoleConfiguration
GuacamoleConfiguration qcConfig = 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()) if (protocol != null && !protocol.isEmpty())
qcConfig.setProtocol(protocol); qcConfig.setProtocol(protocol);
else else
@@ -109,7 +107,7 @@ public class QCParser {
if (port > 0) if (port > 0)
qcConfig.setParameter("port", Integer.toString(port)); 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()) if (host != null && !host.isEmpty())
qcConfig.setParameter("hostname", host); qcConfig.setParameter("hostname", host);
else else
@@ -157,7 +155,7 @@ public class QCParser {
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* If Java lacks UTF-8 support. * If Java lacks UTF-8 support.
*/ */
public static Map<String, String> parseQueryString(String queryStr) private static Map<String, String> parseQueryString(String queryStr)
throws UnsupportedEncodingException { throws UnsupportedEncodingException {
// Split the query string into the pairs // Split the query string into the pairs
@@ -189,7 +187,7 @@ public class QCParser {
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* If Java lacks UTF-8 support. * If Java lacks UTF-8 support.
*/ */
public static void parseUserInfo(String userInfo, private static void parseUserInfo(String userInfo,
GuacamoleConfiguration config) GuacamoleConfiguration config)
throws UnsupportedEncodingException { throws UnsupportedEncodingException {