boolean isAuthenticated = false;
boolean isAuthorized = false;
String tenantAwareUserName = TenantUtils.getTenantAwareUsername(user);
try {
UserRealm realm = AnonymousSessionUtil.getRealmByUserName(
SecurityServiceHolder.getRegistryService(),
SecurityServiceHolder.getRealmService(),user);
isAuthorized = realm.getAuthorizationManager().isUserAuthorized(tenantAwareUserName,
servicePath,
UserCoreConstants.
INVOKE_SERVICE_PERMISSION);
if (isAuthorized == true) {
isAuthenticated = realm.getUserStoreManager().authenticate(tenantAwareUserName, password);
}
return isAuthenticated;
} catch (Exception e) {
log.error(e.getMessage(), e);