From d99d38a9b61c8ffd83489a8fd63e1324b1a6fb0d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 23 Mar 2012 11:57:05 -0700 Subject: [PATCH] Authentication success event and listener. --- .../net/event/AuthenticationSuccessEvent.java | 34 +++++++++++++++++++ .../AuthenticationSuccessListener.java | 28 +++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 guacamole-ext/src/main/java/net/sourceforge/guacamole/net/event/AuthenticationSuccessEvent.java create mode 100644 guacamole-ext/src/main/java/net/sourceforge/guacamole/net/event/listener/AuthenticationSuccessListener.java diff --git a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/event/AuthenticationSuccessEvent.java b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/event/AuthenticationSuccessEvent.java new file mode 100644 index 000000000..73e666a62 --- /dev/null +++ b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/event/AuthenticationSuccessEvent.java @@ -0,0 +1,34 @@ +package net.sourceforge.guacamole.net.event; + +import net.sourceforge.guacamole.net.auth.Credentials; + +/** + * 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(). + * + * @author Michael Jumper + */ +public class AuthenticationSuccessEvent implements CredentialEvent { + + /** + * The credentials which passed authentication + */ + private Credentials credentials; + + /** + * Creates a new AuthenticationSuccessEvent which represents a successful + * authentication attempt with the given credentials. + * + * @param credentials The credentials which passed authentication. + */ + public AuthenticationSuccessEvent(Credentials credentials) { + this.credentials = credentials; + } + + @Override + public Credentials getCredentials() { + return credentials; + } + +} diff --git a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/event/listener/AuthenticationSuccessListener.java b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/event/listener/AuthenticationSuccessListener.java new file mode 100644 index 000000000..f7fea9d56 --- /dev/null +++ b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/event/listener/AuthenticationSuccessListener.java @@ -0,0 +1,28 @@ +package net.sourceforge.guacamole.net.event.listener; + +import net.sourceforge.guacamole.net.event.AuthenticationSuccessEvent; + +/** + * A listener whose hooks will fire immediately before and after a user's + * authentication attempt succeeds. If a user successfully authenticates, + * the authenticationSucceeded() hook has the opportunity to cancel the + * authentication and force it to fail. + * + * @author Michael Jumper + */ +public interface AuthenticationSuccessListener { + + /** + * Event hook which fires immediately after a user's authentication attempt + * succeeds. The return value of this hook dictates whether the + * successful authentication attempt is canceled. + * + * @param e The AuthenticationFailureEvent describing the authentication + * failure that just occurred. + * @return true if the successful authentication attempt should be + * allowed, or false if the attempt should be denied, causing + * the attempt to effectively fail. + */ + public boolean authenticationSucceeded(AuthenticationSuccessEvent e); + +}