|
|
@ -233,7 +233,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType,
|
|
|
|
public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType,
|
|
|
|
String validityPeriod) throws APIManagerException {
|
|
|
|
String validityPeriod, String username) throws APIManagerException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
|
|
|
|
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
|
|
|
|
ApiApplicationKey clientCredentials = getClientCredentials(tenantDomain, tags, applicationName, tokenType,
|
|
|
|
ApiApplicationKey clientCredentials = getClientCredentials(tenantDomain, tags, applicationName, tokenType,
|
|
|
@ -245,15 +245,22 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|
|
|
throw new APIManagerException(msg);
|
|
|
|
throw new APIManagerException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String user =
|
|
|
|
if (username == null || username.isEmpty()) {
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + PrivilegedCarbonContext
|
|
|
|
username =
|
|
|
|
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + PrivilegedCarbonContext
|
|
|
|
|
|
|
|
.getThreadLocalCarbonContext().getTenantDomain(true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (!username.contains("@")) {
|
|
|
|
|
|
|
|
username += "@" + PrivilegedCarbonContext
|
|
|
|
.getThreadLocalCarbonContext().getTenantDomain(true);
|
|
|
|
.getThreadLocalCarbonContext().getTenantDomain(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JWTClientManagerService jwtClientManagerService = APIApplicationManagerExtensionDataHolder.getInstance()
|
|
|
|
JWTClientManagerService jwtClientManagerService = APIApplicationManagerExtensionDataHolder.getInstance()
|
|
|
|
.getJwtClientManagerService();
|
|
|
|
.getJwtClientManagerService();
|
|
|
|
JWTClient jwtClient = jwtClientManagerService.getJWTClient();
|
|
|
|
JWTClient jwtClient = jwtClientManagerService.getJWTClient();
|
|
|
|
AccessTokenInfo accessTokenForAdmin = jwtClient
|
|
|
|
AccessTokenInfo accessTokenForAdmin = jwtClient
|
|
|
|
.getAccessToken(clientCredentials.getConsumerKey(), clientCredentials.getConsumerSecret(), user,
|
|
|
|
.getAccessToken(clientCredentials.getConsumerKey(), clientCredentials.getConsumerSecret(), username,
|
|
|
|
scopes);
|
|
|
|
scopes);
|
|
|
|
|
|
|
|
|
|
|
|
return accessTokenForAdmin;
|
|
|
|
return accessTokenForAdmin;
|
|
|
|