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:
parent
4152df1225
commit
8713d4d52c
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue