Repository: wso2/product-microgateway
Issue: Class cast exception in backend JWT for organizations claim

### Description:
The following error can be observed when the token has the **organizations** claim and backend JWT generation is enabled.

``` 
[2021-10-25 11:35:26,350][363acd6ee699def3feb2cd9e722812c1] ERROR - {org.wso2.choreo.connect.enforcer.commons.model.ParameterResolver} - PathTemplate and RawPath is mismatched.
Oct 25, 2021 11:35:26 AM io.grpc.internal.SerializingExecutor run
SEVERE: Exception while executing runnable io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed@1fbab702
java.lang.ClassCastException: class net.minidev.json.JSONArray cannot be cast to class [Ljava.lang.String; (net.minidev.json.JSONArray is in unnamed module of loader 'app'; [Ljava.lang.String; is in module java.base of loader 'bootstrap')
	at org.wso2.choreo.connect.enforcer.util.FilterUtils.constructJWTContent(FilterUtils.java:356)
	at org.wso2.choreo.connect.enforcer.util.FilterUtils.generateJWTInfoDto(FilterUtils.java:342)
	at org.wso2.choreo.connect.enforcer.security.jwt.JWTAuthenticator.authenticate(JWTAuthenticator.java:270)
	at org.wso2.choreo.connect.enforcer.security.AuthFilter.authenticate(AuthFilter.java:145)
	at org.wso2.choreo.connect.enforcer.security.AuthFilter.handleRequest(AuthFilter.java:125)
	at org.wso2.choreo.connect.enforcer.api.API.executeFilterChain(API.java:42)
	at org.wso2.choreo.connect.enforcer.api.RestAPI.process(RestAPI.java:151)
	at org.wso2.choreo.connect.enforcer.server.HttpRequestHandler.process(HttpRequestHandler.java:57)
	at org.wso2.choreo.connect.enforcer.grpc.ExtAuthService.check(ExtAuthService.java:73)
	at io.envoyproxy.envoy.service.auth.v3.AuthorizationGrpc$MethodHandlers.invoke(AuthorizationGrpc.java:245)
	at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:180)
	at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35)
	at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23)
	at io.grpc.ForwardingServerCallListener$SimpleForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:40)
	at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:331)
	at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:814)
	at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
	at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
```

### Steps to reproduce:



Changed files:
enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/util/FilterUtils.java

diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/util/FilterUtils.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/util/FilterUtils.java
index 8ccd02250..57990879b 100644
--- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/util/FilterUtils.java
+++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/util/FilterUtils.java
@@ -19,6 +19,7 @@
 package org.wso2.choreo.connect.enforcer.util;
 
 import com.nimbusds.jwt.JWTClaimsSet;
+import net.minidev.json.JSONArray;
 import net.minidev.json.JSONObject;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.client.HttpClient;
@@ -353,7 +354,11 @@ public class FilterUtils {
                 jwtInfoDto.setSub(sub);
             }
             if (claims.get(JWTConstants.ORGANIZATIONS) != null) {
-                String[] organizations = (String[]) claims.get(JWTConstants.ORGANIZATIONS);
+                JSONArray orgArray = (JSONArray) claims.get(JWTConstants.ORGANIZATIONS);
+                String[] organizations = new String[orgArray.size()];
+                for (int i = 0; i < orgArray.size(); i++) {
+                    organizations[i] = orgArray.get(i).toString();
+                }
                 jwtInfoDto.setOrganizations(organizations);
             }
         }