Added equals() method.
This commit is contained in:
parent
ae434bd8b3
commit
a9569a2f60
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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() + ": ");
|
||||
|
|
Loading…
Reference in New Issue