Update user context appropriately. Use UserContext for events.

This commit is contained in:
Michael Jumper
2013-08-07 14:51:14 -07:00
parent e8ec136c29
commit c325f443a5
6 changed files with 136 additions and 117 deletions

View File

@@ -1,15 +1,25 @@
package net.sourceforge.guacamole.net.event;
import net.sourceforge.guacamole.net.auth.Credentials;
import net.sourceforge.guacamole.net.auth.UserContext;
/**
* An event which is triggered whenever a user's credentials pass
* authentication. The credentials that passed authentication are included
* within this event, and can be retrieved using getCredentials().
*
* Note that this event is only triggered when the UserContext is initially
* created. Any further updates to the UserContext to not trigger this event.
*
* @author Michael Jumper
*/
public class AuthenticationSuccessEvent implements CredentialEvent {
public class AuthenticationSuccessEvent implements UserEvent, CredentialEvent {
/**
* The UserContext associated with the request that is connecting the
* tunnel, if any.
*/
private UserContext context;
/**
* The credentials which passed authentication.
@@ -20,12 +30,20 @@ public class AuthenticationSuccessEvent implements CredentialEvent {
* Creates a new AuthenticationSuccessEvent which represents a successful
* authentication attempt with the given credentials.
*
* @param context The UserContext created as a result of successful
* authentication.
* @param credentials The credentials which passed authentication.
*/
public AuthenticationSuccessEvent(Credentials credentials) {
public AuthenticationSuccessEvent(UserContext context, Credentials credentials) {
this.context = context;
this.credentials = credentials;
}
@Override
public UserContext getUserContext() {
return context;
}
@Override
public Credentials getCredentials() {
return credentials;

View File

@@ -1,7 +1,7 @@
package net.sourceforge.guacamole.net.event;
import net.sourceforge.guacamole.net.GuacamoleTunnel;
import net.sourceforge.guacamole.net.auth.Credentials;
import net.sourceforge.guacamole.net.auth.UserContext;
/**
* An event which is triggered whenever a tunnel is being closed. The tunnel
@@ -11,13 +11,13 @@ import net.sourceforge.guacamole.net.auth.Credentials;
*
* @author Michael Jumper
*/
public class TunnelCloseEvent implements CredentialEvent, TunnelEvent {
public class TunnelCloseEvent implements UserEvent, TunnelEvent {
/**
* The credentials associated with the request that is closing the
* The UserContext associated with the request that is connecting the
* tunnel, if any.
*/
private Credentials credentials;
private UserContext context;
/**
* The tunnel being closed.
@@ -28,18 +28,18 @@ public class TunnelCloseEvent implements CredentialEvent, TunnelEvent {
* Creates a new TunnelCloseEvent which represents the closing of the
* given tunnel via a request associated with the given credentials.
*
* @param credentials The credentials associated with the request
* closing the tunnel.
* @param context The UserContext associated with the request connecting
* the tunnel.
* @param tunnel The tunnel being closed.
*/
public TunnelCloseEvent(Credentials credentials, GuacamoleTunnel tunnel) {
this.credentials = credentials;
public TunnelCloseEvent(UserContext context, GuacamoleTunnel tunnel) {
this.context = context;
this.tunnel = tunnel;
}
@Override
public Credentials getCredentials() {
return credentials;
public UserContext getUserContext() {
return context;
}
@Override

View File

@@ -1,7 +1,7 @@
package net.sourceforge.guacamole.net.event;
import net.sourceforge.guacamole.net.GuacamoleTunnel;
import net.sourceforge.guacamole.net.auth.Credentials;
import net.sourceforge.guacamole.net.auth.UserContext;
/**
* An event which is triggered whenever a tunnel is being connected. The tunnel
@@ -11,13 +11,13 @@ import net.sourceforge.guacamole.net.auth.Credentials;
*
* @author Michael Jumper
*/
public class TunnelConnectEvent implements CredentialEvent, TunnelEvent {
public class TunnelConnectEvent implements UserEvent, TunnelEvent {
/**
* The credentials associated with the request that is connecting the
* The UserContext associated with the request that is connecting the
* tunnel, if any.
*/
private Credentials credentials;
private UserContext context;
/**
* The tunnel being connected.
@@ -28,18 +28,18 @@ public class TunnelConnectEvent implements CredentialEvent, TunnelEvent {
* Creates a new TunnelConnectEvent which represents the connecting of the
* given tunnel via a request associated with the given credentials.
*
* @param credentials The credentials associated with the request
* connecting the tunnel.
* @param context The UserContext associated with the request connecting
* the tunnel.
* @param tunnel The tunnel being connected.
*/
public TunnelConnectEvent(Credentials credentials, GuacamoleTunnel tunnel) {
this.credentials = credentials;
public TunnelConnectEvent(UserContext context, GuacamoleTunnel tunnel) {
this.context = context;
this.tunnel = tunnel;
}
@Override
public Credentials getCredentials() {
return credentials;
public UserContext getUserContext() {
return context;
}
@Override

View File

@@ -0,0 +1,21 @@
package net.sourceforge.guacamole.net.event;
import net.sourceforge.guacamole.net.auth.UserContext;
/**
* Abstract basis for events which may have an associated UserContext when
* triggered.
*
* @author Michael Jumper
*/
public interface UserEvent {
/**
* Returns the current UserContext of the user triggering the event, if any.
*
* @return The current UserContext of the user triggering the event, if
* any, or null if no UserContext is associated with the event.
*/
UserContext getUserContext();
}