mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-393: Add AuthenticationProvider shutdown hook.
This commit is contained in:
@@ -107,4 +107,9 @@ public class CASAuthenticationProvider implements AuthenticationProvider {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -102,4 +102,9 @@ public class DuoAuthenticationProvider implements AuthenticationProvider {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -107,4 +107,9 @@ public class HTTPHeaderAuthenticationProvider implements AuthenticationProvider
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -104,4 +104,9 @@ public abstract class InjectedAuthenticationProvider implements AuthenticationPr
|
||||
authenticatedUser, credentials);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -103,5 +103,10 @@ public class LDAPAuthenticationProvider implements AuthenticationProvider {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -167,5 +167,12 @@ public interface AuthenticationProvider {
|
||||
UserContext updateUserContext(UserContext context,
|
||||
AuthenticatedUser authenticatedUser,
|
||||
Credentials credentials) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Frees all resources associated with this AuthenticationProvider. This
|
||||
* function will be automatically invoked when the Guacamole server is
|
||||
* shutting down.
|
||||
*/
|
||||
void shutdown();
|
||||
|
||||
}
|
||||
|
@@ -260,4 +260,9 @@ public abstract class SimpleAuthenticationProvider
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,14 +21,17 @@ package org.apache.guacamole;
|
||||
|
||||
import org.apache.guacamole.tunnel.TunnelModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Stage;
|
||||
import com.google.inject.servlet.GuiceServletContextListener;
|
||||
import java.util.List;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import org.apache.guacamole.environment.Environment;
|
||||
import org.apache.guacamole.environment.LocalEnvironment;
|
||||
import org.apache.guacamole.extension.ExtensionModule;
|
||||
import org.apache.guacamole.log.LogModule;
|
||||
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
||||
import org.apache.guacamole.rest.RESTServiceModule;
|
||||
import org.apache.guacamole.rest.auth.HashTokenSessionMap;
|
||||
import org.apache.guacamole.rest.auth.TokenSessionMap;
|
||||
@@ -56,6 +59,12 @@ public class GuacamoleServletContextListener extends GuiceServletContextListener
|
||||
*/
|
||||
private TokenSessionMap sessionMap;
|
||||
|
||||
/**
|
||||
* List of all authentication providers from all loaded extensions.
|
||||
*/
|
||||
@Inject
|
||||
private List<AuthenticationProvider> authProviders;
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||
|
||||
@@ -75,13 +84,21 @@ public class GuacamoleServletContextListener extends GuiceServletContextListener
|
||||
|
||||
@Override
|
||||
protected Injector getInjector() {
|
||||
return Guice.createInjector(Stage.PRODUCTION,
|
||||
|
||||
// Create injector
|
||||
Injector injector = Guice.createInjector(Stage.PRODUCTION,
|
||||
new EnvironmentModule(environment),
|
||||
new LogModule(environment),
|
||||
new ExtensionModule(environment),
|
||||
new RESTServiceModule(sessionMap),
|
||||
new TunnelModule()
|
||||
);
|
||||
|
||||
// Inject any annotated members of this class
|
||||
injector.injectMembers(this);
|
||||
|
||||
return injector;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,6 +110,12 @@ public class GuacamoleServletContextListener extends GuiceServletContextListener
|
||||
if (sessionMap != null)
|
||||
sessionMap.shutdown();
|
||||
|
||||
// Unload all extensions
|
||||
if (authProviders != null) {
|
||||
for (AuthenticationProvider authProvider : authProviders)
|
||||
authProvider.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -209,4 +209,10 @@ public class AuthenticationProviderFacade implements AuthenticationProvider {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
if (authProvider != null)
|
||||
authProvider.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user