From e5a1c734e66d69cc327c14b2f6e30be1d62e40bf Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 22 Jan 2020 13:16:33 +0530 Subject: [PATCH] Revert "Fix login issue with user other than super admin just after starting the pack" This reverts commit b699cae1 --- .../integration/client/OAuthRequestInterceptor.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 c3519912e3..d1a77817f2 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 @@ -39,6 +39,7 @@ import org.wso2.carbon.identity.jwt.client.extension.JWTClient; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; +import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -58,13 +59,15 @@ public class OAuthRequestInterceptor implements RequestInterceptor { private OAuthApplication oAuthApplication; private static Map tenantUserTokenMap = new ConcurrentHashMap<>(); private static final Log log = LogFactory.getLog(OAuthRequestInterceptor.class); + private String username; + private String password; /** * Creates an interceptor that authenticates all requests. */ public OAuthRequestInterceptor() { - String username = APIMConfigReader.getInstance().getConfig().getUsername(); - String password = APIMConfigReader.getInstance().getConfig().getPassword(); + username = APIMConfigReader.getInstance().getConfig().getUsername(); + password = APIMConfigReader.getInstance().getConfig().getPassword(); dcrClient = Feign.builder().client(new OkHttpClient(Utils.getSSLClient())).logger(new Slf4jLogger()) .logLevel(Logger.Level.FULL).requestInterceptor(new BasicAuthRequestInterceptor(username, password)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) @@ -73,6 +76,8 @@ public class OAuthRequestInterceptor implements RequestInterceptor { } public OAuthRequestInterceptor(String username, String password) { + this.username = username; + this.password = password; dcrClient = Feign.builder().client(new OkHttpClient(Utils.getSSLClient())).logger(new Slf4jLogger()) .logLevel(Logger.Level.FULL).requestInterceptor(new BasicAuthRequestInterceptor(username, password)) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) @@ -88,7 +93,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor { clientProfile.setClientName(APPLICATION_NAME); clientProfile.setCallbackUrl(""); clientProfile.setGrantType(GRANT_TYPES); - clientProfile.setOwner(APIMConfigReader.getInstance().getConfig().getUsername()); + clientProfile.setOwner(username); clientProfile.setSaasApp(true); oAuthApplication = dcrClient.register(clientProfile); }