mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fixing failures prompted while invoking APIs that are OAuth protected
This commit is contained in:
parent
8ee09793f2
commit
3c5a3adc2f
@ -64,21 +64,21 @@ public class AuthenticationFrameworkUtil {
|
|||||||
APIKeyValidationInfoDTO apiKeyValidationDTO = tokenValidator.validateKey(context, version, accessToken,
|
APIKeyValidationInfoDTO apiKeyValidationDTO = tokenValidator.validateKey(context, version, accessToken,
|
||||||
requiredAuthenticationLevel, clientDomain);
|
requiredAuthenticationLevel, clientDomain);
|
||||||
if (apiKeyValidationDTO.isAuthorized()) {
|
if (apiKeyValidationDTO.isAuthorized()) {
|
||||||
String userName = apiKeyValidationDTO.getEndUserName();
|
String username = apiKeyValidationDTO.getEndUserName();
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(userName);
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username);
|
||||||
try {
|
try {
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(
|
||||||
IdentityUtil.getTenantIdOFUser(userName));
|
IdentityUtil.getTenantIdOFUser(username));
|
||||||
} catch (IdentityException e) {
|
} catch (IdentityException e) {
|
||||||
throw new AuthenticationException("Error occurred while retrieving the tenant ID of user '" +
|
throw new AuthenticationException("Error occurred while retrieving the tenant ID of user '" +
|
||||||
userName + "'", e);
|
username + "'", e);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
throw new AuthenticationException(apiKeyValidationDTO.getValidationStatus(),
|
throw new AuthenticationException(apiKeyValidationDTO.getValidationStatus(),
|
||||||
"Access failure for API: " + context + ", version: " +
|
"Access failure for API: " + context + ", version: " +
|
||||||
version + " with key: " + accessToken);
|
version + " with key: " + accessToken);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleResponse(Request request, Response response, int statusCode, String payload) {
|
public static void handleResponse(Request request, Response response, int statusCode, String payload) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user