From 25840a12791323861dbdc3478d03a9663ceae342 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Fri, 4 Aug 2017 09:33:37 +0530 Subject: [PATCH] Fixed NPE in API publisher client (#882) --- .../apimgt/integration/client/OAuthRequestInterceptor.java | 4 ++++ .../client/exception/APIMClientOAuthException.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java index d9afb2aa55e..a1ab7d6c736 100755 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java @@ -101,6 +101,10 @@ public class OAuthRequestInterceptor implements RequestInterceptor { REQUIRED_SCOPE); tenantBasedAccessTokenInfo.setExpiresIn( System.currentTimeMillis() + (tenantBasedAccessTokenInfo.getExpiresIn() * 1000)); + if (tenantBasedAccessTokenInfo.getScopes() == null) { + throw new APIMClientOAuthException("Failed to retrieve scopes from access token"); + } + if (tenantBasedAccessTokenInfo.getScopes().contains(APIM_SUBSCRIBE_SCOPE)) { tenantUserTokenMap.put(username, tenantBasedAccessTokenInfo); } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java index 48f92d5abda..359b4b621e7 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java @@ -35,7 +35,7 @@ public class APIMClientOAuthException extends RuntimeException { this.responseStatus = status; } - APIMClientOAuthException(String message) { + public APIMClientOAuthException(String message) { super(message); }