[Yanel-commits] rev 55285 -
public/yanel/trunk/src/core/java/org/wyona/yanel/core/map
michi at wyona.com
michi at wyona.com
Tue Dec 7 15:19:57 CET 2010
Author: michi
Date: 2010-12-07 15:19:57 +0100 (Tue, 07 Dec 2010)
New Revision: 55285
Modified:
public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmDefaultImpl.java
Log:
set identity and policy manager refactored
Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmDefaultImpl.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmDefaultImpl.java 2010-12-07 13:06:12 UTC (rev 55284)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmDefaultImpl.java 2010-12-07 14:19:57 UTC (rev 55285)
@@ -113,7 +113,6 @@
*/
protected void configure(Configuration config) throws Exception {
Yanel yanel = Yanel.getInstance();
- File repoConfig = null;
// Set name if not already set by yanel realms registration config
Configuration nameConfigElement = config.getChild("name", false);
@@ -122,50 +121,9 @@
}
- // Set PolicyManager for this realm
- Configuration repoConfigElement = config.getChild("ac-policies", false);
- if (repoConfigElement != null) {
- PolicyManagerFactory pmFactory = null;
- PolicyManager policyManager = null;
- try {
- String customPolicyManagerFactoryImplClassName = repoConfigElement.getAttribute("class");
- pmFactory = (PolicyManagerFactory) Class.forName(customPolicyManagerFactoryImplClassName).newInstance();
- policyManager = pmFactory.newPolicyManager(ConfigurationUtil.getCustomConfiguration(repoConfigElement, "policy-manager-config", "http://www.wyona.org/security/1.0"), new RealmConfigPathResolver(this));
- } catch (ConfigurationException e) {
- pmFactory = yanel.getPolicyManagerFactory("PolicyManagerFactory");
- log.info("Default PolicyManager will be used for realm: " + getName());
- repoConfig = FileUtil.resolve(getConfigFile(), new File(repoConfigElement.getValue()));
- RepositoryFactory policiesRepoFactory = yanel.getRepositoryFactory("ACPoliciesRepositoryFactory");
- Repository policiesRepo = policiesRepoFactory.newRepository(getID(), repoConfig);
- policyManager = pmFactory.newPolicyManager(policiesRepo);
- }
- setPolicyManager(policyManager);
- }
+ initIdentityManager(config, yanel);
+ initPolicyManager(config, yanel);
-
- // Set IdentityManager for this realm
- repoConfigElement = config.getChild("ac-identities", false);
- if (repoConfigElement != null) {
-
- IdentityManagerFactory imFactory = null;
- IdentityManager identityManager = null;
- try {
- String customIdentityManagerFactoryImplClassName = repoConfigElement.getAttribute("class");
- log.debug("Set custom identity manager " + customIdentityManagerFactoryImplClassName + " for realm: " + getName());
- imFactory = (IdentityManagerFactory) Class.forName(customIdentityManagerFactoryImplClassName).newInstance();
- identityManager = imFactory.newIdentityManager(ConfigurationUtil.getCustomConfiguration(repoConfigElement, "identity-manager-config", "http://www.wyona.org/security/1.0"), new RealmConfigPathResolver(this));
- log.debug("Custom identity manager " + identityManager.getClass().getName() + " has been set for realm: " + getName());
- } catch (ConfigurationException e) {
- imFactory = yanel.getIdentityManagerFactory("IdentityManagerFactory");
- log.info("Default IdentityManager will be used for realm: " + getName());
- repoConfig = FileUtil.resolve(getConfigFile(), new File(repoConfigElement.getValue()));
- RepositoryFactory identitiesRepoFactory = yanel.getRepositoryFactory("ACIdentitiesRepositoryFactory");
- Repository identitiesRepo = identitiesRepoFactory.newRepository(getID(), repoConfig);
- identityManager = imFactory.newIdentityManager(identitiesRepo);
- }
- setIdentityManager(identityManager);
- }
-
// Set WebAuthenticator for this realm
Configuration waConfigElement = config.getChild("web-authenticator", false);
WebAuthenticator wa = null;
@@ -194,7 +152,7 @@
RepositoryFactory extraRepoFactory = yanel.getRepositoryFactory(EXTRA_REPOSITORY_FACTORY_BEAN_ID);
String repoConfigSrc = config.getChild("data", false).getValue();
- repoConfig = FileUtil.resolve(getConfigFile(), new File(repoConfigSrc));
+ File repoConfig = FileUtil.resolve(getConfigFile(), new File(repoConfigSrc));
log.info("Set data repository: " + getID() + ", " + repoConfig);
setRepository(repoFactory.newRepository(getID(), repoConfig));
@@ -557,5 +515,54 @@
return this.i18nCatalogue;
}
+ /**
+ * Init policy manager
+ */
+ protected void initPolicyManager(Configuration config, Yanel yanel) throws Exception {
+ Configuration repoConfigElement = config.getChild("ac-policies", false);
+ if (repoConfigElement != null) {
+ PolicyManagerFactory pmFactory = null;
+ PolicyManager policyManager = null;
+ try {
+ String customPolicyManagerFactoryImplClassName = repoConfigElement.getAttribute("class");
+ pmFactory = (PolicyManagerFactory) Class.forName(customPolicyManagerFactoryImplClassName).newInstance();
+ policyManager = pmFactory.newPolicyManager(ConfigurationUtil.getCustomConfiguration(repoConfigElement, "policy-manager-config", "http://www.wyona.org/security/1.0"), new RealmConfigPathResolver(this));
+ } catch (ConfigurationException e) {
+ pmFactory = yanel.getPolicyManagerFactory("PolicyManagerFactory");
+ log.info("Default PolicyManager will be used for realm: " + getName());
+ File repoConfig = FileUtil.resolve(getConfigFile(), new File(repoConfigElement.getValue()));
+ RepositoryFactory policiesRepoFactory = yanel.getRepositoryFactory("ACPoliciesRepositoryFactory");
+ Repository policiesRepo = policiesRepoFactory.newRepository(getID(), repoConfig);
+ policyManager = pmFactory.newPolicyManager(policiesRepo);
+ }
+ setPolicyManager(policyManager);
+ }
+ }
+ /**
+ * Init identity manager
+ */
+ protected void initIdentityManager(Configuration config, Yanel yanel) throws Exception {
+ Configuration repoConfigElement = config.getChild("ac-identities", false);
+ if (repoConfigElement != null) {
+
+ IdentityManagerFactory imFactory = null;
+ IdentityManager identityManager = null;
+ try {
+ String customIdentityManagerFactoryImplClassName = repoConfigElement.getAttribute("class");
+ log.debug("Set custom identity manager " + customIdentityManagerFactoryImplClassName + " for realm: " + getName());
+ imFactory = (IdentityManagerFactory) Class.forName(customIdentityManagerFactoryImplClassName).newInstance();
+ identityManager = imFactory.newIdentityManager(ConfigurationUtil.getCustomConfiguration(repoConfigElement, "identity-manager-config", "http://www.wyona.org/security/1.0"), new RealmConfigPathResolver(this));
+ log.debug("Custom identity manager " + identityManager.getClass().getName() + " has been set for realm: " + getName());
+ } catch (ConfigurationException e) {
+ imFactory = yanel.getIdentityManagerFactory("IdentityManagerFactory");
+ log.info("Default IdentityManager will be used for realm: " + getName());
+ File repoConfig = FileUtil.resolve(getConfigFile(), new File(repoConfigElement.getValue()));
+ RepositoryFactory identitiesRepoFactory = yanel.getRepositoryFactory("ACIdentitiesRepositoryFactory");
+ Repository identitiesRepo = identitiesRepoFactory.newRepository(getID(), repoConfig);
+ identityManager = imFactory.newIdentityManager(identitiesRepo);
+ }
+ setIdentityManager(identityManager);
+ }
+ }
}
More information about the Yanel-commits
mailing list