Author: sohil.shah(a)jboss.com
Date: 2009-10-10 15:58:52 -0400 (Sat, 10 Oct 2009)
New Revision: 836
Added:
authz/trunk/assemble/src.xml
authz/trunk/samples/secure-pojo/src/test/java/org/jboss/security/authz/samples/pojo/Application.java
Modified:
authz/trunk/.classpath
authz/trunk/documentation/reference-guide/pom.xml
authz/trunk/policy-server/src/main/resources/META-INF/authz-config.xml
authz/trunk/pom.xml
authz/trunk/samples/secure-pojo/pom.xml
Log:
build stuff to get alpha ready to ship
Modified: authz/trunk/.classpath
===================================================================
--- authz/trunk/.classpath 2009-10-09 22:54:35 UTC (rev 835)
+++ authz/trunk/.classpath 2009-10-10 19:58:52 UTC (rev 836)
@@ -37,8 +37,8 @@
<classpathentry kind="var"
path="M2_REPO/sun-jaxb/jaxb-impl/2.1.4/jaxb-impl-2.1.4.jar"/>
<classpathentry kind="var"
path="M2_REPO/sun-jaxb/jaxb-xjc/2.1.4/jaxb-xjc-2.1.4.jar"/>
<classpathentry kind="var"
path="M2_REPO/junit/junit/3.8.2/junit-3.8.2.jar"/>
- <classpathentry kind="var"
path="M2_REPO/org/jboss/security/jboss-sunxacml/2.0.3.SP2-SNAPSHOT/jboss-sunxacml-2.0.3.SP2-SNAPSHOT.jar"
sourcepath="/M2_REPO/org/jboss/security/jboss-sunxacml/2.0.3.SP2-SNAPSHOT/jboss-sunxacml-2.0.3.SP2-SNAPSHOT-sources.jar"/>
- <classpathentry kind="var"
path="M2_REPO/org/jboss/security/jboss-xacml/2.0.3.SP2-SNAPSHOT/jboss-xacml-2.0.3.SP2-SNAPSHOT.jar"
sourcepath="M2_REPO/org/jboss/security/jboss-xacml/2.0.3.SP2-SNAPSHOT/jboss-xacml-2.0.3.SP2-SNAPSHOT-sources.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/jboss/security/jboss-sunxacml/2.0.5-SNAPSHOT/jboss-sunxacml-2.0.5-SNAPSHOT.jar"
sourcepath="/M2_REPO/org/jboss/security/jboss-sunxacml/2.0.5-SNAPSHOT/jboss-sunxacml-2.0.5-SNAPSHOT-sources.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/jboss/security/jboss-xacml/2.0.5-SNAPSHOT/jboss-xacml-2.0.5-SNAPSHOT.jar"
sourcepath="M2_REPO/org/jboss/security/jboss-xacml/2.0.5-SNAPSHOT/jboss-xacml-2.0.5-SNAPSHOT-sources.jar"/>
<classpathentry kind="var"
path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
<classpathentry kind="var"
path="M2_REPO/org/drools/drools-core/4.0.7/drools-core-4.0.7.jar"/>
<classpathentry kind="var"
path="M2_REPO/org/drools/drools-compiler/4.0.7/drools-compiler-4.0.7.jar"/>
Added: authz/trunk/assemble/src.xml
===================================================================
--- authz/trunk/assemble/src.xml (rev 0)
+++ authz/trunk/assemble/src.xml 2009-10-10 19:58:52 UTC (rev 836)
@@ -0,0 +1,36 @@
+<assembly>
+ <id>src</id>
+ <formats>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <baseDirectory>src</baseDirectory>
+ <moduleSets>
+ <moduleSet>
+ <includes>
+ <include>org.jboss.security.authz:common</include>
+ <include>org.jboss.security.authz:component-spec</include>
+ <include>org.jboss.security.authz:core-components</include>
+ <include>org.jboss.security.authz:agent</include>
+ <include>org.jboss.security.authz:policy-server</include>
+ <include>org.jboss.security.authz:samples</include>
+ </includes>
+ <sources>
+ <excludeSubModuleDirectories>false</excludeSubModuleDirectories>
+ <fileSets>
+ <fileSet>
+ <excludes>
+ <exclude>target/**</exclude>
+ <exclude>**/target/**</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+ </sources>
+ </moduleSet>
+ </moduleSets>
+ <files>
+ <file>
+ <source>pom.xml</source>
+ </file>
+ </files>
+</assembly>
\ No newline at end of file
Modified: authz/trunk/documentation/reference-guide/pom.xml
===================================================================
--- authz/trunk/documentation/reference-guide/pom.xml 2009-10-09 22:54:35 UTC (rev 835)
+++ authz/trunk/documentation/reference-guide/pom.xml 2009-10-10 19:58:52 UTC (rev 836)
@@ -1,9 +1,6 @@
<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/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
<parent>
<groupId>org.jboss.security.authz</groupId>
<artifactId>jboss-authz-documentation-parent</artifactId>
@@ -11,6 +8,7 @@
<relativePath>../pom.xml</relativePath>
</parent>
+ <modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.security.authz</groupId>
<artifactId>reference-guide</artifactId>
<name>Reference_Guide</name>
Modified: authz/trunk/policy-server/src/main/resources/META-INF/authz-config.xml
===================================================================
--- authz/trunk/policy-server/src/main/resources/META-INF/authz-config.xml 2009-10-09
22:54:35 UTC (rev 835)
+++ authz/trunk/policy-server/src/main/resources/META-INF/authz-config.xml 2009-10-10
19:58:52 UTC (rev 836)
@@ -22,7 +22,7 @@
</bean>
<bean name="/policy-server/PolicyDecisionPoint"
class="org.jboss.security.authz.policy.server.decision.PolicyDecisionPoint">
- <property name="debug">true</property>
+ <property name="debug">false</property>
</bean>
<bean name="/policy-server/PolicyStore"
class="org.jboss.security.authz.policy.server.provisioning.RelationalDBPolicyStore">
Modified: authz/trunk/pom.xml
===================================================================
--- authz/trunk/pom.xml 2009-10-09 22:54:35 UTC (rev 835)
+++ authz/trunk/pom.xml 2009-10-10 19:58:52 UTC (rev 836)
@@ -15,8 +15,7 @@
<module>core-components</module>
<module>agent</module>
<module>policy-server</module>
- <module>samples</module>
- <module>documentation</module>
+ <module>samples</module>
<!--
<module>http-profile</module>
<module>portal-profile</module>
@@ -290,8 +289,11 @@
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
+ <descriptor>assemble/src.xml</descriptor>
+ <!--
<descriptor>assemble/bin.xml</descriptor>
<descriptor>assemble/doc.xml</descriptor>
+ -->
</descriptors>
</configuration>
</plugin>
Modified: authz/trunk/samples/secure-pojo/pom.xml
===================================================================
--- authz/trunk/samples/secure-pojo/pom.xml 2009-10-09 22:54:35 UTC (rev 835)
+++ authz/trunk/samples/secure-pojo/pom.xml 2009-10-10 19:58:52 UTC (rev 836)
@@ -36,32 +36,7 @@
<groupId>org.jboss.security.authz</groupId>
<artifactId>policy-server</artifactId>
<version>${project.version}</version>
- </dependency>
-
- <!-- test dependencies -->
- <!-- jboss xacml -->
- <dependency>
- <groupId>org.jboss.security</groupId>
- <artifactId>jboss-xacml</artifactId>
- <scope>test</scope>
- </dependency>
- <!-- jboss microcontainer -->
- <dependency>
- <groupId>org.jboss.microcontainer</groupId>
- <artifactId>jboss-kernel</artifactId>
- <scope>test</scope>
- </dependency>
- <!-- Drools -->
- <dependency>
- <groupId>org.drools</groupId>
- <artifactId>drools-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.drools</groupId>
- <artifactId>drools-compiler</artifactId>
- <scope>test</scope>
- </dependency>
+ </dependency>
</dependencies>
<build>
@@ -90,7 +65,7 @@
</executions>
</plugin>
- <!-- running the tests in AOP environment -->
+ <!-- running the unit tests in AOP environment -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
@@ -100,7 +75,31 @@
<useSystemClassLoader>true</useSystemClassLoader>
<argLine>-Djboss.aop.path=src/main/resources/jboss-aop.xml</argLine>
</configuration>
- </plugin>
+ </plugin>
</plugins>
- </build>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>run-application</id>
+ <build>
+ <!-- running the fully integrated sample pojo application -->
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ <forkMode>always</forkMode>
+ <useSystemClassLoader>true</useSystemClassLoader>
+ <argLine>-Djboss.aop.path=src/main/resources/jboss-aop.xml</argLine>
+ <includes>
+ <include>**/Application.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Added:
authz/trunk/samples/secure-pojo/src/test/java/org/jboss/security/authz/samples/pojo/Application.java
===================================================================
---
authz/trunk/samples/secure-pojo/src/test/java/org/jboss/security/authz/samples/pojo/Application.java
(rev 0)
+++
authz/trunk/samples/secure-pojo/src/test/java/org/jboss/security/authz/samples/pojo/Application.java 2009-10-10
19:58:52 UTC (rev 836)
@@ -0,0 +1,221 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.authz.samples.pojo;
+
+import java.util.Calendar;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.samples.pojo.provisioning.SecurityProvisioning;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class Application extends AbstractPOJOTestCase
+{
+ private static Logger log = Logger.getLogger(Application.class);
+
+ private SecurityProvisioning provisioning;
+
+ private Pojo protectedAsset;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ // Bootup the system with the appropriate Policies
+ provisioning = new SecurityProvisioning();
+ provisioning.bootup(SecurityProvisioning.rbac);
+ }
+
+ public void testRunApp() throws Exception
+ {
+ log.info("Starting Secure POJO Application...............");
+
+ log.info("");
+ log.info("");
+ log.info("");
+
+ //Administrator
+ this.runAsAdmin();
+
+ log.info("");
+ log.info("");
+ log.info("");
+
+ //Subscribed User
+ this.runAsTrustedUser();
+
+ log.info("");
+ log.info("");
+ log.info("");
+
+ this.runAsAnonymous();
+
+ log.info("");
+ log.info("");
+ log.info("");
+
+ log.info("Closing Secure POJO Application...................");
+ }
+
+ private void runAsAdmin()
+ {
+ //Administrator
+ log.info("Logging in as Administrator..............");
+ this.loginAsAdmin();
+
+ //Post the secret
+ this.writeToProtectedAsset("Barack Obama will be given Nobel Peace
Prize!!!");
+
+ //Read the secret
+ log.info("Secret of the day is: "+this.readProtectedAsset());
+
+ this.logout();
+ log.info("Logging Out..............................");
+ }
+
+ private void runAsTrustedUser()
+ {
+ //Subscribed User
+ log.info("Logging in as Trusted User..............");
+ this.loginAsUser();
+
+ //Read the secret
+ log.info("Secret of the day is: "+this.readProtectedAsset());
+
+ //Try to update the secret
+ String newSecret = "Wait...I vote for Sarah Palin";
+ log.info("Trying to *modify* the secret.........["+newSecret+"]");
+ try
+ {
+ this.writeToProtectedAsset(newSecret);
+ }
+ catch(Exception e)
+ {
+ if(e instanceof IllegalAccessException)
+ {
+ log.info("Sorry. You cannot *modify* the secret!!!!!");
+ }
+ else
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ this.logout();
+ log.info("Logging Out..............................");
+ }
+
+ private void runAsAnonymous()
+ {
+ //Subscribed User
+ log.info("Anonymous Mode.........................");
+
+ //Read the secret
+ log.info("Trying to *read* the secret.........");
+ try
+ {
+ log.info("Secret of the day is: "+this.readProtectedAsset());
+ }
+ catch(Exception e)
+ {
+ if(e instanceof IllegalAccessException)
+ {
+ log.info("Sorry. You cannot *read* the secret!!!!!");
+ }
+ else
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ //Try to update the secret
+ String hackedSecret = "It must be given to Bush";
+ log.info("Trying to *hack* the
secret.........["+hackedSecret+"]");
+ try
+ {
+ this.writeToProtectedAsset(hackedSecret);
+ }
+ catch(Exception e)
+ {
+ if(e instanceof IllegalAccessException)
+ {
+ log.info("Sorry. You cannot *modify* the secret!!!!!");
+ }
+ else
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ //
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ private String readProtectedAsset()
+ {
+ return this.protectedAsset.getSensitiveData();
+ }
+
+ private void writeToProtectedAsset(String sensitiveInfo)
+ {
+ if(this.protectedAsset == null)
+ {
+ this.protectedAsset = new Pojo();
+ }
+ this.protectedAsset.setSensitiveData(sensitiveInfo);
+ }
+
+ private void loginAsAdmin()
+ {
+ AuthenticatedSession session = new AuthenticatedSession();
+
+ session.setUsername("admin");
+ session.addRole("admin");
+ // session.addRole("/system/admin/badassdude/blah/blah");
+
+ Calendar accessTime = Calendar.getInstance();
+ accessTime.set(Calendar.HOUR_OF_DAY, 8);
+ accessTime.set(Calendar.MINUTE, 0);
+ session.setAccessTime(accessTime.getTime());
+
+ AuthenticatedSession.activeSession.set(session);
+ }
+
+ private void loginAsUser()
+ {
+ AuthenticatedSession session = new AuthenticatedSession();
+
+ session.setUsername("user");
+ session.addRole("regular");
+
+ Calendar accessTime = Calendar.getInstance();
+ accessTime.set(Calendar.HOUR_OF_DAY, 8);
+ accessTime.set(Calendar.MINUTE, 0);
+ session.setAccessTime(accessTime.getTime());
+
+ AuthenticatedSession.activeSession.set(session);
+ }
+
+ private void logout()
+ {
+ AuthenticatedSession.activeSession.set(null);
+ }
+}