in custos-services/custos-integration-services/custos-integration-services-commons/src/main/java/org/apache/custos/integration/services/commons/interceptors/MultiTenantAuthInterceptor.java [55:88]
public Optional<AuthClaim> authorize(Metadata headers, String clientId) {
try {
if (clientId != null && clientId.trim().isEmpty()) {
clientId = null;
}
boolean agentAuthenticationEnabled = isAgentAuthenticationEnabled(headers);
if (agentAuthenticationEnabled) {
return authorizeUsingAgentAndUserJWTTokens(headers);
}
Optional<String> userToken = getUserTokenFromUserTokenHeader(headers);
boolean isBasicAuth = isBasicAuth(headers);
if (clientId == null && userToken.isEmpty() && isBasicAuth) {
return authorize(headers);
} else if (clientId != null && userToken.isEmpty() && isBasicAuth) {
return authorizeParentChildTenantValidationWithBasicAuth(headers, clientId);
} else if (clientId != null && userToken.isPresent()) {
return authorizeParentChildTenantWithBasicAuthAndUserTokenValidation(headers, clientId, userToken.get());
} else if (clientId != null && isUserToken(headers)) {
return authorizeParentChildTenantWithUserTokenValidation(headers, clientId);
} else {
return authorizeUsingUserToken(headers);
}
} catch (Exception ex) {
LOGGER.error(ex.getMessage(),ex);
clearUserTokenFromHeader(headers);
throw ex;
}
}