17
17
package org .springframework .security .web .authentication ;
18
18
19
19
import java .io .Serializable ;
20
+ import java .util .Objects ;
20
21
21
22
import jakarta .servlet .http .HttpServletRequest ;
22
23
import jakarta .servlet .http .HttpSession ;
@@ -62,37 +63,6 @@ private static String extractSessionId(HttpServletRequest request) {
62
63
return (session != null ) ? session .getId () : null ;
63
64
}
64
65
65
- @ Override
66
- public boolean equals (Object obj ) {
67
- if (obj instanceof WebAuthenticationDetails ) {
68
- WebAuthenticationDetails other = (WebAuthenticationDetails ) obj ;
69
- if ((this .remoteAddress == null ) && (other .getRemoteAddress () != null )) {
70
- return false ;
71
- }
72
- if ((this .remoteAddress != null ) && (other .getRemoteAddress () == null )) {
73
- return false ;
74
- }
75
- if (this .remoteAddress != null ) {
76
- if (!this .remoteAddress .equals (other .getRemoteAddress ())) {
77
- return false ;
78
- }
79
- }
80
- if ((this .sessionId == null ) && (other .getSessionId () != null )) {
81
- return false ;
82
- }
83
- if ((this .sessionId != null ) && (other .getSessionId () == null )) {
84
- return false ;
85
- }
86
- if (this .sessionId != null ) {
87
- if (!this .sessionId .equals (other .getSessionId ())) {
88
- return false ;
89
- }
90
- }
91
- return true ;
92
- }
93
- return false ;
94
- }
95
-
96
66
/**
97
67
* Indicates the TCP/IP address the authentication request was received from.
98
68
* @return the address
@@ -111,15 +81,20 @@ public String getSessionId() {
111
81
}
112
82
113
83
@ Override
114
- public int hashCode () {
115
- int code = 7654 ;
116
- if (this .remoteAddress != null ) {
117
- code = code * (this .remoteAddress .hashCode () % 7 );
84
+ public boolean equals (Object o ) {
85
+ if (this == o ) {
86
+ return true ;
118
87
}
119
- if (this . sessionId != null ) {
120
- code = code * ( this . sessionId . hashCode () % 7 ) ;
88
+ if (o == null || getClass () != o . getClass () ) {
89
+ return false ;
121
90
}
122
- return code ;
91
+ WebAuthenticationDetails that = (WebAuthenticationDetails ) o ;
92
+ return Objects .equals (this .remoteAddress , that .remoteAddress ) && Objects .equals (this .sessionId , that .sessionId );
93
+ }
94
+
95
+ @ Override
96
+ public int hashCode () {
97
+ return Objects .hash (this .remoteAddress , this .sessionId );
123
98
}
124
99
125
100
@ Override
0 commit comments