}
}
public RealmConfiguration buildRealmConfiguration(OMElement realmElem) {
RealmConfiguration realmConfig = null;
String userStoreClass = null;
String authorizationManagerClass = null;
String adminRoleName = null;
String adminUserName = null;
String adminPassword = null;
String everyOneRoleName = null;
String realmClass = null;
Map<String, String> userStoreProperties = null;
Map<String, String> authzProperties = null;
Map<String, String> realmProperties = null;
boolean passwordsExternallyManaged = false;
realmClass = (String) realmElem.getAttributeValue(new QName(
UserCoreConstants.RealmConfig.ATTR_NAME_CLASS));
OMElement mainConfig = realmElem.getFirstChildWithName(new QName(
UserCoreConstants.RealmConfig.LOCAL_NAME_CONFIGURATION));
realmProperties = getChildPropertyElements(mainConfig, secretResolver);
String dbUrl = constructDatabaseURL(realmProperties.get(JDBCRealmConstants.URL));
realmProperties.put(JDBCRealmConstants.URL, dbUrl);
OMElement adminUser = mainConfig.getFirstChildWithName(new QName(
UserCoreConstants.RealmConfig.LOCAL_NAME_ADMIN_USER));
adminUserName = adminUser.getFirstChildWithName(
new QName(UserCoreConstants.RealmConfig.LOCAL_NAME_USER_NAME)).getText();
adminPassword = adminUser.getFirstChildWithName(
new QName(UserCoreConstants.RealmConfig.LOCAL_NAME_PASSWORD)).getText();
if (secretResolver != null && secretResolver.isInitialized() &&
secretResolver.isTokenProtected("UserManager.AdminUser.Password")) {
adminPassword = secretResolver.resolve("UserManager.AdminUser.Password");
}
adminRoleName = mainConfig.getFirstChildWithName(
new QName(UserCoreConstants.RealmConfig.LOCAL_NAME_ADMIN_ROLE)).getText();
everyOneRoleName = mainConfig.getFirstChildWithName(
new QName(UserCoreConstants.RealmConfig.LOCAL_NAME_EVERYONE_ROLE)).getText();
OMElement usaConfig = realmElem.getFirstChildWithName(new QName(
UserCoreConstants.RealmConfig.LOCAL_NAME_USER_STORE_MANAGER));
userStoreClass = usaConfig.getAttributeValue(new QName(
UserCoreConstants.RealmConfig.ATTR_NAME_CLASS));
userStoreProperties = getChildPropertyElements(usaConfig, secretResolver);
String sIsPasswordExternallyManaged = userStoreProperties
.get(UserCoreConstants.RealmConfig.LOCAL_PASSWORDS_EXTERNALLY_MANAGED);
if (null != sIsPasswordExternallyManaged && !sIsPasswordExternallyManaged.trim().equals("")) {
passwordsExternallyManaged = Boolean.parseBoolean(sIsPasswordExternallyManaged);
} else {
if (log.isDebugEnabled()) {
log.debug("External password management is disabled.");
}
}
OMElement authzConfig = realmElem.getFirstChildWithName(new QName(
UserCoreConstants.RealmConfig.LOCAL_NAME_ATHZ_MANAGER));
authorizationManagerClass = authzConfig.getAttributeValue(new QName(
UserCoreConstants.RealmConfig.ATTR_NAME_CLASS));
authzProperties = getChildPropertyElements(authzConfig, null);
realmConfig = new RealmConfiguration();
realmConfig.setRealmClassName(realmClass);
realmConfig.setUserStoreClass(userStoreClass);
realmConfig.setAuthorizationManagerClass(authorizationManagerClass);
realmConfig.setAdminRoleName(adminRoleName);
realmConfig.setAdminUserName(adminUserName);
realmConfig.setAdminPassword(adminPassword);
realmConfig.setEveryOneRoleName(everyOneRoleName);
realmConfig.setUserStoreProperties(userStoreProperties);
realmConfig.setAuthzProperties(authzProperties);
realmConfig.setRealmProperties(realmProperties);
realmConfig.setPasswordsExternallyManaged(passwordsExternallyManaged);
if (realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST) == null) {
realmConfig.getUserStoreProperties().put(
UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST,
UserCoreConstants.RealmConfig.PROPERTY_VALUE_DEFAULT_MAX_COUNT);
}
if (realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_READ_ONLY) == null) {
realmConfig.getUserStoreProperties().put(
UserCoreConstants.RealmConfig.PROPERTY_READ_ONLY,
UserCoreConstants.RealmConfig.PROPERTY_VALUE_DEFAULT_READ_ONLY);
}
return realmConfig;