2
0
Ben Alex 21 жил өмнө
parent
commit
a9569a2f60

+ 11 - 1
core/src/main/java/org/acegisecurity/adapters/AbstractAdapterAuthenticationToken.java

@@ -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;
+    }
+}

+ 22 - 0
core/src/main/java/org/acegisecurity/providers/AbstractAuthenticationToken.java

@@ -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() + ": ");