mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 17:13:21 +00:00 
			
		
		
		
	GUACAMOLE-393: Add AuthenticationProvider shutdown hook.
This commit is contained in:
		| @@ -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