All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cloud.sdk.service.prov.api.security.AuthJWTToken Maven / Gradle / Ivy

There is a newer version: 1.40.11
Show newest version
package com.sap.cloud.sdk.service.prov.api.security;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.codec.binary.Base64;

public class AuthJWTToken {
    private JsonObject jwtJson;
    private String jwtStr;
    public  AuthJWTToken(String base64EncodedJWTStr){

        String[] splitString = base64EncodedJWTStr.split("\\.");
        String base64EncodedBody = null;
        if(splitString.length == 3 ) {
            base64EncodedBody = splitString[1];
        }
        if(base64EncodedBody != null && !"".equals(base64EncodedBody)){

            Base64 base64Url = new Base64(true);
            String jwtInfo = new String(base64Url.decode(base64EncodedBody));
            JsonParser jsonParser = new JsonParser();
            jwtJson = (JsonObject) jsonParser.parse(jwtInfo);
            jwtStr = base64EncodedJWTStr;
        }
    }
    public  AuthJWTToken(String jwtToken, JsonObject jwtJson){
        this.jwtStr = jwtToken;
        this.jwtJson = jwtJson;
    }
    public JsonObject getJwtAsJsonNode() {
        return jwtJson;
    }

    public String getJwtAsBase64String() {
        return jwtStr;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy