Skip to content

Commit b398bc3

Browse files
author
Sachin Maheshwari
committed
changing logic to decode token
1 parent bc5a41f commit b398bc3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/java/main/com/cronos/onlinereview/util/JwtTokenUpdater.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,14 @@ public JwtTokenUpdater check() throws Exception {
100100
String[] tokenSplit = jwtCookieV3.getValue().split("\\.");
101101
if (tokenSplit.length <= 1) {
102102
valid = false;
103-
} /*else {
104-
StringBuffer payloadStr = new StringBuffer(tokenSplit[1]);
105-
while (payloadStr.length() % 4 != 0) {
103+
} else {
104+
//StringBuffer payloadStr = new StringBuffer(tokenSplit[1]);
105+
/*while (payloadStr.length() % 4 != 0) {
106106
payloadStr.append('=');
107-
}
108-
109-
String payload = new String(Base64.decode(payloadStr.toString().getBytes(StandardCharsets.UTF_8)));
107+
}*/
108+
//String payload = new String(Base64.decode(payloadStr.toString().getBytes(StandardCharsets.UTF_8)));
109+
110+
String payload = new String(Base64.decodeBase64(tokenSplit[1]), "UTF-8");
110111
JsonNode jsonNode = objectMapper.readValue(payload.toString(), JsonNode.class);
111112

112113
long exp = jsonNode.get("exp").asLong();
@@ -115,7 +116,7 @@ public JwtTokenUpdater check() throws Exception {
115116
if (expDate.before(new Date())) {
116117
valid = false;
117118
}
118-
}*/
119+
}
119120
}
120121
if (jwtCookieV3 == null || !valid) {
121122
String newToken = getRefreshTokenFromApi(jwtCookieV2.getValue());

0 commit comments

Comments
 (0)