this.tenantID=tenantId;
if (!"true".equals(realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_READ_ONLY))
&& this.realmConfig.getUserStoreClass()
.equals(LDAPUserStoreManager.class.getName())) {
throw new UserStoreException(
"LDAPUserStoreManager is unable to operate in Read-Write mode." +
" This is invalid configuration. It can only operate in ReadOnly mode");
}
checkRequiredUserStoreConfiguration();
dataSource = (DataSource) properties.get(UserCoreConstants.DATA_SOURCE);
if (dataSource == null) {
dataSource = DatabaseUtil.getRealmDataSource(realmConfig);
properties.put(UserCoreConstants.DATA_SOURCE, dataSource);
}
if (dataSource == null) {
throw new UserStoreException("Data Source is null");
}
hybridRoleManager = new HybridRoleManager(dataSource, tenantId, realmConfig, userRealm);
//obtain the ldap connection source that was created in DefaultRealmService.
this.connectionSource=(LDAPConnectionContext)properties.get(
UserCoreConstants.LDAP_CONNECTION_SOURCE);
try {
connectionSource.getContext();
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new UserStoreException(
"Cannot create connection to Active directory server. Error message "
+ e.getMessage());
}
this.realm = realm;
this.checkInitialData();