mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-08 06:01:22 +00:00
GUAC-1170: Remove use of deprecated GuacamoleHome.
This commit is contained in:
@@ -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,13 +20,12 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.glyptodon.guacamole.net.basic.rest;
|
package org.glyptodon.guacamole.net.basic.inject;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.matcher.Matchers;
|
import com.google.inject.Inject;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.environment.Environment;
|
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;
|
||||||
@@ -38,56 +37,58 @@ 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
|
||||||
*/
|
*/
|
||||||
public class RESTAuthModule extends AbstractModule {
|
public class AuthenticationModule 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(AuthenticationModule.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Guacamole server environment.
|
* The Guacamole server environment.
|
||||||
*/
|
*/
|
||||||
private Environment environment;
|
private final Environment environment;
|
||||||
|
|
||||||
/**
|
|
||||||
* The AuthenticationProvider to use to authenticate all requests.
|
|
||||||
*/
|
|
||||||
private AuthenticationProvider authProvider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 AuthenticationModule(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
|
||||||
try {
|
try {
|
||||||
|
AuthenticationProvider authProvider = environment.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());
|
||||||
@@ -95,15 +96,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
|
||||||
@@ -20,38 +20,68 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.glyptodon.guacamole.net.basic;
|
package org.glyptodon.guacamole.net.basic.inject;
|
||||||
|
|
||||||
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.net.basic.log.LogModule;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.RESTAuthModule;
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.RESTModule;
|
import org.glyptodon.guacamole.environment.LocalEnvironment;
|
||||||
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(
|
||||||
new LogModule(),
|
Stage.PRODUCTION,
|
||||||
new RESTServletModule(),
|
new EnvironmentModule(environment),
|
||||||
new RESTAuthModule(sessionMap),
|
new LogModule(environment),
|
||||||
|
new AuthenticationModule(environment, sessionMap),
|
||||||
new RESTModule(),
|
new RESTModule(),
|
||||||
new TunnelModule()
|
new TunnelModule()
|
||||||
);
|
);
|
||||||
@@ -60,11 +90,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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Glyptodon LLC
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.glyptodon.guacamole.net.basic.inject;
|
||||||
|
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import org.glyptodon.guacamole.environment.Environment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guice module which binds the base Guacamole server environment.
|
||||||
|
*
|
||||||
|
* @author Michael Jumper
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
protected void configure() {
|
||||||
|
|
||||||
|
// Bind environment
|
||||||
|
bind(Environment.class).toInstance(environment);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@@ -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,7 +20,7 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.glyptodon.guacamole.net.basic.log;
|
package org.glyptodon.guacamole.net.basic.inject;
|
||||||
|
|
||||||
import ch.qos.logback.classic.LoggerContext;
|
import ch.qos.logback.classic.LoggerContext;
|
||||||
import ch.qos.logback.classic.joran.JoranConfigurator;
|
import ch.qos.logback.classic.joran.JoranConfigurator;
|
||||||
@@ -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
|
||||||
@@ -20,12 +20,16 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.glyptodon.guacamole.net.basic.rest;
|
package org.glyptodon.guacamole.net.basic.inject;
|
||||||
|
|
||||||
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;
|
||||||
|
import org.glyptodon.guacamole.net.basic.rest.AuthProviderRESTExceptionWrapper;
|
||||||
|
import org.glyptodon.guacamole.net.basic.rest.AuthProviderRESTExposure;
|
||||||
|
import org.glyptodon.guacamole.net.basic.rest.ObjectRetrievalService;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.auth.TokenRESTService;
|
import org.glyptodon.guacamole.net.basic.rest.auth.TokenRESTService;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.clipboard.ClipboardRESTService;
|
import org.glyptodon.guacamole.net.basic.rest.clipboard.ClipboardRESTService;
|
||||||
import org.glyptodon.guacamole.net.basic.rest.connection.ConnectionRESTService;
|
import org.glyptodon.guacamole.net.basic.rest.connection.ConnectionRESTService;
|
||||||
@@ -37,14 +41,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 RESTModule 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 +68,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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -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
|
||||||
@@ -20,17 +20,21 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.glyptodon.guacamole.net.basic;
|
package org.glyptodon.guacamole.net.basic.inject;
|
||||||
|
|
||||||
import com.google.inject.servlet.ServletModule;
|
import com.google.inject.servlet.ServletModule;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
|
import org.glyptodon.guacamole.net.basic.BasicGuacamoleTunnelServlet;
|
||||||
|
import org.glyptodon.guacamole.net.basic.GuacamoleClassLoader;
|
||||||
|
import org.glyptodon.guacamole.net.basic.TunnelLoader;
|
||||||
|
import org.glyptodon.guacamole.net.basic.TunnelRequestService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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,7 +58,7 @@ public class TunnelModule extends ServletModule {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Attempt to find WebSocket module
|
// Attempt to find WebSocket module
|
||||||
Class<?> module = (Class<?>) GuacamoleClassLoader.getInstance().findClass(classname);
|
Class<?> module = (Class<?>) GuacamoleClassLoader.getInstance().findClass(classname);
|
||||||
|
|
||||||
// Create loader
|
// Create loader
|
||||||
@@ -118,4 +122,3 @@ public class TunnelModule extends ServletModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@@ -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,8 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.glyptodon.guacamole.net.basic.rest;
|
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Guice Module for setting up dependency injection for the
|
* Dependency injection classes specific to the Guacamole web application.
|
||||||
* Guacamole REST API.
|
|
||||||
*
|
|
||||||
* @author James Muehlner
|
|
||||||
*/
|
*/
|
||||||
public class RESTModule extends AbstractModule {
|
package org.glyptodon.guacamole.net.basic.inject;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
|
|
||||||
// Bind generic low-level services
|
|
||||||
bind(ObjectRetrievalService.class);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
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 java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -44,15 +42,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
*
|
*
|
||||||
* @author James Muehlner
|
* @author James Muehlner
|
||||||
*/
|
*/
|
||||||
@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.
|
||||||
*/
|
*/
|
||||||
@@ -70,9 +61,13 @@ 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;
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
</filter-mapping>
|
</filter-mapping>
|
||||||
|
|
||||||
<listener>
|
<listener>
|
||||||
<listener-class>org.glyptodon.guacamole.net.basic.BasicServletContextListener</listener-class>
|
<listener-class>org.glyptodon.guacamole.net.basic.inject.BasicServletContextListener</listener-class>
|
||||||
</listener>
|
</listener>
|
||||||
|
|
||||||
<!-- Audio file mimetype mappings -->
|
<!-- Audio file mimetype mappings -->
|
||||||
|
Reference in New Issue
Block a user