Skip to content

Commit 3ac8150

Browse files
authored
Merge pull request #13057 from PasanT9/mapped-key
Skip retrieve application from external KM for MAPPED keys
2 parents f6d7bf1 + 2b0d1f9 commit 3ac8150

File tree

1 file changed

+21
-17
lines changed
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl

1 file changed

+21
-17
lines changed

Diff for: components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java

+21-17
Original file line numberDiff line numberDiff line change
@@ -2985,23 +2985,27 @@ public boolean updateApplicationOwner(String userId, String organization, Applic
29852985
KeyManagerHolder.getTenantKeyManagerInstance(tenantDomain, apiKey.getKeyManager());
29862986
}
29872987
/* retrieving OAuth application information for specific consumer key */
2988-
consumerKey = apiKey.getConsumerKey();
2989-
OAuthApplicationInfo oAuthApplicationInfo = keyManager.retrieveApplication(consumerKey);
2990-
if (oAuthApplicationInfo.getParameter(ApplicationConstants.OAUTH_CLIENT_NAME) != null) {
2991-
OAuthAppRequest oauthAppRequest = ApplicationUtils.createOauthAppRequest(oAuthApplicationInfo.
2992-
getParameter(ApplicationConstants.OAUTH_CLIENT_NAME).toString(), null,
2993-
oAuthApplicationInfo.getCallBackURL(), null,
2994-
null, application.getTokenType(), this.tenantDomain, apiKey.getKeyManager());
2995-
oauthAppRequest.getOAuthApplicationInfo().setAppOwner(userId);
2996-
oauthAppRequest.getOAuthApplicationInfo().setClientId(consumerKey);
2997-
/* updating the owner of the OAuth application with userId */
2998-
OAuthApplicationInfo updatedAppInfo = keyManager.updateApplicationOwner(oauthAppRequest,
2999-
userId);
3000-
isAppUpdated = true;
3001-
audit.info("Successfully updated the owner of application " + application.getName() +
3002-
" from " + oldUserName + " to " + userId + ".");
3003-
} else {
3004-
throw new APIManagementException("Unable to retrieve OAuth application information.");
2988+
if (!APIConstants.OAuthAppMode.MAPPED.name().equalsIgnoreCase(apiKey.getCreateMode())) {
2989+
consumerKey = apiKey.getConsumerKey();
2990+
OAuthApplicationInfo oAuthApplicationInfo = keyManager.retrieveApplication(consumerKey);
2991+
Object oauthClientName =
2992+
oAuthApplicationInfo.getParameter(ApplicationConstants.OAUTH_CLIENT_NAME);
2993+
if (oauthClientName != null) {
2994+
OAuthAppRequest oauthAppRequest = ApplicationUtils.createOauthAppRequest(
2995+
oauthClientName.toString(), null, oAuthApplicationInfo.getCallBackURL(),
2996+
null, null, application.getTokenType(), this.tenantDomain,
2997+
apiKey.getKeyManager());
2998+
oauthAppRequest.getOAuthApplicationInfo().setAppOwner(userId);
2999+
oauthAppRequest.getOAuthApplicationInfo().setClientId(consumerKey);
3000+
/* updating the owner of the OAuth application with userId */
3001+
OAuthApplicationInfo updatedAppInfo = keyManager.updateApplicationOwner(oauthAppRequest,
3002+
userId);
3003+
isAppUpdated = true;
3004+
audit.info("Successfully updated the owner of application " + application.getName() +
3005+
" from " + oldUserName + " to " + userId + ".");
3006+
} else {
3007+
throw new APIManagementException("Unable to retrieve OAuth application information.");
3008+
}
30053009
}
30063010
}
30073011
} else {

0 commit comments

Comments
 (0)