[jboss-cvs] JBossAS SVN: r73824 - in projects/security/security-jboss-sx/trunk/jbosssx-mc-int: .settings and 27 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 29 19:24:25 EDT 2008
Author: sguilhen at redhat.com
Date: 2008-05-29 19:24:25 -0400 (Thu, 29 May 2008)
New Revision: 73824
Added:
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.classpath
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.project
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.settings/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.settings/org.eclipse.jdt.core.prefs
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/pom.xml
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/ApplicationPolicyBean.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuditPolicyBean.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuthenticationPolicyBean.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuthorizationPolicyBean.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BaseAuthenticationPolicy.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BasePolicyBean.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BasePolicyModule.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/FlaggedPolicyModule.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/IdentityTrustPolicyBean.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/JASPIAuthenticationPolicyBean.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/LoginModuleStackBean.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/RoleMappingPolicyBean.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/StackRefPolicyModule.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/ApplicationPolicyMetaDataFactory.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuditMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuthenticationMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuthorizationMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/BaseModuleMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/BasePolicyMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/FlaggedModuleMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/IdentityTrustMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/JASPIAuthenticationMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/LoginModuleStackMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/ModuleOptionMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/RoleMappingMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/SecurityPolicyMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/StackRefModuleMetaData.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/resources/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/resources/schema/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/resources/schema/security-beans_1_0.xsd
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyExtendsTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyMixedTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyTestSuite.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/AuditPolicyTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/AuthorizationPolicyTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/BasicApplicationPolicyTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/BeanValidator.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/IdentityTrustPolicyTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicyTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ManagersInjectionTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/PolicyValidator.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/RoleMappingPolicyTestCase.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuditManager.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuthenticationManager.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuthorizationManager.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockIdentityTrustManager.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockMappingManager.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockSecurityDomain.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockSecurityManagement.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/TestBean.java
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyExtendsTestCase.xml
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyMixedTestCase.xml
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/AuditPolicyTestCase.xml
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/AuthorizationPolicyTestCase.xml
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/BasicApplicationPolicyTestCase.xml
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/IdentityTrustPolicyTestCase.xml
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicy1.xml
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicy2.xml
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ManagersInjectionTestCase.xml
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/RoleMappingPolicyTestCase.xml
Modified:
projects/security/security-jboss-sx/trunk/jbosssx-mc-int/
Log:
Creation of the jbosssx-mc-int (security-microcontainer integration) module.
Property changes on: projects/security/security-jboss-sx/trunk/jbosssx-mc-int
___________________________________________________________________
Name: svn:ignore
+ target
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.classpath
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.classpath (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.classpath 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,41 @@
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+ <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+ <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.0.2/activation-1.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/ant/ant/1.6.5/ant-1.6.5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/ant/ant-junit/1.6.5/ant-junit-1.6.5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/security/authorization-spi/2.0.2.CR1/authorization-spi-2.0.2.CR1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/security/identity-spi/2.0.2.CR1/identity-spi-2.0.2.CR1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.1.GA/jboss-common-core-2.2.1.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-log4j/2.0.4.GA/jboss-common-logging-log4j-2.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0-SNAPSHOT/jboss-dependency-2.0.0-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jaspi-api/1.0.0.CR1/jboss-jaspi-api-1.0.0.CR1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0-SNAPSHOT/jboss-kernel-2.0.0-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0-SNAPSHOT/jboss-kernel-2.0.0-SNAPSHOT-tests.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.0.0.Beta12/jboss-managed-2.0.0.Beta12.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.0.Beta15/jboss-mdr-2.0.0.Beta15.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.0.0.Beta12/jboss-metatype-2.0.0.Beta12.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.0.Beta12/jboss-reflect-2.0.0.Beta12.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-security-spi-bare/2.0.2.CR1/jboss-security-spi-bare-2.0.2.CR1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-test/1.0.4.GA/jboss-test-1.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/security/jbosssx-client/2.0.2-SNAPSHOT/jbosssx-client-2.0.2-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/security/jbosssx-client/2.0.2-SNAPSHOT/jbosssx-client-2.0.2-SNAPSHOT-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.CR8/jbossxb-2.0.0.CR8.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-slide/webdavlib/2.0/webdavlib-2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.7.1/xml-apis-2.7.1.jar"/>
+</classpath>
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.project
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.project (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.project 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,13 @@
+<projectDescription>
+ <name>jbosssx-mc-int</name>
+ <comment>JBoss Security is a cross cutting project that handles security for the JEMS projects</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/.settings/org.eclipse.jdt.core.prefs 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,5 @@
+#Thu Apr 24 14:05:19 GMT-05:00 2008
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/pom.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/pom.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/pom.xml 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,142 @@
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jbosssx-parent</artifactId>
+ <version>2.0.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jbosssx-mc-int</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Microcontainer Security Integration</name>
+ <url>http://labs.jboss.org/portal/jbosssecurity/</url>
+ <description>JBoss Security is a cross cutting project that handles security for the JEMS projects</description>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+ <dependencies>
+ <!-- Global dependencies -->
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jbosssx-client</artifactId>
+ <version>${org.jboss.security.spi.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-security-spi-bare</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <version>2.0.0.Beta12</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-reflect</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-logging-spi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-logging-log4j</artifactId>
+ <version>2.0.4.GA</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-logging-spi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-test</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-logging-spi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-logging-log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jboss.profiler.jvmti</groupId>
+ <artifactId>jboss-profiler-jvmti</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossxb</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/ApplicationPolicyBean.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/ApplicationPolicyBean.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/ApplicationPolicyBean.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,425 @@
+/*
+ * 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.logging.Logger;
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.AuthorizationManager;
+import org.jboss.security.ISecurityManagement;
+import org.jboss.security.audit.AuditManager;
+import org.jboss.security.auth.login.XMLLoginConfigImpl;
+import org.jboss.security.config.ApplicationPolicy;
+import org.jboss.security.config.ApplicationPolicyRegistration;
+import org.jboss.security.identitytrust.IdentityTrustManager;
+import org.jboss.security.mapping.MappingManager;
+
+/**
+ * <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;
+
+ /** the security management implementation used by this bean to obtain the security managers. */
+ private ISecurityManagement securityManagement;
+
+ protected static Logger logger = Logger.getLogger(ApplicationPolicyBean.class);
+
+ /**
+ * <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;
+ }
+
+ // getters and setters for the policy beans that form the application policy defined for the security domain.
+
+ /**
+ * <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>
+ * Sets the {@code ISecurityManagement} implementation that must be used by this bean to obtain the various security
+ * managers that enforce the security policies specified for the domain this bean represents.
+ * </p>
+ *
+ * @param securityManagement an implementation of the {@code ISecurityManagement} interface.
+ */
+ public void setSecurityManagement(ISecurityManagement securityManagement)
+ {
+ this.securityManagement = securityManagement;
+ }
+
+ // getter methods for the various security managers that enforce the policies defined for the security domain.
+
+ /**
+ * <p>
+ * Obtains a reference to the {@code AuthenticationManager} that enforces the authentication policy.
+ * </p>
+ *
+ * @return the {@code AuthenticationManager} that authenticates users according to the specified policy, or
+ * {@code null} if no {@code AuthenticationManager} is available.
+ */
+ public AuthenticationManager getAuthenticationManager()
+ {
+ AuthenticationManager manager = null;
+ if (this.securityManagement != null)
+ manager = this.securityManagement.getAuthenticationManager(this.name);
+ return manager;
+ }
+
+ /**
+ * <p>
+ * Obtains a reference to the {@code AuthorizationManager} that enforces the authorization policy.
+ * </p>
+ *
+ * @return the {@code AuthorizationManager} that authorizes access to resources according to the specified policy, or
+ * {@code null} if no {@code AuthorizationManager} is available.
+ */
+ public AuthorizationManager getAuthorizationManager()
+ {
+ AuthorizationManager manager = null;
+ if (this.securityManagement != null)
+ manager = this.securityManagement.getAuthorizationManager(this.name);
+ return manager;
+ }
+
+ /**
+ * <p>
+ * Obtains a reference to the {@code MappingManager} that enforces the role-mapping policy.
+ * </p>
+ *
+ * @return the {@code MappingManager} that maps roles and identities according to the specified policy, or
+ * {@code null} if no {@code MappingManager} is available.
+ */
+ public MappingManager getMappingManager()
+ {
+ MappingManager manager = null;
+ if (this.securityManagement != null)
+ manager = this.securityManagement.getMappingManager(this.name);
+ return manager;
+ }
+
+ /**
+ * <p>
+ * Obtains a reference to the {@code AuditManager} that enforces the audit policy.
+ * </p>
+ *
+ * @return the {@code AuditManager} that records security events according to the specified policy, or {@code null}
+ * if no {@code AuditManager} is available.
+ */
+ public AuditManager getAuditManager()
+ {
+ AuditManager manager = null;
+ if (this.securityManagement != null)
+ manager = this.securityManagement.getAuditManager(this.name);
+ return manager;
+ }
+
+ /**
+ * <p>
+ * Obtains a reference to the {@code IdentityTrustManager} that enforces the identity-trust policy.
+ * </p>
+ *
+ * @return the {@code IdentityTrustManager} implementation to be used, or {@code null} if no
+ * {@code IdentityTrustManager} is available.
+ */
+ public IdentityTrustManager getIdentityTrustManager()
+ {
+ IdentityTrustManager manager = null;
+ if (this.securityManagement != null)
+ manager = this.securityManagement.getIdentityTrustManager(this.name);
+ return manager;
+ }
+
+ // lifecycle methods.
+
+ /**
+ * <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.getApplicationPolicy();
+ logger.trace("ApplicationPolicy " + this.name + " created " + policy);
+
+ ApplicationPolicyRegistration policyRegistration = XMLLoginConfigImpl.getInstance();
+ policyRegistration.addApplicationPolicy(this.name, policy);
+
+ logger.trace("ApplicationPolicy " + this.name + " registered");
+ }
+
+ /**
+ * <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.
+ // TODO: flush the authentication cache of the domain being undeployed.
+ XMLLoginConfigImpl.getInstance().removeApplicationPolicy(this.name);
+ logger.trace("ApplicationPolicy " + this.name + " removed");
+ }
+
+ /**
+ * <p>
+ * Creates and return 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.
+ */
+ public ApplicationPolicy getApplicationPolicy()
+ {
+ 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());
+ // TODO: add toString to the other policy beans.
+ return buffer.toString();
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuditPolicyBean.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuditPolicyBean.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuditPolicyBean.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuthenticationPolicyBean.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuthenticationPolicyBean.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuthenticationPolicyBean.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuthorizationPolicyBean.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuthorizationPolicyBean.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/AuthorizationPolicyBean.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BaseAuthenticationPolicy.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BaseAuthenticationPolicy.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BaseAuthenticationPolicy.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BasePolicyBean.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BasePolicyBean.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BasePolicyBean.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BasePolicyModule.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BasePolicyModule.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/BasePolicyModule.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/FlaggedPolicyModule.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/FlaggedPolicyModule.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/FlaggedPolicyModule.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/IdentityTrustPolicyBean.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/IdentityTrustPolicyBean.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/IdentityTrustPolicyBean.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/JASPIAuthenticationPolicyBean.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/JASPIAuthenticationPolicyBean.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/JASPIAuthenticationPolicyBean.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/LoginModuleStackBean.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/LoginModuleStackBean.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/LoginModuleStackBean.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/RoleMappingPolicyBean.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/RoleMappingPolicyBean.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/RoleMappingPolicyBean.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/StackRefPolicyModule.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/StackRefPolicyModule.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/StackRefPolicyModule.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/ApplicationPolicyMetaDataFactory.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/ApplicationPolicyMetaDataFactory.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/ApplicationPolicyMetaDataFactory.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,356 @@
+/*
+ * 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.logging.Logger;
+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
+{
+
+ private static final String DEFAUL_SEC_MANAGEMENT = "JNDIBasedSecurityManagement";
+
+ /** the name of the application policy. */
+ private String policyName;
+
+ /** the name of the parent policy, if any. */
+ private String parentPolicy;
+
+ /** the name of the security management bean. */
+ private String securityManagement = DEFAUL_SEC_MANAGEMENT;
+
+ /** 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;
+
+ protected static Logger logger = Logger.getLogger(ApplicationPolicyMetaDataFactory.class);
+
+ /**
+ * <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 name of the security management bean that must be injected into the policy.
+ * </p>
+ *
+ * @param securityManagement a {@code String} representing the name of the management bean.
+ */
+ @XmlAttribute(name = "securityManagement")
+ public void setSecurityManagement(String securityManagement)
+ {
+ this.securityManagement = securityManagement;
+ }
+
+ /**
+ * <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>();
+ logger.trace("Generating metadata for application-policy " + this.policyName);
+
+ // 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)
+ {
+ logger.trace("Generating authentication metadata for policy " + this.policyName);
+ // 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)
+ {
+ logger.trace("Generating jaspi-authentication metadata for policy " + this.policyName);
+ // 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)
+ {
+ logger.trace("Generating authorization metadata for policy " + this.policyName);
+ // 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)
+ {
+ logger.trace("Generating role-mapping metadata for policy " + this.policyName);
+ // 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)
+ {
+ logger.trace("Generating audit metadata for policy " + this.policyName);
+ // 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)
+ {
+ logger.trace("Generating identity-trust metadata for policy " + this.policyName);
+ // 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);
+ }
+
+ // inject the security management bean.
+ logger.trace("Injecting security management " + this.securityManagement + " into application-policy metadata");
+ ValueMetaData injectManagement = policyBuilder.createInject(this.securityManagement);
+ policyBuilder.addPropertyMetaData("securityManagement", injectManagement);
+
+ return result;
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuditMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuditMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuditMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuthenticationMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuthenticationMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuthenticationMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuthorizationMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuthorizationMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/AuthorizationMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/BaseModuleMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/BaseModuleMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/BaseModuleMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/BasePolicyMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/BasePolicyMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/BasePolicyMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/FlaggedModuleMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/FlaggedModuleMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/FlaggedModuleMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/IdentityTrustMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/IdentityTrustMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/IdentityTrustMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/JASPIAuthenticationMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/JASPIAuthenticationMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/JASPIAuthenticationMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/LoginModuleStackMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/LoginModuleStackMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/LoginModuleStackMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/ModuleOptionMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/ModuleOptionMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/ModuleOptionMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/RoleMappingMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/RoleMappingMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/RoleMappingMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/SecurityPolicyMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/SecurityPolicyMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/SecurityPolicyMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/StackRefModuleMetaData.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/StackRefModuleMetaData.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/java/org/jboss/security/microcontainer/beans/metadata/StackRefModuleMetaData.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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();
+ }
+
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/resources/schema/security-beans_1_0.xsd
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/resources/schema/security-beans_1_0.xsd (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/main/resources/schema/security-beans_1_0.xsd 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:security-beans:1.0"
+ xmlns="urn:jboss:security-beans:1.0"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0"
+>
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[A schema for constructing security beans]]>
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <xsd:element name="policy" type="policyConfigType"/>
+ <xsd:complexType name="policyConfigType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[A Security Policy Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="application-policy" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="application-policy">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[An Application Policy Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:choice>
+ <xsd:element ref="authentication"/>
+ <xsd:element ref="authentication-jaspi"/>
+ </xsd:choice>
+ <xsd:element ref="authorization" minOccurs="0"/>
+ <xsd:element ref="rolemapping" minOccurs="0"/>
+ <xsd:element ref="audit" minOccurs="0"/>
+ <xsd:element ref="identity-trust" minOccurs="0"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="extends" type="xsd:string"/>
+ <xsd:attribute name="securityManagement" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="authentication" type="authenticationType"/>
+ <xsd:complexType name="authenticationType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[An Authentication Policy Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="login-module" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="authentication-jaspi" type="authenticationJaspiType"/>
+ <xsd:complexType name="authenticationJaspiType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[A JASPI Authentication Policy Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="login-module-stack" maxOccurs="unbounded"/>
+ <xsd:element ref="auth-module" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="authorization" type="authorizationType"/>
+ <xsd:complexType name="authorizationType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[An Authorization Policy Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="policy-module" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="rolemapping" type="roleMappingType"/>
+ <xsd:complexType name="roleMappingType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[A Role-Mapping Policy Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="mapping-module" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="audit" type="auditType"/>
+ <xsd:complexType name="auditType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[An Audit Policy Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="provider-module" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="identity-trust" type="identityTrustType"/>
+ <xsd:complexType name="identityTrustType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[An Identity-Trust Policy Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="trust-module" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="login-module" type="loginModuleType"/>
+ <xsd:complexType name="loginModuleType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[A JAAS Login Module Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="module-option" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="code" type="xsd:string" use="required"/>
+ <xsd:attribute name="flag" type="module-option-flag" use="required"/>
+ </xsd:complexType>
+
+ <xsd:element name="module-option">
+ <xsd:complexType mixed="true">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[A JAAS Login Module Option]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:simpleType name="module-option-flag">
+ <xsd:annotation>
+ <xsd:documentation>The flag attribute controls how a login module
+ participates in the overall authentication proceedure.
+ Required - The LoginModule is required to succeed. If it
+ succeeds or fails, authentication still continues to proceed
+ down the LoginModule list.
+
+ Requisite - The LoginModule is required to succeed. If it succeeds,
+ authentication continues down the LoginModule list. If it fails,
+ control immediately returns to the application (authentication does not proceed
+ down the LoginModule list).
+
+ Sufficient - The LoginModule is not required to succeed. If it does
+ succeed, control immediately returns to the application (authentication
+ does not proceed down the LoginModule list). If it fails,
+ authentication continues down the LoginModule list.
+
+ Optional - The LoginModule is not required to succeed. If it succeeds or
+ fails, authentication still continues to proceed down the LoginModule list.
+
+ The overall authentication succeeds only if all required and requisite
+ LoginModules succeed. If a sufficient LoginModule is configured and succeeds,
+ then only the required and requisite LoginModules prior to that sufficient
+ LoginModule need to have succeeded for the overall authentication to succeed.
+ If no required or requisite LoginModules are configured for an application,
+ then at least one sufficient or optional LoginModule must succeed.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="required"/>
+ <xsd:enumeration value="requisite"/>
+ <xsd:enumeration value="sufficient"/>
+ <xsd:enumeration value="optional"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:element name="login-module-stack">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[A Login Module Stack Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="login-module" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="auth-module" type="authModuleType"/>
+ <xsd:complexType name="authModuleType">
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[An Authentication Module Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="module-option" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="code" type="xsd:string" use="required"/>
+ <xsd:attribute name="login-module-stack-ref" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:element name="policy-module">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[An Authorization Module Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="module-option" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="code" type="xsd:string" use="required"/>
+ <xsd:attribute name="flag" type="module-option-flag" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="mapping-module">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[A Role Mapping Module Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="module-option" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="code" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="provider-module">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[An Audit Provider Module Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="module-option" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="code" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="trust-module">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[An Identity Trust Module Configuration]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element ref="module-option" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="code" type="xsd:string" use="required"/>
+ <xsd:attribute name="flag" type="module-option-flag" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyExtendsTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyExtendsTestCase.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyExtendsTestCase.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,154 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import org.jboss.security.auth.login.XMLLoginConfigImpl;
+import org.jboss.security.config.ApplicationPolicy;
+import org.jboss.security.config.RoleMappingInfo;
+import org.jboss.security.microcontainer.beans.ApplicationPolicyBean;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * <p>
+ * This class tests the application policy extension mechanism. The deployed configuration file specifies an application
+ * policy named "TestPolicy2" that extends another application policy, named "TestPolicy1". The modules declared by the
+ * "TestPolicy2" policy are added to the modules "inherited" from the extended "TestPolicy1" policy:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </login-module>
+ * </authentication>
+ * <authorization>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule1" flag="required">
+ * <module-option name="authzOption1">value1</module-option>
+ * <module-option name="authzOption2">value2</module-option>
+ * </policy-module>
+ * </authorization>
+ * <rolemapping>
+ * <mapping-module code="org.jboss.security.mapping.RoleMappingModule1">
+ * <module-option name="mappingOption1">value1</module-option>
+ * <module-option name="mappingOption2">value2</module-option>
+ * </mapping-module>
+ * <mapping-module code="org.jboss.security.mapping.RoleMappingModule2">
+ * <module-option name="mappingOption3">value3</module-option>
+ * <module-option name="mappingOption4">value4</module-option>
+ * </mapping-module>
+ * </rolemapping>
+ * <audit>
+ * <provider-module code="org.jboss.security.audit.AuditModule1">
+ * <module-option name="auditOption1">value1</module-option>
+ * </provider-module>
+ * </audit>
+ * </application-policy>
+ *
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2" extends="TestPolicy1">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ * <module-option name="authOption3">value3</module-option>
+ * <module-option name="authOption4">value4</module-option>
+ * </login-module>
+ * </authentication>
+ * <authorization>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule2" flag="required">
+ * <module-option name="authzOption3">value3</module-option>
+ * <module-option name="authzOption4">value4</module-option>
+ * </policy-module>
+ * </authorization>
+ * <audit>
+ * <provider-module code="org.jboss.security.audit.AuditModule2">
+ * <module-option name="auditOption2">value2</module-option>
+ * </provider-module>
+ * </audit>
+ * <identity-trust>
+ * <trust-module code="org.jboss.security.trust.IdentityTrustModule1" flag="required">
+ * <module-option name="trustOption1">value1</module-option>
+ * <module-option name="trustOption2">value2</module-option>
+ * </trust-module>
+ * </identity-trust>
+ * </application-policy>
+ * </pre>
+ *
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class ApplicationPolicyExtendsTestCase extends MicrocontainerTest
+{
+
+ /**
+ * <p>
+ * Creates an instance of {@code ApplicationPolicyExtendsTestCase} with the specified name.
+ * </p>
+ *
+ * @param name a {@code String} representing the name of this test case.
+ */
+ public ApplicationPolicyExtendsTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ // register the schema to the schema resolver before deploying the xml configuration file.
+ SingletonSchemaResolverFactory.getInstance().addJaxbSchema("urn:jboss:security-beans:1.0",
+ "org.jboss.security.microcontainer.beans.metadata.SecurityPolicyMetaData");
+ super.setUp();
+ }
+
+ /**
+ * <p>
+ * Tests the creation of an {@code ApplicationPolicy} that extends another policy.
+ * </p>
+ *
+ * @throws Exception if an error occurs while running the test.
+ */
+ public void testCompletePolicyCreation() throws Exception
+ {
+ // check the bean constructed by the metadata factory has the parent policy name set.
+ ApplicationPolicyBean bean = (ApplicationPolicyBean) super.getBean("TestPolicy2");
+ assertNotNull("ApplicationPolicyBean not found", bean);
+ assertNotNull("Parent policy name has not been set", bean.getParentPolicy());
+ assertEquals("Unexpected parent policy name", "TestPolicy1", bean.getParentPolicy());
+
+ // validate the real application policy has been created with the expected contents.
+ ApplicationPolicy policy = XMLLoginConfigImpl.getInstance().getApplicationPolicy("TestPolicy2");
+ assertNotNull("Application policy not found", policy);
+
+ // TODO: fix the authentication info merge method to return the specific authentication type.
+ // PolicyValidator.validateAuthenticationPolicy((AuthenticationInfo) policy.getAuthenticationInfo());
+
+ // validate the constructed authorization policy.
+ PolicyValidator.validateAuthorizationPolicy("TestPolicy2", policy.getAuthorizationInfo());
+ // validate the constructed role-mapping policy, whose configuration comes exclusively from the parent policy.
+ PolicyValidator.validateRoleMappingPolicy("TestPolicy1", (RoleMappingInfo) policy.getRoleMappingInfo());
+ // validate the constructed audit policy.
+ PolicyValidator.validateAuditPolicy("TestPolicy2", policy.getAuditInfo());
+ // validate the constructed identity-trust policy.
+ PolicyValidator.validateIdentityTrustPolicy("TestPolicy2", policy.getIdentityTrustInfo());
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyMixedTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyMixedTestCase.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyMixedTestCase.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,120 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import org.jboss.security.microcontainer.beans.ApplicationPolicyBean;
+import org.jboss.security.microcontainer.beans.AuthenticationPolicyBean;
+
+/**
+ * <p>
+ * Extends the {@code BasicApplicationPolicyTestCase} to test the configuration of application policies mixed with
+ * regular beans.
+ * </p>
+ * <p>
+ * The deployed configuration file declares the basic application policies and a couple of beans:
+ *
+ * <pre>
+ * <!-- regular microcontainer beans -->
+ * <bean name="RegularBean$AuthenticationPolicy" class="org.jboss.security.microcontainer.beans.AuthenticationPolicyBean"/>
+ *
+ * <bean name="RegularBean" class="org.jboss.security.microcontainer.beans.ApplicationPolicyBean">
+ * <property name="name">RegularBean</property>
+ * <property name="authenticationPolicy"><inject bean="RegularBean$AuthenticationPolicy"/></property>
+ * </bean>
+ *
+ * <!-- a security application policy that specifies an authentication configuration -->
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ * <module-option name="authOption3">value3</module-option>
+ * <module-option name="authOption4">value4</module-option>
+ * </login-module>
+ * </authentication>
+ * </application-policy>
+ *
+ * <!-- a security application policy that specifies an authentication-jaspi configuration -->
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ * <authentication-jaspi>
+ * <login-module-stack name="ModuleStack1">
+ * <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ * <module-option name="authOption5">value5</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ * </login-module-stack>
+ * <login-module-stack name="ModuleStack2">
+ * <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ * <module-option name="authOption6">value6</module-option>
+ * <module-option name="authOption7">value7</module-option>
+ * </login-module>
+ * </login-module-stack>
+ * <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </auth-module>
+ * </authentication-jaspi>
+ * </application-policy>
+ * </pre>
+ *
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class ApplicationPolicyMixedTestCase extends BasicApplicationPolicyTestCase
+{
+
+ /**
+ * <p>
+ * Creates an instance of {@code ApplicationPolicyMixedTestCase} with the specified name.
+ * </p>
+ *
+ * @param name a {@code String} containing the name of this test case.
+ */
+ public ApplicationPolicyMixedTestCase(String name)
+ {
+ super(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.test.security.microcontainer.beans.BasicApplicationPolicyTestCase#testApplicationPoliciesCreation()
+ */
+ @Override
+ public void testApplicationPoliciesCreation() throws Exception
+ {
+ // validate the basic application policy creation.
+ super.testApplicationPoliciesCreation();
+
+ // check the regular beans have been instantiated.
+ AuthenticationPolicyBean authBean = (AuthenticationPolicyBean) super.getBean("RegularBean$AuthenticationPolicy");
+ assertNotNull("Authentication policy bean not found", authBean);
+
+ ApplicationPolicyBean appPolicyBean = (ApplicationPolicyBean) super.getBean("RegularBean");
+ assertNotNull("Application policy bean not found", appPolicyBean);
+ assertEquals("Incorrect policy name", "RegularBean", appPolicyBean.getName());
+ assertEquals("Unexpected authentication policy bean found", authBean, appPolicyBean.getAuthenticationPolicy());
+ }
+}
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyTestSuite.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyTestSuite.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyTestSuite.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,58 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * <p>
+ * This class implements a {@code TestSuite} for the application policy tests.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class ApplicationPolicyTestSuite extends TestSuite
+{
+ /**
+ * <p>
+ * Creates and returns a {@code TestSuite} containing all application policy tests.
+ * </p>
+ *
+ * @return a reference to the constructed {@code TestSuite}.
+ */
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Application policy tests");
+ suite.addTestSuite(BasicApplicationPolicyTestCase.class);
+ suite.addTestSuite(AuthorizationPolicyTestCase.class);
+ suite.addTestSuite(RoleMappingPolicyTestCase.class);
+ suite.addTestSuite(AuditPolicyTestCase.class);
+ suite.addTestSuite(IdentityTrustPolicyTestCase.class);
+ suite.addTestSuite(ApplicationPolicyMixedTestCase.class);
+ suite.addTestSuite(ApplicationPolicyExtendsTestCase.class);
+ suite.addTestSuite(InvalidApplicationPolicyTestCase.class);
+ suite.addTestSuite(ManagersInjectionTestCase.class);
+
+ return suite;
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/AuditPolicyTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/AuditPolicyTestCase.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/AuditPolicyTestCase.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,146 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import org.jboss.security.auth.login.XMLLoginConfigImpl;
+import org.jboss.security.config.ApplicationPolicy;
+import org.jboss.security.microcontainer.beans.ApplicationPolicyBean;
+import org.jboss.security.microcontainer.beans.AuditPolicyBean;
+
+/**
+ * <p>
+ * Extends the {@code BasicApplicationPolicyTestCase} to test the configuration of audit policies along with the basic
+ * authentication policies.
+ * </p>
+ * <p>
+ * The first scenario tests the configuration of an audit policy toghether with an authentication policy:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ * <module-option name="authOption3">value3</module-option>
+ * <module-option name="authOption4">value4</module-option>
+ * </login-module>
+ * </authentication>
+ * <audit>
+ * <provider-module code="org.jboss.security.audit.AuditModule1">
+ * <module-option name="auditOption1">value1</module-option>
+ * </provider-module>
+ * <provider-module code="org.jboss.security.audit.AuditModule2">
+ * <module-option name="auditOption2">value2</module-option>
+ * </provider-module>
+ * </audit>
+ * </application-policy>
+ * </pre>
+ *
+ * while the second scenario tests the configuration of the audit policy toghether with an authentication-jaspi policy:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ * <authentication-jaspi>
+ * <login-module-stack name="ModuleStack1">
+ * <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ * <module-option name="authOption5">value5</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ * </login-module-stack>
+ * <login-module-stack name="ModuleStack2">
+ * <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ * <module-option name="authOption6">value6</module-option>
+ * <module-option name="authOption7">value7</module-option>
+ * </login-module>
+ * </login-module-stack>
+ * <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </auth-module>
+ * </authentication-jaspi>
+ * <audit>
+ * <provider-module code="org.jboss.security.audit.AuditModule1">
+ * <module-option name="auditOption1">value1</module-option>
+ * </provider-module>
+ * <provider-module code="org.jboss.security.audit.AuditModule2">
+ * <module-option name="auditOption2">value2</module-option>
+ * </provider-module>
+ * </audit>
+ * </application-policy>
+ *
+ * </pre>
+ *
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class AuditPolicyTestCase extends BasicApplicationPolicyTestCase
+{
+
+ /**
+ * <p>
+ * Creates an instance of {@code AuditPolicyTestCase} with the specified name.
+ * </p>
+ *
+ * @param name a {@code String} representing the name of this test case.
+ */
+ public AuditPolicyTestCase(String name)
+ {
+ super(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.test.security.microcontainer.beans.BasicApplicationPolicyTestCase#testApplicationPoliciesCreation()
+ */
+ @Override
+ public void testApplicationPoliciesCreation() throws Exception
+ {
+ super.testApplicationPoliciesCreation();
+
+ // validate the audit policy beans have been properly created.
+ ApplicationPolicyBean policyBean1 = (ApplicationPolicyBean) super.getBean("TestPolicy1");
+ assertNotNull("Unexpected null audit policy found", policyBean1.getAuditPolicy());
+
+ ApplicationPolicyBean policyBean2 = (ApplicationPolicyBean) super.getBean("TestPolicy2");
+ assertNotNull("Unexpected null audit policy found", policyBean1.getAuditPolicy());
+
+ AuditPolicyBean auditBean = (AuditPolicyBean) super.getBean("TestPolicy1$AuditPolicy");
+ // assert the bean retrieved from the microcontainer is the same that has been injected into the app policy.
+ assertEquals(policyBean1.getAuditPolicy(), auditBean);
+ BeanValidator.validateAuditBean(auditBean);
+
+ auditBean = (AuditPolicyBean) super.getBean("TestPolicy2$AuditPolicy");
+ assertEquals(policyBean2.getAuditPolicy(), auditBean);
+ BeanValidator.validateAuditBean(auditBean);
+
+ // verify the contents of the audit policies.
+ ApplicationPolicy policy = XMLLoginConfigImpl.getInstance().getApplicationPolicy("TestPolicy1");
+ PolicyValidator.validateAuditPolicy("TestPolicy1", policy.getAuditInfo());
+
+ policy = XMLLoginConfigImpl.getInstance().getApplicationPolicy("TestPolicy2");
+ PolicyValidator.validateAuditPolicy("TestPolicy2", policy.getAuditInfo());
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/AuthorizationPolicyTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/AuthorizationPolicyTestCase.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/AuthorizationPolicyTestCase.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,151 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import org.jboss.security.auth.login.XMLLoginConfigImpl;
+import org.jboss.security.config.ApplicationPolicy;
+import org.jboss.security.microcontainer.beans.ApplicationPolicyBean;
+import org.jboss.security.microcontainer.beans.AuthorizationPolicyBean;
+
+/**
+ * <p>
+ * Extends the {@code BasicApplicationPolicyTestCase} to test the configuration of authorization policies along with the
+ * basic authentication policies.
+ * </p>
+ * <p>
+ * The first scenario tests the configuration of an authorization policy toghether with an authentication policy:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ * <module-option name="authOption3">value3</module-option>
+ * <module-option name="authOption4">value4</module-option>
+ * </login-module>
+ * </authentication>
+ * <authorization>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule1" flag="required">
+ * <module-option name="authzOption1">value1</module-option>
+ * <module-option name="authzOption2">value2</module-option>
+ * </policy-module>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule2" flag="required">
+ * <module-option name="authzOption3">value3</module-option>
+ * <module-option name="authzOption4">value4</module-option>
+ * </policy-module>
+ * </authorization>
+ * </application-policy>
+ * </pre>
+ *
+ * while the second scenario tests the configuration of the authorization policy toghether with an authentication-jaspi
+ * policy:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ * <authentication-jaspi>
+ * <login-module-stack name="ModuleStack1">
+ * <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ * <module-option name="authOption5">value5</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ * </login-module-stack>
+ * <login-module-stack name="ModuleStack2">
+ * <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ * <module-option name="authOption6">value6</module-option>
+ * <module-option name="authOption7">value7</module-option>
+ * </login-module>
+ * </login-module-stack>
+ * <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </auth-module>
+ * </authentication-jaspi>
+ * <authorization>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule1" flag="required">
+ * <module-option name="authzOption1">value1</module-option>
+ * <module-option name="authzOption2">value2</module-option>
+ * </policy-module>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule2" flag="required">
+ * <module-option name="authzOption3">value3</module-option>
+ * <module-option name="authzOption4">value4</module-option>
+ * </policy-module>
+ * </authorization>
+ * </application-policy>
+ *
+ * </pre>
+ *
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class AuthorizationPolicyTestCase extends BasicApplicationPolicyTestCase
+{
+
+ /**
+ * <p>
+ * Creates an instance of {@code AuthorizationPolicyTestCase} with the specified name.
+ * </p>
+ *
+ * @param name a {@code String} representing the name of this test case.
+ */
+ public AuthorizationPolicyTestCase(String name)
+ {
+ super(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.test.security.microcontainer.beans.BasicApplicationPolicyTestCase#testApplicationPoliciesCreation()
+ */
+ @Override
+ public void testApplicationPoliciesCreation() throws Exception
+ {
+ super.testApplicationPoliciesCreation();
+
+ // validate the authorization-policy beans have been properly created.
+ ApplicationPolicyBean policyBean1 = (ApplicationPolicyBean) super.getBean("TestPolicy1");
+ assertNotNull("Unexpected null authorization policy found", policyBean1.getAuthorizationPolicy());
+
+ ApplicationPolicyBean policyBean2 = (ApplicationPolicyBean) super.getBean("TestPolicy2");
+ assertNotNull("Unexpected null authorization policy found", policyBean1.getAuthorizationPolicy());
+
+ AuthorizationPolicyBean authzBean = (AuthorizationPolicyBean) super.getBean("TestPolicy1$AuthorizationPolicy");
+ // assert the bean retrieved from the microcontainer is the same that has been injected into the app policy.
+ assertEquals(policyBean1.getAuthorizationPolicy(), authzBean);
+ BeanValidator.validateAuthorizationBean(authzBean);
+
+ authzBean = (AuthorizationPolicyBean) super.getBean("TestPolicy2$AuthorizationPolicy");
+ assertEquals(policyBean2.getAuthorizationPolicy(), authzBean);
+ BeanValidator.validateAuthorizationBean(authzBean);
+
+ // verify the contents of the authorization policies.
+ ApplicationPolicy policy = XMLLoginConfigImpl.getInstance().getApplicationPolicy("TestPolicy1");
+ PolicyValidator.validateAuthorizationPolicy("TestPolicy1", policy.getAuthorizationInfo());
+
+ policy = XMLLoginConfigImpl.getInstance().getApplicationPolicy("TestPolicy2");
+ PolicyValidator.validateAuthorizationPolicy("TestPolicy2", policy.getAuthorizationInfo());
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/BasicApplicationPolicyTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/BasicApplicationPolicyTestCase.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/BasicApplicationPolicyTestCase.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,159 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import org.jboss.security.auth.login.AuthenticationInfo;
+import org.jboss.security.auth.login.JASPIAuthenticationInfo;
+import org.jboss.security.auth.login.XMLLoginConfigImpl;
+import org.jboss.security.config.ApplicationPolicy;
+import org.jboss.security.microcontainer.beans.ApplicationPolicyBean;
+import org.jboss.security.microcontainer.beans.AuthenticationPolicyBean;
+import org.jboss.security.microcontainer.beans.JASPIAuthenticationPolicyBean;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * <p>
+ * This class tests the configuration of basic application policies. A basic application policy is one that declares
+ * only the authentication information, using either an authentication or an authentication-jaspi sub-policy.
+ * </p>
+ * <p>
+ * The first scenario tests the configuration of an application policy that declares an authentication sub-policy:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ * <module-option name="authOption3">value3</module-option>
+ * <module-option name="authOption4">value4</module-option>
+ * </login-module>
+ * </authentication>
+ * </application-policy>
+ * </pre>
+ *
+ * while the second scenario tests the configuration of an application policy that declares an authentication-jaspi
+ * sub-policy:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ * <authentication-jaspi>
+ * <login-module-stack name="ModuleStack1">
+ * <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ * <module-option name="authOption5">value5</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ * </login-module-stack>
+ * <login-module-stack name="ModuleStack2">
+ * <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ * <module-option name="authOption6">value6</module-option>
+ * <module-option name="authOption7">value7</module-option>
+ * </login-module>
+ * </login-module-stack>
+ * <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </auth-module>
+ * </authentication-jaspi>
+ * </application-policy>
+ *
+ * </pre>
+ *
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class BasicApplicationPolicyTestCase extends MicrocontainerTest
+{
+
+ /**
+ * <p>
+ * Creates an instance of {@code BasicApplicationPolicyTestCase} with the specified name.
+ * </p>
+ *
+ * @param name a {@code String} representing the name of this test case.
+ */
+ public BasicApplicationPolicyTestCase(String name)
+ {
+ super(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.test.kernel.junit.MicrocontainerTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception
+ {
+ // register the schema to the schema resolver before deploying the xml configuration file.
+ SingletonSchemaResolverFactory.getInstance().addJaxbSchema("urn:jboss:security-beans:1.0",
+ "org.jboss.security.microcontainer.beans.metadata.SecurityPolicyMetaData");
+ super.setUp();
+ }
+
+ /**
+ * <p>
+ * Tests the deployment of the basic application policies. This method first verifies that the expected beans have
+ * been created by the {@code ApplicationPolicyMetaDataFactory} and validates the contents of those beans. It then
+ * verifies that a corresponding {@code ApplicationPolicy} has been successfuly generated by the beans and registered
+ * with the security layer.
+ * </p>
+ *
+ * @throws Exception if an error occurs while running the test.
+ */
+ public void testApplicationPoliciesCreation() throws Exception
+ {
+ // validate the application policy beans have been properly created by the metadata factory.
+ ApplicationPolicyBean policyBean1 = (ApplicationPolicyBean) super.getBean("TestPolicy1");
+ assertNotNull("ApplicationPolicyBean TestPolicy1 not found", policyBean1);
+ assertNotNull("Unexpected null authentication policy found", policyBean1.getAuthenticationPolicy());
+
+ ApplicationPolicyBean policyBean2 = (ApplicationPolicyBean) super.getBean("TestPolicy2");
+ assertNotNull("ApplicationPolicyBean TestPolicy2 not found", policyBean2);
+ assertNotNull("Unexpected null jaspi authentication policy found", policyBean2.getAuthenticationPolicy());
+
+ AuthenticationPolicyBean authBean = (AuthenticationPolicyBean) super.getBean("TestPolicy1$AuthenticationPolicy");
+ // assert the bean retrieved from the microcontainer is the same that has been injected into the app policy.
+ assertEquals(policyBean1.getAuthenticationPolicy(), authBean);
+ BeanValidator.validateAuthenticationBean(authBean);
+
+ JASPIAuthenticationPolicyBean jaspiAuthBean = (JASPIAuthenticationPolicyBean) super
+ .getBean("TestPolicy2$JASPIAuthenticationPolicy");
+ assertEquals(policyBean2.getAuthenticationPolicy(), jaspiAuthBean);
+ BeanValidator.validateJaspiAuthenticationBean(jaspiAuthBean);
+
+ // verify that the application policies have been created in the security layer and validate their contents.
+ ApplicationPolicy policy1 = XMLLoginConfigImpl.getInstance().getApplicationPolicy("TestPolicy1");
+ assertNotNull("Application policy TestPolicy1 not found", policy1);
+ assertEquals("TestPolicy1", policy1.getName());
+ PolicyValidator.validateAuthenticationPolicy((AuthenticationInfo) policy1.getAuthenticationInfo());
+
+ ApplicationPolicy policy2 = XMLLoginConfigImpl.getInstance().getApplicationPolicy("TestPolicy2");
+ assertNotNull("Application policy TestPolicy2 not found", policy2);
+ assertEquals("TestPolicy2", policy2.getName());
+ PolicyValidator.validateJaspiAuthenticationPolicy((JASPIAuthenticationInfo) policy2.getAuthenticationInfo());
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/BeanValidator.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/BeanValidator.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/BeanValidator.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,379 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+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.BasePolicyModule;
+import org.jboss.security.microcontainer.beans.FlaggedPolicyModule;
+import org.jboss.security.microcontainer.beans.IdentityTrustPolicyBean;
+import org.jboss.security.microcontainer.beans.JASPIAuthenticationPolicyBean;
+import org.jboss.security.microcontainer.beans.LoginModuleStackBean;
+import org.jboss.security.microcontainer.beans.RoleMappingPolicyBean;
+import org.jboss.security.microcontainer.beans.StackRefPolicyModule;
+
+/**
+ * <p>
+ * This class validates the contents of the beans that are generated by the {@code ApplicationPolicyMetaDataFactory} in
+ * the various application-policy test scenarios.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class BeanValidator
+{
+
+ /**
+ * <p>
+ * Validates the contents of an {@code AuthenticationPolicyBean} generated by the metadata factory from an
+ * authentication configuration like the following:
+ *
+ * <pre>
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ * <module-option name="authOption3">value3</module-option>
+ * <module-option name="authOption4">value4</module-option>
+ * </login-module>
+ * </authentication>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param bean the {@code AuthenticationPolicyBean} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateAuthenticationBean(AuthenticationPolicyBean bean) throws Exception
+ {
+ Assert.assertNotNull("Invalid null bean", bean);
+
+ // check the login-modules that have been specified in the authentication configuration.
+ List<FlaggedPolicyModule> modules = bean.getModules();
+ Assert.assertNotNull("Invalid null list of modules found", modules);
+ Assert.assertEquals("Invalid number of modules", 2, modules.size());
+
+ // first module should be the org.jboss.security.auth.AuthModule1.
+ Assert.assertEquals("org.jboss.security.auth.AuthModule1", modules.get(0).getCode());
+ Assert.assertEquals("required", modules.get(0).getFlag());
+ Map<String, ?> options = modules.get(0).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authOption1 was not found", options.containsKey("authOption1"));
+ Assert.assertEquals("value1", options.get("authOption1"));
+ Assert.assertTrue("Option authOption2 was not found", options.containsKey("authOption2"));
+ Assert.assertEquals("value2", options.get("authOption2"));
+
+ // second module should be the org.jboss.security.auth.AuthModule2.
+ Assert.assertEquals("org.jboss.security.auth.AuthModule2", modules.get(1).getCode());
+ Assert.assertEquals("optional", modules.get(1).getFlag());
+ options = modules.get(1).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authOption3 was not found", options.containsKey("authOption3"));
+ Assert.assertEquals("value3", options.get("authOption3"));
+ Assert.assertTrue("Option authOption4 was not found", options.containsKey("authOption4"));
+ Assert.assertEquals("value4", options.get("authOption4"));
+ }
+
+ /**
+ * <p>
+ * Validates the contents of a {@code JASPIAuthenticationPolicyBean} generated by the metadata factory from an
+ * authentication-jaspi configuration like the following:
+ *
+ * <pre>
+ * <authentication-jaspi>
+ * <login-module-stack name="ModuleStack1">
+ * <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ * <module-option name="authOption5">value5</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ * </login-module-stack>
+ * <login-module-stack name="ModuleStack2">
+ * <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ * <module-option name="authOption6">value6</module-option>
+ * <module-option name="authOption7">value7</module-option>
+ * </login-module>
+ * </login-module-stack>
+ * <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </auth-module>
+ * </authentication-jaspi>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param bean the {@code JASPIAuthenticationPolicyBean} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateJaspiAuthenticationBean(JASPIAuthenticationPolicyBean bean) throws Exception
+ {
+ Assert.assertNotNull("Invalid null bean", bean);
+
+ // check the stacks of login-modules that have been specified in the authentication-jaspi configuration.
+ List<LoginModuleStackBean> stacks = bean.getModuleStacks();
+ Assert.assertNotNull("Invalid null list of stacks found", stacks);
+ Assert.assertEquals("Invalid number of stacks", 2, stacks.size());
+
+ // validate the contents of the first stack.
+ Assert.assertEquals("Invalid stack name", "ModuleStack1", stacks.get(0).getName());
+ List<FlaggedPolicyModule> modules = stacks.get(0).getLoginModules();
+ Assert.assertNotNull(modules);
+ Assert.assertEquals("Invalid number of modules in stack", 2, modules.size());
+
+ Assert.assertEquals("org.jboss.security.auth.AuthModule3", modules.get(0).getCode());
+ Assert.assertEquals("required", modules.get(0).getFlag());
+ Map<String, ?> options = modules.get(0).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authOption5 was not found", options.containsKey("authOption5"));
+ Assert.assertEquals("value5", options.get("authOption5"));
+
+ Assert.assertEquals("org.jboss.security.auth.AuthModule4", modules.get(1).getCode());
+ Assert.assertEquals("optional", modules.get(1).getFlag());
+ options = modules.get(1).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertEquals(0, options.size());
+
+ // validate the contents of the second stack.
+ Assert.assertEquals("Invalid stack name", "ModuleStack2", stacks.get(1).getName());
+ modules = stacks.get(1).getLoginModules();
+ Assert.assertNotNull(modules);
+ Assert.assertEquals("Invalid number of modules in stack", 1, modules.size());
+
+ Assert.assertEquals("org.jboss.security.auth.AuthModule5", modules.get(0).getCode());
+ Assert.assertEquals("required", modules.get(0).getFlag());
+ options = modules.get(0).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authOption6 was not found", options.containsKey("authOption6"));
+ Assert.assertEquals("value6", options.get("authOption6"));
+ Assert.assertTrue("Option authOption7 was not found", options.containsKey("authOption7"));
+ Assert.assertEquals("value7", options.get("authOption7"));
+
+ // check the auth-modules that have been specified in the authentication-jaspi configuration.
+ List<StackRefPolicyModule> authModules = bean.getModules();
+ Assert.assertNotNull("Invalid null list of auth-modules found", authModules);
+ Assert.assertEquals("Invalid number of modules", 1, authModules.size());
+
+ Assert.assertEquals("org.jboss.security.auth.AuthModule1", authModules.get(0).getCode());
+ Assert.assertEquals("ModuleStack2", authModules.get(0).getStackRef());
+ options = authModules.get(0).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authOption1 was not found", options.containsKey("authOption1"));
+ Assert.assertEquals("value1", options.get("authOption1"));
+ Assert.assertTrue("Option authOption2 was not found", options.containsKey("authOption2"));
+ Assert.assertEquals("value2", options.get("authOption2"));
+ }
+
+ /**
+ * <p>
+ * Validates the contents of an {@code AuthorizationPolicyBean} generated by the metadata factory from an
+ * authorization configuration like the following:
+ *
+ * <pre>
+ * <authorization>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule1" flag="required">
+ * <module-option name="authzOption1">value1</module-option>
+ * <module-option name="authzOption2">value2</module-option>
+ * </policy-module>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule2" flag="required">
+ * <module-option name="authzOption3">value3</module-option>
+ * <module-option name="authzOption4">value4</module-option>
+ * </policy-module>
+ * </authorization>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param bean the {@code AuthorizationPolicyBean} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateAuthorizationBean(AuthorizationPolicyBean bean) throws Exception
+ {
+ Assert.assertNotNull("Invalid null bean", bean);
+
+ // check the policy-modules that have been specified in the authorization configuration.
+ List<FlaggedPolicyModule> modules = bean.getModules();
+ Assert.assertNotNull("Invalid null list of modules found", modules);
+ Assert.assertEquals("Invalid number of modules", 2, modules.size());
+
+ // first module should be the org.jboss.security.authz.AuthorizationModule1.
+ Assert.assertEquals("org.jboss.security.authz.AuthorizationModule1", modules.get(0).getCode());
+ Assert.assertEquals("required", modules.get(0).getFlag());
+ Map<String, ?> options = modules.get(0).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authzOption1 was not found", options.containsKey("authzOption1"));
+ Assert.assertEquals("value1", options.get("authzOption1"));
+ Assert.assertTrue("Option authOption2 was not found", options.containsKey("authzOption2"));
+ Assert.assertEquals("value2", options.get("authzOption2"));
+
+ // second module should be the org.jboss.security.authz.AuthorizationModule2.
+ Assert.assertEquals("org.jboss.security.authz.AuthorizationModule2", modules.get(1).getCode());
+ Assert.assertEquals("required", modules.get(1).getFlag());
+ options = modules.get(1).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authzOption3 was not found", options.containsKey("authzOption3"));
+ Assert.assertEquals("value3", options.get("authzOption3"));
+ Assert.assertTrue("Option authzOption4 was not found", options.containsKey("authzOption4"));
+ Assert.assertEquals("value4", options.get("authzOption4"));
+ }
+
+ /**
+ * <p>
+ * Validates the contents of a {@code RoleMappingPolicyBean} generated by the metadata factory from a role-mapping
+ * configuration like the following:
+ *
+ * <pre>
+ * <rolemapping>
+ * <mapping-module code="org.jboss.security.mapping.RoleMappingModule1">
+ * <module-option name="mappingOption1">value1</module-option>
+ * <module-option name="mappingOption2">value2</module-option>
+ * </mapping-module>
+ * <mapping-module code="org.jboss.security.mapping.RoleMappingModule2">
+ * <module-option name="mappingOption3">value3</module-option>
+ * <module-option name="mappingOption4">value4</module-option>
+ * </mapping-module>
+ * </rolemapping>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param bean the {@code RoleMappingPolicyBean} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateRoleMappingBean(RoleMappingPolicyBean bean) throws Exception
+ {
+ Assert.assertNotNull("Invalid null bean", bean);
+
+ // check the policy-modules that have been specified in the role-mapping configuration.
+ List<BasePolicyModule> modules = bean.getModules();
+ Assert.assertNotNull("Invalid null list of modules found", modules);
+ Assert.assertEquals("Invalid number of modules", 2, modules.size());
+
+ // first module should be the org.jboss.security.mapping.RoleMappingModule1.
+ Assert.assertEquals("org.jboss.security.mapping.RoleMappingModule1", modules.get(0).getCode());
+ Map<String, ?> options = modules.get(0).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option mappingOption1 was not found", options.containsKey("mappingOption1"));
+ Assert.assertEquals("value1", options.get("mappingOption1"));
+ Assert.assertTrue("Option authOption2 was not found", options.containsKey("mappingOption2"));
+ Assert.assertEquals("value2", options.get("mappingOption2"));
+
+ // second module should be the org.jboss.security.mapping.RoleMappingModule2.
+ Assert.assertEquals("org.jboss.security.mapping.RoleMappingModule2", modules.get(1).getCode());
+ options = modules.get(1).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option mappingOption3 was not found", options.containsKey("mappingOption3"));
+ Assert.assertEquals("value3", options.get("mappingOption3"));
+ Assert.assertTrue("Option mappingOption4 was not found", options.containsKey("mappingOption4"));
+ Assert.assertEquals("value4", options.get("mappingOption4"));
+ }
+
+ /**
+ * <p>
+ * Validates the contents of an {@code AuditPolicyBean} generated by the metadata factory from an audit configuration
+ * like the following:
+ *
+ * <pre>
+ * <audit>
+ * <provider-module code="org.jboss.security.audit.AuditModule1">
+ * <module-option name="auditOption1">value1</module-option>
+ * </provider-module>
+ * <provider-module code="org.jboss.security.audit.AuditModule2">
+ * <module-option name="auditOption2">value2</module-option>
+ * </provider-module>
+ * </audit>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param bean the {@code AuditPolicyBean} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateAuditBean(AuditPolicyBean bean) throws Exception
+ {
+ Assert.assertNotNull("Invalid null bean", bean);
+
+ // check the policy-modules that have been specified in the audit configuration.
+ List<BasePolicyModule> modules = bean.getModules();
+ Assert.assertNotNull("Invalid null list of modules found", modules);
+ Assert.assertEquals("Invalid number of modules", 2, modules.size());
+
+ // first module should be the org.jboss.security.audit.AuditModule1.
+ Assert.assertEquals("org.jboss.security.audit.AuditModule1", modules.get(0).getCode());
+ Map<String, ?> options = modules.get(0).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option auditOption1 was not found", options.containsKey("auditOption1"));
+ Assert.assertEquals("value1", options.get("auditOption1"));
+
+ // second module should be the org.jboss.security.audit.AuditModule2.
+ Assert.assertEquals("org.jboss.security.audit.AuditModule2", modules.get(1).getCode());
+ options = modules.get(1).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option auditOption2 was not found", options.containsKey("auditOption2"));
+ Assert.assertEquals("value2", options.get("auditOption2"));
+ }
+
+ /**
+ * <p>
+ * Validates the contents of an {@code IdentityTrustPolicyBean} generated by the metadata factory from an
+ * identity-trust configuration like the following:
+ *
+ * <pre>
+ * <identity-trust>
+ * <trust-module code="org.jboss.security.trust.IdentityTrustModule1" flag="required">
+ * <module-option name="trustOption1">value1</module-option>
+ * <module-option name="trustOption2">value2</module-option>
+ * </trust-module>
+ * </identity-trust>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param bean the {@code IdentityTrustPolicyBean} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateIdentityTrustBean(IdentityTrustPolicyBean bean) throws Exception
+ {
+ Assert.assertNotNull("Invalid null bean", bean);
+
+ // check the policy-modules that have been specified in the identity-trust configuration.
+ List<FlaggedPolicyModule> modules = bean.getModules();
+ Assert.assertNotNull("Invalid null list of modules found", modules);
+ Assert.assertEquals("Invalid number of modules", 1, modules.size());
+
+ // first module should be the org.jboss.security.trust.IdentityTrustModule1.
+ Assert.assertEquals("org.jboss.security.trust.IdentityTrustModule1", modules.get(0).getCode());
+ Map<String, ?> options = modules.get(0).getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option trustOption1 was not found", options.containsKey("trustOption1"));
+ Assert.assertEquals("value1", options.get("trustOption1"));
+ Assert.assertTrue("Option trustOption2 was not found", options.containsKey("trustOption2"));
+ Assert.assertEquals("value2", options.get("trustOption2"));
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/IdentityTrustPolicyTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/IdentityTrustPolicyTestCase.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/IdentityTrustPolicyTestCase.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,144 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import org.jboss.security.auth.login.XMLLoginConfigImpl;
+import org.jboss.security.config.ApplicationPolicy;
+import org.jboss.security.microcontainer.beans.ApplicationPolicyBean;
+import org.jboss.security.microcontainer.beans.IdentityTrustPolicyBean;
+
+/**
+ * <p>
+ * Extends the {@code BasicApplicationPolicyTestCase} to test the configuration of identity-trust policies along with
+ * the basic authentication policies.
+ * </p>
+ * <p>
+ * The first scenario tests the configuration of an identity-trust policy toghether with an authentication policy:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ * <module-option name="authOption3">value3</module-option>
+ * <module-option name="authOption4">value4</module-option>
+ * </login-module>
+ * </authentication>
+ * <identity-trust>
+ * <trust-module code="org.jboss.security.trust.IdentityTrustModule1" flag="required">
+ * <module-option name="trustOption1">value1</module-option>
+ * <module-option name="trustOption2">value2</module-option>
+ * </trust-module>
+ * </identity-trust>
+ * </application-policy>
+ * </pre>
+ *
+ * while the second scenario tests the configuration of the trust policy toghether with an authentication-jaspi policy:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ * <authentication-jaspi>
+ * <login-module-stack name="ModuleStack1">
+ * <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ * <module-option name="authOption5">value5</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ * </login-module-stack>
+ * <login-module-stack name="ModuleStack2">
+ * <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ * <module-option name="authOption6">value6</module-option>
+ * <module-option name="authOption7">value7</module-option>
+ * </login-module>
+ * </login-module-stack>
+ * <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </auth-module>
+ * </authentication-jaspi>
+ * <identity-trust>
+ * <trust-module code="org.jboss.security.trust.IdentityTrustModule1" flag="required">
+ * <module-option name="trustOption1">value1</module-option>
+ * <module-option name="trustOption2">value2</module-option>
+ * </trust-module>
+ * </identity-trust>
+ * </application-policy>
+ *
+ * </pre>
+ *
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ *
+ */
+public class IdentityTrustPolicyTestCase extends BasicApplicationPolicyTestCase
+{
+
+ /**
+ * <p>
+ * Creates an instance of {@code IdentityTrustPolicyTestCase} with the specified name.
+ * </p>
+ *
+ * @param name a {@code String} representing the name of this test case.
+ */
+ public IdentityTrustPolicyTestCase(String name)
+ {
+ super(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.test.security.microcontainer.beans.BasicApplicationPolicyTestCase#testApplicationPoliciesCreation()
+ */
+ @Override
+ public void testApplicationPoliciesCreation() throws Exception
+ {
+ super.testApplicationPoliciesCreation();
+
+ // validate the identity-trust policy beans have been properly created.
+ ApplicationPolicyBean policyBean1 = (ApplicationPolicyBean) super.getBean("TestPolicy1");
+ assertNotNull("Unexpected null identity-trust policy found", policyBean1.getIdentityTrustPolicy());
+
+ ApplicationPolicyBean policyBean2 = (ApplicationPolicyBean) super.getBean("TestPolicy2");
+ assertNotNull("Unexpected null identity-trust policy found", policyBean1.getIdentityTrustPolicy());
+
+ IdentityTrustPolicyBean trustBean = (IdentityTrustPolicyBean) super.getBean("TestPolicy1$IdentityTrustPolicy");
+ // assert the bean retrieved from the microcontainer is the same that has been injected into the app policy.
+ assertEquals(policyBean1.getIdentityTrustPolicy(), trustBean);
+ BeanValidator.validateIdentityTrustBean(trustBean);
+
+ trustBean = (IdentityTrustPolicyBean) super.getBean("TestPolicy2$IdentityTrustPolicy");
+ assertEquals(policyBean2.getIdentityTrustPolicy(), trustBean);
+ BeanValidator.validateIdentityTrustBean(trustBean);
+
+ // verify the contents of the identity-trust policies.
+ ApplicationPolicy policy = XMLLoginConfigImpl.getInstance().getApplicationPolicy("TestPolicy1");
+ PolicyValidator.validateIdentityTrustPolicy("TestPolicy1", policy.getIdentityTrustInfo());
+
+ policy = XMLLoginConfigImpl.getInstance().getApplicationPolicy("TestPolicy2");
+ PolicyValidator.validateIdentityTrustPolicy("TestPolicy2", policy.getIdentityTrustInfo());
+
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicyTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicyTestCase.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicyTestCase.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,108 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * <p>
+ * This class implements a {@code MicrocontainerTest} that aims to validate the behavior of the
+ * {@code ApplicationPolicyMetaDataFactory} when invalid application policies are deployed.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class InvalidApplicationPolicyTestCase extends MicrocontainerTest
+{
+
+ /**
+ * <p>
+ * Creates an instance of {@code InvalidApplicationPolicyTestCase} with the specified name.
+ * </p>
+ *
+ * @param name a {@code String} representing the name of this test case.
+ */
+ public InvalidApplicationPolicyTestCase(String name)
+ {
+ super(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.test.kernel.junit.MicrocontainerTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception
+ {
+ // register the schema to the schema resolver before deploying the xml configuration file.
+ SingletonSchemaResolverFactory.getInstance().addJaxbSchema("urn:jboss:security-beans:1.0",
+ "org.jboss.security.microcontainer.beans.metadata.SecurityPolicyMetaData");
+ super.setUp();
+ }
+
+ /**
+ * <p>
+ * Tests the deployment of invalid application policies, verifying that the expected exceptions are thrown.
+ * </p>
+ *
+ * @throws Exception if an error occurs while running the test.
+ */
+ public void testInvalidApplicationPolicies() throws Exception
+ {
+ boolean exceptionCaught = false;
+ try
+ {
+ // deploy an invalid policy that does not declare any authentication configuration.
+ super.deploy(this.getClass().getResource("InvalidApplicationPolicy1.xml"));
+ }
+ catch (Exception e)
+ {
+ assertTrue(e instanceof RuntimeException);
+ assertEquals("An application policy must have an authentication or authentication-jaspi configuration", e
+ .getMessage());
+ exceptionCaught = true;
+ }
+ assertTrue("Expected exception has not been thrown", exceptionCaught);
+
+ exceptionCaught = false;
+ try
+ {
+ // deploy an invalid policy that declares both types of authentication configuration.
+ super.deploy(this.getClass().getResource("InvalidApplicationPolicy2.xml"));
+ }
+ catch (Exception e)
+ {
+ // expected exception chain: JBossXBException -> RuntimeException -> IllegalArgumentException.
+ assertTrue(e instanceof JBossXBException);
+ assertTrue(e.getCause() instanceof RuntimeException);
+ Throwable rootCause = e.getCause().getCause();
+ assertTrue(rootCause instanceof IllegalArgumentException);
+ assertEquals("An <authentication> configuration has already been defined for the policy", rootCause
+ .getMessage());
+ exceptionCaught = true;
+ }
+ assertTrue("Expected exception has not been thrown", exceptionCaught);
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ManagersInjectionTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ManagersInjectionTestCase.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/ManagersInjectionTestCase.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,161 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.AuthorizationManager;
+import org.jboss.security.audit.AuditManager;
+import org.jboss.security.identitytrust.IdentityTrustManager;
+import org.jboss.security.mapping.MappingManager;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.test.security.microcontainer.metadata.support.MockAuditManager;
+import org.jboss.test.security.microcontainer.metadata.support.MockAuthenticationManager;
+import org.jboss.test.security.microcontainer.metadata.support.MockAuthorizationManager;
+import org.jboss.test.security.microcontainer.metadata.support.MockIdentityTrustManager;
+import org.jboss.test.security.microcontainer.metadata.support.MockMappingManager;
+import org.jboss.test.security.microcontainer.metadata.support.TestBean;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * <p>
+ * This class tests the injection of the various security managers into a bean using an application policy
+ * configuration. The following snippet shows an example of {@code AuthenticationManager} injection:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </login-module>
+ * </authentication>
+ * </application-policy>
+ *
+ * <bean name="TestBean" class="org.jboss.test.security.microcontainer.metadata.support.TestBean">
+ * <property name="authenticationManager">
+ * <inject bean="TestPolicy1" property="authenticationManager"/>
+ * </property>
+ * </bean>
+ * </pre>
+ *
+ * As we can see from the example, the {@code ApplicationPolicyBean} that is generated when the policy is parsed can be
+ * used by other beans to obtain the security managers that are responsible for enforcing the specified policy. In the
+ * example above, a bean uses the policy named {@code TestPolicy1} to obtain the {@code AuthenticationManager} through
+ * injection.
+ * </p>
+ * <p>
+ * The following {@code ApplicationPolicyBean} properties are available for other beans to retrieve the security
+ * managers:
+ * <ul>
+ * <li>authenticationManager - retrieves the {@code AuthenticationManager} that uses the {@code <authentication>}
+ * configuration to authenticate users.</li>
+ * <li>authorizationManager - retrieves the {@code AuthorizationManager} that uses the {@code <authorization>}
+ * configuration to authorize access to resources.</li>
+ * <li>mappingManager - retrieves the {@code MappingManager} that uses the {@code <rolemapping>} configuration to map
+ * roles and identities.</li>
+ * <li>auditManager - retrieves the {@code AuditManager} that uses the {@code <audit>} configuration to perform
+ * auditing.</li>
+ * <li>identityTrustManager - retrieves the {@code IdentityTrustManager} that uses the {@code <identity-trust>}
+ * configuration.</li>
+ * </ul>
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class ManagersInjectionTestCase extends MicrocontainerTest
+{
+
+ /**
+ * <p>
+ * Creates an instance of {@code ManagersInjectionTestCase} with the specified name.
+ * </p>
+ *
+ * @param name a {@code String} representing the name of this test case.
+ */
+ public ManagersInjectionTestCase(String name)
+ {
+ super(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.test.kernel.junit.MicrocontainerTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception
+ {
+ // register the schema to the schema resolver before deploying the xml configuration file.
+ SingletonSchemaResolverFactory.getInstance().addJaxbSchema("urn:jboss:security-beans:1.0",
+ "org.jboss.security.microcontainer.beans.metadata.SecurityPolicyMetaData");
+ super.setUp();
+ }
+
+ /**
+ * <p>
+ * Tests the injection of all security managers into a {@code TestBean}. All managers are represented by mock
+ * objects.
+ * </p>
+ *
+ * @throws Exception if an error occurs while running the tests.
+ */
+ public void testManagersInjection() throws Exception
+ {
+ // get the test bean and validate all mock managers have been injected.
+ TestBean testBean = (TestBean) super.getBean("TestBean");
+ assertNotNull("TestBean could not be found", testBean);
+
+ // check the authentication manager injection.
+ AuthenticationManager authenticationManager = testBean.getAuthenticationManager();
+ assertNotNull("Invalid null AuthenticationManager found", authenticationManager);
+ assertEquals("Invalid AuthenticationManager implementation found", MockAuthenticationManager.class,
+ authenticationManager.getClass());
+ assertEquals("TestPolicy1", authenticationManager.getSecurityDomain());
+
+ // check the authorization manager injection.
+ AuthorizationManager authorizationManager = testBean.getAuthorizationManager();
+ assertNotNull("Invalid null AuthorizationManager found", authorizationManager);
+ assertEquals("Invalid AuthorizationManager implementation found", MockAuthorizationManager.class,
+ authorizationManager.getClass());
+ assertEquals("TestPolicy1", authorizationManager.getSecurityDomain());
+
+ // check the mapping manager injection.
+ MappingManager mappingManager = testBean.getMappingManager();
+ assertNotNull("Invalid null MappingManager found", mappingManager);
+ assertEquals("Invalid MappingManager implementation found", MockMappingManager.class, mappingManager.getClass());
+ assertEquals("TestPolicy1", mappingManager.getSecurityDomain());
+
+ // check the audit manager injection.
+ AuditManager auditManager = testBean.getAuditManager();
+ assertNotNull("Invalid null AuditManager found", auditManager);
+ assertEquals("Invalid AuditManager implementation found", MockAuditManager.class, auditManager.getClass());
+ assertEquals("TestPolicy1", auditManager.getSecurityDomain());
+
+ // check the identity-trust injection.
+ IdentityTrustManager trustManager = testBean.getIdentityTrustManager();
+ assertNotNull("Invalid null IdentityTrustManager found", trustManager);
+ assertEquals("Invalid IdentityTrustManager implementation found", MockIdentityTrustManager.class, trustManager
+ .getClass());
+ assertEquals("TestPolicy1", trustManager.getSecurityDomain());
+
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/PolicyValidator.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/PolicyValidator.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/PolicyValidator.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,388 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import java.util.Map;
+
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
+
+import junit.framework.Assert;
+
+import org.jboss.security.audit.config.AuditProviderEntry;
+import org.jboss.security.auth.container.config.AuthModuleEntry;
+import org.jboss.security.auth.login.AuthenticationInfo;
+import org.jboss.security.auth.login.JASPIAuthenticationInfo;
+import org.jboss.security.auth.login.LoginModuleStackHolder;
+import org.jboss.security.authorization.config.AuthorizationModuleEntry;
+import org.jboss.security.config.AuditInfo;
+import org.jboss.security.config.AuthorizationInfo;
+import org.jboss.security.config.IdentityTrustInfo;
+import org.jboss.security.config.RoleMappingInfo;
+import org.jboss.security.identitytrust.config.IdentityTrustModuleEntry;
+import org.jboss.security.mapping.config.MappingModuleEntry;
+
+/**
+ * <p>
+ * This class validates the contents of the policies that have been registered with the security layer in the various
+ * application-policy test scenarios.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class PolicyValidator
+{
+
+ /**
+ * <p>
+ * Validates the contents of an {@code AuthenticationInfo} object that has been generated by the
+ * {@code AuthenticationPolicyBean} that corresponds to the following authentication configuration:
+ *
+ * <pre>
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ * <module-option name="authOption3">value3</module-option>
+ * <module-option name="authOption4">value4</module-option>
+ * </login-module>
+ * </authentication>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param authInfo the {@code AuthenticationInfo} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateAuthenticationPolicy(AuthenticationInfo authInfo) throws Exception
+ {
+
+ Assert.assertNotNull("Authentication policy not found", authInfo);
+ Assert.assertEquals("Authentication policy has unexpected name", "TestPolicy1", authInfo.getName());
+
+ AppConfigurationEntry[] entries = authInfo.getAppConfigurationEntry();
+ Assert.assertNotNull("Invalid AppConfigurationEntry array", entries);
+ Assert.assertEquals("Unexpected number of configuration entries", 2, entries.length);
+
+ // first entry should be the org.jboss.security.auth.AuthModule1.
+ Assert.assertEquals("org.jboss.security.auth.AuthModule1", entries[0].getLoginModuleName());
+ Assert.assertEquals(LoginModuleControlFlag.REQUIRED, entries[0].getControlFlag());
+ Map<String, ?> options = entries[0].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authOption1 was not found", options.containsKey("authOption1"));
+ Assert.assertEquals("value1", options.get("authOption1"));
+ Assert.assertTrue("Option authOption2 was not found", options.containsKey("authOption2"));
+ Assert.assertEquals("value2", options.get("authOption2"));
+
+ // second entry should be the org.jboss.security.auth.AuthModule2.
+ Assert.assertEquals("org.jboss.security.auth.AuthModule2", entries[1].getLoginModuleName());
+ Assert.assertEquals(LoginModuleControlFlag.OPTIONAL, entries[1].getControlFlag());
+ options = entries[1].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authOption3 was not found", options.containsKey("authOption3"));
+ Assert.assertEquals("value3", options.get("authOption3"));
+ Assert.assertTrue("Option authOption4 was not found", options.containsKey("authOption4"));
+ Assert.assertEquals("value4", options.get("authOption4"));
+ }
+
+ /**
+ * <p>
+ * Validates the contents of a {@code JASPIAuthenticationInfo} object that has been generated by the
+ * {@code JASPIAuthenticationPolicyBean} that corresponds to the following authentication-jaspi configuration:
+ *
+ * <pre>
+ * <authentication-jaspi>
+ * <login-module-stack name="ModuleStack1">
+ * <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ * <module-option name="authOption5">value5</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ * </login-module-stack>
+ * <login-module-stack name="ModuleStack2">
+ * <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ * <module-option name="authOption6">value6</module-option>
+ * <module-option name="authOption7">value7</module-option>
+ * </login-module>
+ * </login-module-stack>
+ * <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </auth-module>
+ * </authentication-jaspi>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param authInfo the {@code JASPIAuthenticationInfo} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateJaspiAuthenticationPolicy(JASPIAuthenticationInfo authInfo) throws Exception
+ {
+ // validate the contents of the authentication policy defined.
+ Assert.assertNotNull("Authentication policy not found", authInfo);
+ Assert.assertEquals("Authentication policy has unexpected name", "TestPolicy2", authInfo.getName());
+
+ // validate the login-modules stacks defined by the authentication-jaspi configuration.
+ LoginModuleStackHolder[] stacks = authInfo.getLoginModuleStackHolder();
+ Assert.assertNotNull("Unexpected null stack of login modules");
+ Assert.assertEquals("Invalid number of stacks", 2, stacks.length);
+
+ // first stack defined should be the ModuleStack1.
+ Assert.assertEquals("ModuleStack1", stacks[0].getName());
+ Assert.assertEquals("Invalid number of login modules for the ModuleStack1", 2, stacks[0]
+ .getAppConfigurationEntry().length);
+
+ AppConfigurationEntry[] entries = stacks[0].getAppConfigurationEntry();
+ Assert.assertEquals("org.jboss.security.auth.AuthModule3", entries[0].getLoginModuleName());
+ Assert.assertEquals(LoginModuleControlFlag.REQUIRED, entries[0].getControlFlag());
+ Map<String, ?> options = entries[0].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authOption5 was not found", options.containsKey("authOption5"));
+ Assert.assertEquals("value5", options.get("authOption5"));
+
+ Assert.assertEquals("org.jboss.security.auth.AuthModule4", entries[1].getLoginModuleName());
+ Assert.assertEquals(LoginModuleControlFlag.OPTIONAL, entries[1].getControlFlag());
+ Assert.assertEquals(0, entries[1].getOptions().size());
+
+ // second stack defined should be the ModuleStack2.
+ Assert.assertEquals("ModuleStack2", stacks[1].getName());
+ Assert.assertEquals("Invalid number of login modules for the ModuleStack2", 1, stacks[1]
+ .getAppConfigurationEntry().length);
+
+ entries = stacks[1].getAppConfigurationEntry();
+ Assert.assertEquals("org.jboss.security.auth.AuthModule5", entries[0].getLoginModuleName());
+ Assert.assertEquals(LoginModuleControlFlag.REQUIRED, entries[0].getControlFlag());
+ options = entries[0].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authOption6 was not found", options.containsKey("authOption6"));
+ Assert.assertEquals("value6", options.get("authOption6"));
+ Assert.assertTrue("Option authOption7 was not found", options.containsKey("authOption7"));
+ Assert.assertEquals("value7", options.get("authOption7"));
+
+ // validate the auth-modules defined by the authentication-jaspi configuration.
+ AuthModuleEntry[] authEntries = authInfo.getAuthModuleEntry();
+ Assert.assertNotNull(authEntries);
+ Assert.assertEquals("Invalid number of auth-modules", 1, authEntries.length);
+
+ Assert.assertEquals("org.jboss.security.auth.AuthModule1", authEntries[0].getAuthModuleName());
+ Assert.assertEquals("ModuleStack2", authEntries[0].getLoginModuleStackHolderName());
+ options = authEntries[0].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authOption1 was not found", options.containsKey("authOption1"));
+ Assert.assertEquals("value1", options.get("authOption1"));
+ Assert.assertTrue("Option authOption2 was not found", options.containsKey("authOption2"));
+ Assert.assertEquals("value2", options.get("authOption2"));
+ }
+
+ /**
+ * <p>
+ * Validates the contents of an {@code AuthorizationInfo} object that has been generated by the
+ * {@code AuthorizationPolicyBean} that corresponds to the following authorization configuration:
+ *
+ * <pre>
+ * <authorization>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule1" flag="required">
+ * <module-option name="authzOption1">value1</module-option>
+ * <module-option name="authzOption2">value2</module-option>
+ * </policy-module>
+ * <policy-module code="org.jboss.security.authz.AuthorizationModule2" flag="required">
+ * <module-option name="authzOption3">value3</module-option>
+ * <module-option name="authzOption4">value4</module-option>
+ * </policy-module>
+ * </authorization>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param appPolicyName the name of the application-policy that specifies the authorization configuration.
+ * @param authzInfo the {@code AuthorizationInfo} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateAuthorizationPolicy(String appPolicyName, AuthorizationInfo authzInfo) throws Exception
+ {
+ Assert.assertNotNull("Authorization policy not found", authzInfo);
+ Assert.assertEquals("Authorization policy has unexpected name", appPolicyName, authzInfo.getName());
+
+ AuthorizationModuleEntry[] entries = authzInfo.getAuthorizationModuleEntry();
+ Assert.assertNotNull("Invalid null AuthorizationModuleEntry array", entries);
+ Assert.assertEquals("Unexpected number of authorization entries", 2, entries.length);
+
+ // first entry should be the org.jboss.security.authz.AuthorizationModule1.
+ Assert.assertEquals("org.jboss.security.authz.AuthorizationModule1", entries[0].getPolicyModuleName());
+ Assert.assertEquals("required", entries[0].getControlFlag().toString());
+ Map<String, ?> options = entries[0].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authzOption1 was not found", options.containsKey("authzOption1"));
+ Assert.assertEquals("value1", options.get("authzOption1"));
+ Assert.assertTrue("Option authzOption2 was not found", options.containsKey("authzOption2"));
+ Assert.assertEquals("value2", options.get("authzOption2"));
+
+ // second entry should be the org.jboss.security.authz.AuthorizationModule2.
+ Assert.assertEquals("org.jboss.security.authz.AuthorizationModule2", entries[1].getPolicyModuleName());
+ Assert.assertEquals("required", entries[1].getControlFlag().toString());
+ options = entries[1].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option authzOption3 was not found", options.containsKey("authzOption3"));
+ Assert.assertEquals("value3", options.get("authzOption3"));
+ Assert.assertTrue("Option authzOption4 was not found", options.containsKey("authzOption4"));
+ Assert.assertEquals("value4", options.get("authzOption4"));
+ }
+
+ /**
+ * <p>
+ * Validates the contents of a {@code RoleMappingInfo} object that has been generated by the
+ * {@code RoleMappingPolicyBean} that corresponds to the following rolemapping configuration:
+ *
+ * <pre>
+ * <rolemapping>
+ * <mapping-module code="org.jboss.security.mapping.RoleMappingModule1">
+ * <module-option name="mappingOption1">value1</module-option>
+ * <module-option name="mappingOption2">value2</module-option>
+ * </mapping-module>
+ * <mapping-module code="org.jboss.security.mapping.RoleMappingModule2">
+ * <module-option name="mappingOption3">value3</module-option>
+ * <module-option name="mappingOption4">value4</module-option>
+ * </mapping-module>
+ * </rolemapping>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param appPolicyName the name of the application-policy that specifies the rolemapping configuration.
+ * @param mappingInfo the {@code RoleMappingInfo} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateRoleMappingPolicy(String appPolicyName, RoleMappingInfo mappingInfo) throws Exception
+ {
+ Assert.assertNotNull("Role-mapping policy not found", mappingInfo);
+ Assert.assertEquals("Role-mapping policy has unexpected name", appPolicyName, mappingInfo.getName());
+
+ MappingModuleEntry[] entries = mappingInfo.getMappingModuleEntry();
+ Assert.assertNotNull("Invalid null MappingModuleEntry array", entries);
+ Assert.assertEquals("Unexpected number of role-mapping entries", 2, entries.length);
+
+ // first entry should be the org.jboss.security.mapping.RoleMappingModule1.
+ Assert.assertEquals("org.jboss.security.mapping.RoleMappingModule1", entries[0].getMappingModuleName());
+ Map<String, ?> options = entries[0].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option mappingOption1 was not found", options.containsKey("mappingOption1"));
+ Assert.assertEquals("value1", options.get("mappingOption1"));
+ Assert.assertTrue("Option mappingOption2 was not found", options.containsKey("mappingOption2"));
+ Assert.assertEquals("value2", options.get("mappingOption2"));
+
+ // second entry should be the org.jboss.security.mapping.RoleMappingModule2.
+ Assert.assertEquals("org.jboss.security.mapping.RoleMappingModule2", entries[1].getMappingModuleName());
+ options = entries[1].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option mappingOption3 was not found", options.containsKey("mappingOption3"));
+ Assert.assertEquals("value3", options.get("mappingOption3"));
+ Assert.assertTrue("Option mappingOption4 was not found", options.containsKey("mappingOption4"));
+ Assert.assertEquals("value4", options.get("mappingOption4"));
+ }
+
+ /**
+ * <p>
+ * Validates the contents of an {@code AuditInfo} object that has been generated by the {@code AuditPolicyBean} that
+ * corresponds to the following audit configuration:
+ *
+ * <pre>
+ * <audit>
+ * <provider-module code="org.jboss.security.audit.AuditModule1">
+ * <module-option name="auditOption1">value1</module-option>
+ * </provider-module>
+ * <provider-module code="org.jboss.security.audit.AuditModule2">
+ * <module-option name="auditOption2">value2</module-option>
+ * </provider-module>
+ * </audit>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param appPolicyName the name of the application-policy that specifies the audit configuration.
+ * @param auditInfo the {@code AuditInfo} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateAuditPolicy(String appPolicyName, AuditInfo auditInfo) throws Exception
+ {
+ Assert.assertNotNull("Audit policy not found", auditInfo);
+ Assert.assertEquals("Audit policy has unexpected name", appPolicyName, auditInfo.getName());
+
+ AuditProviderEntry[] entries = auditInfo.getAuditProviderEntry();
+ Assert.assertNotNull("Invalid null AuditProviderEntry array", entries);
+ Assert.assertEquals("Unexpected number of audit entries", 2, entries.length);
+
+ // first entry should be the org.jboss.security.audit.AuditModule1.
+ Assert.assertEquals("org.jboss.security.audit.AuditModule1", entries[0].getName());
+ Map<String, ?> options = entries[0].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option auditOption1 was not found", options.containsKey("auditOption1"));
+ Assert.assertEquals("value1", options.get("auditOption1"));
+
+ // second entry should be the org.jboss.security.audit.AuditModule2.
+ Assert.assertEquals("org.jboss.security.audit.AuditModule2", entries[1].getName());
+ options = entries[1].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option auditOption2 was not found", options.containsKey("auditOption2"));
+ Assert.assertEquals("value2", options.get("auditOption2"));
+ }
+
+ /**
+ * <p>
+ * Validates the contents of an {@code IdentityTrustInfo} object that has been generated by the
+ * {@code IdentityTrustPolicyBean} that corresponds to the following identity-trust configuration:
+ *
+ * <pre>
+ * <identity-trust>
+ * <trust-module code="org.jboss.security.trust.IdentityTrustModule1" flag="required">
+ * <module-option name="trustOption1">value1</module-option>
+ * <module-option name="trustOption2">value2</module-option>
+ * </trust-module>
+ * </identity-trust>
+ * </pre>
+ *
+ * </p>
+ *
+ * @param appPolicyName the name of the application-policy that specifies the identity-trust configuration.
+ * @param trustInfo the {@code IdentityTrustInfo} instance being validated.
+ * @throws Exception if an error occurs while running the validation tests.
+ */
+ public static void validateIdentityTrustPolicy(String appPolicyName, IdentityTrustInfo trustInfo) throws Exception
+ {
+ Assert.assertNotNull("Identity-trust policy not found", trustInfo);
+ Assert.assertEquals("Identity-trust policy has unexpected name", appPolicyName, trustInfo.getName());
+
+ IdentityTrustModuleEntry[] entries = trustInfo.getIdentityTrustModuleEntry();
+ Assert.assertNotNull("Invalid null IdentityTrustModuleEntry array", entries);
+ Assert.assertEquals("Unexpected number of identity-trust entries", 1, entries.length);
+
+ // first entry should be the org.jboss.security.trust.IdentityTrustModule1.
+ Assert.assertEquals("org.jboss.security.trust.IdentityTrustModule1", entries[0].getName());
+ Map<String, ?> options = entries[0].getOptions();
+ Assert.assertNotNull("Unexpected null options map", options);
+ Assert.assertTrue("Option trustOption1 was not found", options.containsKey("trustOption1"));
+ Assert.assertEquals("value1", options.get("trustOption1"));
+ Assert.assertTrue("Option trustOption2 was not found", options.containsKey("trustOption2"));
+ Assert.assertEquals("value2", options.get("trustOption2"));
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/RoleMappingPolicyTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/RoleMappingPolicyTestCase.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/RoleMappingPolicyTestCase.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,153 @@
+/*
+ * 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.test.security.microcontainer.metadata;
+
+import org.jboss.security.auth.login.XMLLoginConfigImpl;
+import org.jboss.security.config.ApplicationPolicy;
+import org.jboss.security.config.RoleMappingInfo;
+import org.jboss.security.microcontainer.beans.ApplicationPolicyBean;
+import org.jboss.security.microcontainer.beans.RoleMappingPolicyBean;
+
+/**
+ * <p>
+ * Extends the {@code BasicApplicationPolicyTestCase} to test the configuration of role-mapping policies along with the
+ * basic authentication policies.
+ * </p>
+ * <p>
+ * The first scenario tests the configuration of a role-mapping policy toghether with an authentication policy:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ * <module-option name="authOption3">value3</module-option>
+ * <module-option name="authOption4">value4</module-option>
+ * </login-module>
+ * </authentication>
+ * <rolemapping>
+ * <mapping-module code="org.jboss.security.mapping.RoleMappingModule1">
+ * <module-option name="mappingOption1">value1</module-option>
+ * <module-option name="mappingOption2">value2</module-option>
+ * </mapping-module>
+ * <mapping-module code="org.jboss.security.mapping.RoleMappingModule2">
+ * <module-option name="mappingOption3">value3</module-option>
+ * <module-option name="mappingOption4">value4</module-option>
+ * </mapping-module>
+ * </rolemapping>
+ * </application-policy>
+ * </pre>
+ *
+ * while the second scenario tests the configuration of the role-mapping policy toghether with an authentication-jaspi
+ * policy:
+ *
+ * <pre>
+ * <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ * <authentication-jaspi>
+ * <login-module-stack name="ModuleStack1">
+ * <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ * <module-option name="authOption5">value5</module-option>
+ * </login-module>
+ * <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ * </login-module-stack>
+ * <login-module-stack name="ModuleStack2">
+ * <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ * <module-option name="authOption6">value6</module-option>
+ * <module-option name="authOption7">value7</module-option>
+ * </login-module>
+ * </login-module-stack>
+ * <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ * <module-option name="authOption1">value1</module-option>
+ * <module-option name="authOption2">value2</module-option>
+ * </auth-module>
+ * </authentication-jaspi>
+ * <rolemapping>
+ * <mapping-module code="org.jboss.security.mapping.RoleMappingModule1">
+ * <module-option name="mappingOption1">value1</module-option>
+ * <module-option name="mappingOption2">value2</module-option>
+ * </mapping-module>
+ * <mapping-module code="org.jboss.security.mapping.RoleMappingModule2">
+ * <module-option name="mappingOption3">value3</module-option>
+ * <module-option name="mappingOption4">value4</module-option>
+ * </mapping-module>
+ * </rolemapping>
+ * </application-policy>
+ *
+ * </pre>
+ *
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class RoleMappingPolicyTestCase extends BasicApplicationPolicyTestCase
+{
+
+ /**
+ * <p>
+ * Creates an instance of {@code RoleMappingPolicyTestCase} with the specified name.
+ * </p>
+ *
+ * @param name a {@code String} representing the name of this test case.
+ */
+ public RoleMappingPolicyTestCase(String name)
+ {
+ super(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.test.security.microcontainer.beans.BasicApplicationPolicyTestCase#testApplicationPoliciesCreation()
+ */
+ @Override
+ public void testApplicationPoliciesCreation() throws Exception
+ {
+ super.testApplicationPoliciesCreation();
+
+ // validate the role-mapping policy beans have been properly created.
+ ApplicationPolicyBean policyBean1 = (ApplicationPolicyBean) super.getBean("TestPolicy1");
+ assertNotNull("Unexpected null role-mapping policy found", policyBean1.getRoleMappingPolicy());
+
+ ApplicationPolicyBean policyBean2 = (ApplicationPolicyBean) super.getBean("TestPolicy2");
+ assertNotNull("Unexpected null role-mapping policy found", policyBean1.getRoleMappingPolicy());
+
+ RoleMappingPolicyBean mappingBean = (RoleMappingPolicyBean) super.getBean("TestPolicy1$RoleMappingPolicy");
+ // assert the bean retrieved from the microcontainer is the same that has been injected into the app policy.
+ assertEquals(policyBean1.getRoleMappingPolicy(), mappingBean);
+ BeanValidator.validateRoleMappingBean(mappingBean);
+
+ mappingBean = (RoleMappingPolicyBean) super.getBean("TestPolicy2$RoleMappingPolicy");
+ assertEquals(policyBean2.getRoleMappingPolicy(), mappingBean);
+ BeanValidator.validateRoleMappingBean(mappingBean);
+
+ // verify the contents of the role-mapping policies.
+ ApplicationPolicy policy = XMLLoginConfigImpl.getInstance().getApplicationPolicy("TestPolicy1");
+ PolicyValidator.validateRoleMappingPolicy("TestPolicy1", (RoleMappingInfo) policy.getRoleMappingInfo());
+
+ policy = XMLLoginConfigImpl.getInstance().getApplicationPolicy("TestPolicy2");
+ PolicyValidator.validateRoleMappingPolicy("TestPolicy2", (RoleMappingInfo) policy.getRoleMappingInfo());
+
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuditManager.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuditManager.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuditManager.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,70 @@
+/*
+ * 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.test.security.microcontainer.metadata.support;
+
+import org.jboss.security.audit.AuditEvent;
+import org.jboss.security.audit.AuditManager;
+
+/**
+ * <p>
+ * A mock {@code AuditManager} implementation used in the tests.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class MockAuditManager implements AuditManager
+{
+
+ private final String domainName;
+
+ /**
+ * <p>
+ * Creates an instance of {@code MockAuditManager} with the specified security domain name.
+ * </p>
+ *
+ * @param domainName a {@code String} representing the name of the security domain.
+ */
+ public MockAuditManager(String domainName)
+ {
+ this.domainName = domainName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.audit.AuditManager#audit(org.jboss.security.audit.AuditEvent)
+ */
+ public void audit(AuditEvent event)
+ {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.BaseSecurityManager#getSecurityDomain()
+ */
+ public String getSecurityDomain()
+ {
+ return this.domainName;
+ }
+
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuthenticationManager.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuthenticationManager.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuthenticationManager.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,129 @@
+/*
+ * 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.test.security.microcontainer.metadata.support;
+
+import java.security.Principal;
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.message.MessageInfo;
+
+import org.jboss.security.AuthenticationManager;
+
+/**
+ * <p>
+ * A mock {@code AuthenticationManager} implementation used in the tests.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class MockAuthenticationManager implements AuthenticationManager
+{
+ private final String domainName;
+
+ /**
+ * <p>
+ * Creates an instance of {@code MockAuthenticationManager} with the specified security domain name.
+ * </p>
+ *
+ * @param domainName a {@code String} representing the name of the security domain.
+ */
+ public MockAuthenticationManager(String domainName)
+ {
+ this.domainName = domainName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthenticationManager#getActiveSubject()
+ */
+ public Subject getActiveSubject()
+ {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthenticationManager#getTargetPrincipal(java.security.Principal, java.util.Map)
+ */
+ public Principal getTargetPrincipal(Principal principal, Map<String, Object> options)
+ {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthenticationManager#isValid(java.security.Principal, java.lang.Object)
+ */
+ public boolean isValid(Principal principal, Object credentials)
+ {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthenticationManager#isValid(java.security.Principal, java.lang.Object,
+ * javax.security.auth.Subject)
+ */
+ public boolean isValid(Principal principal, Object credentials, Subject subject)
+ {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthenticationManager#isValid(javax.security.auth.message.MessageInfo,
+ * javax.security.auth.Subject, java.lang.String)
+ */
+ public boolean isValid(MessageInfo info, Subject subject, String layer)
+ {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthenticationManager#isValid(javax.security.auth.message.MessageInfo,
+ * javax.security.auth.Subject, java.lang.String, javax.security.auth.callback.CallbackHandler)
+ */
+ public boolean isValid(MessageInfo info, Subject subject, String layer, CallbackHandler handler)
+ {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.BaseSecurityManager#getSecurityDomain()
+ */
+ public String getSecurityDomain()
+ {
+ return domainName;
+ }
+
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuthorizationManager.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuthorizationManager.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockAuthorizationManager.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,158 @@
+/*
+ * 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.test.security.microcontainer.metadata.support;
+
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.Map;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+
+import org.jboss.security.AuthorizationManager;
+import org.jboss.security.authorization.AuthorizationException;
+import org.jboss.security.authorization.EntitlementHolder;
+import org.jboss.security.authorization.Resource;
+import org.jboss.security.identity.Identity;
+import org.jboss.security.identity.RoleGroup;
+
+/**
+ * <p>
+ * A mock {@code AuthorizationManager} implementation used in the tests.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class MockAuthorizationManager implements AuthorizationManager
+{
+
+ private final String domainName;
+
+ /**
+ * <p>
+ * Creates an instance of {@code MockAuthorizationManager} using the specified security domain name.
+ * </p>
+ *
+ * @param domainName a {@code String} representing the name of the security domain.
+ */
+ public MockAuthorizationManager(String domainName)
+ {
+ this.domainName = domainName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthorizationManager#authorize(org.jboss.security.authorization.Resource)
+ */
+ public int authorize(Resource resource) throws AuthorizationException
+ {
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthorizationManager#authorize(org.jboss.security.authorization.Resource,
+ * javax.security.auth.Subject, org.jboss.security.identity.RoleGroup)
+ */
+ public int authorize(Resource resource, Subject subject, RoleGroup group) throws AuthorizationException
+ {
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthorizationManager#authorize(org.jboss.security.authorization.Resource,
+ * javax.security.auth.Subject, java.security.acl.Group)
+ */
+ public int authorize(Resource resource, Subject subject, Group group) throws AuthorizationException
+ {
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthorizationManager#doesUserHaveRole(java.security.Principal, java.util.Set)
+ */
+ public boolean doesUserHaveRole(Principal principal, Set<Principal> roles)
+ {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthorizationManager#getEntitlements(java.lang.Class,
+ * org.jboss.security.authorization.Resource, org.jboss.security.identity.Identity)
+ */
+ public <T> EntitlementHolder<T> getEntitlements(Class<T> clazz, Resource resource, Identity identity)
+ throws AuthorizationException
+ {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthorizationManager#getSubjectRoles(javax.security.auth.Subject,
+ * javax.security.auth.callback.CallbackHandler)
+ */
+ public RoleGroup getSubjectRoles(Subject subject, CallbackHandler handler)
+ {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthorizationManager#getTargetRoles(java.security.Principal, java.util.Map)
+ */
+ public Group getTargetRoles(Principal principal, Map<String, Object> options)
+ {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.AuthorizationManager#getUserRoles(java.security.Principal)
+ */
+ public Set<Principal> getUserRoles(Principal principal)
+ {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.BaseSecurityManager#getSecurityDomain()
+ */
+ public String getSecurityDomain()
+ {
+ return this.domainName;
+ }
+
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockIdentityTrustManager.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockIdentityTrustManager.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockIdentityTrustManager.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,71 @@
+/*
+ * 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.test.security.microcontainer.metadata.support;
+
+import org.jboss.security.SecurityContext;
+import org.jboss.security.identitytrust.IdentityTrustManager;
+
+/**
+ * <p>
+ * A mock {@code IdentityTrustManager} implementation used in the tests.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class MockIdentityTrustManager implements IdentityTrustManager
+{
+
+ private final String domainName;
+
+ /**
+ * <p>
+ * Creates an instance of {@code MockIdentityTrustManager} with the specified security domain name.
+ * </p>
+ *
+ * @param domainName a {@code String} representing the name of the security domain.
+ */
+ public MockIdentityTrustManager(String domainName)
+ {
+ this.domainName = domainName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.identitytrust.IdentityTrustManager#isTrusted(org.jboss.security.SecurityContext)
+ */
+ public TrustDecision isTrusted(SecurityContext context)
+ {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.BaseSecurityManager#getSecurityDomain()
+ */
+ public String getSecurityDomain()
+ {
+ return this.domainName;
+ }
+
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockMappingManager.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockMappingManager.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockMappingManager.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,71 @@
+/*
+ * 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.test.security.microcontainer.metadata.support;
+
+import org.jboss.security.mapping.MappingContext;
+import org.jboss.security.mapping.MappingManager;
+
+/**
+ * <p>
+ * A mock {@code MappingManager} implementation used in the tests.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class MockMappingManager implements MappingManager
+{
+
+ private final String domainName;
+
+ /**
+ * <p>
+ * Creates an instance of {@code MockMappingManager} with the specified security domain name.
+ * </p>
+ *
+ * @param domainName a {@code String} representing the name of the security domain.
+ */
+ public MockMappingManager(String domainName)
+ {
+ this.domainName = domainName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.mapping.MappingManager#getMappingContext(java.lang.Class)
+ */
+ public <T> MappingContext<T> getMappingContext(Class<T> clazz)
+ {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.BaseSecurityManager#getSecurityDomain()
+ */
+ public String getSecurityDomain()
+ {
+ return this.domainName;
+ }
+
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockSecurityDomain.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockSecurityDomain.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockSecurityDomain.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,125 @@
+/*
+ * 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.test.security.microcontainer.metadata.support;
+
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.AuthorizationManager;
+import org.jboss.security.audit.AuditManager;
+import org.jboss.security.identitytrust.IdentityTrustManager;
+import org.jboss.security.mapping.MappingManager;
+
+/**
+ * <p>
+ * Mock security domain. This class is used by the {@code MockSecurityManagement} to obtain the security managers
+ * applicable for a domain.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class MockSecurityDomain
+{
+ private final AuthenticationManager authenticationManager;
+
+ private final AuthorizationManager authorizationManager;
+
+ private final MappingManager mappingManager;
+
+ private final AuditManager auditManager;
+
+ private final IdentityTrustManager identityTrustManager;
+
+ /**
+ * <p>
+ * Creates a {@code MockSecurityDomain} instance with the specified domain name.
+ * </p>
+ *
+ * @param domainName a {@code String} representing the name of the security domain.
+ */
+ public MockSecurityDomain(String domainName)
+ {
+ this.authenticationManager = new MockAuthenticationManager(domainName);
+ this.authorizationManager = new MockAuthorizationManager(domainName);
+ this.mappingManager = new MockMappingManager(domainName);
+ this.auditManager = new MockAuditManager(domainName);
+ this.identityTrustManager = new MockIdentityTrustManager(domainName);
+ }
+
+ /**
+ * <p>
+ * Obtains a reference to the {@code AuthenticationManager} used in this domain.
+ * </p>
+ *
+ * @return the {@code AuthenticationManager} implementation.
+ */
+ public AuthenticationManager getAuthenticationManager()
+ {
+ return this.authenticationManager;
+ }
+
+ /**
+ * <p>
+ * Obtains the {@code AuthorizationManager} used in this domain.
+ * </p>
+ *
+ * @return the {@code AuthorizationManager} implementation.
+ */
+ public AuthorizationManager getAuthorizationManager()
+ {
+ return this.authorizationManager;
+ }
+
+ /**
+ * <p>
+ * Obtains the {@code MappingManager} used in this domain.
+ * </p>
+ *
+ * @return the {@code MappingManager} implementation.
+ */
+ public MappingManager getMappingManager()
+ {
+ return this.mappingManager;
+ }
+
+ /**
+ * <p>
+ * Obtains the {@code AuditManager} used in this domain.
+ * </p>
+ *
+ * @return the {@code AuditManager} implementation.
+ */
+ public AuditManager getAuditManager()
+ {
+ return this.auditManager;
+ }
+
+ /**
+ * <p>
+ * Obtains the {@code IdentityTrustManager} used in this domain.
+ * </p>
+ *
+ * @return the {@code IdentityTrustManager} implementation.
+ */
+ public IdentityTrustManager getIdentityTrustManager()
+ {
+ return this.identityTrustManager;
+ }
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockSecurityManagement.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockSecurityManagement.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/MockSecurityManagement.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -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.test.security.microcontainer.metadata.support;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.AuthorizationManager;
+import org.jboss.security.ISecurityManagement;
+import org.jboss.security.audit.AuditManager;
+import org.jboss.security.identitytrust.IdentityTrustManager;
+import org.jboss.security.mapping.MappingManager;
+
+/**
+ * <p>
+ * A mock {@code ISecurityManagement} implementation used in the tests.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class MockSecurityManagement implements ISecurityManagement
+{
+
+ private static final long serialVersionUID = 5675440537362912806L;
+
+ private static Map<String, MockSecurityDomain> domains = new HashMap<String, MockSecurityDomain>();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.ISecurityManagement#getAuditManager(java.lang.String)
+ */
+ public AuditManager getAuditManager(String securityDomain)
+ {
+ MockSecurityDomain mockDomain = domains.get(securityDomain);
+ if (mockDomain == null)
+ {
+ mockDomain = new MockSecurityDomain(securityDomain);
+ domains.put(securityDomain, mockDomain);
+ }
+ return mockDomain.getAuditManager();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.ISecurityManagement#getAuthenticationManager(java.lang.String)
+ */
+ public AuthenticationManager getAuthenticationManager(String securityDomain)
+ {
+ MockSecurityDomain mockDomain = domains.get(securityDomain);
+ if (mockDomain == null)
+ {
+ mockDomain = new MockSecurityDomain(securityDomain);
+ domains.put(securityDomain, mockDomain);
+ }
+ return mockDomain.getAuthenticationManager();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.ISecurityManagement#getAuthorizationManager(java.lang.String)
+ */
+ public AuthorizationManager getAuthorizationManager(String securityDomain)
+ {
+ MockSecurityDomain mockDomain = domains.get(securityDomain);
+ if (mockDomain == null)
+ {
+ mockDomain = new MockSecurityDomain(securityDomain);
+ domains.put(securityDomain, mockDomain);
+ }
+ return mockDomain.getAuthorizationManager();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.ISecurityManagement#getIdentityTrustManager(java.lang.String)
+ */
+ public IdentityTrustManager getIdentityTrustManager(String securityDomain)
+ {
+ MockSecurityDomain mockDomain = domains.get(securityDomain);
+ if (mockDomain == null)
+ {
+ mockDomain = new MockSecurityDomain(securityDomain);
+ domains.put(securityDomain, mockDomain);
+ }
+ return mockDomain.getIdentityTrustManager();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.security.ISecurityManagement#getMappingManager(java.lang.String)
+ */
+ public MappingManager getMappingManager(String securityDomain)
+ {
+ MockSecurityDomain mockDomain = domains.get(securityDomain);
+ if (mockDomain == null)
+ {
+ mockDomain = new MockSecurityDomain(securityDomain);
+ domains.put(securityDomain, mockDomain);
+ }
+ return mockDomain.getMappingManager();
+ }
+
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/TestBean.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/TestBean.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/java/org/jboss/test/security/microcontainer/metadata/support/TestBean.java 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,170 @@
+/*
+ * 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.test.security.microcontainer.metadata.support;
+
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.AuthorizationManager;
+import org.jboss.security.audit.AuditManager;
+import org.jboss.security.identitytrust.IdentityTrustManager;
+import org.jboss.security.mapping.MappingManager;
+
+/**
+ * <p>
+ * A simple POJO used in the injection tests.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class TestBean
+{
+
+ private AuthenticationManager authenticationManager;
+
+ private AuthorizationManager authorizationManager;
+
+ private MappingManager mappingManager;
+
+ private AuditManager auditManager;
+
+ private IdentityTrustManager identityTrustManager;
+
+ /**
+ * <p>
+ * Obtains the {@code AuthenticationManager} that has been injected into this bean.
+ * </p>
+ *
+ * @return a reference to the {@code AuthenticationManager}.
+ */
+ public AuthenticationManager getAuthenticationManager()
+ {
+ return this.authenticationManager;
+ }
+
+ /**
+ * <p>
+ * Sets the {@code AuthenticationManager}. This is done via injection in the tests.
+ * </p>
+ *
+ * @param authenticationManager a reference to the {@code AuthenticationManager} to be set.
+ */
+ public void setAuthenticationManager(AuthenticationManager authenticationManager)
+ {
+ this.authenticationManager = authenticationManager;
+ }
+
+ /**
+ * <p>
+ * Obtains the {@code AuthorizationManager} that has been injected into this bean.
+ * </p>
+ *
+ * @return a reference to the {@code AuthorizationManager}.
+ */
+ public AuthorizationManager getAuthorizationManager()
+ {
+ return this.authorizationManager;
+ }
+
+ /**
+ * <p>
+ * Sets the {@code AuthorizationManager}. This is done via injection in the tests.
+ * </p>
+ *
+ * @param authorizationManager a reference to the {@code AuthorizationManager} to be set.
+ */
+ public void setAuthorizationManager(AuthorizationManager authorizationManager)
+ {
+ this.authorizationManager = authorizationManager;
+ }
+
+ /**
+ * <p>
+ * Obtains the {@code MappingManager} that has been injected into this bean.
+ * </p>
+ *
+ * @return a reference to the {@code MappingManager}.
+ */
+ public MappingManager getMappingManager()
+ {
+ return this.mappingManager;
+ }
+
+ /**
+ * <p>
+ * Sets the {@code MappingManager}. This is done via injection in the tests.
+ * </p>
+ *
+ * @param mappingManager a reference to the {@code MappingManager} to be set.
+ */
+ public void setMappingManager(MappingManager mappingManager)
+ {
+ this.mappingManager = mappingManager;
+ }
+
+ /**
+ * <p>
+ * Obtains the {@code AuditManager} that has been injected into this bean.
+ * </p>
+ *
+ * @return a reference to the {@code AuditManager}.
+ */
+ public AuditManager getAuditManager()
+ {
+ return this.auditManager;
+ }
+
+ /**
+ * <p>
+ * Sets the {@code AuditManager}. This is done via injection in the tests.
+ * </p>
+ *
+ * @param auditManager a reference to the {@code AuditManager} to be set.
+ */
+ public void setAuditManager(AuditManager auditManager)
+ {
+ this.auditManager = auditManager;
+ }
+
+ /**
+ * <p>
+ * Obtains the {@code IdentityTrustManager} that has been injected into this bean.
+ * </p>
+ *
+ * @return a reference to the {@code IdentityTrustManager}.
+ */
+ public IdentityTrustManager getIdentityTrustManager()
+ {
+ return this.identityTrustManager;
+ }
+
+ /**
+ * <p>
+ * Sets the {@code IdentityTrustManager}. This is done via injection in the tests.
+ * </p>
+ *
+ * @param identityTrustManager a reference to the {@code IdentityTrustManager} to be set.
+ */
+ public void setIdentityTrustManager(IdentityTrustManager identityTrustManager)
+ {
+ this.identityTrustManager = identityTrustManager;
+ }
+
+}
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyExtendsTestCase.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyExtendsTestCase.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyExtendsTestCase.xml 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- the security management bean -->
+ <bean name="JNDIBasedSecurityManagement"
+ class="org.jboss.test.security.microcontainer.metadata.support.MockSecurityManagement"/>
+
+ <!-- a regular application policy -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ <authentication>
+ <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </login-module>
+ </authentication>
+ <authorization>
+ <policy-module code="org.jboss.security.authz.AuthorizationModule1" flag="required">
+ <module-option name="authzOption1">value1</module-option>
+ <module-option name="authzOption2">value2</module-option>
+ </policy-module>
+ </authorization>
+ <rolemapping>
+ <mapping-module code="org.jboss.security.mapping.RoleMappingModule1">
+ <module-option name="mappingOption1">value1</module-option>
+ <module-option name="mappingOption2">value2</module-option>
+ </mapping-module>
+ <mapping-module code="org.jboss.security.mapping.RoleMappingModule2">
+ <module-option name="mappingOption3">value3</module-option>
+ <module-option name="mappingOption4">value4</module-option>
+ </mapping-module>
+ </rolemapping>
+ <audit>
+ <provider-module code="org.jboss.security.audit.AuditModule1">
+ <module-option name="auditOption1">value1</module-option>
+ </provider-module>
+ </audit>
+ </application-policy>
+
+ <!-- an application policy that extends the previously declared TestPolicy1 policy -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2" extends="TestPolicy1">
+ <authentication>
+ <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ <module-option name="authOption3">value3</module-option>
+ <module-option name="authOption4">value4</module-option>
+ </login-module>
+ </authentication>
+ <authorization>
+ <policy-module code="org.jboss.security.authz.AuthorizationModule2" flag="required">
+ <module-option name="authzOption3">value3</module-option>
+ <module-option name="authzOption4">value4</module-option>
+ </policy-module>
+ </authorization>
+ <audit>
+ <provider-module code="org.jboss.security.audit.AuditModule2">
+ <module-option name="auditOption2">value2</module-option>
+ </provider-module>
+ </audit>
+ <identity-trust>
+ <trust-module code="org.jboss.security.trust.IdentityTrustModule1" flag="required">
+ <module-option name="trustOption1">value1</module-option>
+ <module-option name="trustOption2">value2</module-option>
+ </trust-module>
+ </identity-trust>
+
+ </application-policy>
+
+</deployment>
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyMixedTestCase.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyMixedTestCase.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ApplicationPolicyMixedTestCase.xml 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- the security management bean -->
+ <bean name="JNDIBasedSecurityManagement"
+ class="org.jboss.test.security.microcontainer.metadata.support.MockSecurityManagement"/>
+
+ <!-- regular microcontainer beans -->
+ <bean name="RegularBean$AuthenticationPolicy" class="org.jboss.security.microcontainer.beans.AuthenticationPolicyBean"/>
+
+ <bean name="RegularBean" class="org.jboss.security.microcontainer.beans.ApplicationPolicyBean">
+ <property name="name">RegularBean</property>
+ <property name="authenticationPolicy"><inject bean="RegularBean$AuthenticationPolicy"/></property>
+ </bean>
+
+ <!-- a security application policy that specifies an authentication configuration -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ <authentication>
+ <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ <module-option name="authOption3">value3</module-option>
+ <module-option name="authOption4">value4</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <!-- a security application policy that specifies an authentication-jaspi configuration -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ <authentication-jaspi>
+ <login-module-stack name="ModuleStack1">
+ <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ <module-option name="authOption5">value5</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ </login-module-stack>
+ <login-module-stack name="ModuleStack2">
+ <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ <module-option name="authOption6">value6</module-option>
+ <module-option name="authOption7">value7</module-option>
+ </login-module>
+ </login-module-stack>
+ <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </auth-module>
+ </authentication-jaspi>
+ </application-policy>
+</deployment>
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/AuditPolicyTestCase.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/AuditPolicyTestCase.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/AuditPolicyTestCase.xml 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- the security management bean -->
+ <bean name="JNDIBasedSecurityManagement"
+ class="org.jboss.test.security.microcontainer.metadata.support.MockSecurityManagement"/>
+
+ <!-- an application policy that specifies authentication and audit configurations -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ <authentication>
+ <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ <module-option name="authOption3">value3</module-option>
+ <module-option name="authOption4">value4</module-option>
+ </login-module>
+ </authentication>
+ <audit>
+ <provider-module code="org.jboss.security.audit.AuditModule1">
+ <module-option name="auditOption1">value1</module-option>
+ </provider-module>
+ <provider-module code="org.jboss.security.audit.AuditModule2">
+ <module-option name="auditOption2">value2</module-option>
+ </provider-module>
+ </audit>
+ </application-policy>
+
+ <!-- an application policy that specifies authentication-jaspi and audit configurations -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ <authentication-jaspi>
+ <login-module-stack name="ModuleStack1">
+ <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ <module-option name="authOption5">value5</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ </login-module-stack>
+ <login-module-stack name="ModuleStack2">
+ <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ <module-option name="authOption6">value6</module-option>
+ <module-option name="authOption7">value7</module-option>
+ </login-module>
+ </login-module-stack>
+ <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </auth-module>
+ </authentication-jaspi>
+ <audit>
+ <provider-module code="org.jboss.security.audit.AuditModule1">
+ <module-option name="auditOption1">value1</module-option>
+ </provider-module>
+ <provider-module code="org.jboss.security.audit.AuditModule2">
+ <module-option name="auditOption2">value2</module-option>
+ </provider-module>
+ </audit>
+ </application-policy>
+
+</deployment>
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/AuthorizationPolicyTestCase.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/AuthorizationPolicyTestCase.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/AuthorizationPolicyTestCase.xml 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- the security management bean -->
+ <bean name="JNDIBasedSecurityManagement"
+ class="org.jboss.test.security.microcontainer.metadata.support.MockSecurityManagement"/>
+
+ <!-- an application policy that specifies authentication and authorization configurations -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ <authentication>
+ <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ <module-option name="authOption3">value3</module-option>
+ <module-option name="authOption4">value4</module-option>
+ </login-module>
+ </authentication>
+ <authorization>
+ <policy-module code="org.jboss.security.authz.AuthorizationModule1" flag="required">
+ <module-option name="authzOption1">value1</module-option>
+ <module-option name="authzOption2">value2</module-option>
+ </policy-module>
+ <policy-module code="org.jboss.security.authz.AuthorizationModule2" flag="required">
+ <module-option name="authzOption3">value3</module-option>
+ <module-option name="authzOption4">value4</module-option>
+ </policy-module>
+ </authorization>
+ </application-policy>
+
+ <!-- an application policy that specifies authentication-jaspi and authorization configurations -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ <authentication-jaspi>
+ <login-module-stack name="ModuleStack1">
+ <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ <module-option name="authOption5">value5</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ </login-module-stack>
+ <login-module-stack name="ModuleStack2">
+ <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ <module-option name="authOption6">value6</module-option>
+ <module-option name="authOption7">value7</module-option>
+ </login-module>
+ </login-module-stack>
+ <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </auth-module>
+ </authentication-jaspi>
+ <authorization>
+ <policy-module code="org.jboss.security.authz.AuthorizationModule1" flag="required">
+ <module-option name="authzOption1">value1</module-option>
+ <module-option name="authzOption2">value2</module-option>
+ </policy-module>
+ <policy-module code="org.jboss.security.authz.AuthorizationModule2" flag="required">
+ <module-option name="authzOption3">value3</module-option>
+ <module-option name="authzOption4">value4</module-option>
+ </policy-module>
+ </authorization>
+ </application-policy>
+
+</deployment>
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/BasicApplicationPolicyTestCase.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/BasicApplicationPolicyTestCase.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/BasicApplicationPolicyTestCase.xml 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- the security management bean -->
+ <bean name="JNDIBasedSecurityManagement"
+ class="org.jboss.test.security.microcontainer.metadata.support.MockSecurityManagement"/>
+
+ <!-- an application policy that specifies an authentication configuration -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ <authentication>
+ <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ <module-option name="authOption3">value3</module-option>
+ <module-option name="authOption4">value4</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <!-- an application policy that specifies an authentication-jaspi configuration -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ <authentication-jaspi>
+ <login-module-stack name="ModuleStack1">
+ <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ <module-option name="authOption5">value5</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ </login-module-stack>
+ <login-module-stack name="ModuleStack2">
+ <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ <module-option name="authOption6">value6</module-option>
+ <module-option name="authOption7">value7</module-option>
+ </login-module>
+ </login-module-stack>
+ <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </auth-module>
+ </authentication-jaspi>
+ </application-policy>
+
+</deployment>
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/IdentityTrustPolicyTestCase.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/IdentityTrustPolicyTestCase.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/IdentityTrustPolicyTestCase.xml 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- the security management bean -->
+ <bean name="JNDIBasedSecurityManagement"
+ class="org.jboss.test.security.microcontainer.metadata.support.MockSecurityManagement"/>
+
+ <!-- an application policy that specifies authentication and identity-trust configurations -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ <authentication>
+ <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ <module-option name="authOption3">value3</module-option>
+ <module-option name="authOption4">value4</module-option>
+ </login-module>
+ </authentication>
+ <identity-trust>
+ <trust-module code="org.jboss.security.trust.IdentityTrustModule1" flag="required">
+ <module-option name="trustOption1">value1</module-option>
+ <module-option name="trustOption2">value2</module-option>
+ </trust-module>
+ </identity-trust>
+ </application-policy>
+
+ <!-- an application policy that specifies authentication-jaspi and identity-trust configurations -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ <authentication-jaspi>
+ <login-module-stack name="ModuleStack1">
+ <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ <module-option name="authOption5">value5</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ </login-module-stack>
+ <login-module-stack name="ModuleStack2">
+ <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ <module-option name="authOption6">value6</module-option>
+ <module-option name="authOption7">value7</module-option>
+ </login-module>
+ </login-module-stack>
+ <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </auth-module>
+ </authentication-jaspi>
+ <identity-trust>
+ <trust-module code="org.jboss.security.trust.IdentityTrustModule1" flag="required">
+ <module-option name="trustOption1">value1</module-option>
+ <module-option name="trustOption2">value2</module-option>
+ </trust-module>
+ </identity-trust>
+ </application-policy>
+
+</deployment>
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicy1.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicy1.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicy1.xml 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- the security management bean -->
+ <bean name="JNDIBasedSecurityManagement"
+ class="org.jboss.test.security.microcontainer.metadata.support.MockSecurityManagement"/>
+
+ <!-- invalid application policy: does not have authentication configuration -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="InvalidPolicy1">
+ <authorization>
+ <policy-module code="org.jboss.security.authz.AuthorizationModule2" flag="required">
+ <module-option name="authzOption3">value3</module-option>
+ <module-option name="authzOption4">value4</module-option>
+ </policy-module>
+ </authorization>
+ <audit>
+ <provider-module code="org.jboss.security.audit.AuditModule2">
+ <module-option name="auditOption2">value2</module-option>
+ </provider-module>
+ </audit>
+ <identity-trust>
+ <trust-module code="org.jboss.security.trust.IdentityTrustModule1" flag="required">
+ <module-option name="trustOption1">value1</module-option>
+ <module-option name="trustOption2">value2</module-option>
+ </trust-module>
+ </identity-trust>
+ </application-policy>
+
+</deployment>
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicy2.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicy2.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/InvalidApplicationPolicy2.xml 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- the security management bean -->
+ <bean name="JNDIBasedSecurityManagement"
+ class="org.jboss.test.security.microcontainer.metadata.support.MockSecurityManagement"/>
+
+ <!-- invalid application policy: declares both types of authentication at the same time -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="InvalidPolicy2">
+ <authentication>
+ <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ <module-option name="authOption3">value3</module-option>
+ <module-option name="authOption4">value4</module-option>
+ </login-module>
+ </authentication>
+ <authentication-jaspi>
+ <login-module-stack name="ModuleStack1">
+ <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ <module-option name="authOption5">value5</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ </login-module-stack>
+ <login-module-stack name="ModuleStack2">
+ <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ <module-option name="authOption6">value6</module-option>
+ <module-option name="authOption7">value7</module-option>
+ </login-module>
+ </login-module-stack>
+ <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </auth-module>
+ </authentication-jaspi>
+ </application-policy>
+</deployment>
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ManagersInjectionTestCase.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ManagersInjectionTestCase.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/ManagersInjectionTestCase.xml 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- the security management bean -->
+ <bean name="JNDIBasedSecurityManagement"
+ class="org.jboss.test.security.microcontainer.metadata.support.MockSecurityManagement"/>
+
+
+ <!-- a regular application policy -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ <authentication>
+ <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </login-module>
+ </authentication>
+ <authorization>
+ <policy-module code="org.jboss.security.authz.AuthorizationModule1" flag="required">
+ <module-option name="authzOption1">value1</module-option>
+ <module-option name="authzOption2">value2</module-option>
+ </policy-module>
+ </authorization>
+ <rolemapping>
+ <mapping-module code="org.jboss.security.mapping.RoleMappingModule1">
+ <module-option name="mappingOption1">value1</module-option>
+ <module-option name="mappingOption2">value2</module-option>
+ </mapping-module>
+ <mapping-module code="org.jboss.security.mapping.RoleMappingModule2">
+ <module-option name="mappingOption3">value3</module-option>
+ <module-option name="mappingOption4">value4</module-option>
+ </mapping-module>
+ </rolemapping>
+ <audit>
+ <provider-module code="org.jboss.security.audit.AuditModule1">
+ <module-option name="auditOption1">value1</module-option>
+ </provider-module>
+ </audit>
+ <identity-trust>
+ <trust-module code="org.jboss.security.trust.IdentityTrustModule1" flag="required">
+ <module-option name="trustOption1">value1</module-option>
+ <module-option name="trustOption2">value2</module-option>
+ </trust-module>
+ </identity-trust>
+ </application-policy>
+
+ <!-- a test bean where we inject the security managers -->
+ <bean name="TestBean" class="org.jboss.test.security.microcontainer.metadata.support.TestBean">
+ <property name="authenticationManager"><inject bean="TestPolicy1" property="authenticationManager"/></property>
+ <property name="authorizationManager"><inject bean="TestPolicy1" property="authorizationManager"/></property>
+ <property name="mappingManager"><inject bean="TestPolicy1" property="mappingManager"/></property>
+ <property name="auditManager"><inject bean="TestPolicy1" property="auditManager"/></property>
+ <property name="identityTrustManager"><inject bean="TestPolicy1" property="identityTrustManager"/></property>
+ </bean>
+
+</deployment>
Added: projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/RoleMappingPolicyTestCase.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/RoleMappingPolicyTestCase.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/jbosssx-mc-int/src/test/resources/org/jboss/test/security/microcontainer/metadata/RoleMappingPolicyTestCase.xml 2008-05-29 23:24:25 UTC (rev 73824)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- the security management bean -->
+ <bean name="JNDIBasedSecurityManagement"
+ class="org.jboss.test.security.microcontainer.metadata.support.MockSecurityManagement"/>
+
+ <!-- an application policy that specifies authentication and role-mapping configurations -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy1">
+ <authentication>
+ <login-module code="org.jboss.security.auth.AuthModule1" flag="required">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule2" flag="optional">
+ <module-option name="authOption3">value3</module-option>
+ <module-option name="authOption4">value4</module-option>
+ </login-module>
+ </authentication>
+ <rolemapping>
+ <mapping-module code="org.jboss.security.mapping.RoleMappingModule1">
+ <module-option name="mappingOption1">value1</module-option>
+ <module-option name="mappingOption2">value2</module-option>
+ </mapping-module>
+ <mapping-module code="org.jboss.security.mapping.RoleMappingModule2">
+ <module-option name="mappingOption3">value3</module-option>
+ <module-option name="mappingOption4">value4</module-option>
+ </mapping-module>
+ </rolemapping>
+ </application-policy>
+
+ <!-- an application policy that specifies authentication-jaspi and role-mapping configurations -->
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="TestPolicy2">
+ <authentication-jaspi>
+ <login-module-stack name="ModuleStack1">
+ <login-module code="org.jboss.security.auth.AuthModule3" flag="required">
+ <module-option name="authOption5">value5</module-option>
+ </login-module>
+ <login-module code="org.jboss.security.auth.AuthModule4" flag="optional"/>
+ </login-module-stack>
+ <login-module-stack name="ModuleStack2">
+ <login-module code="org.jboss.security.auth.AuthModule5" flag="required">
+ <module-option name="authOption6">value6</module-option>
+ <module-option name="authOption7">value7</module-option>
+ </login-module>
+ </login-module-stack>
+ <auth-module code="org.jboss.security.auth.AuthModule1" login-module-stack-ref="ModuleStack2">
+ <module-option name="authOption1">value1</module-option>
+ <module-option name="authOption2">value2</module-option>
+ </auth-module>
+ </authentication-jaspi>
+ <rolemapping>
+ <mapping-module code="org.jboss.security.mapping.RoleMappingModule1">
+ <module-option name="mappingOption1">value1</module-option>
+ <module-option name="mappingOption2">value2</module-option>
+ </mapping-module>
+ <mapping-module code="org.jboss.security.mapping.RoleMappingModule2">
+ <module-option name="mappingOption3">value3</module-option>
+ <module-option name="mappingOption4">value4</module-option>
+ </mapping-module>
+ </rolemapping>
+ </application-policy>
+
+</deployment>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list