Search in sources :

Example 1 with BPackage

use of org.ballerinalang.jvm.types.BPackage in project product-microgateway by wso2.

the class MGWJWTGeneratorInvoker method getRetrievedClaims.

public static BMap<String, Object> getRetrievedClaims(BMap<String, Object> authContext) {
    try {
        List<ClaimDTO> claimList = abstractMGWClaimRetriever.retrieveClaims(convertBMapToMap(authContext));
        if (claimList == null) {
            return null;
        }
        BPackage packageId = new BPackage("wso2", "gateway", "3.2.1");
        BMap<String, Object> bMap = BValueCreator.createRecordValue(packageId, "RetrievedUserClaimsListDTO");
        bMap.put("count", claimList.size());
        BArray bArray = (BArray) bMap.get("list");
        for (Object claimDTO : claimList) {
            bArray.append(BValueCreator.createRecordValue(packageId, "ClaimDTO", (Map<String, Object>) claimDTO));
        }
        return bMap;
    // Not to break the flow if an exception occured during claim retrieval
    } catch (Exception e) {
        log.error("Error while retrieving user claims from remote url.", e);
        return null;
    }
}
Also used : ClaimDTO(org.wso2.micro.gateway.jwt.generator.ClaimDTO) HashMap(java.util.HashMap) Map(java.util.Map) BMap(org.ballerinalang.jvm.values.api.BMap) BArray(org.ballerinalang.jvm.values.api.BArray) InvocationTargetException(java.lang.reflect.InvocationTargetException) BPackage(org.ballerinalang.jvm.types.BPackage)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BPackage (org.ballerinalang.jvm.types.BPackage)1 BArray (org.ballerinalang.jvm.values.api.BArray)1 BMap (org.ballerinalang.jvm.values.api.BMap)1 ClaimDTO (org.wso2.micro.gateway.jwt.generator.ClaimDTO)1