in services/src/main/java/org/apache/custos/service/auth/TokenAuthorizer.java [198:227]
public Optional<AuthClaim> authorize(HttpHeaders headers, String clientId) {
try {
if (clientId != null && clientId.trim().isEmpty()) {
clientId = null;
}
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("Error while generating AuthClaims for authorize", ex);
throw ex;
}
}