Authentication success event and listener.

This commit is contained in:
Michael Jumper
2012-03-23 11:57:05 -07:00
parent e9fcab10b1
commit d99d38a9b6
2 changed files with 62 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -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);
}