mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Merge pull request #165 from glyptodon/build-warnings
GUAC-1170: Fix Java compiler warnings.
This commit is contained in:
@@ -20,9 +20,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-Xlint:all</arg>
|
||||||
|
<arg>-Werror</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
<fork>true</fork>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@ import org.glyptodon.guacamole.GuacamoleException;
|
|||||||
import org.glyptodon.guacamole.net.GuacamoleSocket;
|
import org.glyptodon.guacamole.net.GuacamoleSocket;
|
||||||
import org.glyptodon.guacamole.net.GuacamoleTunnel;
|
import org.glyptodon.guacamole.net.GuacamoleTunnel;
|
||||||
import org.glyptodon.guacamole.net.InetGuacamoleSocket;
|
import org.glyptodon.guacamole.net.InetGuacamoleSocket;
|
||||||
|
import org.glyptodon.guacamole.net.SimpleGuacamoleTunnel;
|
||||||
import org.glyptodon.guacamole.protocol.ConfiguredGuacamoleSocket;
|
import org.glyptodon.guacamole.protocol.ConfiguredGuacamoleSocket;
|
||||||
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
|
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
|
||||||
import org.glyptodon.guacamole.servlet.GuacamoleHTTPTunnelServlet;
|
import org.glyptodon.guacamole.servlet.GuacamoleHTTPTunnelServlet;
|
||||||
@@ -63,7 +64,7 @@ public class DummyGuacamoleTunnelServlet extends GuacamoleHTTPTunnelServlet {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Create tunnel from now-configured socket
|
// Create tunnel from now-configured socket
|
||||||
GuacamoleTunnel tunnel = new GuacamoleTunnel(socket);
|
GuacamoleTunnel tunnel = new SimpleGuacamoleTunnel(socket);
|
||||||
|
|
||||||
// Attach tunnel
|
// Attach tunnel
|
||||||
GuacamoleSession session = new GuacamoleSession(httpSession);
|
GuacamoleSession session = new GuacamoleSession(httpSession);
|
||||||
|
@@ -26,9 +26,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-Xlint:all</arg>
|
||||||
|
<arg>-Werror</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
<fork>true</fork>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@@ -316,7 +316,7 @@ public abstract class ModeledDirectoryObjectService<InternalType extends Modeled
|
|||||||
|
|
||||||
// Do not query if no identifiers given
|
// Do not query if no identifiers given
|
||||||
if (identifiers.isEmpty())
|
if (identifiers.isEmpty())
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.<InternalType>emptyList();
|
||||||
|
|
||||||
Collection<ModelType> objects;
|
Collection<ModelType> objects;
|
||||||
|
|
||||||
|
@@ -96,7 +96,7 @@ public abstract class ModeledGroupedDirectoryObjectService<InternalType extends
|
|||||||
|
|
||||||
// If both parents have the same identifier, nothing has changed
|
// If both parents have the same identifier, nothing has changed
|
||||||
if (parentIdentifier != null && parentIdentifier.equals(oldParentIdentifier))
|
if (parentIdentifier != null && parentIdentifier.equals(oldParentIdentifier))
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.<String>emptyList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -204,7 +204,7 @@ public class ConnectionService extends ModeledGroupedDirectoryObjectService<Mode
|
|||||||
Map<String, String> parameters = connection.getConfiguration().getParameters();
|
Map<String, String> parameters = connection.getConfiguration().getParameters();
|
||||||
|
|
||||||
// Convert parameters to model objects
|
// Convert parameters to model objects
|
||||||
Collection<ParameterModel> parameterModels = new ArrayList(parameters.size());
|
Collection<ParameterModel> parameterModels = new ArrayList<ParameterModel>(parameters.size());
|
||||||
for (Map.Entry<String, String> parameterEntry : parameters.entrySet()) {
|
for (Map.Entry<String, String> parameterEntry : parameters.entrySet()) {
|
||||||
|
|
||||||
// Get parameter name and value
|
// Get parameter name and value
|
||||||
|
@@ -106,7 +106,7 @@ public abstract class ModeledObjectPermissionService
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Produce collection of affected identifiers
|
// Produce collection of affected identifiers
|
||||||
Collection<String> affectedIdentifiers = new HashSet(permissions.size());
|
Collection<String> affectedIdentifiers = new HashSet<String>(permissions.size());
|
||||||
for (ObjectPermission permission : permissions)
|
for (ObjectPermission permission : permissions)
|
||||||
affectedIdentifiers.add(permission.getObjectIdentifier());
|
affectedIdentifiers.add(permission.getObjectIdentifier());
|
||||||
|
|
||||||
|
@@ -424,12 +424,12 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
|
|||||||
|
|
||||||
// If not a balancing group, there are no balanced connections
|
// If not a balancing group, there are no balanced connections
|
||||||
if (connectionGroup.getType() != ConnectionGroup.Type.BALANCING)
|
if (connectionGroup.getType() != ConnectionGroup.Type.BALANCING)
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.<ModeledConnection>emptyList();
|
||||||
|
|
||||||
// If group has no children, there are no balanced connections
|
// If group has no children, there are no balanced connections
|
||||||
Collection<String> identifiers = connectionMapper.selectIdentifiersWithin(connectionGroup.getIdentifier());
|
Collection<String> identifiers = connectionMapper.selectIdentifiersWithin(connectionGroup.getIdentifier());
|
||||||
if (identifiers.isEmpty())
|
if (identifiers.isEmpty())
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.<ModeledConnection>emptyList();
|
||||||
|
|
||||||
// Retrieve all children
|
// Retrieve all children
|
||||||
Collection<ConnectionModel> models = connectionMapper.select(identifiers);
|
Collection<ConnectionModel> models = connectionMapper.select(identifiers);
|
||||||
@@ -453,7 +453,7 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
|
|||||||
// Simply return empty list if there are no active tunnels
|
// Simply return empty list if there are no active tunnels
|
||||||
Collection<ActiveConnectionRecord> records = activeTunnels.values();
|
Collection<ActiveConnectionRecord> records = activeTunnels.values();
|
||||||
if (records.isEmpty())
|
if (records.isEmpty())
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.<ActiveConnectionRecord>emptyList();
|
||||||
|
|
||||||
// Build set of all connection identifiers associated with active tunnels
|
// Build set of all connection identifiers associated with active tunnels
|
||||||
Set<String> identifiers = new HashSet<String>(records.size());
|
Set<String> identifiers = new HashSet<String>(records.size());
|
||||||
@@ -521,7 +521,7 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
|
|||||||
|
|
||||||
// If not a balancing group, assume no connections
|
// If not a balancing group, assume no connections
|
||||||
if (connectionGroup.getType() != ConnectionGroup.Type.BALANCING)
|
if (connectionGroup.getType() != ConnectionGroup.Type.BALANCING)
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.<ActiveConnectionRecord>emptyList();
|
||||||
|
|
||||||
return activeConnectionGroups.get(connectionGroup.getIdentifier());
|
return activeConnectionGroups.get(connectionGroup.getIdentifier());
|
||||||
|
|
||||||
|
@@ -120,7 +120,7 @@ public class ActiveConnectionMultimap {
|
|||||||
if (connections != null)
|
if (connections != null)
|
||||||
return Collections.unmodifiableCollection(connections);
|
return Collections.unmodifiableCollection(connections);
|
||||||
|
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.<ActiveConnectionRecord>emptyList();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,9 +26,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-Xlint:all</arg>
|
||||||
|
<arg>-Werror</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
<fork>true</fork>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@@ -37,7 +37,6 @@ import org.glyptodon.guacamole.auth.jdbc.tunnel.UnrestrictedGuacamoleTunnelServi
|
|||||||
import org.glyptodon.guacamole.auth.jdbc.user.UserContextService;
|
import org.glyptodon.guacamole.auth.jdbc.user.UserContextService;
|
||||||
import org.glyptodon.guacamole.environment.Environment;
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
||||||
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a MySQL based implementation of the AuthenticationProvider
|
* Provides a MySQL based implementation of the AuthenticationProvider
|
||||||
|
@@ -26,9 +26,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-Xlint:all</arg>
|
||||||
|
<arg>-Werror</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
<fork>true</fork>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@@ -20,9 +20,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-Xlint:all</arg>
|
||||||
|
<arg>-Werror</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
<fork>true</fork>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@@ -36,8 +36,9 @@ import org.glyptodon.guacamole.GuacamoleException;
|
|||||||
import org.glyptodon.guacamole.net.auth.Credentials;
|
import org.glyptodon.guacamole.net.auth.Credentials;
|
||||||
import net.sourceforge.guacamole.net.auth.ldap.properties.LDAPGuacamoleProperties;
|
import net.sourceforge.guacamole.net.auth.ldap.properties.LDAPGuacamoleProperties;
|
||||||
import org.glyptodon.guacamole.GuacamoleServerException;
|
import org.glyptodon.guacamole.GuacamoleServerException;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
|
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
||||||
import org.glyptodon.guacamole.net.auth.simple.SimpleAuthenticationProvider;
|
import org.glyptodon.guacamole.net.auth.simple.SimpleAuthenticationProvider;
|
||||||
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
|
||||||
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
|
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -56,6 +57,23 @@ public class LDAPAuthenticationProvider extends SimpleAuthenticationProvider {
|
|||||||
*/
|
*/
|
||||||
private Logger logger = LoggerFactory.getLogger(LDAPAuthenticationProvider.class);
|
private Logger logger = LoggerFactory.getLogger(LDAPAuthenticationProvider.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guacamole server environment.
|
||||||
|
*/
|
||||||
|
private final Environment environment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new LDAPAuthenticationProvider that authenticates users
|
||||||
|
* against an LDAP directory.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If a required property is missing, or an error occurs while parsing
|
||||||
|
* a property.
|
||||||
|
*/
|
||||||
|
public LDAPAuthenticationProvider() throws GuacamoleException {
|
||||||
|
environment = new LocalEnvironment();
|
||||||
|
}
|
||||||
|
|
||||||
// Courtesy of OWASP: https://www.owasp.org/index.php/Preventing_LDAP_Injection_in_Java
|
// Courtesy of OWASP: https://www.owasp.org/index.php/Preventing_LDAP_Injection_in_Java
|
||||||
private static String escapeLDAPSearchFilter(String filter) {
|
private static String escapeLDAPSearchFilter(String filter) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -146,8 +164,8 @@ public class LDAPAuthenticationProvider extends SimpleAuthenticationProvider {
|
|||||||
|
|
||||||
ldapConnection = new LDAPConnection();
|
ldapConnection = new LDAPConnection();
|
||||||
ldapConnection.connect(
|
ldapConnection.connect(
|
||||||
GuacamoleProperties.getRequiredProperty(LDAPGuacamoleProperties.LDAP_HOSTNAME),
|
environment.getRequiredProperty(LDAPGuacamoleProperties.LDAP_HOSTNAME),
|
||||||
GuacamoleProperties.getRequiredProperty(LDAPGuacamoleProperties.LDAP_PORT)
|
environment.getRequiredProperty(LDAPGuacamoleProperties.LDAP_PORT)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -156,12 +174,12 @@ public class LDAPAuthenticationProvider extends SimpleAuthenticationProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get username attribute
|
// Get username attribute
|
||||||
String username_attribute = GuacamoleProperties.getRequiredProperty(
|
String username_attribute = environment.getRequiredProperty(
|
||||||
LDAPGuacamoleProperties.LDAP_USERNAME_ATTRIBUTE
|
LDAPGuacamoleProperties.LDAP_USERNAME_ATTRIBUTE
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get user base DN
|
// Get user base DN
|
||||||
String user_base_dn = GuacamoleProperties.getRequiredProperty(
|
String user_base_dn = environment.getRequiredProperty(
|
||||||
LDAPGuacamoleProperties.LDAP_USER_BASE_DN
|
LDAPGuacamoleProperties.LDAP_USER_BASE_DN
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -191,7 +209,7 @@ public class LDAPAuthenticationProvider extends SimpleAuthenticationProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get config base DN
|
// Get config base DN
|
||||||
String config_base_dn = GuacamoleProperties.getRequiredProperty(
|
String config_base_dn = environment.getRequiredProperty(
|
||||||
LDAPGuacamoleProperties.LDAP_CONFIG_BASE_DN
|
LDAPGuacamoleProperties.LDAP_CONFIG_BASE_DN
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -234,10 +252,10 @@ public class LDAPAuthenticationProvider extends SimpleAuthenticationProvider {
|
|||||||
if (parameterAttribute != null) {
|
if (parameterAttribute != null) {
|
||||||
|
|
||||||
// For each parameter
|
// For each parameter
|
||||||
Enumeration<String> parameters = parameterAttribute.getStringValues();
|
Enumeration<?> parameters = parameterAttribute.getStringValues();
|
||||||
while (parameters.hasMoreElements()) {
|
while (parameters.hasMoreElements()) {
|
||||||
|
|
||||||
String parameter = parameters.nextElement();
|
String parameter = (String) parameters.nextElement();
|
||||||
|
|
||||||
// Parse parameter
|
// Parse parameter
|
||||||
int equals = parameter.indexOf('=');
|
int equals = parameter.indexOf('=');
|
||||||
|
@@ -20,9 +20,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-Xlint:all</arg>
|
||||||
|
<arg>-Werror</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
<fork>true</fork>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@@ -30,10 +30,11 @@ import java.io.IOException;
|
|||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.GuacamoleServerException;
|
import org.glyptodon.guacamole.GuacamoleServerException;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
|
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
||||||
import org.glyptodon.guacamole.net.auth.simple.SimpleAuthenticationProvider;
|
import org.glyptodon.guacamole.net.auth.simple.SimpleAuthenticationProvider;
|
||||||
import org.glyptodon.guacamole.net.auth.Credentials;
|
import org.glyptodon.guacamole.net.auth.Credentials;
|
||||||
import org.glyptodon.guacamole.properties.FileGuacamoleProperty;
|
import org.glyptodon.guacamole.properties.FileGuacamoleProperty;
|
||||||
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
|
||||||
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
|
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -86,6 +87,11 @@ public class NoAuthenticationProvider extends SimpleAuthenticationProvider {
|
|||||||
*/
|
*/
|
||||||
private long configTime;
|
private long configTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guacamole server environment.
|
||||||
|
*/
|
||||||
|
private final Environment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The filename of the XML file to read the user mapping from.
|
* The filename of the XML file to read the user mapping from.
|
||||||
*/
|
*/
|
||||||
@@ -98,6 +104,19 @@ public class NoAuthenticationProvider extends SimpleAuthenticationProvider {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new NoAuthenticationProvider that does not perform any
|
||||||
|
* authentication at all. All attempts to access the Guacamole system are
|
||||||
|
* presumed to be authorized.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If a required property is missing, or an error occurs while parsing
|
||||||
|
* a property.
|
||||||
|
*/
|
||||||
|
public NoAuthenticationProvider() throws GuacamoleException {
|
||||||
|
environment = new LocalEnvironment();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the configuration file, as defined within guacamole.properties.
|
* Retrieves the configuration file, as defined within guacamole.properties.
|
||||||
*
|
*
|
||||||
@@ -106,7 +125,7 @@ public class NoAuthenticationProvider extends SimpleAuthenticationProvider {
|
|||||||
* property.
|
* property.
|
||||||
*/
|
*/
|
||||||
private File getConfigurationFile() throws GuacamoleException {
|
private File getConfigurationFile() throws GuacamoleException {
|
||||||
return GuacamoleProperties.getRequiredProperty(NOAUTH_CONFIG);
|
return environment.getRequiredProperty(NOAUTH_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void init() throws GuacamoleException {
|
public synchronized void init() throws GuacamoleException {
|
||||||
|
@@ -54,9 +54,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-Xlint:all</arg>
|
||||||
|
<arg>-Werror</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
<fork>true</fork>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@@ -54,9 +54,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-Xlint:all</arg>
|
||||||
|
<arg>-Werror</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
<fork>true</fork>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@@ -65,7 +65,7 @@ public class CredentialsInfo {
|
|||||||
* CredentialsInfo object which describes empty credentials. No parameters
|
* CredentialsInfo object which describes empty credentials. No parameters
|
||||||
* are required.
|
* are required.
|
||||||
*/
|
*/
|
||||||
public static final CredentialsInfo EMPTY = new CredentialsInfo(Collections.EMPTY_LIST);
|
public static final CredentialsInfo EMPTY = new CredentialsInfo(Collections.<Parameter>emptyList());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CredentialsInfo object which describes standard username/password
|
* CredentialsInfo object which describes standard username/password
|
||||||
|
@@ -117,7 +117,7 @@ public class SimpleConnection extends AbstractConnection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ConnectionRecord> getHistory() throws GuacamoleException {
|
public List<ConnectionRecord> getHistory() throws GuacamoleException {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.<ConnectionRecord>emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@ public class SimpleDirectory<ObjectType> implements Directory<ObjectType> {
|
|||||||
/**
|
/**
|
||||||
* The Map of objects to provide access to.
|
* The Map of objects to provide access to.
|
||||||
*/
|
*/
|
||||||
private Map<String, ObjectType> objects = Collections.EMPTY_MAP;
|
private Map<String, ObjectType> objects = Collections.<String, ObjectType>emptyMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new empty SimpleDirectory which does not provide access to
|
* Creates a new empty SimpleDirectory which does not provide access to
|
||||||
|
@@ -42,7 +42,7 @@ public class SimpleObjectPermissionSet implements ObjectPermissionSet {
|
|||||||
/**
|
/**
|
||||||
* The set of all permissions currently granted.
|
* The set of all permissions currently granted.
|
||||||
*/
|
*/
|
||||||
private Set<ObjectPermission> permissions = Collections.EMPTY_SET;
|
private Set<ObjectPermission> permissions = Collections.<ObjectPermission>emptySet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new empty SimpleObjectPermissionSet.
|
* Creates a new empty SimpleObjectPermissionSet.
|
||||||
|
@@ -40,7 +40,7 @@ public class SimpleSystemPermissionSet implements SystemPermissionSet {
|
|||||||
/**
|
/**
|
||||||
* The set of all permissions currently granted.
|
* The set of all permissions currently granted.
|
||||||
*/
|
*/
|
||||||
private Set<SystemPermission> permissions = Collections.EMPTY_SET;
|
private Set<SystemPermission> permissions = Collections.<SystemPermission>emptySet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new empty SimpleSystemPermissionSet.
|
* Creates a new empty SimpleSystemPermissionSet.
|
||||||
|
@@ -126,7 +126,7 @@ public class SimpleUserContext implements UserContext {
|
|||||||
// Add root group that contains only the given configurations
|
// Add root group that contains only the given configurations
|
||||||
this.rootGroup = new SimpleConnectionGroup(
|
this.rootGroup = new SimpleConnectionGroup(
|
||||||
ROOT_IDENTIFIER, ROOT_IDENTIFIER,
|
ROOT_IDENTIFIER, ROOT_IDENTIFIER,
|
||||||
connectionIdentifiers, Collections.EMPTY_LIST
|
connectionIdentifiers, Collections.<String>emptyList()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Build new user from credentials
|
// Build new user from credentials
|
||||||
|
@@ -54,9 +54,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-Xlint:all</arg>
|
||||||
|
<arg>-Werror</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
<fork>true</fork>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@@ -29,6 +29,8 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
|
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
||||||
import org.glyptodon.guacamole.net.auth.Credentials;
|
import org.glyptodon.guacamole.net.auth.Credentials;
|
||||||
import org.glyptodon.guacamole.net.auth.simple.SimpleAuthenticationProvider;
|
import org.glyptodon.guacamole.net.auth.simple.SimpleAuthenticationProvider;
|
||||||
import org.glyptodon.guacamole.net.basic.auth.Authorization;
|
import org.glyptodon.guacamole.net.basic.auth.Authorization;
|
||||||
@@ -36,7 +38,6 @@ import org.glyptodon.guacamole.net.basic.auth.UserMapping;
|
|||||||
import org.glyptodon.guacamole.xml.DocumentHandler;
|
import org.glyptodon.guacamole.xml.DocumentHandler;
|
||||||
import org.glyptodon.guacamole.net.basic.xml.user_mapping.UserMappingTagHandler;
|
import org.glyptodon.guacamole.net.basic.xml.user_mapping.UserMappingTagHandler;
|
||||||
import org.glyptodon.guacamole.properties.FileGuacamoleProperty;
|
import org.glyptodon.guacamole.properties.FileGuacamoleProperty;
|
||||||
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
|
||||||
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
|
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -69,6 +70,11 @@ public class BasicFileAuthenticationProvider extends SimpleAuthenticationProvide
|
|||||||
*/
|
*/
|
||||||
private UserMapping user_mapping;
|
private UserMapping user_mapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guacamole server environment.
|
||||||
|
*/
|
||||||
|
private final Environment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The filename of the XML file to read the user user_mapping from.
|
* The filename of the XML file to read the user user_mapping from.
|
||||||
*/
|
*/
|
||||||
@@ -79,6 +85,18 @@ public class BasicFileAuthenticationProvider extends SimpleAuthenticationProvide
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new BasicFileAuthenticationProvider that authenticates users
|
||||||
|
* against simple, monolithic XML file.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If a required property is missing, or an error occurs while parsing
|
||||||
|
* a property.
|
||||||
|
*/
|
||||||
|
public BasicFileAuthenticationProvider() throws GuacamoleException {
|
||||||
|
environment = new LocalEnvironment();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a UserMapping containing all authorization data given within
|
* Returns a UserMapping containing all authorization data given within
|
||||||
* the XML file specified by the "basic-user-mapping" property in
|
* the XML file specified by the "basic-user-mapping" property in
|
||||||
@@ -94,7 +112,7 @@ public class BasicFileAuthenticationProvider extends SimpleAuthenticationProvide
|
|||||||
|
|
||||||
// Get user user_mapping file
|
// Get user user_mapping file
|
||||||
File user_mapping_file =
|
File user_mapping_file =
|
||||||
GuacamoleProperties.getRequiredProperty(BASIC_USER_MAPPING);
|
environment.getRequiredProperty(BASIC_USER_MAPPING);
|
||||||
|
|
||||||
// If user_mapping not yet read, or user_mapping has been modified, reread
|
// If user_mapping not yet read, or user_mapping has been modified, reread
|
||||||
if (user_mapping == null ||
|
if (user_mapping == null ||
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Glyptodon LLC
|
* Copyright (C) 2015 Glyptodon LLC
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -24,35 +24,67 @@ package org.glyptodon.guacamole.net.basic;
|
|||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.Stage;
|
||||||
import com.google.inject.servlet.GuiceServletContextListener;
|
import com.google.inject.servlet.GuiceServletContextListener;
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
|
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
||||||
import org.glyptodon.guacamole.net.basic.log.LogModule;
|
import org.glyptodon.guacamole.net.basic.log.LogModule;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.RESTAuthModule;
|
import org.glyptodon.guacamole.net.basic.rest.RESTAuthModule;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.RESTModule;
|
|
||||||
import org.glyptodon.guacamole.net.basic.rest.RESTServletModule;
|
import org.glyptodon.guacamole.net.basic.rest.RESTServletModule;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.auth.BasicTokenSessionMap;
|
import org.glyptodon.guacamole.net.basic.rest.auth.BasicTokenSessionMap;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.auth.TokenSessionMap;
|
import org.glyptodon.guacamole.net.basic.rest.auth.TokenSessionMap;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ServletContextListener to listen for initialization of the servlet context
|
* A ServletContextListener to listen for initialization of the servlet context
|
||||||
* in order to set up dependency injection.
|
* in order to set up dependency injection.
|
||||||
*
|
*
|
||||||
* @author James Muehlner
|
* @author James Muehlner
|
||||||
*/
|
*/
|
||||||
public class BasicServletContextListener extends GuiceServletContextListener {
|
public class BasicServletContextListener extends GuiceServletContextListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logger for this class.
|
||||||
|
*/
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(BasicServletContextListener.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Guacamole server environment.
|
||||||
|
*/
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton instance of a TokenSessionMap.
|
* Singleton instance of a TokenSessionMap.
|
||||||
*/
|
*/
|
||||||
private final TokenSessionMap sessionMap = new BasicTokenSessionMap();
|
private TokenSessionMap sessionMap;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
environment = new LocalEnvironment();
|
||||||
|
sessionMap = new BasicTokenSessionMap(environment);
|
||||||
|
}
|
||||||
|
catch (GuacamoleException e) {
|
||||||
|
logger.error("Unable to read guacamole.properties: {}", e.getMessage());
|
||||||
|
logger.debug("Error reading guacamole.properties.", e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.contextInitialized(servletContextEvent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Injector getInjector() {
|
protected Injector getInjector() {
|
||||||
return Guice.createInjector(
|
return Guice.createInjector(Stage.PRODUCTION,
|
||||||
new LogModule(),
|
new EnvironmentModule(environment),
|
||||||
new RESTServletModule(),
|
new LogModule(environment),
|
||||||
new RESTAuthModule(sessionMap),
|
new RESTAuthModule(environment, sessionMap),
|
||||||
new RESTModule(),
|
new RESTServletModule(),
|
||||||
new TunnelModule()
|
new TunnelModule()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -60,11 +92,12 @@ public class BasicServletContextListener extends GuiceServletContextListener {
|
|||||||
@Override
|
@Override
|
||||||
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
||||||
|
|
||||||
// Shutdown TokenSessionMap
|
|
||||||
sessionMap.shutdown();
|
|
||||||
|
|
||||||
super.contextDestroyed(servletContextEvent);
|
super.contextDestroyed(servletContextEvent);
|
||||||
|
|
||||||
|
// Shutdown TokenSessionMap
|
||||||
|
if (sessionMap != null)
|
||||||
|
sessionMap.shutdown();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Glyptodon LLC
|
* Copyright (C) 2015 Glyptodon LLC
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -20,24 +20,41 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.glyptodon.guacamole.net.basic.rest;
|
package org.glyptodon.guacamole.net.basic;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Guice Module for setting up dependency injection for the
|
* Guice module which binds the base Guacamole server environment.
|
||||||
* Guacamole REST API.
|
*
|
||||||
*
|
* @author Michael Jumper
|
||||||
* @author James Muehlner
|
|
||||||
*/
|
*/
|
||||||
public class RESTModule extends AbstractModule {
|
public class EnvironmentModule extends AbstractModule {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Guacamole server environment.
|
||||||
|
*/
|
||||||
|
private final Environment environment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new EnvironmentModule which will bind the given environment
|
||||||
|
* for future injection.
|
||||||
|
*
|
||||||
|
* @param environment
|
||||||
|
* The environment to bind.
|
||||||
|
*/
|
||||||
|
public EnvironmentModule(Environment environment) {
|
||||||
|
this.environment = environment;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
|
||||||
// Bind generic low-level services
|
// Bind environment
|
||||||
bind(ObjectRetrievalService.class);
|
bind(Environment.class).toInstance(environment);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@@ -33,8 +33,9 @@ import java.security.PrivilegedExceptionAction;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
|
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
||||||
import org.glyptodon.guacamole.net.basic.properties.BasicGuacamoleProperties;
|
import org.glyptodon.guacamole.net.basic.properties.BasicGuacamoleProperties;
|
||||||
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ClassLoader implementation which finds classes within a configurable
|
* A ClassLoader implementation which finds classes within a configurable
|
||||||
@@ -69,9 +70,14 @@ public class GuacamoleClassLoader extends ClassLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GuacamoleClassLoader run() throws GuacamoleException {
|
public GuacamoleClassLoader run() throws GuacamoleException {
|
||||||
|
|
||||||
|
// TODONT: This should be injected, but GuacamoleClassLoader will be removed soon.
|
||||||
|
Environment environment = new LocalEnvironment();
|
||||||
|
|
||||||
return new GuacamoleClassLoader(
|
return new GuacamoleClassLoader(
|
||||||
GuacamoleProperties.getProperty(BasicGuacamoleProperties.LIB_DIRECTORY)
|
environment.getProperty(BasicGuacamoleProperties.LIB_DIRECTORY)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -29,11 +29,11 @@ import java.util.Collections;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
import org.glyptodon.guacamole.net.GuacamoleTunnel;
|
import org.glyptodon.guacamole.net.GuacamoleTunnel;
|
||||||
import org.glyptodon.guacamole.net.auth.Credentials;
|
import org.glyptodon.guacamole.net.auth.Credentials;
|
||||||
import org.glyptodon.guacamole.net.auth.UserContext;
|
import org.glyptodon.guacamole.net.auth.UserContext;
|
||||||
import org.glyptodon.guacamole.net.basic.properties.BasicGuacamoleProperties;
|
import org.glyptodon.guacamole.net.basic.properties.BasicGuacamoleProperties;
|
||||||
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -83,12 +83,21 @@ public class GuacamoleSession {
|
|||||||
/**
|
/**
|
||||||
* Creates a new Guacamole session associated with the given user context.
|
* Creates a new Guacamole session associated with the given user context.
|
||||||
*
|
*
|
||||||
* @param credentials The credentials provided by the user during login.
|
* @param environment
|
||||||
* @param userContext The user context to associate this session with.
|
* The environment of the Guacamole server associated with this new
|
||||||
* @throws GuacamoleException If an error prevents the session from being
|
* session.
|
||||||
* created.
|
*
|
||||||
|
* @param credentials
|
||||||
|
* The credentials provided by the user during login.
|
||||||
|
*
|
||||||
|
* @param userContext
|
||||||
|
* The user context to associate this session with.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error prevents the session from being created.
|
||||||
*/
|
*/
|
||||||
public GuacamoleSession(Credentials credentials, UserContext userContext) throws GuacamoleException {
|
public GuacamoleSession(Environment environment, Credentials credentials,
|
||||||
|
UserContext userContext) throws GuacamoleException {
|
||||||
|
|
||||||
this.lastAccessedTime = System.currentTimeMillis();
|
this.lastAccessedTime = System.currentTimeMillis();
|
||||||
this.credentials = credentials;
|
this.credentials = credentials;
|
||||||
@@ -99,11 +108,11 @@ public class GuacamoleSession {
|
|||||||
|
|
||||||
// Get all listener classes from properties
|
// Get all listener classes from properties
|
||||||
Collection<Class> listenerClasses =
|
Collection<Class> listenerClasses =
|
||||||
GuacamoleProperties.getProperty(BasicGuacamoleProperties.EVENT_LISTENERS);
|
environment.getProperty(BasicGuacamoleProperties.EVENT_LISTENERS);
|
||||||
|
|
||||||
// Add an instance of each class to the list
|
// Add an instance of each class to the list
|
||||||
if (listenerClasses != null) {
|
if (listenerClasses != null) {
|
||||||
for (Class listenerClass : listenerClasses) {
|
for (Class<?> listenerClass : listenerClasses) {
|
||||||
|
|
||||||
// Instantiate listener
|
// Instantiate listener
|
||||||
Object listener = listenerClass.getConstructor().newInstance();
|
Object listener = listenerClass.getConstructor().newInstance();
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 Glyptodon LLC
|
* Copyright (C) 2015 Glyptodon LLC
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Module which loads tunnel implementations.
|
* Module which loads tunnel implementations.
|
||||||
*
|
*
|
||||||
* @author Michael Jumper
|
* @author Michael Jumper
|
||||||
*/
|
*/
|
||||||
public class TunnelModule extends ServletModule {
|
public class TunnelModule extends ServletModule {
|
||||||
@@ -54,12 +54,11 @@ public class TunnelModule extends ServletModule {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Attempt to find WebSocket module
|
// Attempt to find WebSocket module
|
||||||
Class<TunnelLoader> module = (Class<TunnelLoader>)
|
Class<?> module = (Class<?>) GuacamoleClassLoader.getInstance().findClass(classname);
|
||||||
GuacamoleClassLoader.getInstance().findClass(classname);
|
|
||||||
|
|
||||||
// Create loader
|
// Create loader
|
||||||
TunnelLoader loader = module.getConstructor().newInstance();
|
TunnelLoader loader = (TunnelLoader) module.getConstructor().newInstance();
|
||||||
|
|
||||||
// Install module, if supported
|
// Install module, if supported
|
||||||
if (loader.isSupported()) {
|
if (loader.isSupported()) {
|
||||||
@@ -119,4 +118,3 @@ public class TunnelModule extends ServletModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,6 +29,7 @@ import java.util.List;
|
|||||||
import org.glyptodon.guacamole.GuacamoleClientException;
|
import org.glyptodon.guacamole.GuacamoleClientException;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.GuacamoleSecurityException;
|
import org.glyptodon.guacamole.GuacamoleSecurityException;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
import org.glyptodon.guacamole.io.GuacamoleReader;
|
import org.glyptodon.guacamole.io.GuacamoleReader;
|
||||||
import org.glyptodon.guacamole.net.DelegatingGuacamoleTunnel;
|
import org.glyptodon.guacamole.net.DelegatingGuacamoleTunnel;
|
||||||
import org.glyptodon.guacamole.net.GuacamoleTunnel;
|
import org.glyptodon.guacamole.net.GuacamoleTunnel;
|
||||||
@@ -41,7 +42,6 @@ import org.glyptodon.guacamole.net.event.TunnelCloseEvent;
|
|||||||
import org.glyptodon.guacamole.net.event.TunnelConnectEvent;
|
import org.glyptodon.guacamole.net.event.TunnelConnectEvent;
|
||||||
import org.glyptodon.guacamole.net.event.listener.TunnelCloseListener;
|
import org.glyptodon.guacamole.net.event.listener.TunnelCloseListener;
|
||||||
import org.glyptodon.guacamole.net.event.listener.TunnelConnectListener;
|
import org.glyptodon.guacamole.net.event.listener.TunnelConnectListener;
|
||||||
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
|
||||||
import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
|
import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -59,6 +59,12 @@ import org.slf4j.LoggerFactory;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class TunnelRequestService {
|
public class TunnelRequestService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Guacamole server environment.
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger for this class.
|
* Logger for this class.
|
||||||
*/
|
*/
|
||||||
@@ -309,7 +315,7 @@ public class TunnelRequestService {
|
|||||||
|
|
||||||
// Monitor instructions which pertain to server-side events, if necessary
|
// Monitor instructions which pertain to server-side events, if necessary
|
||||||
try {
|
try {
|
||||||
if (GuacamoleProperties.getProperty(ClipboardRESTService.INTEGRATION_ENABLED, false)) {
|
if (environment.getProperty(ClipboardRESTService.INTEGRATION_ENABLED, false)) {
|
||||||
|
|
||||||
ClipboardState clipboard = session.getClipboardState();
|
ClipboardState clipboard = session.getClipboardState();
|
||||||
return new MonitoringGuacamoleReader(clipboard, super.acquireReader());
|
return new MonitoringGuacamoleReader(clipboard, super.acquireReader());
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Glyptodon LLC
|
* Copyright (C) 2015 Glyptodon LLC
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -28,7 +28,7 @@ import ch.qos.logback.core.joran.spi.JoranException;
|
|||||||
import ch.qos.logback.core.util.StatusPrinter;
|
import ch.qos.logback.core.util.StatusPrinter;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.glyptodon.guacamole.properties.GuacamoleHome;
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -44,11 +44,27 @@ public class LogModule extends AbstractModule {
|
|||||||
*/
|
*/
|
||||||
private final Logger logger = LoggerFactory.getLogger(LogModule.class);
|
private final Logger logger = LoggerFactory.getLogger(LogModule.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Guacamole server environment.
|
||||||
|
*/
|
||||||
|
private final Environment environment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new LogModule which uses the given environment to determine
|
||||||
|
* the logging configuration.
|
||||||
|
*
|
||||||
|
* @param environment
|
||||||
|
* The environment to use when configuring logging.
|
||||||
|
*/
|
||||||
|
public LogModule(Environment environment) {
|
||||||
|
this.environment = environment;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
|
||||||
// Only load logback configuration if GUACAMOLE_HOME exists
|
// Only load logback configuration if GUACAMOLE_HOME exists
|
||||||
File guacamoleHome = GuacamoleHome.getDirectory();
|
File guacamoleHome = environment.getGuacamoleHome();
|
||||||
if (!guacamoleHome.isDirectory())
|
if (!guacamoleHome.isDirectory())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -58,7 +74,7 @@ public class LogModule extends AbstractModule {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
logger.info("Loading logback configuration from \"{}\".", logbackConfiguration);
|
logger.info("Loading logback configuration from \"{}\".", logbackConfiguration);
|
||||||
|
|
||||||
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||||
context.reset();
|
context.reset();
|
||||||
|
|
||||||
@@ -77,8 +93,7 @@ public class LogModule extends AbstractModule {
|
|||||||
logger.error("Initialization of logback failed: {}", e.getMessage());
|
logger.error("Initialization of logback failed: {}", e.getMessage());
|
||||||
logger.debug("Unable to load logback configuration..", e);
|
logger.debug("Unable to load logback configuration..", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Glyptodon LLC
|
* Copyright (C) 2015 Glyptodon LLC
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -23,21 +23,20 @@
|
|||||||
package org.glyptodon.guacamole.net.basic.rest;
|
package org.glyptodon.guacamole.net.basic.rest;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.matcher.Matchers;
|
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
import org.glyptodon.guacamole.net.auth.AuthenticationProvider;
|
import org.glyptodon.guacamole.net.auth.AuthenticationProvider;
|
||||||
import org.glyptodon.guacamole.net.basic.properties.BasicGuacamoleProperties;
|
import org.glyptodon.guacamole.net.basic.properties.BasicGuacamoleProperties;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.auth.AuthTokenGenerator;
|
import org.glyptodon.guacamole.net.basic.rest.auth.AuthTokenGenerator;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.auth.AuthenticationService;
|
import org.glyptodon.guacamole.net.basic.rest.auth.AuthenticationService;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.auth.SecureRandomAuthTokenGenerator;
|
import org.glyptodon.guacamole.net.basic.rest.auth.SecureRandomAuthTokenGenerator;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.auth.TokenSessionMap;
|
import org.glyptodon.guacamole.net.basic.rest.auth.TokenSessionMap;
|
||||||
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Guice Module for setting up authentication-specific dependency injection.
|
* A Guice Module for setting up authentication-specific dependency injection.
|
||||||
*
|
*
|
||||||
* @author James Muehlner
|
* @author James Muehlner
|
||||||
* @author Michael Jumper
|
* @author Michael Jumper
|
||||||
*/
|
*/
|
||||||
@@ -46,35 +45,48 @@ public class RESTAuthModule extends AbstractModule {
|
|||||||
/**
|
/**
|
||||||
* Logger for this class.
|
* Logger for this class.
|
||||||
*/
|
*/
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RESTAuthModule.class);
|
private final Logger logger = LoggerFactory.getLogger(RESTAuthModule.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AuthenticationProvider to use to authenticate all requests.
|
* The Guacamole server environment.
|
||||||
*/
|
*/
|
||||||
private AuthenticationProvider authProvider;
|
private final Environment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton instance of a TokenSessionMap.
|
* Singleton instance of TokenSessionMap.
|
||||||
*/
|
*/
|
||||||
private final TokenSessionMap sessionMap;
|
private final TokenSessionMap tokenSessionMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a module which handles binding of authentication-related
|
* Creates a module which handles binding of authentication-related
|
||||||
* objects, including the singleton TokenSessionMap.
|
* objects, including the singleton TokenSessionMap.
|
||||||
*
|
*
|
||||||
* @param sessionMap An instance of TokenSessionMap to inject as a singleton
|
* @param environment
|
||||||
* wherever needed.
|
* The environment to use when configuring authentication.
|
||||||
|
*
|
||||||
|
* @param tokenSessionMap
|
||||||
|
* An instance of TokenSessionMap to inject as a singleton wherever
|
||||||
|
* needed.
|
||||||
*/
|
*/
|
||||||
public RESTAuthModule(TokenSessionMap sessionMap) {
|
public RESTAuthModule(Environment environment,
|
||||||
this.sessionMap = sessionMap;
|
TokenSessionMap tokenSessionMap) {
|
||||||
|
this.environment = environment;
|
||||||
|
this.tokenSessionMap = tokenSessionMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
|
||||||
|
// Bind session map
|
||||||
|
bind(TokenSessionMap.class).toInstance(tokenSessionMap);
|
||||||
|
|
||||||
|
// Bind low-level services
|
||||||
|
bind(AuthenticationService.class);
|
||||||
|
bind(AuthTokenGenerator.class).to(SecureRandomAuthTokenGenerator.class);
|
||||||
|
|
||||||
// Get and bind auth provider instance
|
// Get and bind auth provider instance
|
||||||
try {
|
try {
|
||||||
authProvider = GuacamoleProperties.getRequiredProperty(BasicGuacamoleProperties.AUTH_PROVIDER);
|
AuthenticationProvider authProvider = environment.getRequiredProperty(BasicGuacamoleProperties.AUTH_PROVIDER);
|
||||||
bind(AuthenticationProvider.class).toInstance(authProvider);
|
bind(AuthenticationProvider.class).toInstance(authProvider);
|
||||||
}
|
}
|
||||||
catch (GuacamoleException e) {
|
catch (GuacamoleException e) {
|
||||||
@@ -83,15 +95,6 @@ public class RESTAuthModule extends AbstractModule {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind singleton TokenSessionMap
|
|
||||||
bind(TokenSessionMap.class).toInstance(sessionMap);
|
|
||||||
|
|
||||||
bind(AuthenticationService.class);
|
|
||||||
bind(AuthTokenGenerator.class).to(SecureRandomAuthTokenGenerator.class);
|
|
||||||
|
|
||||||
// Bind @AuthProviderRESTExposure annotation
|
|
||||||
bindInterceptor(Matchers.any(), Matchers.annotatedWith(AuthProviderRESTExposure.class), new AuthProviderRESTExceptionWrapper());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Glyptodon LLC
|
* Copyright (C) 2015 Glyptodon LLC
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
package org.glyptodon.guacamole.net.basic.rest;
|
package org.glyptodon.guacamole.net.basic.rest;
|
||||||
|
|
||||||
import com.google.inject.Scopes;
|
import com.google.inject.Scopes;
|
||||||
|
import com.google.inject.matcher.Matchers;
|
||||||
import com.google.inject.servlet.ServletModule;
|
import com.google.inject.servlet.ServletModule;
|
||||||
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
|
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
|
||||||
import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
|
import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
|
||||||
@@ -37,14 +38,24 @@ import org.glyptodon.guacamole.net.basic.rest.user.UserRESTService;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A Guice Module to set up the servlet mappings for the Guacamole REST API.
|
* A Guice Module to set up the servlet mappings for the Guacamole REST API.
|
||||||
*
|
*
|
||||||
* @author James Muehlner
|
* @author James Muehlner
|
||||||
*/
|
*/
|
||||||
public class RESTServletModule extends ServletModule {
|
public class RESTServletModule extends ServletModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configureServlets() {
|
protected void configureServlets() {
|
||||||
|
|
||||||
|
// Bind @AuthProviderRESTExposure annotation
|
||||||
|
bindInterceptor(
|
||||||
|
Matchers.any(),
|
||||||
|
Matchers.annotatedWith(AuthProviderRESTExposure.class),
|
||||||
|
new AuthProviderRESTExceptionWrapper()
|
||||||
|
);
|
||||||
|
|
||||||
|
// Bind convenience services used by the REST API
|
||||||
|
bind(ObjectRetrievalService.class);
|
||||||
|
|
||||||
// Set up the API endpoints
|
// Set up the API endpoints
|
||||||
bind(ActiveConnectionRESTService.class);
|
bind(ActiveConnectionRESTService.class);
|
||||||
bind(ClipboardRESTService.class);
|
bind(ClipboardRESTService.class);
|
||||||
@@ -54,12 +65,12 @@ public class RESTServletModule extends ServletModule {
|
|||||||
bind(ProtocolRESTService.class);
|
bind(ProtocolRESTService.class);
|
||||||
bind(TokenRESTService.class);
|
bind(TokenRESTService.class);
|
||||||
bind(UserRESTService.class);
|
bind(UserRESTService.class);
|
||||||
|
|
||||||
// Set up the servlet and JSON mappings
|
// Set up the servlet and JSON mappings
|
||||||
bind(GuiceContainer.class);
|
bind(GuiceContainer.class);
|
||||||
bind(JacksonJsonProvider.class).in(Scopes.SINGLETON);
|
bind(JacksonJsonProvider.class).in(Scopes.SINGLETON);
|
||||||
serve("/api/*").with(GuiceContainer.class);
|
serve("/api/*").with(GuiceContainer.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
package org.glyptodon.guacamole.net.basic.rest.auth;
|
package org.glyptodon.guacamole.net.basic.rest.auth;
|
||||||
|
|
||||||
import com.google.inject.Singleton;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -31,9 +30,9 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
import org.glyptodon.guacamole.net.basic.GuacamoleSession;
|
import org.glyptodon.guacamole.net.basic.GuacamoleSession;
|
||||||
import org.glyptodon.guacamole.net.basic.properties.BasicGuacamoleProperties;
|
import org.glyptodon.guacamole.net.basic.properties.BasicGuacamoleProperties;
|
||||||
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -43,7 +42,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
*
|
*
|
||||||
* @author James Muehlner
|
* @author James Muehlner
|
||||||
*/
|
*/
|
||||||
@Singleton
|
|
||||||
public class BasicTokenSessionMap implements TokenSessionMap {
|
public class BasicTokenSessionMap implements TokenSessionMap {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,15 +61,19 @@ public class BasicTokenSessionMap implements TokenSessionMap {
|
|||||||
Collections.synchronizedMap(new LinkedHashMap<String, GuacamoleSession>(16, 0.75f, true));
|
Collections.synchronizedMap(new LinkedHashMap<String, GuacamoleSession>(16, 0.75f, true));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new BasicTokenGuacamoleSessionMap and initialize the session timeout value.
|
* Create a new BasicTokenGuacamoleSessionMap configured using the given
|
||||||
|
* environment.
|
||||||
|
*
|
||||||
|
* @param environment
|
||||||
|
* The environment to use when configuring the token session map.
|
||||||
*/
|
*/
|
||||||
public BasicTokenSessionMap() {
|
public BasicTokenSessionMap(Environment environment) {
|
||||||
|
|
||||||
int sessionTimeoutValue;
|
int sessionTimeoutValue;
|
||||||
|
|
||||||
// Read session timeout from guacamole.properties
|
// Read session timeout from guacamole.properties
|
||||||
try {
|
try {
|
||||||
sessionTimeoutValue = GuacamoleProperties.getProperty(BasicGuacamoleProperties.API_SESSION_TIMEOUT, 60);
|
sessionTimeoutValue = environment.getProperty(BasicGuacamoleProperties.API_SESSION_TIMEOUT, 60);
|
||||||
}
|
}
|
||||||
catch (GuacamoleException e) {
|
catch (GuacamoleException e) {
|
||||||
logger.error("Unable to read guacamole.properties: {}", e.getMessage());
|
logger.error("Unable to read guacamole.properties: {}", e.getMessage());
|
||||||
|
@@ -37,6 +37,7 @@ import javax.ws.rs.core.MediaType;
|
|||||||
import javax.ws.rs.core.MultivaluedMap;
|
import javax.ws.rs.core.MultivaluedMap;
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
import org.glyptodon.guacamole.net.auth.AuthenticationProvider;
|
import org.glyptodon.guacamole.net.auth.AuthenticationProvider;
|
||||||
import org.glyptodon.guacamole.net.auth.Credentials;
|
import org.glyptodon.guacamole.net.auth.Credentials;
|
||||||
import org.glyptodon.guacamole.net.auth.UserContext;
|
import org.glyptodon.guacamole.net.auth.UserContext;
|
||||||
@@ -58,6 +59,12 @@ import org.slf4j.LoggerFactory;
|
|||||||
@Path("/tokens")
|
@Path("/tokens")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class TokenRESTService {
|
public class TokenRESTService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Guacamole server environment.
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The authentication provider used to authenticate this user.
|
* The authentication provider used to authenticate this user.
|
||||||
@@ -269,7 +276,7 @@ public class TokenRESTService {
|
|||||||
// If no existing session, generate a new token/session pair
|
// If no existing session, generate a new token/session pair
|
||||||
else {
|
else {
|
||||||
authToken = authTokenGenerator.getToken();
|
authToken = authTokenGenerator.getToken();
|
||||||
tokenSessionMap.put(authToken, new GuacamoleSession(credentials, userContext));
|
tokenSessionMap.put(authToken, new GuacamoleSession(environment, credentials, userContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("Login was successful for user \"{}\".", userContext.self().getIdentifier());
|
logger.debug("Login was successful for user \"{}\".", userContext.self().getIdentifier());
|
||||||
|
@@ -29,12 +29,12 @@ import javax.ws.rs.QueryParam;
|
|||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.GuacamoleUnsupportedException;
|
import org.glyptodon.guacamole.GuacamoleUnsupportedException;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
import org.glyptodon.guacamole.net.basic.ClipboardState;
|
import org.glyptodon.guacamole.net.basic.ClipboardState;
|
||||||
import org.glyptodon.guacamole.net.basic.GuacamoleSession;
|
import org.glyptodon.guacamole.net.basic.GuacamoleSession;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.AuthProviderRESTExposure;
|
import org.glyptodon.guacamole.net.basic.rest.AuthProviderRESTExposure;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.auth.AuthenticationService;
|
import org.glyptodon.guacamole.net.basic.rest.auth.AuthenticationService;
|
||||||
import org.glyptodon.guacamole.properties.BooleanGuacamoleProperty;
|
import org.glyptodon.guacamole.properties.BooleanGuacamoleProperty;
|
||||||
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A REST service for reading the current contents of the clipboard.
|
* A REST service for reading the current contents of the clipboard.
|
||||||
@@ -44,6 +44,12 @@ import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
|||||||
@Path("/clipboard")
|
@Path("/clipboard")
|
||||||
public class ClipboardRESTService {
|
public class ClipboardRESTService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Guacamole server environment.
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A service for authenticating users from auth tokens.
|
* A service for authenticating users from auth tokens.
|
||||||
*/
|
*/
|
||||||
@@ -71,7 +77,7 @@ public class ClipboardRESTService {
|
|||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
// Only bother if actually enabled
|
// Only bother if actually enabled
|
||||||
if (GuacamoleProperties.getProperty(INTEGRATION_ENABLED, false)) {
|
if (environment.getProperty(INTEGRATION_ENABLED, false)) {
|
||||||
|
|
||||||
// Get clipboard
|
// Get clipboard
|
||||||
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
|
||||||
|
@@ -122,7 +122,7 @@ public class APIConnectionWrapper implements Connection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends ConnectionRecord> getHistory() throws GuacamoleException {
|
public List<? extends ConnectionRecord> getHistory() throws GuacamoleException {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.<ConnectionRecord>emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -79,7 +79,7 @@ public class LanguageRESTService {
|
|||||||
* filename.
|
* filename.
|
||||||
*/
|
*/
|
||||||
private static final Pattern LANGUAGE_KEY_PATTERN = Pattern.compile(".*/([a-z]+_[A-Z]+)\\.json");
|
private static final Pattern LANGUAGE_KEY_PATTERN = Pattern.compile(".*/([a-z]+_[A-Z]+)\\.json");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map of all available language keys to their corresponding
|
* Returns a map of all available language keys to their corresponding
|
||||||
* human-readable names.
|
* human-readable names.
|
||||||
@@ -104,16 +104,19 @@ public class LanguageRESTService {
|
|||||||
@Context ServletContext servletContext) throws GuacamoleException {
|
@Context ServletContext servletContext) throws GuacamoleException {
|
||||||
|
|
||||||
// Get the paths of all the translation files
|
// Get the paths of all the translation files
|
||||||
Set<String> resourcePaths = servletContext.getResourcePaths(TRANSLATION_PATH);
|
Set<?> resourcePaths = servletContext.getResourcePaths(TRANSLATION_PATH);
|
||||||
|
|
||||||
// If no translation files found, return an empty map
|
// If no translation files found, return an empty map
|
||||||
if (resourcePaths == null)
|
if (resourcePaths == null)
|
||||||
return Collections.EMPTY_MAP;
|
return Collections.<String, String>emptyMap();
|
||||||
|
|
||||||
Map<String, String> languageMap = new HashMap<String, String>();
|
Map<String, String> languageMap = new HashMap<String, String>();
|
||||||
|
|
||||||
// Iterate through all the found language files and add them to the return map
|
// Iterate through all the found language files and add them to the return map
|
||||||
for (String resourcePath : resourcePaths) {
|
for (Object resourcePathObject : resourcePaths) {
|
||||||
|
|
||||||
|
// Each resource path is guaranteed to be a string
|
||||||
|
String resourcePath = (String) resourcePathObject;
|
||||||
|
|
||||||
// Get input stream for language file
|
// Get input stream for language file
|
||||||
InputStream languageFileStream = servletContext.getResourceAsStream(resourcePath);
|
InputStream languageFileStream = servletContext.getResourceAsStream(resourcePath);
|
||||||
|
Reference in New Issue
Block a user