mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-01 09:42:13 +00:00
Updated hashcode and equals
Closes gh-4133
This commit is contained in:
parent
e071c28e8a
commit
2a487ae7f8
@ -17,6 +17,7 @@
|
|||||||
package org.springframework.security.web.authentication;
|
package org.springframework.security.web.authentication;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpSession;
|
import jakarta.servlet.http.HttpSession;
|
||||||
@ -62,37 +63,6 @@ public class WebAuthenticationDetails implements Serializable {
|
|||||||
return (session != null) ? session.getId() : null;
|
return (session != null) ? session.getId() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj instanceof WebAuthenticationDetails) {
|
|
||||||
WebAuthenticationDetails other = (WebAuthenticationDetails) obj;
|
|
||||||
if ((this.remoteAddress == null) && (other.getRemoteAddress() != null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ((this.remoteAddress != null) && (other.getRemoteAddress() == null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.remoteAddress != null) {
|
|
||||||
if (!this.remoteAddress.equals(other.getRemoteAddress())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((this.sessionId == null) && (other.getSessionId() != null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ((this.sessionId != null) && (other.getSessionId() == null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.sessionId != null) {
|
|
||||||
if (!this.sessionId.equals(other.getSessionId())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates the TCP/IP address the authentication request was received from.
|
* Indicates the TCP/IP address the authentication request was received from.
|
||||||
* @return the address
|
* @return the address
|
||||||
@ -110,16 +80,21 @@ public class WebAuthenticationDetails implements Serializable {
|
|||||||
return this.sessionId;
|
return this.sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
WebAuthenticationDetails that = (WebAuthenticationDetails) o;
|
||||||
|
return Objects.equals(this.remoteAddress, that.remoteAddress) && Objects.equals(this.sessionId, that.sessionId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int code = 7654;
|
return Objects.hash(this.remoteAddress, this.sessionId);
|
||||||
if (this.remoteAddress != null) {
|
|
||||||
code = code * (this.remoteAddress.hashCode() % 7);
|
|
||||||
}
|
|
||||||
if (this.sessionId != null) {
|
|
||||||
code = code * (this.sessionId.hashCode() % 7);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user