@@ -2985,23 +2985,27 @@ public boolean updateApplicationOwner(String userId, String organization, Applic
2985
2985
KeyManagerHolder .getTenantKeyManagerInstance (tenantDomain , apiKey .getKeyManager ());
2986
2986
}
2987
2987
/* 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
+ }
3005
3009
}
3006
3010
}
3007
3011
} else {
0 commit comments