mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-393: Merge add extension logout/shutdown hooks
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
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -204,4 +204,9 @@ public class SharedUserContext implements UserContext {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
// Nothing to invalidate
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -191,4 +191,9 @@ public class ModeledUserContext extends RestrictedObject
|
||||
return ModeledSharingProfile.ATTRIBUTES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
// Nothing to invalidate
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -136,4 +136,9 @@ public abstract class RemoteAuthenticatedUser implements AuthenticatedUser {
|
||||
return authenticationProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
// Nothing to invalidate
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -103,5 +103,10 @@ public class LDAPAuthenticationProvider implements AuthenticationProvider {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -229,4 +229,9 @@ public class UserContext implements org.apache.guacamole.net.auth.UserContext {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
// Nothing to invalidate
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -29,4 +29,9 @@ public abstract class AbstractAuthenticatedUser extends AbstractIdentifiable
|
||||
|
||||
// Prior functionality now resides within AbstractIdentifiable
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
// Nothing to invalidate
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -49,4 +49,11 @@ public interface AuthenticatedUser extends Identifiable {
|
||||
*/
|
||||
Credentials getCredentials();
|
||||
|
||||
/**
|
||||
* Invalidates this authenticated user and their associated token such that
|
||||
* they are no longer logged in. This function will be automatically
|
||||
* invoked when the user logs out, or when their session expires.
|
||||
*/
|
||||
void invalidate();
|
||||
|
||||
}
|
||||
|
@@ -168,4 +168,11 @@ public interface AuthenticationProvider {
|
||||
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();
|
||||
|
||||
}
|
||||
|
@@ -212,4 +212,11 @@ public interface UserContext {
|
||||
*/
|
||||
Collection<Form> getSharingProfileAttributes();
|
||||
|
||||
/**
|
||||
* Invalidates this user context, releasing all associated resources. This
|
||||
* function will be invoked when the user logs out, or when their session
|
||||
* is automatically invalidated.
|
||||
*/
|
||||
void invalidate();
|
||||
|
||||
}
|
||||
|
@@ -260,4 +260,9 @@ public abstract class SimpleAuthenticationProvider
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -234,4 +234,9 @@ public class SimpleUserContext implements UserContext {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
// Nothing to invalidate
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -252,6 +252,13 @@ public class GuacamoleSession {
|
||||
}
|
||||
}
|
||||
|
||||
// Invalidate all user contextx
|
||||
for (UserContext userContext : userContexts)
|
||||
userContext.invalidate();
|
||||
|
||||
// Invalidate the authenticated user object
|
||||
authenticatedUser.invalidate();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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