From 8cff7155991ad5000aef92292e640b59cef62164 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Wed, 26 Apr 2006 01:18:42 +0000 Subject: [PATCH] SEC-222: Improve hashCode() to use XOR. --- .../providers/AbstractAuthenticationToken.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/acegisecurity/providers/AbstractAuthenticationToken.java b/core/src/main/java/org/acegisecurity/providers/AbstractAuthenticationToken.java index 7c980c1605..c18cef2f0a 100644 --- a/core/src/main/java/org/acegisecurity/providers/AbstractAuthenticationToken.java +++ b/core/src/main/java/org/acegisecurity/providers/AbstractAuthenticationToken.java @@ -145,28 +145,28 @@ public abstract class AbstractAuthenticationToken implements Authentication { } public int hashCode() { - int code = 2305; + int code = 31; if (this.getAuthorities() != null) { for (int i = 0; i < this.getAuthorities().length; i++) { - code = code * (this.getAuthorities()[i].hashCode() % 7); + code ^= this.getAuthorities()[i].hashCode(); } } if (this.getPrincipal() != null) { - code = code * (this.getPrincipal().hashCode() % 7); + code ^= this.getPrincipal().hashCode(); } if (this.getCredentials() != null) { - code = code * (this.getCredentials().hashCode() % 7); + code ^= this.getCredentials().hashCode(); } if (this.getDetails() != null) { - code = code * (this.getDetails().hashCode() % 7); + code ^= this.getDetails().hashCode(); } if (this.isAuthenticated()) { - code = code * -3; + code ^= -37; } return code;