Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/src/main/java/com/auth0/jwt/interfaces/DecodedJWT.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.auth0.jwt.interfaces;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
* Class that represents a Json Web Token that was decoded from it's string representation.
*/
Expand Down Expand Up @@ -34,4 +37,22 @@ public interface DecodedJWT extends Payload, Header {
* @return the Signature of the JWT.
*/
String getSignature();

/**
* Getter for the Header contained in the JWT as a decoded JSON string.
*
* @return the decoded Header JSON.
*/
default String getHeaderJson() {
return new String(Base64.getUrlDecoder().decode(getHeader()), StandardCharsets.UTF_8);
}

/**
* Getter for the Payload contained in the JWT as a decoded JSON string.
*
* @return the decoded Payload JSON.
*/
default String getPayloadJson() {
return new String(Base64.getUrlDecoder().decode(getPayload()), StandardCharsets.UTF_8);
}
}