From 3ca4672ac655d0357ca4d94ad3f4035f4ac1097a Mon Sep 17 00:00:00 2001 From: aselarbd Date: Fri, 7 Sep 2018 14:21:14 +0530 Subject: [PATCH] This commit fix the issue "Change password option does not work from the portal IOT server 3.1.0 " For more info refer https://github.com/wso2/product-iots/issues/1835 --- .../APIManagementProviderServiceImpl.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index 487177ed61..aaa3cb87c1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -26,6 +26,7 @@ import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; import org.wso2.carbon.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil; +import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor; import org.wso2.carbon.apimgt.integration.client.store.*; import org.wso2.carbon.apimgt.integration.generated.client.store.model.*; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -58,8 +59,19 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe tenantDomain, CONTENT_TYPE, null, null); return true; } catch (FeignException e) { - return false; - } + if (e.status() == 401) { + OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor(); + String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + oAuthRequestInterceptor.removeToken(username, tenantDomain); + try { + storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, + APP_TIER_TYPE,tenantDomain, CONTENT_TYPE, null, null); + } catch (FeignException ex) { + log.error("Invalid Attempt : " + ex); + return false; + } + } } + return false; } @Override