GUAC-1170: Remove use of deprecated GuacamoleProperties.

This commit is contained in:
Michael Jumper
2015-04-26 14:29:35 -07:00
parent 51e9ff77e5
commit 5fc0ff66b5
12 changed files with 138 additions and 31 deletions

View File

@@ -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

View File

@@ -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
); );

View File

@@ -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 {

View File

@@ -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 ||

View File

@@ -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)
); );
} }
}); });

View File

@@ -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,7 +108,7 @@ 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) {

View File

@@ -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());

View File

@@ -25,13 +25,14 @@ package org.glyptodon.guacamole.net.basic.rest;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.matcher.Matchers; 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.environment.LocalEnvironment;
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;
@@ -48,6 +49,11 @@ public class RESTAuthModule extends AbstractModule {
*/ */
private static final Logger logger = LoggerFactory.getLogger(RESTAuthModule.class); private static final Logger logger = LoggerFactory.getLogger(RESTAuthModule.class);
/**
* The Guacamole server environment.
*/
private Environment environment;
/** /**
* The AuthenticationProvider to use to authenticate all requests. * The AuthenticationProvider to use to authenticate all requests.
*/ */
@@ -72,10 +78,16 @@ public class RESTAuthModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
// Get and bind auth provider instance
try { try {
authProvider = GuacamoleProperties.getRequiredProperty(BasicGuacamoleProperties.AUTH_PROVIDER);
// Bind environment
environment = new LocalEnvironment();
bind(Environment.class).toInstance(environment);
// Get and bind auth provider instance
authProvider = environment.getRequiredProperty(BasicGuacamoleProperties.AUTH_PROVIDER);
bind(AuthenticationProvider.class).toInstance(authProvider); bind(AuthenticationProvider.class).toInstance(authProvider);
} }
catch (GuacamoleException e) { catch (GuacamoleException e) {
logger.error("Unable to read authentication provider from guacamole.properties: {}", e.getMessage()); logger.error("Unable to read authentication provider from guacamole.properties: {}", e.getMessage());

View File

@@ -22,6 +22,7 @@
package org.glyptodon.guacamole.net.basic.rest.auth; package org.glyptodon.guacamole.net.basic.rest.auth;
import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
@@ -31,9 +32,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;
@@ -46,6 +47,12 @@ import org.slf4j.LoggerFactory;
@Singleton @Singleton
public class BasicTokenSessionMap implements TokenSessionMap { public class BasicTokenSessionMap implements TokenSessionMap {
/**
* The Guacamole server environment.
*/
@Inject
private Environment environment;
/** /**
* Logger for this class. * Logger for this class.
*/ */
@@ -71,7 +78,7 @@ public class BasicTokenSessionMap implements TokenSessionMap {
// 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());

View File

@@ -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;
@@ -59,6 +60,12 @@ import org.slf4j.LoggerFactory;
@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());

View File

@@ -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);