Added equals() method.

This commit is contained in:
Ben Alex 2004-03-26 11:05:10 +00:00
parent ae434bd8b3
commit a9569a2f60
2 changed files with 33 additions and 1 deletions

View File

@ -105,4 +105,14 @@ public abstract class AbstractAdapterAuthenticationToken
return false;
}
}
public boolean equals(Object obj) {
if (obj instanceof AbstractAdapterAuthenticationToken) {
if (!super.equals(obj))
return false;
AbstractAdapterAuthenticationToken test = (AbstractAdapterAuthenticationToken) obj;
return (this.getKeyHash() == test.getKeyHash());
}
return false;
}
}

View File

@ -27,6 +27,28 @@ import net.sf.acegisecurity.Authentication;
public abstract class AbstractAuthenticationToken implements Authentication {
//~ Methods ================================================================
public boolean equals(Object obj) {
if (obj instanceof AbstractAuthenticationToken) {
AbstractAuthenticationToken test = (AbstractAuthenticationToken) obj;
if (this.getAuthorities().length != test.getAuthorities().length) {
return false;
}
for (int i = 0; i < this.getAuthorities().length; i++) {
if (!this.getAuthorities()[i].equals(test.getAuthorities()[i])) {
return false;
}
}
return (this.getPrincipal().equals(test.getPrincipal())
&& this.getCredentials().equals(test.getCredentials())
&& (this.isAuthenticated() == test.isAuthenticated()));
}
return false;
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(super.toString() + ": ");