From 78df09db8a61ca83ab098431ea4debd43eb98a29 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Thu, 9 Feb 2006 02:53:27 +0000 Subject: [PATCH] SEC-175: Add equals(Object) method. --- .../ui/WebAuthenticationDetails.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/core/src/main/java/org/acegisecurity/ui/WebAuthenticationDetails.java b/core/src/main/java/org/acegisecurity/ui/WebAuthenticationDetails.java index 29f6d2b5ef..33bd5d28a8 100644 --- a/core/src/main/java/org/acegisecurity/ui/WebAuthenticationDetails.java +++ b/core/src/main/java/org/acegisecurity/ui/WebAuthenticationDetails.java @@ -79,6 +79,44 @@ public class WebAuthenticationDetails implements SessionIdentifierAware, */ protected void doPopulateAdditionalInformation(HttpServletRequest request) {} + public boolean equals(Object obj) { + if (obj instanceof WebAuthenticationDetails) { + WebAuthenticationDetails rhs = (WebAuthenticationDetails) obj; + + if ((remoteAddress == null) && (rhs.getRemoteAddress() != null)) { + return false; + } + + if ((remoteAddress != null) && (rhs.getRemoteAddress() == null)) { + return false; + } + + if (remoteAddress != null) { + if (!remoteAddress.equals(rhs.getRemoteAddress())) { + return false; + } + } + + if ((sessionId == null) && (rhs.getSessionId() != null)) { + return false; + } + + if ((sessionId != null) && (rhs.getSessionId() == null)) { + return false; + } + + if (sessionId != null) { + if (!sessionId.equals(rhs.getSessionId())) { + return false; + } + } + + return true; + } + + return false; + } + /** * Indicates the TCP/IP address the authentication request was received * from.