...
Code Block | ||||
---|---|---|---|---|
| ||||
import java.util.Base64; import com.google.gson.JsonObject; import com.google.gson.JsonParser; public class ParseJWT { public staticString void mainparseServiceId(String[] argstoken) { // Assume token is passed or retrieved from headers String token = "your.jwt.token.here"; // Split token into its parts String[] chunks = token.split("\\."); Base64.Decoder decoder = Base64.getUrlDecoder(); // Decode payload String payload = new String(decoder.decode(chunks[1])); // Parse JSON using Gson JsonObject jsonObject = JsonParser.parseString(payload).getAsJsonObject(); // Extract the client_id String clientId = jsonObject.get("client_id").getAsString(); System.out.println("Client ID: " + clientId)return clientId; } } |
In the create policy code check if there is an header and if there is a clientId use it as serviceId, other cases are covered having default serviceId (If there is no header, if there is an header but not a clientId)
...