mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-25 21:42:17 +00:00
Enhanced equals() method.
This commit is contained in:
parent
cff8894b99
commit
cab961bfa6
@ -31,15 +31,24 @@ public abstract class AbstractAuthenticationToken implements Authentication {
|
|||||||
if (obj instanceof AbstractAuthenticationToken) {
|
if (obj instanceof AbstractAuthenticationToken) {
|
||||||
AbstractAuthenticationToken test = (AbstractAuthenticationToken) obj;
|
AbstractAuthenticationToken test = (AbstractAuthenticationToken) obj;
|
||||||
|
|
||||||
|
if (!((this.getAuthorities() == null)
|
||||||
|
&& (test.getAuthorities() == null))) {
|
||||||
|
if ((this.getAuthorities() == null)
|
||||||
|
|| (test.getAuthorities() == null)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.getAuthorities().length != test.getAuthorities().length) {
|
if (this.getAuthorities().length != test.getAuthorities().length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < this.getAuthorities().length; i++) {
|
for (int i = 0; i < this.getAuthorities().length; i++) {
|
||||||
if (!this.getAuthorities()[i].equals(test.getAuthorities()[i])) {
|
if (!this.getAuthorities()[i].equals(
|
||||||
|
test.getAuthorities()[i])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (this.getPrincipal().equals(test.getPrincipal())
|
return (this.getPrincipal().equals(test.getPrincipal())
|
||||||
&& this.getCredentials().equals(test.getCredentials())
|
&& this.getCredentials().equals(test.getCredentials())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user