Skip to content

Commit 04b5268

Browse files
author
sachin-maheshwari
authored
Merge pull request #104 from topcoder-platform/hotfix/RS256-token
Hotfix DEV - RS256 token decoding issue
2 parents dc27eb8 + c02d9df commit 04b5268

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ workflows:
9696
context : org-global
9797
filters:
9898
branches:
99-
only: [dev-circleci2, dev]
99+
only: [dev, 'hotfix/RS256-token']
100100
- build-prod:
101101
context : org-global
102102
filters:

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.util.Date;
2121

2222
import org.apache.struts2.ServletActionContext;
23-
import org.apache.xerces.utils.Base64;
23+
import org.apache.commons.codec.binary.Base64;
2424

2525
import com.fasterxml.jackson.databind.JsonNode;
2626
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -101,12 +101,13 @@ public JwtTokenUpdater check() throws Exception {
101101
if (tokenSplit.length <= 1) {
102102
valid = false;
103103
} else {
104-
StringBuffer payloadStr = new StringBuffer(tokenSplit[1]);
105-
while (payloadStr.length() % 4 != 0) {
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();

0 commit comments

Comments
 (0)