Authentication subclasses Principal, so it's directly usable by classes that want a Principal. No implementations need to change if they subclass AbstractAuthenticationToken, as it implements the one and only method required by Principal.

This commit is contained in:
Ben Alex 2004-05-04 07:35:41 +00:00
parent 4152df1225
commit 8713d4d52c
3 changed files with 9 additions and 1 deletions

View File

@ -15,6 +15,9 @@
package net.sf.acegisecurity;
import java.security.Principal;
/**
* Represents an authentication request.
*
@ -30,7 +33,7 @@ package net.sf.acegisecurity;
* @author Ben Alex
* @version $Id$
*/
public interface Authentication {
public interface Authentication extends Principal {
//~ Methods ================================================================
public void setAuthenticated(boolean isAuthenticated);

View File

@ -27,6 +27,10 @@ import net.sf.acegisecurity.Authentication;
public abstract class AbstractAuthenticationToken implements Authentication {
//~ Methods ================================================================
public String getName() {
return this.getPrincipal().toString();
}
public boolean equals(Object obj) {
if (obj instanceof AbstractAuthenticationToken) {
AbstractAuthenticationToken test = (AbstractAuthenticationToken) obj;

View File

@ -55,6 +55,7 @@ public class AbstractAuthenticationTokenTests extends TestCase {
"ROLE_TWO")});
assertEquals("Test", token.getPrincipal());
assertEquals("Password", token.getCredentials());
assertEquals("Test", token.getName());
}
public void testObjectsEquals() throws Exception {