Fix equals and hashCode alignment

Fixes gh-4588
This commit is contained in:
Rob Winch 2017-09-28 16:56:28 -05:00
parent 646b3e48b3
commit f3828924ff
6 changed files with 69 additions and 0 deletions

View File

@ -128,6 +128,18 @@ public class AccessControlEntryImpl implements AccessControlEntry,
return true;
}
@Override
public int hashCode() {
int result = this.acl.hashCode();
result = 31 * result + this.permission.hashCode();
result = 31 * result + (this.id != null ? this.id.hashCode() : 0);
result = 31 * result + this.sid.hashCode();
result = 31 * result + (this.auditFailure ? 1 : 0);
result = 31 * result + (this.auditSuccess ? 1 : 0);
result = 31 * result + (this.granting ? 1 : 0);
return result;
}
public Acl getAcl() {
return acl;
}

View File

@ -325,6 +325,22 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
return false;
}
@Override
public int hashCode() {
int result = this.parentAcl != null ? this.parentAcl.hashCode() : 0;
result = 31 * result + this.aclAuthorizationStrategy.hashCode();
result = 31 * result + (this.permissionGrantingStrategy != null ?
this.permissionGrantingStrategy.hashCode() :
0);
result = 31 * result + (this.aces != null ? this.aces.hashCode() : 0);
result = 31 * result + this.objectIdentity.hashCode();
result = 31 * result + this.id.hashCode();
result = 31 * result + (this.owner != null ? this.owner.hashCode() : 0);
result = 31 * result + (this.loadedSids != null ? this.loadedSids.hashCode() : 0);
result = 31 * result + (this.entriesInheriting ? 1 : 0);
return result;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("AclImpl[");

View File

@ -144,6 +144,17 @@ public class CasAuthenticationToken extends AbstractAuthenticationToken implemen
return false;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + this.credentials.hashCode();
result = 31 * result + this.principal.hashCode();
result = 31 * result + this.userDetails.hashCode();
result = 31 * result + this.keyHash;
result = 31 * result + (this.assertion != null ? this.assertion.hashCode() : 0);
return result;
}
public Object getCredentials() {
return this.credentials;
}

View File

@ -100,6 +100,13 @@ public class AnonymousAuthenticationToken extends AbstractAuthenticationToken im
return false;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + this.keyHash;
return result;
}
/**
* Always returns an empty <code>String</code>
*

View File

@ -120,4 +120,10 @@ public class RememberMeAuthenticationToken extends AbstractAuthenticationToken {
return false;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + this.keyHash;
return result;
}
}

View File

@ -60,6 +60,23 @@ public final class Header {
return this.headerValues;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Header header = (Header) o;
if (!this.headerName.equals(header.headerName)) {
return false;
}
return this.headerValues.equals(header.headerValues);
}
public int hashCode() {
return headerName.hashCode() + headerValues.hashCode();
}