diff --git a/components/org.wso2.carbon.identity.conditional.auth.functions.jwt.decode/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/jwt/decode/JwtDecodeImpl.java b/components/org.wso2.carbon.identity.conditional.auth.functions.jwt.decode/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/jwt/decode/JwtDecodeImpl.java index fbf7fd48..64cba053 100644 --- a/components/org.wso2.carbon.identity.conditional.auth.functions.jwt.decode/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/jwt/decode/JwtDecodeImpl.java +++ b/components/org.wso2.carbon.identity.conditional.auth.functions.jwt.decode/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/jwt/decode/JwtDecodeImpl.java @@ -26,6 +26,7 @@ import org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException; import java.text.ParseException; +import java.util.Map; /** * Represents javascript function provided in conditional authentication to decode a jwt assertion and retrieve @@ -68,12 +69,28 @@ public String getValueFromDecodedAssertion(String clientAssertion, String parame public JSONObject getDecodedAssertion(String encodedAssertion, boolean isParameterInPayload) throws ParseException { JWSObject plainObject; + Map resultMap; plainObject = JWSObject.parse(encodedAssertion); if (isParameterInPayload) { - return plainObject.getPayload().toJSONObject(); + resultMap = plainObject.getPayload().toJSONObject(); } else { - return plainObject.getHeader().toJSONObject(); + resultMap = plainObject.getHeader().toJSONObject(); + } + JSONObject jsonObject = new JSONObject(resultMap); + recursivelyConvertToJson(jsonObject); + return jsonObject; + } + + private void recursivelyConvertToJson(JSONObject jsonObject) { + + for (String key : jsonObject.keySet()) { + Object value = jsonObject.get(key); + if (value instanceof Map) { + // Recursively convert any Map to JSONObject + jsonObject.put(key, new JSONObject((Map) value)); + recursivelyConvertToJson((JSONObject) jsonObject.get(key)); + } } } diff --git a/pom.xml b/pom.xml index 97b2b940..f1540715 100644 --- a/pom.xml +++ b/pom.xml @@ -569,8 +569,8 @@ 4.1.3.wso2v1 [4.1.3.wso2v1,5.0) 1.5.3 - 7.3.0.wso2v1 - [7.3.0,8.0.0) + 10.3.0.wso2v1 + [10.0.0,11.0.0) 2.4.9 [2.3,3) 1.10.19