Skip to content

Commit

Permalink
Merge pull request #105 from topcoder-platform/hotfix-master/RS256-de…
Browse files Browse the repository at this point in the history
…code-token-issue

Master (HotFix) - New Auth Changes
  • Loading branch information
sachin-maheshwari authored Nov 2, 2020
2 parents 533d5af + 73f6128 commit 84fcb49
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.Date;

import org.apache.struts2.ServletActionContext;
import org.apache.xerces.utils.Base64;
import org.apache.commons.codec.binary.Base64;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -101,12 +101,15 @@ public JwtTokenUpdater check() throws Exception {
if (tokenSplit.length <= 1) {
valid = false;
} else {
StringBuffer payloadStr = new StringBuffer(tokenSplit[1]);
/*StringBuffer payloadStr = new StringBuffer(tokenSplit[1]);
while (payloadStr.length() % 4 != 0) {
payloadStr.append('=');
}
String payload = new String(Base64.decode(payloadStr.toString().getBytes(StandardCharsets.UTF_8)));
*/

String payload = new String(Base64.decodeBase64(tokenSplit[1]), "UTF-8");
JsonNode jsonNode = objectMapper.readValue(payload.toString(), JsonNode.class);

long exp = jsonNode.get("exp").asLong();
Expand Down

0 comments on commit 84fcb49

Please sign in to comment.