Add hashMe method to compute AT hash value as needed

pull/1611/head
Enrico Vianello 2023-07-25 18:09:17 +01:00
parent fc8f1452e6
commit 60034aee1b
1 changed files with 10 additions and 0 deletions

View File

@ -20,6 +20,7 @@
*/
package org.mitre.oauth2.model;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -54,6 +55,7 @@ import org.springframework.security.oauth2.common.OAuth2AccessTokenJackson2Deser
import org.springframework.security.oauth2.common.OAuth2AccessTokenJackson2Serializer;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import com.google.common.hash.Hashing;
import com.nimbusds.jwt.JWT;
/**
@ -345,4 +347,12 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
additionalInformation.put(ID_TOKEN_FIELD_NAME, idToken.serialize());
}
}
public void hashMe() {
if (jwtValue != null) {
this.tokenValueHash = Hashing.sha256()
.hashString(jwtValue.serialize(), StandardCharsets.UTF_8)
.toString();
}
}
}