[jboss-cvs] jboss-seam/src/main/org/jboss/seam/security/config ...
Shane Bryzak
Shane_Bryzak at symantec.com
Wed Jan 17 18:55:37 EST 2007
User: sbryzak2
Date: 07/01/17 18:55:36
Modified: src/main/org/jboss/seam/security/config
SecurityConfiguration.java
Log:
support multiple application policies
Revision Changes Path
1.14 +35 -27 jboss-seam/src/main/org/jboss/seam/security/config/SecurityConfiguration.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SecurityConfiguration.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/security/config/SecurityConfiguration.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- SecurityConfiguration.java 9 Jan 2007 08:07:02 -0000 1.13
+++ SecurityConfiguration.java 17 Jan 2007 23:55:36 -0000 1.14
@@ -45,7 +45,7 @@
@Intercept(InterceptionType.NEVER)
public class SecurityConfiguration
{
- public static final String LOGIN_MODULE_NAME = "seam";
+ public static final String DEFAULT_LOGIN_MODULE_NAME = "default";
private static final String SECURITY_CONFIG_FILENAME = "/META-INF/security-config.xml";
@@ -68,11 +68,13 @@
private static final String SECURITY_PERMISSION = "permission";
// login modules
- private static final String LOGIN_MODULES = "loginmodules";
- private static final String LOGIN_MODULE = "loginmodule";
- private static final String LOGIN_MODULE_CLASS = "class";
+ private static final String APPLICATION_POLICY = "application-policy";
+ private static final String APPLICATION_POLICY_NAME = "name";
+ private static final String AUTHENTICATION = "authentication";
+ private static final String LOGIN_MODULE = "login-module";
+ private static final String LOGIN_MODULE_CODE = "code";
private static final String LOGIN_MODULE_FLAG = "flag";
- private static final String LOGIN_MODULE_OPTION = "option";
+ private static final String LOGIN_MODULE_OPTION = "module-option";
private static final String LOGIN_MODULE_OPTION_NAME = "name";
// login module flags
@@ -199,8 +201,8 @@
if (env.element(SECURITY_ROLES) != null)
loadSecurityRoles(env.element(SECURITY_ROLES));
- if (env.element(LOGIN_MODULES) != null)
- loadLoginModules(env.element(LOGIN_MODULES));
+ List<Element> policies = env.elements(APPLICATION_POLICY);
+ loadLoginModules(policies);
}
catch (Exception ex)
{
@@ -323,27 +325,29 @@
}
@SuppressWarnings("unchecked")
- protected void loadLoginModules(Element loginModulesElement)
+ protected void loadLoginModules(List<Element> policies)
throws SecurityConfigException
{
loginModuleConfig = new LoginModuleConfiguration();
List<AppConfigurationEntry> entries = new ArrayList<AppConfigurationEntry>();
- List<Element> moduleElements = loginModulesElement.elements(LOGIN_MODULE);
- if (moduleElements != null)
+ for (Element policy : policies)
{
- for (Element loginModule : moduleElements)
+ List<Element> modules = policy.element(AUTHENTICATION).elements(LOGIN_MODULE);
+ if (modules != null)
+ {
+ for (Element module : modules)
{
Map<String, String> options = new HashMap<String, String>();
- for (Element option : (List<Element>) loginModule.elements(LOGIN_MODULE_OPTION))
+ for (Element option : (List<Element>) module.elements(LOGIN_MODULE_OPTION))
{
options.put(option.attributeValue(LOGIN_MODULE_OPTION_NAME),
option.getTextTrim());
}
- AppConfigurationEntry entry = new AppConfigurationEntry(loginModule
- .attributeValue(LOGIN_MODULE_CLASS), getControlFlag(loginModule
+ AppConfigurationEntry entry = new AppConfigurationEntry(module
+ .attributeValue(LOGIN_MODULE_CODE), getControlFlag(module
.attributeValue(LOGIN_MODULE_FLAG)), options);
entries.add(entry);
}
@@ -351,7 +355,11 @@
AppConfigurationEntry[] e = new AppConfigurationEntry[entries.size()];
entries.toArray(e);
- loginModuleConfig.addEntry(LOGIN_MODULE_NAME, e);
+ if (policy.attribute(APPLICATION_POLICY_NAME) != null)
+ loginModuleConfig.addEntry(policy.attributeValue(APPLICATION_POLICY_NAME), e);
+ else
+ loginModuleConfig.addEntry(DEFAULT_LOGIN_MODULE_NAME, e);
+ }
}
}
More information about the jboss-cvs-commits
mailing list