}
private static UserRealm getUserRealm(String username) {
UserRealm userRealm = null;
RealmService realmService = AuthorizationServiceDataHolder.getInstance().getRealmService();
if (null != realmService) {
try {
// Get tenant ID
int tenantID = 0;
int domainNameSeparatorIndex = username.indexOf(DOMAIN_NAME_SEPARATOR);
if (-1 != domainNameSeparatorIndex) { // Service case
String domainName = username.substring(domainNameSeparatorIndex + 1);
tenantID = realmService.getTenantManager().getTenantId(domainName);
}
// Get Realm
userRealm = realmService.getTenantUserRealm(tenantID);
} catch (UserStoreException e) {
logger.warn("Error while getting tenant user realm for user " + username);
} catch (NullPointerException e) {
logger.error("Error while accessing the realm service : " + e.getMessage());
}