[jboss-cvs] JBossAS SVN: r73371 - in trunk: security/src/main/org/jboss/security and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 13 17:06:13 EDT 2008
Author: sguilhen at redhat.com
Date: 2008-05-13 17:06:13 -0400 (Tue, 13 May 2008)
New Revision: 73371
Added:
trunk/security/src/main/org/jboss/security/microcontainer/
trunk/security/src/main/org/jboss/security/microcontainer/beans/
trunk/security/src/main/org/jboss/security/microcontainer/beans/ApplicationPolicyBean.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/AuditPolicyBean.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/AuthenticationPolicyBean.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/AuthorizationPolicyBean.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/BaseAuthenticationPolicy.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/BasePolicyBean.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/BasePolicyModule.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/FlaggedPolicyModule.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/IdentityTrustPolicyBean.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/JASPIAuthenticationPolicyBean.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/LoginModuleStackBean.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/RoleMappingPolicyBean.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/StackRefPolicyModule.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/ApplicationPolicyMetaDataFactory.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuditMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuthenticationMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuthorizationMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/BaseModuleMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/BasePolicyMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/FlaggedModuleMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/IdentityTrustMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/JASPIAuthenticationMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/LoginModuleStackMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/ModuleOptionMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/RoleMappingMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/SecurityPolicyMetaData.java
trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/StackRefModuleMetaData.java
Modified:
trunk/security/build.xml
trunk/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java
trunk/server/src/etc/deployers/security-deployer-beans.xml
Log:
JBAS-5312: Addition of a metadata factory and related classes that allow for the declaration of application-policies in -beans.xml files.
Modified: trunk/security/build.xml
===================================================================
--- trunk/security/build.xml 2008-05-13 21:06:05 UTC (rev 73370)
+++ trunk/security/build.xml 2008-05-13 21:06:13 UTC (rev 73371)
@@ -74,6 +74,7 @@
<path id="library.classpath">
<path refid="apache.log4j.classpath"/>
<path refid="javassist.classpath"/>
+ <path refid="javax.xml.bind.classpath"/>
</path>
Modified: trunk/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java
===================================================================
--- trunk/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java 2008-05-13 21:06:05 UTC (rev 73370)
+++ trunk/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -47,7 +47,7 @@
public XMLLoginConfig()
{
- config = new XMLLoginConfigImpl();
+ config = XMLLoginConfigImpl.getInstance();
}
// --- Begin XMLLoginConfigMBean interface methods
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/ApplicationPolicyBean.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/ApplicationPolicyBean.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/ApplicationPolicyBean.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,313 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import org.jboss.security.auth.login.XMLLoginConfigImpl;
+import org.jboss.security.config.ApplicationPolicy;
+import org.jboss.security.config.ApplicationPolicyRegistration;
+
+/**
+ * <p>
+ * This class represents an application policy. An application policy describes the security requirements
+ * (authentication, authorization, role-mapping, audit, and identity-trust) for a specific security domain. Each of
+ * these requirements is described by the appropriate sub-policy.
+ * </p>
+ * <p>
+ * Once this bean is started by the microcontainer it uses the information from all configured sub-policies to generate
+ * an {@code org.jboss.security.config.ApplicationPolicy} and then registers the generated policy with the security
+ * layer.
+ * </p>
+ *
+ * @see org.jboss.security.microcontainer.beans.BaseAuthenticationPolicy
+ * @see org.jboss.security.microcontainer.beans.AuthorizationPolicyBean
+ * @see org.jboss.security.microcontainer.beans.RoleMappingPolicyBean
+ * @see org.jboss.security.microcontainer.beans.AuditPolicyBean
+ * @see org.jboss.security.microcontainer.beans.IdentityTrustPolicyBean
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class ApplicationPolicyBean
+{
+ private static final String DEFAULT_NAME = "other";
+
+ /** The application policy name. */
+ private String name = DEFAULT_NAME;
+
+ /** The name of the parent policy, if any. */
+ private String parentPolicy;
+
+ /** The authentication policy configured as part of this application policy. */
+ private BaseAuthenticationPolicy<?> authenticationPolicy;
+
+ /** the authorization policy configured as part of this application policy. */
+ private AuthorizationPolicyBean authorizationPolicy;
+
+ /** the role-mapping policy configured as part of this application policy. */
+ private RoleMappingPolicyBean roleMappingPolicy;
+
+ /** the audit policy configured as part of this application policy. */
+ private AuditPolicyBean auditPolicy;
+
+ /** the identity-trust policy configured as part of this application policy. */
+ private IdentityTrustPolicyBean identityTrustPolicy;
+
+ // TODO: add logging to the metadata factories and also to the beans.
+
+ /**
+ * <p>
+ * Obtains the name of the application policy.
+ * </p>
+ *
+ * @return a {@code String} representing the name of the application policy.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * <p>
+ * Sets the name of the application policy.
+ * </p>
+ *
+ * @param name a {@code String} representing the name to be set.
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * <p>
+ * Obtains the name of the parent policy.
+ * </p>
+ *
+ * @return a {@code String} representing the name of the parent policy.
+ */
+ public String getParentPolicy()
+ {
+ return parentPolicy;
+ }
+
+ /**
+ * <p>
+ * Sets the name of the parent policy.
+ * </p>
+ *
+ * @param parentPolicy a {@code String} representing the name of the parent policy to be set.
+ */
+ public void setParentPolicy(String parentPolicy)
+ {
+ this.parentPolicy = parentPolicy;
+ }
+
+ /**
+ * <p>
+ * Obtains the authentication policy that has been configured as part of this application policy.
+ * </p>
+ *
+ * @return a {@code BaseAuthenticationPolicy} representing the configured authentication policy.
+ */
+ public BaseAuthenticationPolicy<?> getAuthenticationPolicy()
+ {
+ return authenticationPolicy;
+ }
+
+ /**
+ * <p>
+ * Sets the authentication policy to be used by this application policy.
+ * </p>
+ *
+ * @param authenticationPolicy a {@code BaseAuthenticationPolicy} representing the policy to be set.
+ */
+ public void setAuthenticationPolicy(BaseAuthenticationPolicy<?> authenticationPolicy)
+ {
+ this.authenticationPolicy = authenticationPolicy;
+ }
+
+ /**
+ * <p>
+ * Obtains the authorization policy that has been configured as part of this application policy.
+ * </p>
+ *
+ * @return an {@code AuthorizationPolicyBean} representing the configured authorization policy.
+ */
+ public AuthorizationPolicyBean getAuthorizationPolicy()
+ {
+ return authorizationPolicy;
+ }
+
+ /**
+ * <p>
+ * Sets the authorization policy to be used by this application policy.
+ *
+ * @param authorizationPolicy an {@code AuthorizationPolicyBean} representing the policy to be set.
+ */
+ public void setAuthorizationPolicy(AuthorizationPolicyBean authorizationPolicy)
+ {
+ this.authorizationPolicy = authorizationPolicy;
+ }
+
+ /**
+ * <p>
+ * Obtains the role-mapping policy that has been configured as part of this application policy.
+ * </p>
+ *
+ * @return a {@code RoleMappingPolicyBean} representing the configured role-mapping policy.
+ */
+ public RoleMappingPolicyBean getRoleMappingPolicy()
+ {
+ return roleMappingPolicy;
+ }
+
+ /**
+ * <p>
+ * Sets the role-mapping policy to be used by this application policy.
+ * </p>
+ *
+ * @param roleMappingPolicy a {@code RoleMappingPolicyBean} representing the policy to be set.
+ */
+ public void setRoleMappingPolicy(RoleMappingPolicyBean roleMappingPolicy)
+ {
+ this.roleMappingPolicy = roleMappingPolicy;
+ }
+
+ /**
+ * <p>
+ * Obtains the audit policy that has been configured as part of this application policy.
+ * </p>
+ *
+ * @return an {@code AuditPolicyBean} representing the configured audit policy.
+ */
+ public AuditPolicyBean getAuditPolicy()
+ {
+ return auditPolicy;
+ }
+
+ /**
+ * <p>
+ * Sets the audit policy to be used by this application policy.
+ * </p>
+ *
+ * @param auditPolicy an {@code AuditPolicyBean} representing the policy to be set.
+ */
+ public void setAuditPolicy(AuditPolicyBean auditPolicy)
+ {
+ this.auditPolicy = auditPolicy;
+ }
+
+ /**
+ * <p>
+ * Obtains the identity-trust policy that has been configured as part of this application policy.
+ * </p>
+ *
+ * @return an {@code IdentityTrustPolicyBean} representing the configured identity-trust policy.
+ */
+ public IdentityTrustPolicyBean getIdentityTrustPolicy()
+ {
+ return identityTrustPolicy;
+ }
+
+ /**
+ * <p>
+ * Sets the identity-trust policy to be used by this application policy.
+ * </p>
+ *
+ * @param identityTrustPolicy an {@code IdentityTrustPolicyBean} representing the policy to be set.
+ */
+ public void setIdentityTrustPolicy(IdentityTrustPolicyBean identityTrustPolicy)
+ {
+ this.identityTrustPolicy = identityTrustPolicy;
+ }
+
+ /**
+ * <p>
+ * Registers the application policy with the security framework once this bean has started.
+ * </p>
+ *
+ * @throws Exception if an error occurs while registering the application policy.
+ */
+ public void start() throws Exception
+ {
+ // create the application policy using the information from the beans and push it to the security layer.
+ ApplicationPolicy policy = this.createApplicationPolicy();
+
+ // TODO: get the ApplicationPolicyRegistration implementation through injection.
+ ApplicationPolicyRegistration policyRegistration = XMLLoginConfigImpl.getInstance();
+ policyRegistration.addApplicationPolicy(this.name, policy);
+
+ }
+
+ /**
+ * <p>
+ * Unregisters the application policy from the security framework when the bean stops.
+ * </p>
+ *
+ * @throws Exception if an error occurs while unregistering the application policy.
+ */
+ public void stop() throws Exception
+ {
+ // unregister the application policy.
+ XMLLoginConfigImpl.getInstance().removeApplicationPolicy(this.name);
+ }
+
+ /**
+ * <p>
+ * Creates an {@code org.jboss.security.conf.ApplicationPolicy} object using the information contained in this bean
+ * and in the sub-policies beans.
+ * </p>
+ *
+ * @return a reference to the constructed {@code ApplicationPolicy} object.
+ */
+ private ApplicationPolicy createApplicationPolicy()
+ {
+ ApplicationPolicy policy = new ApplicationPolicy(this.name);
+ policy.setBaseApplicationPolicyName(this.parentPolicy);
+ if (this.authenticationPolicy != null)
+ policy.setAuthenticationInfo(this.authenticationPolicy.getPolicyInfo(this.name));
+ if (this.authorizationPolicy != null)
+ policy.setAuthorizationInfo(this.authorizationPolicy.getPolicyInfo(this.name));
+ if (this.roleMappingPolicy != null)
+ policy.setRoleMappingInfo(this.roleMappingPolicy.getPolicyInfo(this.name));
+ if (this.auditPolicy != null)
+ policy.setAuditInfo(this.auditPolicy.getPolicyInfo(this.name));
+ if (this.identityTrustPolicy != null)
+ policy.setIdentityTrustInfo(this.identityTrustPolicy.getPolicyInfo(this.name));
+
+ return policy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer("Application Policy Contents: " + this.name + "\n\n");
+ if (this.authenticationPolicy != null)
+ buffer.append(this.authenticationPolicy.toString());
+
+ return buffer.toString();
+ }
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/AuditPolicyBean.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/AuditPolicyBean.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/AuditPolicyBean.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import org.jboss.security.audit.config.AuditProviderEntry;
+import org.jboss.security.config.AuditInfo;
+
+/**
+ * <p>
+ * This class represents an audit policy.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class AuditPolicyBean extends BasePolicyBean<BasePolicyModule, AuditInfo>
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.BasePolicyBean#getPolicyInfo(java.lang.String)
+ */
+ @Override
+ public AuditInfo getPolicyInfo(String domainName)
+ {
+ AuditInfo info = new AuditInfo(domainName);
+ for (BasePolicyModule module : this.modules)
+ {
+ AuditProviderEntry entry = new AuditProviderEntry(module.getCode(), module.getOptions());
+ info.add(entry);
+ }
+ return info;
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/AuthenticationPolicyBean.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/AuthenticationPolicyBean.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/AuthenticationPolicyBean.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import javax.security.auth.login.AppConfigurationEntry;
+
+import org.jboss.security.auth.login.AuthenticationInfo;
+import org.jboss.security.auth.login.BaseAuthenticationInfo;
+
+/**
+ * <p>
+ * This class represents an authentication policy. An authentication policy describes the mechanisms and modules that
+ * must be used in order to authenticate the users when they attempt to access a resource that is protected by a
+ * security domain.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class AuthenticationPolicyBean extends BaseAuthenticationPolicy<FlaggedPolicyModule>
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.BaseAuthenticationPolicy#getPolicyInfo(java.lang.String)
+ */
+ @Override
+ public BaseAuthenticationInfo getPolicyInfo(String domainName)
+ {
+ AppConfigurationEntry[] entries = new AppConfigurationEntry[this.modules.size()];
+ int entryIndex = 0;
+ for (FlaggedPolicyModule moduleBean : this.modules)
+ entries[entryIndex++] = moduleBean.getAppConfigurationEntry();
+
+ AuthenticationInfo info = new AuthenticationInfo(domainName);
+ info.setAppConfigurationEntry(entries);
+ return info;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer("Authentication Policy:\n");
+ for (int i = 0; i < modules.size(); i++)
+ {
+ FlaggedPolicyModule module = modules.get(i);
+ buffer.append("Module[" + i + "]\n");
+ buffer.append(module.toString());
+ }
+ return buffer.toString();
+ }
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/AuthorizationPolicyBean.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/AuthorizationPolicyBean.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/AuthorizationPolicyBean.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import org.jboss.security.authorization.config.AuthorizationModuleEntry;
+import org.jboss.security.config.AuthorizationInfo;
+import org.jboss.security.config.ControlFlag;
+
+/**
+ * <p>
+ * This class represents an authorization policy.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class AuthorizationPolicyBean extends BasePolicyBean<FlaggedPolicyModule, AuthorizationInfo>
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.BasePolicyBean#getPolicyInfo(java.lang.String)
+ */
+ @Override
+ public AuthorizationInfo getPolicyInfo(String domainName)
+ {
+ AuthorizationInfo info = new AuthorizationInfo(domainName);
+ for (FlaggedPolicyModule module : this.modules)
+ {
+ AuthorizationModuleEntry entry = new AuthorizationModuleEntry(module.getCode(), module.getOptions());
+ entry.setControlFlag(new ControlFlag(module.getFlag()));
+ info.add(entry);
+ }
+
+ return info;
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/BaseAuthenticationPolicy.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/BaseAuthenticationPolicy.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/BaseAuthenticationPolicy.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import org.jboss.security.auth.login.BaseAuthenticationInfo;
+
+/**
+ * <p>
+ * Superclass of the authentication and jaspi-authentication policies.
+ * </p>
+ *
+ * @see org.jboss.security.microcontainer.beans.AuditPolicyBean
+ * @see org.jboss.security.microcontainer.beans.JASPIAuthenticationPolicyBean
+ *
+ * @param <M> the type of the modules used by the authentication policy.
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public abstract class BaseAuthenticationPolicy<M> extends BasePolicyBean<M, BaseAuthenticationInfo>
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.BasePolicyBean#getPolicyInfo(java.lang.String)
+ */
+ @Override
+ public abstract BaseAuthenticationInfo getPolicyInfo(String domainName);
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/BasePolicyBean.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/BasePolicyBean.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/BasePolicyBean.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * Superclass of all policy beans that compose an {@code ApplicationPolicyBean}.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ *
+ * @param <M> the type of the modules used by the policy.
+ * @param <I> the type of the info object that the policy is capable of generating.
+ */
+public abstract class BasePolicyBean<M, I>
+{
+
+ /** the policy's set of modules. */
+ protected List<M> modules;
+
+ /**
+ * <p>
+ * Creates an instance of {@code BasePolicyBean}.
+ * </p>
+ */
+ public BasePolicyBean()
+ {
+ this.modules = new ArrayList<M>();
+ }
+
+ /**
+ * <p>
+ * Gets a reference to collection of modules used by this policy.
+ * </p>
+ *
+ * @return a reference to the {@code List} that contains the policy's modules.
+ */
+ public List<M> getModules()
+ {
+ return modules;
+ }
+
+ /**
+ * <p>
+ * Sets the collection of modules used by this policy.
+ * </p>
+ *
+ * @param modules a {@code List} containing all modules to be used by this policy.
+ */
+ public void setModules(List<M> modules)
+ {
+ this.modules = modules;
+ }
+
+ /**
+ * <p>
+ * Creates a security info object using the information contained in this policy bean.
+ * </p>
+ *
+ * @param domainName a {@code String} containing the security domain name of this policy.
+ * @return the generated info object.
+ */
+ public abstract I getPolicyInfo(String domainName);
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/BasePolicyModule.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/BasePolicyModule.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/BasePolicyModule.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * <p>
+ * This bean represents a basic policy module, with its class name and options map.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class BasePolicyModule
+{
+
+ /** the fully-qualified name of the module. */
+ protected String code;
+
+ /** The module's options map (name -> value). */
+ protected Map<String, Object> options;
+
+ /**
+ * <p>
+ * Creates an instance of {@code BasePolicyModule}.
+ * </p>
+ */
+ public BasePolicyModule()
+ {
+ this.options = new HashMap<String, Object>();
+ }
+
+ /**
+ * <p>
+ * Obtains the fully-qualified class name of the module.
+ * </p>
+ *
+ * @return a {@code String} representing the class name.
+ */
+ public String getCode()
+ {
+ return code;
+ }
+
+ /**
+ * <p>
+ * Sets the fully-qualified class name of the module.
+ * </p>
+ *
+ * @param code a {@code String} representing the class name to be set.
+ */
+ public void setCode(String code)
+ {
+ this.code = code;
+ }
+
+ /**
+ * <p>
+ * Obtains the module's options.
+ * </p>
+ *
+ * @return a {@code Map<String,Object>} containing the module's options.
+ */
+ public Map<String, Object> getOptions()
+ {
+ return options;
+ }
+
+ /**
+ * <p>
+ * Sets the options of the module.
+ * </p>
+ *
+ * @param options a {@code Map<String,Object>} containing the options to be set.
+ */
+ public void setOptions(Map<String, Object> options)
+ {
+ this.options = options;
+ }
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/FlaggedPolicyModule.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/FlaggedPolicyModule.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/FlaggedPolicyModule.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import java.util.Map;
+
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
+
+/**
+ * <p>
+ * This class represents a flagged module, that is, a module that has a flag used to control the overall execution
+ * process. For example, the authenticaton login-modules specify a flag to indicate whether each module is required or
+ * not to succeed in order for the overall authentication process to be successful.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class FlaggedPolicyModule extends BasePolicyModule
+{
+
+ /** String representation of the control flag. */
+ protected String flag;
+
+ /** Login module control flag. */
+ protected LoginModuleControlFlag controlFlag;
+
+ /**
+ * <p>
+ * Obtains the control flag of the login module.
+ * </p>
+ *
+ * @return a {@code String} representing the control flag.
+ */
+ public String getFlag()
+ {
+ return flag;
+ }
+
+ /**
+ * <p>
+ * Sets the control flag of the login module.
+ * </p>
+ *
+ * @param flag a {@code String} representing the control flag to be set.
+ */
+ public void setFlag(String flag)
+ {
+ if (flag == null)
+ throw new IllegalArgumentException("Invalid null module flag");
+ // set the control flag using the string representation specified.
+ flag = flag.toLowerCase();
+ if (AppConfigurationEntry.LoginModuleControlFlag.REQUIRED.toString().indexOf(flag) > 0)
+ this.controlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
+ else if (AppConfigurationEntry.LoginModuleControlFlag.REQUISITE.toString().indexOf(flag) > 0)
+ this.controlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUISITE;
+ else if (AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT.toString().indexOf(flag) > 0)
+ this.controlFlag = AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT;
+ else if (AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL.toString().indexOf(flag) > 0)
+ this.controlFlag = AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL;
+ else
+ throw new IllegalArgumentException("Invalid module flag: " + flag);
+
+ this.flag = flag;
+ }
+
+ /**
+ * <p>
+ * Utility method that creates an {@code AppConfigurationEntry} object using the information contained in this bean.
+ * </p>
+ *
+ * @return a reference to the {@code AppConfigurationEntry} that has been constructed.
+ */
+ public AppConfigurationEntry getAppConfigurationEntry()
+ {
+ return new AppConfigurationEntry(super.code, this.controlFlag, super.options);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Login module class: " + super.code);
+ buffer.append("\nLogin module flag: " + this.flag);
+ buffer.append("\nLogin module options: \n");
+ for (Map.Entry<String, Object> entry : super.options.entrySet())
+ buffer.append("\tname= " + entry.getKey() + ", value= " + entry.getValue() + "\n");
+ return buffer.toString();
+ }
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/IdentityTrustPolicyBean.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/IdentityTrustPolicyBean.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/IdentityTrustPolicyBean.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import org.jboss.security.config.ControlFlag;
+import org.jboss.security.config.IdentityTrustInfo;
+import org.jboss.security.identitytrust.config.IdentityTrustModuleEntry;
+
+/**
+ * <p>
+ * This class represents an identity-trust policy.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class IdentityTrustPolicyBean extends BasePolicyBean<FlaggedPolicyModule, IdentityTrustInfo>
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.BasePolicyBean#getPolicyInfo(java.lang.String)
+ */
+ @Override
+ public IdentityTrustInfo getPolicyInfo(String domainName)
+ {
+ IdentityTrustInfo info = new IdentityTrustInfo(domainName);
+ for (FlaggedPolicyModule module : this.modules)
+ {
+ IdentityTrustModuleEntry entry = new IdentityTrustModuleEntry(module.getCode(), module.getOptions());
+ entry.setControlFlag(new ControlFlag(module.getFlag()));
+ info.add(entry);
+ }
+ return info;
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/JASPIAuthenticationPolicyBean.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/JASPIAuthenticationPolicyBean.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/JASPIAuthenticationPolicyBean.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.security.auth.container.config.AuthModuleEntry;
+import org.jboss.security.auth.login.BaseAuthenticationInfo;
+import org.jboss.security.auth.login.JASPIAuthenticationInfo;
+
+/**
+ * <p>
+ * This class represents a jaspi authentication policy. An authentication policy describes the mechanisms and modules
+ * that must be used in order to authenticate the users when they attempt to access a resource that is protected by a
+ * security domain.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class JASPIAuthenticationPolicyBean extends BaseAuthenticationPolicy<StackRefPolicyModule>
+{
+
+ /** the login-module stacks of the policy. */
+ private List<LoginModuleStackBean> moduleStacks;
+
+ /**
+ * <p>
+ * Created an instance of {@code JASPIAuthenticationPolicyBean}.
+ * </p>
+ */
+ public JASPIAuthenticationPolicyBean()
+ {
+ this.moduleStacks = new ArrayList<LoginModuleStackBean>();
+ }
+
+ /**
+ * <p>
+ * Obtains the login-module stacks of the policy.
+ * </p>
+ *
+ * @return a {@code List<LoginModuleStackBean>} containing the policy's login-module stacks.
+ */
+ public List<LoginModuleStackBean> getModuleStacks()
+ {
+ return moduleStacks;
+ }
+
+ /**
+ * <p>
+ * Sets the login-module stacks of the policy.
+ * </p>
+ *
+ * @param moduleStacks a {@code List<LoginModuleStackBean>} containing the stacks to be set.
+ */
+ public void setModuleStacks(List<LoginModuleStackBean> moduleStacks)
+ {
+ this.moduleStacks = moduleStacks;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.BasePolicyBean#getPolicyInfo(java.lang.String)
+ */
+ @Override
+ public BaseAuthenticationInfo getPolicyInfo(String domainName)
+ {
+ JASPIAuthenticationInfo info = new JASPIAuthenticationInfo(domainName);
+ // add the auth modules to the authentication info.
+ for (StackRefPolicyModule module : super.modules)
+ info.add(new AuthModuleEntry(module.getCode(), module.getOptions(), module.getStackRef()));
+
+ // add the stack modules to the authentication info.
+ for (LoginModuleStackBean stackBean : this.moduleStacks)
+ info.add(stackBean.getLoginModuleStackHolder());
+
+ return info;
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/LoginModuleStackBean.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/LoginModuleStackBean.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/LoginModuleStackBean.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.security.auth.login.AppConfigurationEntry;
+
+import org.jboss.security.auth.login.LoginModuleStackHolder;
+
+/**
+ * <p>
+ * This class represents a stack of login-modules that has been configured as part of a JASPI authentication policy.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class LoginModuleStackBean
+{
+
+ /** the name of the stack. */
+ private String name;
+
+ /** the login-modules that are part of the stack. */
+ private List<FlaggedPolicyModule> loginModules;
+
+ /**
+ * <p>
+ * Creates an instance of {@code LoginModuleStackBean}.
+ * </p>
+ */
+ public LoginModuleStackBean()
+ {
+ this.loginModules = new ArrayList<FlaggedPolicyModule>();
+ }
+
+ /**
+ * <p>
+ * Obtains the name of the stack.
+ * </p>
+ *
+ * @return a {@code String} representing the name of the stack.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * <p>
+ * Sets the name of the stack.
+ * </p>
+ *
+ * @param name a {@code String} representing the name to be set.
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * <p>
+ * Obtains the login-modules that form the stack.
+ * </p>
+ *
+ * @return a {@code List<FlaggedPolicyModule>} containing the login-modules.
+ */
+ public List<FlaggedPolicyModule> getLoginModules()
+ {
+ return loginModules;
+ }
+
+ /**
+ * <p>
+ * Sets the login-modules that form the stack.
+ * </p>
+ *
+ * @param loginModules a {@code List<FlaggedPolicyModule>} containing the modules to be set.
+ */
+ public void setLoginModules(List<FlaggedPolicyModule> loginModules)
+ {
+ this.loginModules = loginModules;
+ }
+
+ /**
+ * <p>
+ * Creates a {@code LoginModuleStackHolder} using the information contained in this bean.
+ * </p>
+ *
+ * @return the constructed {@code LoginModuleStackHolder}.
+ */
+ public LoginModuleStackHolder getLoginModuleStackHolder()
+ {
+ LoginModuleStackHolder holder = new LoginModuleStackHolder(this.name, new ArrayList<AppConfigurationEntry>());
+
+ for (FlaggedPolicyModule module : this.loginModules)
+ holder.addAppConfigurationEntry(module.getAppConfigurationEntry());
+
+ return holder;
+ }
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/RoleMappingPolicyBean.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/RoleMappingPolicyBean.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/RoleMappingPolicyBean.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+import org.jboss.security.config.RoleMappingInfo;
+import org.jboss.security.mapping.config.MappingModuleEntry;
+
+/**
+ * <p>
+ * This class represents a role-mapping policy.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class RoleMappingPolicyBean extends BasePolicyBean<BasePolicyModule, RoleMappingInfo>
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.BasePolicyBean#getPolicyInfo(java.lang.String)
+ */
+ @Override
+ public RoleMappingInfo getPolicyInfo(String domainName)
+ {
+ RoleMappingInfo info = new RoleMappingInfo(domainName);
+ for (BasePolicyModule module : super.modules)
+ {
+ MappingModuleEntry entry = new MappingModuleEntry(module.getCode(), module.getOptions());
+ info.add(entry);
+ }
+ return info;
+ }
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/StackRefPolicyModule.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/StackRefPolicyModule.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/StackRefPolicyModule.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans;
+
+/**
+ * <p>
+ * This class represents a policy module that contains a reference to a login-module stack configured in a JASPI policy.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class StackRefPolicyModule extends BasePolicyModule
+{
+
+ /** the name of the login-module stack referenced by the module. */
+ private String stackRef;
+
+ /**
+ * <p>
+ * Obtains the name of the login-module stack referenced by the module.
+ * </p>
+ *
+ * @return a {@code String} representing the name of the login-module stack.
+ */
+ public String getStackRef()
+ {
+ return stackRef;
+ }
+
+ /**
+ * <p>
+ * Sets the name of the login-module stack referenced by the module.
+ * </p>
+ *
+ * @param stackRef a {@code String} representing the name of the login-module stack.
+ */
+ public void setStackRef(String stackRef)
+ {
+ this.stackRef = stackRef;
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/ApplicationPolicyMetaDataFactory.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/ApplicationPolicyMetaDataFactory.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/ApplicationPolicyMetaDataFactory.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,323 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.security.microcontainer.beans.ApplicationPolicyBean;
+import org.jboss.security.microcontainer.beans.AuditPolicyBean;
+import org.jboss.security.microcontainer.beans.AuthenticationPolicyBean;
+import org.jboss.security.microcontainer.beans.AuthorizationPolicyBean;
+import org.jboss.security.microcontainer.beans.IdentityTrustPolicyBean;
+import org.jboss.security.microcontainer.beans.JASPIAuthenticationPolicyBean;
+import org.jboss.security.microcontainer.beans.RoleMappingPolicyBean;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * <p>
+ * This class represents the {@code <application-policy>} element in a security configuration. It is also a
+ * {@code BeanMetaDataFactory} implementation that uses all the metadata created during the XB parse to build an
+ * instance of {@code ApplicationPolicyBean}.
+ * </p>
+ * <p>
+ * An example of {@code <application-policy>} configuration is as follows:
+ *
+ * <pre>
+ * <deployment xmlns="urn:jboss:bean-deployer:2.0">
+ *
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
+ * <module-option name="usersProperties">jboss-users.properties</module-option>
+ * <module-option name="rolesProperties">jboss-roles.properties</module-option>
+ * </login-module>
+ * </authentication>
+ * </application-policy>
+ * ...
+ * </deployment>
+ * </pre>
+ *
+ * The information parsed from an {@code <application-policy>} configuration is used to create a graph of metadata
+ * classes that has this class as root. Being a {@code BeanMetaDataFactory}, this class uses the metadata graph to
+ * create an instance of {@code ApplicationPolicyBean} and all correlated beans, registering them with the
+ * microcontainer.
+ * </p>
+ *
+ * @see org.jboss.security.microcontainer.beans.ApplicationPolicyBean
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+ at JBossXmlSchema(namespace = "urn:jboss:security-beans:1.0", elementFormDefault = XmlNsForm.QUALIFIED)
+ at XmlRootElement(name = "application-policy")
+ at XmlType(name = "applicationPolicyType", propOrder = {"authentication", "jaspiAuthentication", "authorization",
+ "roleMapping", "audit", "identityTrust"})
+public class ApplicationPolicyMetaDataFactory implements BeanMetaDataFactory
+{
+
+ /** the name of the application policy. */
+ private String policyName;
+
+ /** the name of the parent policy, if any. */
+ private String parentPolicy;
+
+ /** the metadata of the authentication policy. */
+ private AuthenticationMetaData authMetaData;
+
+ /** the metadata of the jaspi authentication policy. */
+ private JASPIAuthenticationMetaData jaspiMetaData;
+
+ /** the metadata of the authorization policy. */
+ private AuthorizationMetaData authzMetaData;
+
+ /** the metadata of the role-mapping policy. */
+ private RoleMappingMetaData mappingMetaData;
+
+ /** the metadata of the audit policy. */
+ private AuditMetaData auditMetaData;
+
+ /** the metadata of the identity-trust policy. */
+ private IdentityTrustMetaData trustMetaData;
+
+ /**
+ * <p>
+ * Sets the name of the application policy.
+ * </p>
+ *
+ * @param policyName a {@code String} representing the name to be set.
+ */
+ @XmlAttribute(name = "name", required = true)
+ public void setPolicyName(String policyName)
+ {
+ this.policyName = policyName;
+ }
+
+ /**
+ * <p>
+ * Sets the name of the parent application policy, if applicable.
+ * </p>
+ *
+ * @param parentPolicy a {@code String} representing the name of the parent policy.
+ */
+ @XmlAttribute(name = "extends")
+ public void setParentPolicy(String parentPolicy)
+ {
+ this.parentPolicy = parentPolicy;
+ }
+
+ /**
+ * <p>
+ * Sets the metadata generated as a result of parsing the <authentication> element in an application policy
+ * configuration.
+ * </p>
+ *
+ * @param authMetaData a reference to the generated {@code AuthenticationMetaData}.
+ */
+ @XmlElement(name = "authentication", type = AuthenticationMetaData.class)
+ public void setAuthentication(AuthenticationMetaData authMetaData)
+ {
+ // authentication and authentication-jaspi are mutually exclusive.
+ if (this.jaspiMetaData != null)
+ throw new IllegalArgumentException(
+ "An <authentication-jaspi> configuration has already been defined for the policy");
+ this.authMetaData = authMetaData;
+ }
+
+ /**
+ * <p>
+ * Sets the metadata generated as a result of parsing the <authentication-jaspi> element in an application
+ * policy configuration.
+ * </p>
+ *
+ * @param jaspiMetaData a reference to the generated {@code JASPIAuthenticationMetaData}.
+ */
+ @XmlElement(name = "authentication-jaspi", type = JASPIAuthenticationMetaData.class)
+ public void setJaspiAuthentication(JASPIAuthenticationMetaData jaspiMetaData)
+ {
+ // authentication and authentication-jaspi are mutually exclusive.
+ if (this.authMetaData != null)
+ throw new IllegalArgumentException("An <authentication> configuration has already been defined for the policy");
+ this.jaspiMetaData = jaspiMetaData;
+ }
+
+ /**
+ * <p>
+ * Sets the metadata generated as a result of parsing the <authorization> element in an application policy
+ * configuration.
+ * </p>
+ *
+ * @param authzMetaData a reference to the generated {@code AuthorizationMetaData}.
+ */
+ @XmlElement(name = "authorization", type = AuthorizationMetaData.class)
+ public void setAuthorization(AuthorizationMetaData authzMetaData)
+ {
+ this.authzMetaData = authzMetaData;
+ }
+
+ /**
+ * <p>
+ * Sets the metadata generated as a result of parsing the <rolemapping> element in an application policy
+ * configuration.
+ * </p>
+ *
+ * @param mappingMetaData a reference to the generated {@code RoleMappingMetaData}.
+ */
+ @XmlElement(name = "rolemapping", type = RoleMappingMetaData.class)
+ public void setRoleMapping(RoleMappingMetaData mappingMetaData)
+ {
+ this.mappingMetaData = mappingMetaData;
+ }
+
+ /**
+ * <p>
+ * Sets the metadata generated as a result of parsing the <audit> element in an application policy
+ * configuration.
+ * </p>
+ *
+ * @param auditMetaData a reference to the generated {@code AuditMetaData}.
+ */
+ @XmlElement(name = "audit", type = AuditMetaData.class)
+ public void setAudit(AuditMetaData auditMetaData)
+ {
+ this.auditMetaData = auditMetaData;
+ }
+
+ /**
+ * <p>
+ * Sets the metadata generated as a result of parsing the <identity-trust> element in an application policy
+ * configuration.
+ * </p>
+ *
+ * @param trustMetaData a reference to the generated {@code IdentityTrustMetaData}.
+ */
+ @XmlElement(name = "identity-trust", type = IdentityTrustMetaData.class)
+ public void setIdentityTrust(IdentityTrustMetaData trustMetaData)
+ {
+ this.trustMetaData = trustMetaData;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.beans.metadata.spi.BeanMetaDataFactory#getBeans()
+ */
+ @XmlTransient
+ public List<BeanMetaData> getBeans()
+ {
+ List<BeanMetaData> result = new ArrayList<BeanMetaData>();
+
+ // create the metadata for the application policy bean.
+ BeanMetaDataBuilder policyBuilder = BeanMetaDataBuilder.createBuilder(this.policyName,
+ ApplicationPolicyBean.class.getName());
+ policyBuilder.addPropertyMetaData("name", this.policyName);
+ policyBuilder.addPropertyMetaData("parentPolicy", this.parentPolicy);
+ result.add(policyBuilder.getBeanMetaData());
+
+ // authentication metadata.
+ if (this.authMetaData != null)
+ {
+ // get the metadata for the authentication policy bean.
+ String authPolicyName = this.policyName + "$AuthenticationPolicy";
+ result.addAll(this.authMetaData.getBeans(authPolicyName, AuthenticationPolicyBean.class.getName()));
+
+ // inject the authentication policy into the application policy.
+ ValueMetaData injectAuthenticationPolicy = policyBuilder.createInject(authPolicyName);
+ policyBuilder.addPropertyMetaData("authenticationPolicy", injectAuthenticationPolicy);
+ }
+ else if (this.jaspiMetaData != null)
+ {
+ // get the metadata for the jaspi authentication policy bean.
+ String authPolicyName = this.policyName + "$JASPIAuthenticationPolicy";
+ result.addAll(this.jaspiMetaData.getBeans(authPolicyName, JASPIAuthenticationPolicyBean.class.getName()));
+
+ // inject the jaspi authentication policy into the application policy.
+ ValueMetaData injectAuthenticationPolicy = policyBuilder.createInject(authPolicyName);
+ policyBuilder.addPropertyMetaData("authenticationPolicy", injectAuthenticationPolicy);
+ }
+ // if no authentication configuration was found and the policy does not extend another policy, throw an exception.
+ else if (this.parentPolicy == null)
+ {
+ throw new RuntimeException(
+ "An application policy must have an authentication or authentication-jaspi configuration");
+ }
+
+ // authorization metadata.
+ if (this.authzMetaData != null)
+ {
+ // get the metadata for the authorization policy bean.
+ String authzPolicyName = this.policyName + "$AuthorizationPolicy";
+ result.addAll(this.authzMetaData.getBeans(authzPolicyName, AuthorizationPolicyBean.class.getName()));
+
+ // inject the authorization policy into the application policy.
+ ValueMetaData injectAuthorizationPolicy = policyBuilder.createInject(authzPolicyName);
+ policyBuilder.addPropertyMetaData("authorizationPolicy", injectAuthorizationPolicy);
+ }
+
+ // role-mappoing metadata.
+ if (this.mappingMetaData != null)
+ {
+ // get the metadata for the role-mapping policy bean.
+ String mappingPolicyName = this.policyName + "$RoleMappingPolicy";
+ result.addAll(this.mappingMetaData.getBeans(mappingPolicyName, RoleMappingPolicyBean.class.getName()));
+
+ // inject the role-mapping policy into the application policy.
+ ValueMetaData injectMappingPolicy = policyBuilder.createInject(mappingPolicyName);
+ policyBuilder.addPropertyMetaData("roleMappingPolicy", injectMappingPolicy);
+ }
+
+ // audit metadata.
+ if (this.auditMetaData != null)
+ {
+ // get the metadata for the audit policy bean.
+ String auditPolicyName = this.policyName + "$AuditPolicy";
+ result.addAll(this.auditMetaData.getBeans(auditPolicyName, AuditPolicyBean.class.getName()));
+
+ // inject the audit policy into the application policy.
+ ValueMetaData injectAuditPolicy = policyBuilder.createInject(auditPolicyName);
+ policyBuilder.addPropertyMetaData("auditPolicy", injectAuditPolicy);
+ }
+
+ // identity-trust metadata.
+ if (this.trustMetaData != null)
+ {
+ // get the metadata for the identity-trust policy bean.
+ String trustPolicyName = this.policyName + "$IdentityTrustPolicy";
+ result.addAll(this.trustMetaData.getBeans(trustPolicyName, IdentityTrustPolicyBean.class.getName()));
+
+ // inject the identity-trust policy into the application policy.
+ ValueMetaData injectIdentityTrustPolicy = policyBuilder.createInject(trustPolicyName);
+ policyBuilder.addPropertyMetaData("identityTrustPolicy", injectIdentityTrustPolicy);
+ }
+
+ return result;
+ }
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuditMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuditMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuditMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * <p>
+ * This class represents the {@code <audit>} configuration in an application policy and contains the audit metadata
+ * information extracted by the XB parser.
+ * </p>
+ * <p>
+ * The following policy excerpt shows an example of {@code <audit>} configuration:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * ...
+ * </authentication>
+ * ...
+ * <audit>
+ * <provider-module code="org.jboss.security.audit.AuditModule">
+ * <module-option name="auditOption">audit.value</module-option>
+ * </provider-module>
+ * </audit>
+ * ...
+ * </application-policy>
+ * </pre>
+ *
+ * The metadata that results from the XB parsing is used by the microcontainer to create an instance of
+ * {@code AuditPolicyBean} and inject this instance into the {@code ApplicationPolicyBean} that represents the
+ * application policy as a whole.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class AuditMetaData extends BasePolicyMetaData
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.metadata.BasePolicyMetaData#setModules(java.util.List)
+ */
+ @Override
+ @XmlElement(name = "provider-module", type = BaseModuleMetaData.class)
+ public void setModules(List<BaseModuleMetaData> modules)
+ {
+ super.modules = modules;
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuthenticationMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuthenticationMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuthenticationMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * <p>
+ * This class represents the {@code <authentication>} configuration in an application policy and contains the
+ * authentication metadata information extracted by the XB parser.
+ * </p>
+ * <p>
+ * The following policy excerpt shows an example of {@code <authentication>} configuration:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
+ * <module-option name="usersProperties">jboss-users.properties</module-option>
+ * <module-option name="rolesProperties">jboss-roles.properties</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.spi.DataBaseServerLoginModule" flag="optional">
+ * <module-option name="principalsQuery">SELECT PASSWD FROM USERS WHERE USER_ID=?</module-option>
+ * <module-option name="rolesQuery">SELECT ROLE_ID, 'Roles' FROM ROLES WHERE USER_ID=?</module-option>
+ * </login-module>
+ * </authentication>
+ * ...
+ * </application-policy>
+ * </pre>
+ *
+ * The metadata that results from the XB parsing is used by the microcontainer to create an instance of
+ * {@code AuthenticationPolicyBean} and inject this instance into the {@code ApplicationPolicyBean} that represents the
+ * application policy as a whole.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class AuthenticationMetaData extends BasePolicyMetaData
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.metadata.BasePolicyMetaData#setModules(java.util.List)
+ */
+ @Override
+ @XmlElement(name = "login-module", type = FlaggedModuleMetaData.class)
+ public void setModules(List<BaseModuleMetaData> modules)
+ {
+ super.modules = modules;
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuthorizationMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuthorizationMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/AuthorizationMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * <p>
+ * This class represents the {@code <authorization>} configuration in an application policy and contains the
+ * authorization metadata information extracted by the XB parser.
+ * </p>
+ * <p>
+ * The following policy excerpt shows an example of {@code <authorization>} configuration:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * ...
+ * </authentication>
+ * <authorization>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule1" flag="required">
+ * <module-option name="authzOption1">authz1.value1</module-option>
+ * </policy-module>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule2" flag="required">
+ * <module-option name="authzOption1">authz2.value1</module-option>
+ * <module-option name="authzOption2">authz2.value2</module-option>
+ * </policy-module>
+ * </authorization>
+ * ...
+ * </application-policy>
+ * </pre>
+ *
+ * The metadata that results from the XB parsing is used by the microcontainer to create an instance of
+ * {@code AuthorizationPolicyBean} and inject this instance into the {@code ApplicationPolicyBean} that represents the
+ * application policy as a whole.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class AuthorizationMetaData extends BasePolicyMetaData
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.metadata.BasePolicyMetaData#setModules(java.util.List)
+ */
+ @Override
+ @XmlElement(name = "policy-module", type = FlaggedModuleMetaData.class)
+ public void setModules(List<BaseModuleMetaData> modules)
+ {
+ super.modules = modules;
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/BaseModuleMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/BaseModuleMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/BaseModuleMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.security.microcontainer.beans.BasePolicyModule;
+
+/**
+ * <p>
+ * This class contains the metadata of a simple policy module.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class BaseModuleMetaData
+{
+ /** the fully-qualified class name of the module. */
+ protected String code;
+
+ /** the module options metadata. */
+ protected List<ModuleOptionMetaData> moduleOptions;
+
+ /**
+ * <p>
+ * Obtains the fully-qualified class name of the module.
+ * </p>
+ *
+ * @return a {@code String} containing the module's class name.
+ */
+ public String getCode()
+ {
+ return code;
+ }
+
+ /**
+ * <p>
+ * Sets the fully-qualified class name of the module.
+ * </p>
+ *
+ * @param code a {@code String} containing the class name to be set.
+ */
+ @XmlAttribute(required = true)
+ public void setCode(String code)
+ {
+ this.code = code;
+ }
+
+ /**
+ * <p>
+ * Obtains the metadata of the module options.
+ * </p>
+ *
+ * @return a {@code List<ModuleOptionMetaData>} containing the option's metadata.
+ */
+ public List<ModuleOptionMetaData> getModuleOptions()
+ {
+ return moduleOptions;
+ }
+
+ /**
+ * <p>
+ * Sets the metadata of the module options.
+ * </p>
+ *
+ * @param moduleOptions a {@code List<ModuleOptionMetaData>} containing the metadata to be set.
+ */
+ @XmlElement(name = "module-option", type = ModuleOptionMetaData.class)
+ public void setModuleOptions(List<ModuleOptionMetaData> moduleOptions)
+ {
+ this.moduleOptions = moduleOptions;
+ }
+
+ /**
+ * <p>
+ * the {@code BeanMetaData} object that will be used by the microcontainer to create and populate an instance of
+ * {@code BasePolicyModule}.
+ * </p>
+ *
+ * @param moduleName the name of the module bean to be created.
+ * @return a {@code BeanMetaData} object containing the metadata needed to create the module bean.
+ */
+ public BeanMetaData getBean(String moduleName)
+ {
+ // create the metadata for the module bean.
+ BeanMetaDataBuilder moduleBuilder = BeanMetaDataBuilder.createBuilder(moduleName, BasePolicyModule.class
+ .getName());
+ moduleBuilder.addPropertyMetaData("code", this.code);
+
+ // add the options map to the metadata.
+ if (this.moduleOptions != null)
+ {
+ Map<String, String> optionsMap = new HashMap<String, String>();
+ for (ModuleOptionMetaData optionMetaData : this.moduleOptions)
+ optionsMap.put(optionMetaData.getName(), optionMetaData.getValue());
+ moduleBuilder.addPropertyMetaData("options", optionsMap);
+ }
+
+ return moduleBuilder.getBeanMetaData();
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/BasePolicyMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/BasePolicyMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/BasePolicyMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+
+/**
+ * <p>
+ * Superclass of all policies that form an application-policy. It defines the metadata common to all policies.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class BasePolicyMetaData
+{
+ /** the collection of the modules specified for the policy. */
+ protected List<BaseModuleMetaData> modules;
+
+ /**
+ * <p>
+ * Obtains the metadata of the modules that have been specified for the policy.
+ * </p>
+ *
+ * @return a {@code List<BaseModuleMetaData>} containig the metadata of the modules.
+ */
+ public List<BaseModuleMetaData> getModules()
+ {
+ return modules;
+ }
+
+ /**
+ * <p>
+ * Sets the metadata of the modules that have been specified for the policy.
+ * </p>
+ *
+ * @param modules a {@code List<BaseModuleMetaData>} containing the metadata to be set.
+ */
+ public void setModules(List<BaseModuleMetaData> modules)
+ {
+ this.modules = modules;
+ }
+
+ /**
+ * <p>
+ * Creates the {@code BeanMetaData} objects that will be used by the microcontainer to create and populate an
+ * instance of the policy bean.
+ * </p>
+ *
+ * @param policyName the name of the policy bean to be created.
+ * @param beanClass the class name of the policy bean.
+ * @return a {@code List} containing all {@code BeanMetaData} objects needed to create the policy bean and its
+ * modules.
+ */
+ public List<BeanMetaData> getBeans(String policyName, String beanClass)
+ {
+ // create the metadata for the policy bean.
+ List<BeanMetaData> result = new ArrayList<BeanMetaData>();
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(policyName, beanClass);
+ result.add(builder.getBeanMetaData());
+
+ if (this.modules != null)
+ {
+ // if there are modules defined, add their metadata to the result.
+ int moduleIndex = 0;
+ List<ValueMetaData> modulesMetaData = builder.createList();
+ for (BaseModuleMetaData moduleMetaData : this.modules)
+ {
+ String moduleName = policyName + "$Module" + moduleIndex++;
+ result.add(moduleMetaData.getBean(moduleName));
+ // inject the module into the collection of modules metadata.
+ ValueMetaData injectLoginModule = builder.createInject(moduleName);
+ modulesMetaData.add(injectLoginModule);
+ }
+ // inject the collection of modules into the policy bean.
+ builder.addPropertyMetaData("modules", modulesMetaData);
+ }
+
+ // give subclasses a chance to add policy-specific metadata information to the result.
+ this.addBeans(policyName, result, builder);
+
+ return result;
+ }
+
+ /**
+ * <p>
+ * This method allows subclasses to add policy-specific metadata to the collection of {@code BeanMetaData} that is
+ * being constructed by the {@code getBeans(String, String)} method.
+ * </p>
+ *
+ * @param policyName the name of the policy bean to be created.
+ * @param beans the collection of {@code BeanMetaData} objects that has been created and populated by the
+ * {@code getBeans} method.
+ * @param builder the {@code BeanMetaDataBuilder} used to create the {@code BeanMetaData} objects.
+ * @see #getBeans(String, String)
+ */
+ public void addBeans(String policyName, List<BeanMetaData> beans, BeanMetaDataBuilder builder)
+ {
+ }
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/FlaggedModuleMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/FlaggedModuleMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/FlaggedModuleMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.security.microcontainer.beans.FlaggedPolicyModule;
+
+/**
+ * <p>
+ * This class extends the {@code BaseModuleMetaData} to add the metadata needed to build a {@code FlaggedPolicyModule}.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class FlaggedModuleMetaData extends BaseModuleMetaData
+{
+
+ /** the flag (required, requisite, sufficient, optional) of the module. */
+ private String flag;
+
+ /**
+ * <p>
+ * Obtains the flag of the module.
+ * </p>
+ *
+ * @return a {@code String} representing the module's flag.
+ */
+ public String getFlag()
+ {
+ return flag;
+ }
+
+ /**
+ * <p>
+ * Sets the flag of the module.
+ * </p>
+ *
+ * @param flag a {@code String} representing the flag to be set.
+ */
+ @XmlAttribute(required = true)
+ public void setFlag(String flag)
+ {
+ this.flag = flag;
+ }
+
+ /**
+ * <p>
+ * Overrides the superclass method to create a {@code BeanMetaDataObject} that will be used by the microcontainer to
+ * generate an instance of {@code FlaggedPolicyModule}.
+ * </p>
+ */
+ @Override
+ public BeanMetaData getBean(String moduleName)
+ {
+ // create the metadata for the module bean.
+ BeanMetaDataBuilder moduleBuilder = BeanMetaDataBuilder.createBuilder(moduleName, FlaggedPolicyModule.class
+ .getName());
+ moduleBuilder.addPropertyMetaData("code", this.code);
+ moduleBuilder.addPropertyMetaData("flag", this.flag);
+
+ // add the options map to the metadata.
+ if (this.moduleOptions != null)
+ {
+ Map<String, String> optionsMap = new HashMap<String, String>();
+ for (ModuleOptionMetaData optionMetaData : this.moduleOptions)
+ optionsMap.put(optionMetaData.getName(), optionMetaData.getValue());
+ moduleBuilder.addPropertyMetaData("options", optionsMap);
+ }
+
+ return moduleBuilder.getBeanMetaData();
+ }
+
+}
\ No newline at end of file
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/IdentityTrustMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/IdentityTrustMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/IdentityTrustMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * <p>
+ * This class represents the {@code <identity-trust>} configuration in an application policy and contains the
+ * identity-trust metadata information extracted by the XB parser.
+ * </p>
+ * <p>
+ * The following policy excerpt shows an example of {@code <identity-trust>} configuration:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * ...
+ * </authentication>
+ * ...
+ * <identity-trust>
+ * <trust-module code="org.jboss.security.trust.IdentityTrustModule" flag="required">
+ * <module-option name="trustOption1">trust.value1</module-option>
+ * <module-option name="trustOption2">trust.value2</module-option>
+ * </trust-module>
+ * </identity-trust>
+ * </application-policy>
+ * </pre>
+ *
+ * The metadata that results from the XB parsing is used by the microcontainer to create an instance of
+ * {@code IdentityTrustPolicyBean} and inject this instance into the {@code ApplicationPolicyBean} that represents the
+ * application policy as a whole.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class IdentityTrustMetaData extends BasePolicyMetaData
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.metadata.BasePolicyMetaData#setModules(java.util.List)
+ */
+ @Override
+ @XmlElement(name = "trust-module", type = FlaggedModuleMetaData.class)
+ public void setModules(List<BaseModuleMetaData> modules)
+ {
+ super.modules = modules;
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/JASPIAuthenticationMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/JASPIAuthenticationMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/JASPIAuthenticationMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+
+/**
+ * <p>
+ * This class represents the {@code <authentication-jaspi>} configuration in an application policy and contains the
+ * jaspi authentication metadata information extracted by the XB parser.
+ * </p>
+ * <p>
+ * The following policy excerpt shows an example of {@code <authentication-jaspi>} configuration:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication-jaspi>
+ * <login-module-stack name="ModuleStack1">
+ * <login-module code="org.jboss.security.auth.StackModule1" flag="required">
+ * <module-option name="stackOption1">stack1.value1</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.StackModule2" flag="option"/>
+ * </login-module-stack>
+ * <login-module-stack name="ModuleStack2">
+ * <login-module code="org.jboss.security.auth.StackModule1" flag="required">
+ * <module-option name="stackOption1">stack2.value1</module-option>
+ * <module-option name="stackOption2">stack2.value2</module-option>
+ * </login-module>
+ * </login-module-stack>
+ * <auth-module code="org.jboss.security.auth.AuthModule" login-module-stack-ref="ModuleStack1">
+ * <module-option name="authOption1">auth.value1</module-option>
+ * <module-option name="authOption2">auth.value2</module-option>
+ * </auth-module>
+ * </authentication-jaspi>
+ * ...
+ * </application-policy>
+ * </pre>
+ *
+ * The metadata that results from the XB parsing is used by the microcontainer to create an instance of
+ * {@code JASPIAuthenticationPolicyBean} and inject this instance into the {@code ApplicationPolicyBean} that represents
+ * the application policy as a whole.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+ at XmlType(name = "authenticationJaspiType", propOrder = {"moduleStacks", "modules"})
+public class JASPIAuthenticationMetaData extends BasePolicyMetaData
+{
+
+ /** the collection of module stacks of the jaspi policy. */
+ private List<LoginModuleStackMetaData> moduleStacks;
+
+ /**
+ * <p>
+ * Obtains the metadata of the module stacks.
+ * </p>
+ *
+ * @return a {@code List<LoginModuleStackMetaData>} containing the module stacks metadata.
+ */
+ public List<LoginModuleStackMetaData> getModuleStacks()
+ {
+ return moduleStacks;
+ }
+
+ /**
+ * <p>
+ * Sets the metadata of the module stacks.
+ * </p>
+ *
+ * @param moduleStacks a {@code List<LoginModuleStackMetaData>} containing the metadata to be set.
+ */
+ @XmlElement(name = "login-module-stack", type = LoginModuleStackMetaData.class)
+ public void setModuleStacks(List<LoginModuleStackMetaData> moduleStacks)
+ {
+ this.moduleStacks = moduleStacks;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.metadata.BasePolicyMetaData#setModules(java.util.List)
+ */
+ @Override
+ @XmlElement(name = "auth-module", type = StackRefModuleMetaData.class)
+ public void setModules(List<BaseModuleMetaData> modules)
+ {
+ super.modules = modules;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.metadata.BasePolicyMetaData#addBeans(java.lang.String,
+ * java.util.List, org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder)
+ */
+ @Override
+ public void addBeans(String policyName, List<BeanMetaData> beans, BeanMetaDataBuilder builder)
+ {
+ if (this.moduleStacks != null)
+ {
+ // if there are stacks of login modules, add them to the jaspi policy metadata being created.
+ int stackIndex = 0;
+ List<ValueMetaData> stackMetaData = builder.createList();
+ for (LoginModuleStackMetaData moduleStack : this.moduleStacks)
+ {
+ String moduleStackName = policyName + "$ModuleStack" + stackIndex++;
+ beans.addAll(moduleStack.getBeans(moduleStackName));
+ ValueMetaData injectModuleStack = builder.createInject(moduleStackName);
+ stackMetaData.add(injectModuleStack);
+ }
+ builder.addPropertyMetaData("moduleStacks", stackMetaData);
+ }
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/LoginModuleStackMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/LoginModuleStackMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/LoginModuleStackMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.security.microcontainer.beans.LoginModuleStackBean;
+
+/**
+ * <p>
+ * This class contains the metadata of a stack of login modules.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class LoginModuleStackMetaData
+{
+
+ /** the name of the login module stack. */
+ private String name;
+
+ /** the metadata of the stack modules. */
+ private List<FlaggedModuleMetaData> loginModules;
+
+ /**
+ * <p>
+ * Obtains the name of the login module stack.
+ * </p>
+ *
+ * @return a {@code String} containing the name of the stack.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * <p>
+ * Sets the name of the login module stack.
+ * </p>
+ *
+ * @param name a {@code String} containing the name to be set.
+ */
+ @XmlAttribute
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * <p>
+ * Obtains the metadata of the stack modules.
+ * </p>
+ *
+ * @return a {@code List} containing the metadata of the stack modules.
+ */
+ public List<FlaggedModuleMetaData> getLoginModules()
+ {
+ return loginModules;
+ }
+
+ /**
+ * <p>
+ * Sets the stack modules metadata.
+ * </p>
+ *
+ * @param loginModules a {@code List} containing the metadata to be set.
+ */
+ @XmlElement(name = "login-module", type = FlaggedModuleMetaData.class)
+ public void setLoginModules(List<FlaggedModuleMetaData> loginModules)
+ {
+ this.loginModules = loginModules;
+ }
+
+ /**
+ * <p>
+ * Creates the {@code BeanMetaData} objects that will be used by the microcontainer to create and populate an
+ * instance of {@code LoginModuleStackBean}.
+ * </p>
+ *
+ * @param stackName the name of the {@code LoginModuleStackBean} to be created.
+ * @return a {@code List} containing all {@code BeanMetaData} objects needed to create the bean and its modules.
+ */
+ public List<BeanMetaData> getBeans(String stackName)
+ {
+ // create the metadata for the LoginModuleStackBean.
+ List<BeanMetaData> result = new ArrayList<BeanMetaData>();
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(stackName, LoginModuleStackBean.class.getName());
+ builder.addPropertyMetaData("name", this.name);
+ result.add(builder.getBeanMetaData());
+
+ if (this.loginModules != null)
+ {
+ // if there are modules, create their metadata and inject them into the stack metadata.
+ int moduleIndex = 0;
+ List<ValueMetaData> modulesMetaData = builder.createList();
+ for (BaseModuleMetaData moduleMetaData : this.loginModules)
+ {
+ String loginModuleName = stackName + "$Module" + moduleIndex++;
+ // create the module metadata.
+ result.add(moduleMetaData.getBean(loginModuleName));
+ ValueMetaData injectLoginModule = builder.createInject(loginModuleName);
+ modulesMetaData.add(injectLoginModule);
+ }
+ // inject all modules into the stack metadata.
+ builder.addPropertyMetaData("loginModules", modulesMetaData);
+ }
+
+ return result;
+ }
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/ModuleOptionMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/ModuleOptionMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/ModuleOptionMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlValue;
+
+/**
+ * <p>
+ * This class contains the metadata of a module option.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class ModuleOptionMetaData
+{
+ /** the name of the option. */
+ private String name;
+
+ /** the value of the option. */
+ private String value;
+
+ /**
+ * <p>
+ * Obtains the name of the option.
+ * </p>
+ *
+ * @return a {@code String} representing the option's name.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * <p>
+ * Sets the name of the option.
+ * </p>
+ *
+ * @param name a {@code String} representing the name to be set.
+ */
+ @XmlAttribute(required = true)
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * <p>
+ * Obtains the value of the option.
+ * </p>
+ *
+ * @return a {@code String} representing the option's value.
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * <p>
+ * Sets the value of the option.
+ * </p>
+ *
+ * @param value {@code String} representing the value to be set.
+ */
+ @XmlValue
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/RoleMappingMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/RoleMappingMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/RoleMappingMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * <p>
+ * This class represents the {@code <rolemapping>} configuration in an application policy and contains the role-mapping
+ * metadata information extracted by the XB parser.
+ * </p>
+ * <p>
+ * The following policy excerpt shows an example of {@code <rolemapping>} configuration:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * ...
+ * </authentication>
+ * ...
+ * <rolemapping>
+ * <mapping-module code="org.jboss.security.mapping.RoleMappingModule">
+ * <module-option name="mappingOption1">mapping.value1</module-option>
+ * <module-option name="mappingOption2">mapping.value2</module-option>
+ * </mapping-module>
+ * </rolemapping>
+ * ...
+ * </application-policy>
+ * </pre>
+ *
+ * The metadata that results from the XB parsing is used by the microcontainer to create an instance of
+ * {@code IdentityTrustPolicyBean} and inject this instance into the {@code ApplicationPolicyBean} that represents the
+ * application policy as a whole.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class RoleMappingMetaData extends BasePolicyMetaData
+{
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.microcontainer.beans.metadata.BasePolicyMetaData#setModules(java.util.List)
+ */@Override
+ @XmlElement(name = "mapping-module", type = BaseModuleMetaData.class)
+ public void setModules(List<BaseModuleMetaData> modules)
+ {
+ super.modules = modules;
+ }
+
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/SecurityPolicyMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/SecurityPolicyMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/SecurityPolicyMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * <p>
+ * This class represents the top-level <policy> element of a security policy.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+ at JBossXmlSchema(namespace = "urn:jboss:security-beans:1.0", elementFormDefault = XmlNsForm.QUALIFIED)
+ at XmlRootElement(name = "policy")
+ at XmlType(name = "policyType", propOrder = {"appPolicies"})
+public class SecurityPolicyMetaData implements BeanMetaDataFactory
+{
+
+ /** the collection of application policy metadata. */
+ private List<ApplicationPolicyMetaDataFactory> appPolicies;
+
+ /**
+ * <p>
+ * Obtains the metadata of the application policies.
+ * </p>
+ *
+ * @return a {@code List} containing the metadata of the application policies.
+ */
+ public List<ApplicationPolicyMetaDataFactory> getAppPolicies()
+ {
+ return appPolicies;
+ }
+
+ /**
+ * <p>
+ * Sets the application policies metadata.
+ * </p>
+ *
+ * @param appPolicies a {@code List} containing the metadata to be set.
+ */
+ @XmlElement(name = "application-policy", type = ApplicationPolicyMetaDataFactory.class)
+ public void setAppPolicies(List<ApplicationPolicyMetaDataFactory> appPolicies)
+ {
+ this.appPolicies = appPolicies;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.beans.metadata.spi.BeanMetaDataFactory#getBeans()
+ */
+ public List<BeanMetaData> getBeans()
+ {
+ List<BeanMetaData> result = new ArrayList<BeanMetaData>();
+ for (ApplicationPolicyMetaDataFactory factory : this.appPolicies)
+ result.addAll(factory.getBeans());
+
+ return result;
+ }
+}
Added: trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/StackRefModuleMetaData.java
===================================================================
--- trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/StackRefModuleMetaData.java (rev 0)
+++ trunk/security/src/main/org/jboss/security/microcontainer/beans/metadata/StackRefModuleMetaData.java 2008-05-13 21:06:13 UTC (rev 73371)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.microcontainer.beans.metadata;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.security.microcontainer.beans.StackRefPolicyModule;
+
+/**
+ * <p>
+ * This class extends the {@code BaseModuleMetaData} to add the metadata needed to build a {@code StackRefPolicyModule}.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class StackRefModuleMetaData extends BaseModuleMetaData
+{
+
+ /** the stack reference of the module. */
+ private String stackRef;
+
+ /**
+ * <p>
+ * Obtains the name of the stack referred by the module.
+ * </p>
+ *
+ * @return a {@code String} representing the stack name.
+ */
+ public String getStackRef()
+ {
+ return stackRef;
+ }
+
+ /**
+ * <p>
+ * Sets the name of the stack referred by the module.
+ * </p>
+ *
+ * @param stackRef a {@code String} representing the name to be set.
+ */
+ @XmlAttribute(name = "login-module-stack-ref")
+ public void setStackRef(String stackRef)
+ {
+ this.stackRef = stackRef;
+ }
+
+ /**
+ * <p>
+ * Overrides the superclass method to create a {@code BeanMetaDataObject} that will be used by the microcontainer to
+ * generate an instance of {@code StackRefPolicyModule}.
+ * </p>
+ */
+ @Override
+ public BeanMetaData getBean(String moduleName)
+ {
+ // create the metadata for the module bean.
+ BeanMetaDataBuilder moduleBuilder = BeanMetaDataBuilder.createBuilder(moduleName, StackRefPolicyModule.class
+ .getName());
+ moduleBuilder.addPropertyMetaData("code", this.code);
+ moduleBuilder.addPropertyMetaData("stackRef", this.stackRef);
+
+ // add the options map to the metadata.
+ if (this.moduleOptions != null)
+ {
+ Map<String, String> optionsMap = new HashMap<String, String>();
+ for (ModuleOptionMetaData optionMetaData : this.moduleOptions)
+ optionsMap.put(optionMetaData.getName(), optionMetaData.getValue());
+ moduleBuilder.addPropertyMetaData("options", optionsMap);
+ }
+
+ return moduleBuilder.getBeanMetaData();
+ }
+
+}
Modified: trunk/server/src/etc/deployers/security-deployer-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/security-deployer-beans.xml 2008-05-13 21:06:05 UTC (rev 73370)
+++ trunk/server/src/etc/deployers/security-deployer-beans.xml 2008-05-13 21:06:13 UTC (rev 73371)
@@ -9,4 +9,12 @@
<bean name="EJBSecurityDeployer" class="org.jboss.ejb.deployers.EjbSecurityDeployer"/>
<bean name="WARSecurityDeployer" class="org.jboss.web.deployers.WarSecurityDeployer"/>
+ <bean name="SecurityParser" class="org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer">
+ <constructor>
+ <parameter>org.jboss.security.microcontainer.beans.metadata.SecurityPolicyMetaData</parameter>
+ </constructor>
+ <property name="suffix">-policy.xml</property>
+ <property name="registerWithJBossXB">true</property>
+ </bean>
+
</deployment>
More information about the jboss-cvs-commits
mailing list