From 8d470f0aedfe68a30a15862a58fca822f631adcc Mon Sep 17 00:00:00 2001 From: Andrey Litvitski Date: Fri, 4 Jul 2025 19:51:04 +0300 Subject: [PATCH] implement equals and hashCode in `OidcIdToken` Closes: #15156 Signed-off-by: Andrey Litvitski --- .../security/oauth2/core/oidc/OidcIdToken.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/oidc/OidcIdToken.java b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/oidc/OidcIdToken.java index c62975a75f5..9ed58ef9ddc 100644 --- a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/oidc/OidcIdToken.java +++ b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/oidc/OidcIdToken.java @@ -73,6 +73,23 @@ public Map getClaims() { return this.claims; } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || this.getClass() != obj.getClass()) { + return false; + } + OidcIdToken that = (OidcIdToken) obj; + return this.getClaims().equals(that.getClaims()); + } + + @Override + public int hashCode() { + return this.getClaims().hashCode(); + } + /** * Create a {@link Builder} based on the given token value * @param tokenValue the token value to use