Author: sohil.shah(a)jboss.com
Date: 2008-10-03 18:21:02 -0400 (Fri, 03 Oct 2008)
New Revision: 12033
Added:
modules/authorization/
modules/authorization/trunk/
modules/authorization/trunk/.classpath
modules/authorization/trunk/.project
modules/authorization/trunk/PEP/
modules/authorization/trunk/PEP/pom.xml
modules/authorization/trunk/PEP/src/
modules/authorization/trunk/PEP/src/main/
modules/authorization/trunk/PEP/src/main/java/
modules/authorization/trunk/PEP/src/main/resources/
modules/authorization/trunk/PEP/src/test/
modules/authorization/trunk/PEP/src/test/java/
modules/authorization/trunk/PEP/src/test/java/org/
modules/authorization/trunk/PEP/src/test/java/org/jboss/
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/NoPermitMeansDeniedAlg.java
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/RuleCombiningAlgImplies.java
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestPDP.java
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestPolicyBuilder.java
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestRequestContext.java
modules/authorization/trunk/PEP/src/test/resources/
modules/authorization/trunk/PEP/src/test/resources/log4j.properties
modules/authorization/trunk/build/
modules/authorization/trunk/build/misc/
modules/authorization/trunk/build/misc/codeguide.html
modules/authorization/trunk/classes/
modules/authorization/trunk/pom.xml
modules/authorization/trunk/security-console/
modules/authorization/trunk/security-console/ear/
modules/authorization/trunk/security-console/ear/pom.xml
modules/authorization/trunk/security-console/ejb/
modules/authorization/trunk/security-console/ejb/pom.xml
modules/authorization/trunk/security-console/ejb/src/
modules/authorization/trunk/security-console/ejb/src/main/
modules/authorization/trunk/security-console/ejb/src/main/java/
modules/authorization/trunk/security-console/ejb/src/main/java/org/
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/Register.java
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/RegisterAction.java
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/User.java
modules/authorization/trunk/security-console/ejb/src/main/resources/
modules/authorization/trunk/security-console/ejb/src/main/resources/META-INF/
modules/authorization/trunk/security-console/ejb/src/main/resources/META-INF/ejb-jar.xml
modules/authorization/trunk/security-console/ejb/src/main/resources/META-INF/persistence.xml
modules/authorization/trunk/security-console/ejb/src/main/resources/seam.properties
modules/authorization/trunk/security-console/pom.xml
modules/authorization/trunk/security-console/war/
modules/authorization/trunk/security-console/war/pom.xml
modules/authorization/trunk/security-console/war/src/
modules/authorization/trunk/security-console/war/src/main/
modules/authorization/trunk/security-console/war/src/main/webapp/
modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/
modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/components.xml
modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/faces-config.xml
modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/web.xml
modules/authorization/trunk/security-console/war/src/main/webapp/index.html
modules/authorization/trunk/security-console/war/src/main/webapp/register.xhtml
modules/authorization/trunk/security-console/war/src/main/webapp/registered.xhtml
Log:
backing up some code
Added: modules/authorization/trunk/.classpath
===================================================================
--- modules/authorization/trunk/.classpath (rev 0)
+++ modules/authorization/trunk/.classpath 2008-10-03 22:21:02 UTC (rev 12033)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src"
path="security-console/ejb/src/main/java"/>
+ <classpathentry kind="src" path="PEP/src/main/java"/>
+ <classpathentry kind="src" path="PEP/src/main/resources"/>
+ <classpathentry kind="src" path="PEP/src/test/java"/>
+ <classpathentry kind="src" path="PEP/src/test/resources"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="classes"/>
+ <classpathentry kind="var"
path="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/asm/asm/1.5.3/asm-1.5.3.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/cglib/cglib/2.1_3/cglib-2.1_3.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/commons-beanutils/commons-beanutils/1.6/commons-beanutils-1.6.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/dom4j/dom4j/1.6.1-jboss/dom4j-1.6.1-jboss.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/javax/ejb/ejb-api/3.0/ejb-api-3.0.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/javax/el/el-api/1.0/el-api-1.0.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/hibernate/hibernate/3.2.4.sp1/hibernate-3.2.4.sp1.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/hibernate/hibernate-validator/3.0.0.GA/hibernate-validator-3.0.0.GA.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/javassist/javassist/3.3.GA/javassist-3.3.GA.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/jboss/el/jboss-el/2.0.1.GA/jboss-el-2.0.1.GA.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/jboss/seam/jboss-seam/2.0.2.SP1/jboss-seam-2.0.2.SP1.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/jboss/seam/jboss-seam-ui/2.0.2.SP1/jboss-seam-ui-2.0.2.SP1.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/javax/faces/jsf-api/1.2_04-p02/jsf-api-1.2_04-p02.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar"/>
+ <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-SNAPSHOT/jboss-sunxacml-2.0.3-SNAPSHOT.jar"
sourcepath="M2_REPO/org/jboss/security/jboss-sunxacml/2.0.3-SNAPSHOT/jboss-sunxacml-2.0.3-SNAPSHOT-sources.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/jboss/security/jboss-xacml/2.0.3-SNAPSHOT/jboss-xacml-2.0.3-SNAPSHOT.jar"
sourcepath="M2_REPO/org/jboss/security/jboss-xacml/2.0.3-SNAPSHOT/jboss-xacml-2.0.3-SNAPSHOT-sources.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+</classpath>
Added: modules/authorization/trunk/.project
===================================================================
--- modules/authorization/trunk/.project (rev 0)
+++ modules/authorization/trunk/.project 2008-10-03 22:21:02 UTC (rev 12033)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>module-authorization</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: modules/authorization/trunk/PEP/pom.xml
===================================================================
--- modules/authorization/trunk/PEP/pom.xml (rev 0)
+++ modules/authorization/trunk/PEP/pom.xml 2008-10-03 22:21:02 UTC (rev 12033)
@@ -0,0 +1,65 @@
+<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.authz</groupId>
+ <artifactId>jboss-authz-parent</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-authz-pep</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Authorization PEP</name>
+ <url>http://www.jboss.org</url>
+ <description>A Generic PEP (Policy Enforcement Point)
component</description>
+
+ <dependencies>
+ <!-- jboss xacml -->
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-xacml</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-sunxacml</artifactId>
+ </dependency>
+
+ <!-- sun jaxb -->
+ <dependency>
+ <groupId>sun-jaxb</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>sun-jaxb</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>sun-jaxb</groupId>
+ <artifactId>jaxb-xjc</artifactId>
+ </dependency>
+
+ <!-- junit -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ <includes>
+ <include>**/TestPDP.java</include>
+ <!--
+ <include>**/TestPolicyBuilder.java</include>
+ -->
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added:
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/NoPermitMeansDeniedAlg.java
===================================================================
---
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/NoPermitMeansDeniedAlg.java
(rev 0)
+++
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/NoPermitMeansDeniedAlg.java 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * 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.test.pep;
+
+import java.util.List;
+import java.util.Iterator;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.security.xacml.sunxacml.combine.RuleCombiningAlgorithm;
+import org.jboss.security.xacml.sunxacml.EvaluationCtx;
+import org.jboss.security.xacml.sunxacml.ctx.Result;
+import org.jboss.security.xacml.sunxacml.Rule;
+import org.jboss.security.xacml.sunxacml.combine.RuleCombinerElement;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class NoPermitMeansDeniedAlg extends RuleCombiningAlgorithm
+{
+ /**
+ *
+ * @throws URISyntaxException
+ */
+ public NoPermitMeansDeniedAlg() throws URISyntaxException
+ {
+ super(new URI("rule-combining-alg:nopermit-means-denied"));
+ }
+
+ /**
+ *
+ * @param context
+ * @param rules
+ * @return
+ */
+ public Result combine(EvaluationCtx context, List parameters, List ruleElements)
+ {
+ Result result = new Result(Result.DECISION_PERMIT);
+
+ Iterator rules = ruleElements.iterator();
+ boolean permitFound = false;
+ while(rules.hasNext())
+ {
+ RuleCombinerElement ruleCombinerElement = (RuleCombinerElement)rules.next();
+ Rule rule = ruleCombinerElement.getRule();
+ Result currentResult = rule.evaluate(context);
+
+ if(currentResult.getDecision() == Result.DECISION_PERMIT)
+ {
+ permitFound = true;
+ break;
+ }
+ }
+
+ if(!permitFound)
+ {
+ result = new Result(Result.DECISION_DENY);
+ }
+
+ return result;
+ }
+}
Added:
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/RuleCombiningAlgImplies.java
===================================================================
---
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/RuleCombiningAlgImplies.java
(rev 0)
+++
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/RuleCombiningAlgImplies.java 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * 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.test.pep;
+
+import java.util.List;
+import java.util.Iterator;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.security.xacml.sunxacml.combine.RuleCombiningAlgorithm;
+import org.jboss.security.xacml.sunxacml.EvaluationCtx;
+import org.jboss.security.xacml.sunxacml.ctx.Result;
+import org.jboss.security.xacml.sunxacml.Rule;
+import org.jboss.security.xacml.sunxacml.combine.RuleCombinerElement;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class RuleCombiningAlgImplies extends RuleCombiningAlgorithm
+{
+ /**
+ *
+ * @throws URISyntaxException
+ */
+ public RuleCombiningAlgImplies() throws URISyntaxException
+ {
+ super(new URI("rule-combining-alg:cms-implies"));
+ }
+
+ /**
+ *
+ * @param context
+ * @param rules
+ * @return
+ */
+ public Result combine(EvaluationCtx context, List parameters, List ruleElements)
+ {
+ Iterator rules = ruleElements.iterator();
+ while(rules.hasNext())
+ {
+ RuleCombinerElement ruleCombinerElement = (RuleCombinerElement)rules.next();
+ Rule rule = ruleCombinerElement.getRule();
+ }
+
+ // if nothing returned Permit, then the alg returns Deny
+ return new Result(Result.DECISION_DENY);
+ }
+}
Added:
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestPDP.java
===================================================================
---
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestPDP.java
(rev 0)
+++
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestPDP.java 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,813 @@
+/******************************************************************************
+ * 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.test.pep;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.net.URI;
+import java.io.File;
+import java.io.FileOutputStream;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.xacml.core.model.context.ActionType;
+import org.jboss.security.xacml.core.model.context.AttributeType;
+import org.jboss.security.xacml.core.model.context.AttributeValueType;
+import org.jboss.security.xacml.core.model.context.ObjectFactory;
+import org.jboss.security.xacml.core.model.context.RequestType;
+import org.jboss.security.xacml.core.model.context.ResourceType;
+import org.jboss.security.xacml.core.model.context.SubjectType;
+
+import org.jboss.security.xacml.core.model.policy.ActionMatchType;
+import org.jboss.security.xacml.core.model.policy.ActionsType;
+import org.jboss.security.xacml.core.model.policy.ApplyType;
+import org.jboss.security.xacml.core.model.policy.ConditionType;
+import org.jboss.security.xacml.core.model.policy.EffectType;
+import org.jboss.security.xacml.core.model.policy.ExpressionType;
+import org.jboss.security.xacml.core.model.policy.FunctionType;
+import org.jboss.security.xacml.core.model.policy.PolicyType;
+import org.jboss.security.xacml.core.model.policy.ResourceMatchType;
+import org.jboss.security.xacml.core.model.policy.ResourcesType;
+import org.jboss.security.xacml.core.model.policy.RuleType;
+import org.jboss.security.xacml.core.model.policy.SubjectAttributeDesignatorType;
+import org.jboss.security.xacml.core.model.policy.TargetType;
+
+
+import org.jboss.security.xacml.factories.RequestResponseContextFactory;
+import org.jboss.security.xacml.factories.PolicyAttributeFactory;
+import org.jboss.security.xacml.interfaces.RequestContext;
+import org.jboss.security.xacml.interfaces.ResponseContext;
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
+
+import org.jboss.security.xacml.sunxacml.PDP;
+import org.jboss.security.xacml.sunxacml.PDPConfig;
+import org.jboss.security.xacml.sunxacml.finder.AttributeFinder;
+import org.jboss.security.xacml.sunxacml.finder.impl.CurrentEnvModule;
+import org.jboss.security.xacml.sunxacml.finder.impl.SelectorModule;
+import org.jboss.security.xacml.sunxacml.finder.PolicyFinder;
+import org.jboss.security.xacml.sunxacml.support.finder.FilePolicyModule;
+import org.jboss.security.xacml.sunxacml.ctx.RequestCtx;
+import org.jboss.security.xacml.sunxacml.ctx.ResponseCtx;
+import org.jboss.security.xacml.sunxacml.combine.CombiningAlgFactory;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class TestPDP extends TestCase
+{
+ private static Logger log = Logger.getLogger(TestPDP.class);
+
+ /**
+ *
+ */
+ public void setUp() throws Exception
+ {
+ //Setup custom combining algorithms
+ boolean register = true;
+ String naIsDeniedURI = new NoPermitMeansDeniedAlg().getIdentifier().toString();
+ CombiningAlgFactory factory = CombiningAlgFactory.getInstance();
+ Set supportedAlgorithms = factory.getSupportedAlgorithms();
+ String[] algorithms = (String[])supportedAlgorithms.toArray(new
String[supportedAlgorithms.size()]);
+ for(String supportedAlgorithm: algorithms)
+ {
+ if(supportedAlgorithm.equals(naIsDeniedURI))
+ {
+ register = false;
+ }
+ }
+ if(register)
+ {
+ factory.addAlgorithm(new NoPermitMeansDeniedAlg());
+ }
+
+ this.generateSimplePolicy();
+ this.generateMultiTierPolicy();
+ }
+
+ /**
+ *
+ */
+ public void tearDown() throws Exception
+ {
+ this.deleteSimplePolicy();
+ this.deleteMultiTierPolicy();
+ }
+
+
+ public void testSimplePermit() throws Exception
+ {
+ //PDP Setup
+ String[] policyFiles = new String[]{"simple-policy.xml"};
+ PDP pdp = new PDP(new PDPConfig(this.getAttributeFinder(),
this.getPolicyFinder(policyFiles), null));
+ assertNotNull(pdp);
+
+ //Request Setup
+ RequestContext requestContext = this.createPermitRequestContext();
+ assertNotNull(requestContext);
+
+ log.info("-----------------------------------");
+ requestContext.marshall(System.out);
+
+ //Process the request
+ ResponseCtx response =
pdp.evaluate((RequestCtx)requestContext.get(XACMLConstants.REQUEST_CTX));
+ assertNotNull(response);
+
+ log.info("-----------------------------------");
+ response.encode(System.out);
+
+ ResponseContext responseContext =
RequestResponseContextFactory.createResponseContext();
+ responseContext.set(XACMLConstants.RESPONSE_CTX, response);
+ assertNotNull(responseContext);
+ assertEquals(responseContext.getDecision(), XACMLConstants.DECISION_PERMIT);
+
+ log.info("-----------------------------------");
+ log.info("Decision="+responseContext.getDecision());
+ }
+
+
+ public void testSimpleDeny() throws Exception
+ {
+ //PDP Setup
+ String[] policyFiles = new String[]{"simple-policy.xml"};
+ PDP pdp = new PDP(new PDPConfig(this.getAttributeFinder(),
this.getPolicyFinder(policyFiles), null));
+ assertNotNull(pdp);
+
+ //Request Setup
+ RequestContext requestContext = this.createDenyRequestContext();
+ assertNotNull(requestContext);
+
+ log.info("-----------------------------------");
+ requestContext.marshall(System.out);
+
+ //Process the request
+ ResponseCtx response =
pdp.evaluate((RequestCtx)requestContext.get(XACMLConstants.REQUEST_CTX));
+ assertNotNull(response);
+
+ log.info("-----------------------------------");
+ response.encode(System.out);
+
+ ResponseContext responseContext =
RequestResponseContextFactory.createResponseContext();
+ responseContext.set(XACMLConstants.RESPONSE_CTX, response);
+ assertNotNull(responseContext);
+ assertEquals(responseContext.getDecision(), XACMLConstants.DECISION_DENY);
+
+ log.info("-----------------------------------");
+ log.info("Decision="+responseContext.getDecision());
+ }
+
+
+ public void testMultiTierPermit() throws Exception
+ {
+ //PDP Setup
+ String[] policyFiles = new String[]{"multitier-policy.xml"};
+ PDP pdp = new PDP(new PDPConfig(this.getAttributeFinder(),
this.getPolicyFinder(policyFiles), null));
+ assertNotNull(pdp);
+
+ //Request Setup
+ RequestContext requestContext = this.createPermitMultiTierRequestContext();
+ assertNotNull(requestContext);
+
+ log.info("-----------------------------------");
+ requestContext.marshall(System.out);
+
+ //Process the request
+ RequestCtx requestCtx =
(RequestCtx)requestContext.get(XACMLConstants.REQUEST_CTX);
+ ResponseCtx response = pdp.evaluate(requestCtx);
+ assertNotNull(response);
+
+ log.info("-----------------------------------");
+ response.encode(System.out);
+
+ ResponseContext responseContext =
RequestResponseContextFactory.createResponseContext();
+ responseContext.set(XACMLConstants.RESPONSE_CTX, response);
+ assertNotNull(responseContext);
+ assertEquals(responseContext.getDecision(), XACMLConstants.DECISION_PERMIT);
+
+ log.info("-----------------------------------");
+ log.info("Decision="+responseContext.getDecision());
+ }
+
+ /*public void testRecursivePermit() throws Exception
+ {
+ //PDP Setup
+ String[] policyFiles = new
String[]{"/home/soshah/projects/jboss-portal/sandbox/trunk/prototype/resources/policy/recursive-policy.xml"};
+ PDP pdp = new PDP(new PDPConfig(this.getAttributeFinder(),
this.getPolicyFinder(policyFiles), null));
+ assertNotNull(pdp);
+
+ //Request Setup
+ RequestContext requestContext =
this.createPermitRecursiveRequestContext("/protected/private/index2.html");
+ assertNotNull(requestContext);
+
+ log.info("-----------------------------------");
+ requestContext.marshall(System.out);
+
+ //Process the request
+ RequestCtx requestCtx =
(RequestCtx)requestContext.get(XACMLConstants.REQUEST_CTX);
+ ResponseCtx response = pdp.evaluate(requestCtx);
+ assertNotNull(response);
+
+ log.info("-----------------------------------");
+ response.encode(System.out);
+
+ ResponseContext responseContext =
RequestResponseContextFactory.createResponseContext();
+ responseContext.set(XACMLConstants.RESPONSE_CTX, response);
+ assertNotNull(responseContext);
+ assertEquals(responseContext.getDecision(), XACMLConstants.DECISION_PERMIT);
+
+ log.info("-----------------------------------");
+ log.info("Decision="+responseContext.getDecision());
+ }*/
+
+ /*public void testImplies() throws Exception
+ {
+ //PDP Setup
+ String[] policyFiles = new
String[]{"/home/soshah/projects/jboss-portal/sandbox/trunk/prototype/src/resources/policy/implies-policy.xml"};
+
+ //Register the custom Rule Combining Algorithm
+ CombiningAlgFactory factory = CombiningAlgFactory.getInstance();
+ factory.addAlgorithm(new RuleCombiningAlgImplies());
+
+ PDP pdp = new PDP(new PDPConfig(this.getAttributeFinder(),
this.getPolicyFinder(policyFiles), null));
+ assertNotNull(pdp);
+
+ //Request Setup
+ RequestContext requestContext = this.createImpliesRequestContext();
+ assertNotNull(requestContext);
+
+ log.info("-----------------------------------");
+ requestContext.marshall(System.out);
+
+ //Process the request
+ RequestCtx requestCtx =
(RequestCtx)requestContext.get(XACMLConstants.REQUEST_CTX);
+ ResponseCtx response = pdp.evaluate(requestCtx);
+ assertNotNull(response);
+
+ log.info("-----------------------------------");
+ response.encode(System.out);
+
+ ResponseContext responseContext =
RequestResponseContextFactory.createResponseContext();
+ responseContext.set(XACMLConstants.RESPONSE_CTX, response);
+ assertNotNull(responseContext);
+ assertEquals(responseContext.getDecision(), XACMLConstants.DECISION_PERMIT);
+
+ log.info("-----------------------------------");
+ log.info("Decision="+responseContext.getDecision());
+ }*/
+
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
+ private AttributeFinder getAttributeFinder()
+ {
+ //Prefill the attribute finder with the Sun's impl of
+ //environment attribute module and the selector attribute module
+ AttributeFinder attributeFinder = new AttributeFinder();
+ List attributeModules = new ArrayList();
+ attributeModules.add(new CurrentEnvModule());
+ attributeModules.add(new SelectorModule());
+ attributeFinder.setModules(attributeModules);
+ return attributeFinder;
+ }
+
+ private PolicyFinder getPolicyFinder(String[] policyFiles) throws Exception
+ {
+ //Create a PolicyFinderModule and initialize it...in this case,
+ // we're using the sample FilePolicyModule that is pre-configured
+ // with a set of policies from the filesystem
+ FilePolicyModule filePolicyModule = new FilePolicyModule();
+ for (int i = 0; i < policyFiles.length; i++)
+ filePolicyModule.addPolicy(policyFiles[i]);
+
+ // next, setup the PolicyFinder that this PDP will use
+ PolicyFinder policyFinder = new PolicyFinder();
+ Set policyModules = new HashSet();
+ policyModules.add(filePolicyModule);
+ policyFinder.setModules(policyModules);
+
+ return policyFinder;
+ }
+
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
+ private RequestContext createPermitRequestContext() throws Exception
+ {
+ //Create ObjectFactory
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ //Create Subjects
+ SubjectType subject = objectFactory.createSubjectType();
+ AttributeType subjectAttribute = objectFactory.createAttributeType();
+ subjectAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ROLE);
+ subjectAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType subjectId = objectFactory.createAttributeValueType();
+ subjectId.getContent().add("developer");
+ subjectAttribute.getAttributeValue().add(subjectId);
+ subject.getAttribute().add(subjectAttribute);
+
+ //Create Resource
+ ResourceType resource = objectFactory.createResourceType();
+ AttributeType resourceAttribute = objectFactory.createAttributeType();
+ resourceAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_RESOURCE_ID);
+ resourceAttribute.setDataType(XMLSchemaConstants.DATATYPE_ANYURI);
+ AttributeValueType resourceId = objectFactory.createAttributeValueType();
+
resourceId.getContent().add("http://www.redhat.com/protected/index.h...;
+ resourceAttribute.getAttributeValue().add(resourceId);
+ resource.getAttribute().add(resourceAttribute);
+
+ //Create Action
+ ActionType action = objectFactory.createActionType();
+ AttributeType actionAttribute = objectFactory.createAttributeType();
+ actionAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ACTION_ID);
+ actionAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType actionId = objectFactory.createAttributeValueType();
+ actionId.getContent().add("write");
+ actionAttribute.getAttributeValue().add(actionId);
+ action.getAttribute().add(actionAttribute);
+
+ //Create RequestContext
+ RequestContext requestContext = RequestResponseContextFactory.createRequestCtx();
+
+ //Create a RequestType
+ RequestType requestType = objectFactory.createRequestType();
+ requestType.getSubject().add(subject);
+ requestType.setAction(action);
+ requestType.getResource().add(resource);
+
+ //Spit out RequestContext
+ requestContext.setRequest(requestType);
+
+ return requestContext;
+ }
+
+ private RequestContext createDenyRequestContext() throws Exception
+ {
+ //Create ObjectFactory
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ //Create Subjects
+ SubjectType subject = objectFactory.createSubjectType();
+ AttributeType subjectAttribute = objectFactory.createAttributeType();
+ subjectAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ROLE);
+ subjectAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType subjectId = objectFactory.createAttributeValueType();
+ subjectId.getContent().add("anonymous");
+ subjectAttribute.getAttributeValue().add(subjectId);
+ subject.getAttribute().add(subjectAttribute);
+
+ //Create Resource
+ ResourceType resource = objectFactory.createResourceType();
+ AttributeType resourceAttribute = objectFactory.createAttributeType();
+ resourceAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_RESOURCE_ID);
+ resourceAttribute.setDataType(XMLSchemaConstants.DATATYPE_ANYURI);
+ AttributeValueType resourceId = objectFactory.createAttributeValueType();
+
resourceId.getContent().add("http://www.redhat.com/protected/index.h...;
+ resourceAttribute.getAttributeValue().add(resourceId);
+ resource.getAttribute().add(resourceAttribute);
+
+ //Create Action
+ ActionType action = objectFactory.createActionType();
+ AttributeType actionAttribute = objectFactory.createAttributeType();
+ actionAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ACTION_ID);
+ actionAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType actionId = objectFactory.createAttributeValueType();
+ actionId.getContent().add("write");
+ actionAttribute.getAttributeValue().add(actionId);
+ action.getAttribute().add(actionAttribute);
+
+ //Create RequestContext
+ RequestContext requestContext = RequestResponseContextFactory.createRequestCtx();
+
+ //Create a RequestType
+ RequestType requestType = objectFactory.createRequestType();
+ requestType.getSubject().add(subject);
+ requestType.setAction(action);
+ requestType.getResource().add(resource);
+
+ //Spit out RequestContext
+ requestContext.setRequest(requestType);
+
+ return requestContext;
+ }
+
+ private RequestContext createPermitMultiTierRequestContext() throws Exception
+ {
+ //Create ObjectFactory
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ //Create Subjects
+ SubjectType subject = objectFactory.createSubjectType();
+ AttributeType subjectAttribute = objectFactory.createAttributeType();
+ subjectAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ROLE);
+ subjectAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType subjectId = objectFactory.createAttributeValueType();
+ subjectId.getContent().add("developer");
+ subjectAttribute.getAttributeValue().add(subjectId);
+ subject.getAttribute().add(subjectAttribute);
+
+ //Create Resource
+ ResourceType resource = objectFactory.createResourceType();
+ AttributeType resourceAttribute = objectFactory.createAttributeType();
+ resourceAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_RESOURCE_ID);
+ resourceAttribute.setDataType(XMLSchemaConstants.DATATYPE_ANYURI);
+ AttributeValueType resourceId = objectFactory.createAttributeValueType();
+ resourceId.getContent().add("org.jboss.cms.CMSService");
+ resourceAttribute.getAttributeValue().add(resourceId);
+ resource.getAttribute().add(resourceAttribute);
+
+ AttributeType param0Attribute = objectFactory.createAttributeType();
+ param0Attribute.setAttributeId(XACMLConstants.CUSTOM_ATTR+":param0");
+ param0Attribute.setDataType(XMLSchemaConstants.DATATYPE_ANYURI);
+ AttributeValueType param0Id = objectFactory.createAttributeValueType();
+
param0Id.getContent().add("http://www.redhat.com/protected/index.htm...;
+ param0Attribute.getAttributeValue().add(param0Id);
+ resource.getAttribute().add(param0Attribute);
+
+
+ //Create Action
+ ActionType action = objectFactory.createActionType();
+ AttributeType actionAttribute = objectFactory.createAttributeType();
+ actionAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ACTION_ID);
+ actionAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType actionId = objectFactory.createAttributeValueType();
+ actionId.getContent().add("write");
+ actionAttribute.getAttributeValue().add(actionId);
+ action.getAttribute().add(actionAttribute);
+
+ //Create RequestContext
+ RequestContext requestContext = RequestResponseContextFactory.createRequestCtx();
+
+ //Create a RequestType
+ RequestType requestType = objectFactory.createRequestType();
+ requestType.getSubject().add(subject);
+ requestType.setAction(action);
+ requestType.getResource().add(resource);
+
+ //Spit out RequestContext
+ requestContext.setRequest(requestType);
+
+ return requestContext;
+ }
+
+ private RequestContext createPermitRecursiveRequestContext(String path) throws
Exception
+ {
+ //Create ObjectFactory
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ //Create Subjects
+ SubjectType subject = objectFactory.createSubjectType();
+ AttributeType subjectAttribute = objectFactory.createAttributeType();
+ subjectAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ROLE);
+ subjectAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType subjectId = objectFactory.createAttributeValueType();
+ subjectId.getContent().add("developer");
+ subjectAttribute.getAttributeValue().add(subjectId);
+ subject.getAttribute().add(subjectAttribute);
+
+ //Create Resource
+ ResourceType resource = objectFactory.createResourceType();
+ AttributeType resourceAttribute = objectFactory.createAttributeType();
+ resourceAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_RESOURCE_ID);
+ resourceAttribute.setDataType(XMLSchemaConstants.DATATYPE_ANYURI);
+ AttributeValueType resourceId = objectFactory.createAttributeValueType();
+ resourceId.getContent().add("org.jboss.cms.CMSService");
+ resourceAttribute.getAttributeValue().add(resourceId);
+ resource.getAttribute().add(resourceAttribute);
+
+ StringBuffer buffer = new StringBuffer("/");
+ StringTokenizer st = new StringTokenizer(path, "/");
+ while(st.hasMoreTokens())
+ {
+ buffer.append(st.nextToken());
+ AttributeType param1Attribute = objectFactory.createAttributeType();
+ param1Attribute.setAttributeId(XACMLConstants.CUSTOM_ATTR+":param0");
+ param1Attribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType param1Id = objectFactory.createAttributeValueType();
+ param1Id.getContent().add(buffer.toString());
+ param1Attribute.getAttributeValue().add(param1Id);
+ resource.getAttribute().add(param1Attribute);
+
+ if(st.hasMoreTokens())
+ {
+ buffer.append("/");
+ }
+ }
+
+
+ //Create Action
+ ActionType action = objectFactory.createActionType();
+ AttributeType actionAttribute = objectFactory.createAttributeType();
+ actionAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ACTION_ID);
+ actionAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType actionId = objectFactory.createAttributeValueType();
+ actionId.getContent().add("update");
+ actionAttribute.getAttributeValue().add(actionId);
+ action.getAttribute().add(actionAttribute);
+
+ //Create RequestContext
+ RequestContext requestContext = RequestResponseContextFactory.createRequestCtx();
+
+ //Create a RequestType
+ RequestType requestType = objectFactory.createRequestType();
+ requestType.getSubject().add(subject);
+ requestType.setAction(action);
+ requestType.getResource().add(resource);
+
+ //Spit out RequestContext
+ requestContext.setRequest(requestType);
+
+ return requestContext;
+ }
+
+ private RequestContext createImpliesRequestContext() throws Exception
+ {
+ //Create ObjectFactory
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ //Create Subjects
+ SubjectType subject = objectFactory.createSubjectType();
+ AttributeType subjectAttribute = objectFactory.createAttributeType();
+ subjectAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ROLE);
+ subjectAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType subjectId = objectFactory.createAttributeValueType();
+ subjectId.getContent().add("developer");
+ subjectAttribute.getAttributeValue().add(subjectId);
+ subject.getAttribute().add(subjectAttribute);
+
+ //Create Resource
+ ResourceType resource = objectFactory.createResourceType();
+ AttributeType resourceAttribute = objectFactory.createAttributeType();
+ resourceAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_RESOURCE_ID);
+ resourceAttribute.setDataType(XMLSchemaConstants.DATATYPE_ANYURI);
+ AttributeValueType resourceId = objectFactory.createAttributeValueType();
+ resourceId.getContent().add("org.jboss.cms.CMSService");
+ resourceAttribute.getAttributeValue().add(resourceId);
+ resource.getAttribute().add(resourceAttribute);
+
+ AttributeType param0Attribute = objectFactory.createAttributeType();
+ param0Attribute.setAttributeId(XACMLConstants.CUSTOM_ATTR+":param0");
+ param0Attribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType param0Id = objectFactory.createAttributeValueType();
+ param0Id.getContent().add("/protected/write.html");
+ param0Attribute.getAttributeValue().add(param0Id);
+ resource.getAttribute().add(param0Attribute);
+
+
+ //Create Action
+ ActionType action = objectFactory.createActionType();
+ AttributeType actionAttribute = objectFactory.createAttributeType();
+ actionAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ACTION_ID);
+ actionAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType actionId = objectFactory.createAttributeValueType();
+ actionId.getContent().add("read");
+ actionAttribute.getAttributeValue().add(actionId);
+ action.getAttribute().add(actionAttribute);
+
+ //Create RequestContext
+ RequestContext requestContext = RequestResponseContextFactory.createRequestCtx();
+
+ //Create a RequestType
+ RequestType requestType = objectFactory.createRequestType();
+ requestType.getSubject().add(subject);
+ requestType.setAction(action);
+ requestType.getResource().add(resource);
+
+ //Spit out RequestContext
+ requestContext.setRequest(requestType);
+
+ return requestContext;
+ }
+
//--------------------------------------------------------------------------------------------------------------------------------------------------------
+ private void generateSimplePolicy() throws Exception
+ {
+ org.jboss.security.xacml.core.model.policy.ObjectFactory objectFactory = new
org.jboss.security.xacml.core.model.policy.ObjectFactory();
+
+ PolicyType policyType = new PolicyType();
+ policyType.setPolicyId("SimplePolicy");
+ policyType.setVersion("2.0");
+ policyType.setRuleCombiningAlgId(new
NoPermitMeansDeniedAlg().getIdentifier().toString());
+
+ //Create a target
+ TargetType targetType = new TargetType();
+
+ ResourcesType resourcesType = new ResourcesType();
+ org.jboss.security.xacml.core.model.policy.ResourceType resourceType = new
org.jboss.security.xacml.core.model.policy.ResourceType();
+ ResourceMatchType rmt = new ResourceMatchType();
+ rmt.setMatchId(XACMLConstants.FUNCTION_ANYURI_EQUAL);
+
rmt.setResourceAttributeDesignator(PolicyAttributeFactory.createAttributeDesignatorType(
+ XACMLConstants.ATTRIBUTEID_RESOURCE_ID, XMLSchemaConstants.DATATYPE_ANYURI,
null, false));
+ rmt.setAttributeValue(PolicyAttributeFactory
+ .createAnyURIAttributeType(new
URI("http://www.redhat.com/protected/index.html")));
+ resourceType.getResourceMatch().add(rmt);
+ resourcesType.getResource().add(resourceType);
+
+ targetType.setResources(resourcesType);
+
+ policyType.setTarget(targetType);
+
+ //Create a Rule
+ RuleType permitRule = new RuleType();
+ permitRule.setRuleId("WriteRule");
+ permitRule.setEffect(EffectType.PERMIT);
+
+ ActionsType permitRuleActionsType = new ActionsType();
+ org.jboss.security.xacml.core.model.policy.ActionType permitRuleActionType = new
org.jboss.security.xacml.core.model.policy.ActionType();
+
+ ActionMatchType amct = new ActionMatchType();
+ amct.setMatchId("urn:oasis:names:tc:xacml:1.0:function:string-equal");
+
amct.setAttributeValue(PolicyAttributeFactory.createStringAttributeType("write"));
+
amct.setActionAttributeDesignator(PolicyAttributeFactory.createAttributeDesignatorType(
+ XACMLConstants.ATTRIBUTEID_ACTION_ID, XMLSchemaConstants.DATATYPE_STRING,
null, false));
+ permitRuleActionType.getActionMatch().add(amct);
+ TargetType permitRuleTargetType = new TargetType();
+ permitRuleActionsType.getAction().add(permitRuleActionType);
+ permitRuleTargetType.setActions(permitRuleActionsType);
+ permitRule.setTarget(permitRuleTargetType);
+
+ ConditionType permitRuleConditionType = new ConditionType();
+ FunctionType functionType = new FunctionType();
+ functionType.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+ JAXBElement<ExpressionType> jaxbElementFunctionType =
objectFactory.createExpression(functionType);
+ permitRuleConditionType.setExpression(jaxbElementFunctionType);
+
+ ApplyType permitRuleApplyType = new ApplyType();
+ permitRuleApplyType.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
+
+ SubjectAttributeDesignatorType sadt =
PolicyAttributeFactory.createSubjectAttributeDesignatorType(
+ XACMLConstants.ATTRIBUTEID_ROLE, XMLSchemaConstants.DATATYPE_STRING, null,
false, null);
+ JAXBElement<SubjectAttributeDesignatorType> sadtElement =
objectFactory.createSubjectAttributeDesignator(sadt);
+ org.jboss.security.xacml.core.model.policy.AttributeValueType avt =
PolicyAttributeFactory.createStringAttributeType("developer");
+ JAXBElement<org.jboss.security.xacml.core.model.policy.AttributeValueType>
jaxbAVT = objectFactory.createAttributeValue(avt);
+ permitRuleApplyType.getExpression().add(jaxbAVT);
+ permitRuleApplyType.getExpression().add(sadtElement);
+
+
permitRuleConditionType.setExpression(objectFactory.createApply(permitRuleApplyType));
+
+ permitRule.setCondition(permitRuleConditionType);
+
+
policyType.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(permitRule);
+
+ //marshal it into xml format
+ FileOutputStream fos = null;
+ try
+ {
+ fos = new FileOutputStream(new File("simple-policy.xml"));
+ policyType.marshall(fos);
+
log.info("-------------------------------------------------------------------");
+ policyType.marshall(System.out);
+
log.info("-------------------------------------------------------------------");
+ }
+ finally
+ {
+ if(fos != null)
+ {
+ fos.close();
+ }
+ }
+ }
+
+ private void deleteSimplePolicy() throws Exception
+ {
+ File file = new File("simple-policy.xml");
+ file.delete();
+ }
+
+ private void generateMultiTierPolicy() throws Exception
+ {
+ org.jboss.security.xacml.core.model.policy.ObjectFactory objectFactory = new
org.jboss.security.xacml.core.model.policy.ObjectFactory();
+
+ PolicyType policyType = new PolicyType();
+ policyType.setPolicyId("MultiTierPolicy");
+ policyType.setVersion("2.0");
+ policyType.setRuleCombiningAlgId(new
NoPermitMeansDeniedAlg().getIdentifier().toString());
+
+ //Create a target
+ TargetType targetType = new TargetType();
+
+ //Add a Web Tier resource
+ ResourcesType resourcesType = new ResourcesType();
+ org.jboss.security.xacml.core.model.policy.ResourceType resourceType = new
org.jboss.security.xacml.core.model.policy.ResourceType();
+ ResourceMatchType rmt = new ResourceMatchType();
+ rmt.setMatchId(XACMLConstants.FUNCTION_ANYURI_EQUAL);
+
rmt.setResourceAttributeDesignator(PolicyAttributeFactory.createAttributeDesignatorType(
+ XACMLConstants.ATTRIBUTEID_RESOURCE_ID, XMLSchemaConstants.DATATYPE_ANYURI,
null, false));
+ rmt.setAttributeValue(PolicyAttributeFactory
+ .createAnyURIAttributeType(new
URI("http://www.redhat.com/protected/index.html")));
+ resourceType.getResourceMatch().add(rmt);
+ resourcesType.getResource().add(resourceType);
+
+ //Add a POJO tier resource
+ resourceType = new org.jboss.security.xacml.core.model.policy.ResourceType();
+ rmt = new ResourceMatchType();
+ rmt.setMatchId(XACMLConstants.FUNCTION_ANYURI_EQUAL);
+
rmt.setResourceAttributeDesignator(PolicyAttributeFactory.createAttributeDesignatorType(
+ XACMLConstants.ATTRIBUTEID_RESOURCE_ID, XMLSchemaConstants.DATATYPE_ANYURI,
null, false));
+ rmt.setAttributeValue(PolicyAttributeFactory
+ .createAnyURIAttributeType(new URI("org.jboss.cms.CMSService")));
+ resourceType.getResourceMatch().add(rmt);
+
+ rmt = new ResourceMatchType();
+ rmt.setMatchId(XACMLConstants.FUNCTION_ANYURI_EQUAL);
+
rmt.setResourceAttributeDesignator(PolicyAttributeFactory.createAttributeDesignatorType(
+ XACMLConstants.CUSTOM_ATTR+":param0",
XMLSchemaConstants.DATATYPE_ANYURI, null, false));
+ rmt.setAttributeValue(PolicyAttributeFactory
+ .createAnyURIAttributeType(new
URI("http://www.redhat.com/protected/index.html")));
+ resourceType.getResourceMatch().add(rmt);
+
+ resourcesType.getResource().add(resourceType);
+
+
+ targetType.setResources(resourcesType);
+
+ policyType.setTarget(targetType);
+
+ //Create a Rule
+ RuleType permitRule = new RuleType();
+ permitRule.setRuleId("WriteRule");
+ permitRule.setEffect(EffectType.PERMIT);
+
+ ActionsType permitRuleActionsType = new ActionsType();
+ org.jboss.security.xacml.core.model.policy.ActionType permitRuleActionType = new
org.jboss.security.xacml.core.model.policy.ActionType();
+
+ ActionMatchType amct = new ActionMatchType();
+ amct.setMatchId("urn:oasis:names:tc:xacml:1.0:function:string-equal");
+
amct.setAttributeValue(PolicyAttributeFactory.createStringAttributeType("write"));
+
amct.setActionAttributeDesignator(PolicyAttributeFactory.createAttributeDesignatorType(
+ XACMLConstants.ATTRIBUTEID_ACTION_ID, XMLSchemaConstants.DATATYPE_STRING,
null, false));
+ permitRuleActionType.getActionMatch().add(amct);
+ TargetType permitRuleTargetType = new TargetType();
+ permitRuleActionsType.getAction().add(permitRuleActionType);
+ permitRuleTargetType.setActions(permitRuleActionsType);
+ permitRule.setTarget(permitRuleTargetType);
+
+ ConditionType permitRuleConditionType = new ConditionType();
+ FunctionType functionType = new FunctionType();
+ functionType.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+ JAXBElement<ExpressionType> jaxbElementFunctionType =
objectFactory.createExpression(functionType);
+ permitRuleConditionType.setExpression(jaxbElementFunctionType);
+
+ ApplyType permitRuleApplyType = new ApplyType();
+ permitRuleApplyType.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
+
+ SubjectAttributeDesignatorType sadt =
PolicyAttributeFactory.createSubjectAttributeDesignatorType(
+ XACMLConstants.ATTRIBUTEID_ROLE, XMLSchemaConstants.DATATYPE_STRING, null,
false, null);
+ JAXBElement<SubjectAttributeDesignatorType> sadtElement =
objectFactory.createSubjectAttributeDesignator(sadt);
+ org.jboss.security.xacml.core.model.policy.AttributeValueType avt =
PolicyAttributeFactory.createStringAttributeType("developer");
+ JAXBElement<org.jboss.security.xacml.core.model.policy.AttributeValueType>
jaxbAVT = objectFactory.createAttributeValue(avt);
+ permitRuleApplyType.getExpression().add(jaxbAVT);
+ permitRuleApplyType.getExpression().add(sadtElement);
+
+
permitRuleConditionType.setExpression(objectFactory.createApply(permitRuleApplyType));
+
+ permitRule.setCondition(permitRuleConditionType);
+
+
policyType.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(permitRule);
+
+ //marshal it into xml format
+ FileOutputStream fos = null;
+ try
+ {
+ fos = new FileOutputStream(new File("multitier-policy.xml"));
+ policyType.marshall(fos);
+
log.info("-------------------------------------------------------------------");
+ policyType.marshall(System.out);
+
log.info("-------------------------------------------------------------------");
+ }
+ finally
+ {
+ if(fos != null)
+ {
+ fos.close();
+ }
+ }
+ }
+
+ private void deleteMultiTierPolicy() throws Exception
+ {
+ File file = new File("multitier-policy.xml");
+ file.delete();
+ }
+}
Added:
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestPolicyBuilder.java
===================================================================
---
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestPolicyBuilder.java
(rev 0)
+++
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestPolicyBuilder.java 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,139 @@
+/******************************************************************************
+ * 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.test.pep;
+
+import java.net.URI;
+
+import javax.xml.bind.JAXBElement;
+
+import org.jboss.security.xacml.core.model.policy.ActionMatchType;
+import org.jboss.security.xacml.core.model.policy.ActionType;
+import org.jboss.security.xacml.core.model.policy.ActionsType;
+import org.jboss.security.xacml.core.model.policy.ApplyType;
+import org.jboss.security.xacml.core.model.policy.AttributeValueType;
+import org.jboss.security.xacml.core.model.policy.ConditionType;
+import org.jboss.security.xacml.core.model.policy.EffectType;
+import org.jboss.security.xacml.core.model.policy.ExpressionType;
+import org.jboss.security.xacml.core.model.policy.FunctionType;
+import org.jboss.security.xacml.core.model.policy.ObjectFactory;
+import org.jboss.security.xacml.core.model.policy.PolicyType;
+import org.jboss.security.xacml.core.model.policy.ResourceMatchType;
+import org.jboss.security.xacml.core.model.policy.ResourceType;
+import org.jboss.security.xacml.core.model.policy.ResourcesType;
+import org.jboss.security.xacml.core.model.policy.RuleType;
+import org.jboss.security.xacml.core.model.policy.SubjectAttributeDesignatorType;
+import org.jboss.security.xacml.core.model.policy.TargetType;
+import org.jboss.security.xacml.factories.PolicyAttributeFactory;
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class TestPolicyBuilder extends TestCase
+{
+ /**
+ *
+ * @throws Exception
+ */
+ public void testSimplePolicyBuilder() throws Exception
+ {
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ PolicyType policyType = new PolicyType();
+ policyType.setPolicyId("ExamplePolicy");
+ policyType.setVersion("2.0");
+ policyType.setRuleCombiningAlgId(XACMLConstants.RULE_COMBINING_PERMIT_OVERRIDES);
+
+ //Create a target
+ TargetType targetType = new TargetType();
+
+ ResourcesType resourcesType = new ResourcesType();
+ ResourceType resourceType = new ResourceType();
+ ResourceMatchType rmt = new ResourceMatchType();
+ rmt.setMatchId(XACMLConstants.FUNCTION_ANYURI_EQUAL);
+
rmt.setResourceAttributeDesignator(PolicyAttributeFactory.createAttributeDesignatorType(
+ XACMLConstants.ATTRIBUTEID_RESOURCE_ID, XMLSchemaConstants.DATATYPE_ANYURI,
null, false));
+ rmt.setAttributeValue(PolicyAttributeFactory
+ .createAnyURIAttributeType(new
URI("http://www.redhat.com/protected/index.html")));
+ resourceType.getResourceMatch().add(rmt);
+ resourcesType.getResource().add(resourceType);
+
+ targetType.setResources(resourcesType);
+
+ policyType.setTarget(targetType);
+
+ //Create a Rule
+ RuleType permitRule = new RuleType();
+ permitRule.setRuleId("WriteRule");
+ permitRule.setEffect(EffectType.PERMIT);
+
+ ActionsType permitRuleActionsType = new ActionsType();
+ ActionType permitRuleActionType = new ActionType();
+
+ ActionMatchType amct = new ActionMatchType();
+ amct.setMatchId("urn:oasis:names:tc:xacml:1.0:function:string-equal");
+
amct.setAttributeValue(PolicyAttributeFactory.createStringAttributeType("write"));
+
amct.setActionAttributeDesignator(PolicyAttributeFactory.createAttributeDesignatorType(
+ XACMLConstants.ATTRIBUTEID_ACTION_ID, XMLSchemaConstants.DATATYPE_STRING,
null, false));
+ permitRuleActionType.getActionMatch().add(amct);
+ TargetType permitRuleTargetType = new TargetType();
+ permitRuleActionsType.getAction().add(permitRuleActionType);
+ permitRuleTargetType.setActions(permitRuleActionsType);
+ permitRule.setTarget(permitRuleTargetType);
+
+ ConditionType permitRuleConditionType = new ConditionType();
+ FunctionType functionType = new FunctionType();
+ functionType.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+ JAXBElement<ExpressionType> jaxbElementFunctionType =
objectFactory.createExpression(functionType);
+ permitRuleConditionType.setExpression(jaxbElementFunctionType);
+
+ ApplyType permitRuleApplyType = new ApplyType();
+ permitRuleApplyType.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
+
+ SubjectAttributeDesignatorType sadt =
PolicyAttributeFactory.createSubjectAttributeDesignatorType(
+ XACMLConstants.ATTRIBUTEID_ROLE, XMLSchemaConstants.DATATYPE_STRING, null,
false, null);
+ JAXBElement<SubjectAttributeDesignatorType> sadtElement =
objectFactory.createSubjectAttributeDesignator(sadt);
+ AttributeValueType avt =
PolicyAttributeFactory.createStringAttributeType("developer");
+ JAXBElement<AttributeValueType> jaxbAVT =
objectFactory.createAttributeValue(avt);
+ permitRuleApplyType.getExpression().add(jaxbAVT);
+ permitRuleApplyType.getExpression().add(sadtElement);
+
+
permitRuleConditionType.setExpression(objectFactory.createApply(permitRuleApplyType));
+
+ permitRule.setCondition(permitRuleConditionType);
+
+
policyType.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(permitRule);
+ //Create a Deny Rule
+ RuleType denyRule = new RuleType();
+ denyRule.setRuleId("DenyRule");
+ denyRule.setEffect(EffectType.DENY);
+
policyType.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(denyRule);
+
+ //marshal it into xml format
+ policyType.marshall(System.out);
+ }
+}
Added:
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestRequestContext.java
===================================================================
---
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestRequestContext.java
(rev 0)
+++
modules/authorization/trunk/PEP/src/test/java/org/jboss/security/authz/test/pep/TestRequestContext.java 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,100 @@
+/******************************************************************************
+ * 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.test.pep;
+
+import org.jboss.security.xacml.factories.RequestResponseContextFactory;
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
+import org.jboss.security.xacml.interfaces.RequestContext;
+
+import org.jboss.security.xacml.core.model.context.ObjectFactory;
+import org.jboss.security.xacml.core.model.context.AttributeType;
+import org.jboss.security.xacml.core.model.context.AttributeValueType;
+import org.jboss.security.xacml.core.model.context.SubjectType;
+import org.jboss.security.xacml.core.model.context.RequestType;
+import org.jboss.security.xacml.core.model.context.ResourceType;
+import org.jboss.security.xacml.core.model.context.ActionType;
+
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class TestRequestContext extends TestCase
+{
+ /**
+ *
+ * @throws Exception
+ */
+ public void testRequestGeneration() throws Exception
+ {
+ //Create ObjectFactory
+ ObjectFactory objectFactory = new ObjectFactory();
+
+ //Create Subjects
+ SubjectType subject = objectFactory.createSubjectType();
+ AttributeType subjectAttribute = objectFactory.createAttributeType();
+ subjectAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ROLE);
+ subjectAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType subjectId = objectFactory.createAttributeValueType();
+ subjectId.getContent().add("developer");
+ subjectAttribute.getAttributeValue().add(subjectId);
+ subject.getAttribute().add(subjectAttribute);
+
+ //Create Resource
+ ResourceType resource = objectFactory.createResourceType();
+ AttributeType resourceAttribute = objectFactory.createAttributeType();
+ resourceAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_RESOURCE_ID);
+ resourceAttribute.setDataType(XMLSchemaConstants.DATATYPE_ANYURI);
+ AttributeValueType resourceId = objectFactory.createAttributeValueType();
+
resourceId.getContent().add("http://www.redhat.com/protected/index.h...;
+ resourceAttribute.getAttributeValue().add(resourceId);
+ resource.getAttribute().add(resourceAttribute);
+
+ //Create Action
+ ActionType action = objectFactory.createActionType();
+ AttributeType actionAttribute = objectFactory.createAttributeType();
+ actionAttribute.setAttributeId(XACMLConstants.ATTRIBUTEID_ACTION_ID);
+ actionAttribute.setDataType(XMLSchemaConstants.DATATYPE_STRING);
+ AttributeValueType actionId = objectFactory.createAttributeValueType();
+ actionId.getContent().add("write");
+ actionAttribute.getAttributeValue().add(actionId);
+ action.getAttribute().add(actionAttribute);
+
+ //Create RequestContext
+ RequestContext requestContext = RequestResponseContextFactory.createRequestCtx();
+
+ //Create a RequestType
+ RequestType requestType = objectFactory.createRequestType();
+ requestType.getSubject().add(subject);
+ requestType.setAction(action);
+ requestType.getResource().add(resource);
+
+ //Spit out RequestContext
+ requestContext.setRequest(requestType);
+
+ requestContext.marshall(System.out);
+ }
+}
Added: modules/authorization/trunk/PEP/src/test/resources/log4j.properties
===================================================================
--- modules/authorization/trunk/PEP/src/test/resources/log4j.properties
(rev 0)
+++ modules/authorization/trunk/PEP/src/test/resources/log4j.properties 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,8 @@
+# Set root category priority to INFO and its only appender to CONSOLE.
+log4j.rootCategory=INFO, CONSOLE
+
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=INFO
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
Added: modules/authorization/trunk/build/misc/codeguide.html
===================================================================
--- modules/authorization/trunk/build/misc/codeguide.html (rev 0)
+++ modules/authorization/trunk/build/misc/codeguide.html 2008-10-03 22:21:02 UTC (rev
12033)
@@ -0,0 +1,133 @@
+<html>
+
+<head>
+<style type="text/css">
+pre { border-style:solid; border-width:thin; padding:5px; background-color:#EEEEFF;}
+span.bad { text-decoration:line-through; }
+span.important { font-weight:bold; color:red; }
+</style>
+</head>
+
+<body>
+
+<h2>Coding Conventions</h2>
+
+<h3>Some more general guidelines</h3>
+<ul>
+<li>Fully qualified imports should be used, rather than importing
x.y.*.</li>
+<li>Use newlines for opening braces, so that the top and bottom braces can be
visually matched.</li>
+<li>Aid visual separation of logical steps by introducing newlines and appropriate
comments above them.</li>
+</ul>
+
+
+<h3>A class that conforms to JBoss coding guidelines</h3>
+
+<pre>
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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 x;
+
+// <span class="important">Explicit imports</span>
+import a.b.C1; // <span class="important">good</span>
+import a.b.C2;
+import a.b.C3;
+
+// <span class="important">Do not write</span>
+<span class="bad">import a.b.*;</span> // <span
class="important">bad</span>
+
+// <span class="important">DO NOT USE "TAB" TO INDENT CODE USE
*3* SPACES FOR PORTABILITY AMONG EDITORS</span>
+
+/**
+ * A description of this class.
+ *
+ * @see SomeRelatedClass.
+ *
+ * @version <tt>$Revision: 7755 $</tt>
+ * @author <a href="mailto:{email}">{full
name}</a>
+ */
+public class X
+ extends Y
+ implements Z
+{
+ public void startService() throws Exception
+ {
+ // Use the newline for the opening bracket so we can match top
+ // and bottom bracket visually
+
+ Class cls = Class.forName(dataSourceClass);
+ vendorSource = (XADataSource)cls.newInstance();
+
+ // Jump a line between logically distinct <span
class="important">steps</span> and add<
+ // line of comment to it
+ cls = vendorSource.getClass();
+
+ // Comment lines <span class="important">always</span> start
with an uppercase
+ // except if it is the second line
+ if(properties != null)
+ {
+
+ try
+ {
+ }
+ catch (IOException ioe)
+ {
+ }
+ for (Iterator i = props.entrySet().iterator(); i.hasNext();)
+ {
+
+ // Get the name and value for the attributes
+ Map.Entry entry = (Map.Entry) i.next();
+ String attributeName = (String) entry.getKey();
+ String attributeValue = (String) entry.getValue();
+
+ // Print the debug message
+ log.debug("Setting attribute '" + attributeName + "'
to '" + attributeValue + "'");
+
+ // get the attribute
+ Method setAttribute =
+ cls.getMethod("set" + attributeName, new Class[] { String.class
});
+
+ // And set the value
+ setAttribute.invoke(vendorSource, new Object[] { attributeValue });
+ }
+ }
+
+ <span class="bad">// this is a <span
class="important">bad</span> comment line because it starts with a
lower case</span>
+ vendorSource.getXAConnection().close();
+
+ // Bind in JNDI
+ bind(new InitialContext(), "java:/"+getPoolName(),
+ new Reference(vendorSource.getClass().getName(),
+ getClass().getName(), null));
+
+ // Block must always be delimited explicitely
+ if (0 == 0)
+ <span class="important">{</span>
+ System.out.println(true);
+ <span class="important">}</span>
+
+ }
+}
+</pre>
+</body>
+</html>
Property changes on: modules/authorization/trunk/build/misc/codeguide.html
___________________________________________________________________
Name: svn:executable
+
Added: modules/authorization/trunk/pom.xml
===================================================================
--- modules/authorization/trunk/pom.xml (rev 0)
+++ modules/authorization/trunk/pom.xml 2008-10-03 22:21:02 UTC (rev 12033)
@@ -0,0 +1,255 @@
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>jboss-authz-parent</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>JBoss Authorization</name>
+ <url>http://www.jboss.org</url>
+ <description>JBoss Authorization</description>
+
+ <modules>
+ <module>security-console</module>
+ <module>PEP</module>
+ </modules>
+
+ <properties>
+ <version.jboss.seam>2.0.2.SP1</version.jboss.seam>
+ <version.facelets>1.1.14</version.facelets>
+ <version.ajax4jsf>1.1.1</version.ajax4jsf>
+ <version.richfaces>3.0.1</version.richfaces>
+ <version.hibernate>3.0.0.GA</version.hibernate>
+ <version.javax.persistence>1.0</version.javax.persistence>
+ <version.javax.ejb>3.0</version.javax.ejb>
+ <version.javax.faces>1.2_04-p02</version.javax.faces>
+ <version.commons-beanutils>1.6</version.commons-beanutils>
+ <version.commons-digester>1.6</version.commons-digester>
+ <version.junit>3.8.2</version.junit>
+ <version.sun.jaxb>2.1.4</version.sun.jaxb>
+ <version.jboss.xacml>2.0.3-SNAPSHOT</version.jboss.xacml>
+ <version.apache.log4j>1.2.14</version.apache.log4j>
+
+ <!-- local environment properties -->
+ <jboss.home>/home/soshah/appServers/jboss-4.2.2.GA</jboss.home>
+ <server.name>security</server.name>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- seam dependencies -->
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam</artifactId>
+ <version>${version.jboss.seam}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam-ui</artifactId>
+ <version>${version.jboss.seam}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.facelets</groupId>
+ <artifactId>jsf-facelets</artifactId>
+ <version>${version.facelets}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>${version.commons-beanutils}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <version>${version.commons-digester}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- richfaces dependencies -->
+ <dependency>
+ <groupId>org.ajax4jsf</groupId>
+ <artifactId>ajax4jsf</artifactId>
+ <version>${version.ajax4jsf}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces</artifactId>
+ <version>${version.richfaces}</version>
+ <scope>provided</scope>
+ </dependency>
+
+
+ <!-- dependencies provided by the runtime -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>${version.hibernate}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>${version.javax.persistence}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.ejb</groupId>
+ <artifactId>ejb-api</artifactId>
+ <version>${version.javax.ejb}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>${version.javax.faces}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- sun jaxb -->
+ <dependency>
+ <groupId>sun-jaxb</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>${version.sun.jaxb}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>sun-jaxb</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>${version.sun.jaxb}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>sun-jaxb</groupId>
+ <artifactId>jaxb-xjc</artifactId>
+ <version>${version.sun.jaxb}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- jboss xacml -->
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-xacml</artifactId>
+ <version>${version.jboss.xacml}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-sunxacml</artifactId>
+ <version>${version.jboss.xacml}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- junit -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${version.apache.log4j}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <!-- project wide dependencies -->
+ <dependencies>
+ <!-- logging -->
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <aggregate>true</aggregate>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <
url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <layout>default</layout>
+ <
url>http://snapshots.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <
id>java.net maven repository</id>
+ <
url>http://download.java.net/maven/2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <distributionManagement>
+ <repository>
+ <!--Copy the distribution jar file to a local checkout of the maven
repository
+ - This variable can be set in $MAVEN_HOME/conf/settings.xml-->
+ <id>repository.jboss.org</id>
+ <url>file://${jboss.repository.root}</url>
+ </repository>
+ <snapshotRepository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <
url>dav:https://snapshots.jboss.org/maven2</url>
+ <uniqueVersion>true</uniqueVersion>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
Added: modules/authorization/trunk/security-console/ear/pom.xml
===================================================================
--- modules/authorization/trunk/security-console/ear/pom.xml (rev
0)
+++ modules/authorization/trunk/security-console/ear/pom.xml 2008-10-03 22:21:02 UTC (rev
12033)
@@ -0,0 +1,197 @@
+<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.authz</groupId>
+ <artifactId>security-console-aggregator</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>security-console</artifactId>
+ <packaging>ear</packaging>
+ <name>JBoss Security Console</name>
+ <url>http://www.jboss.org</url>
+ <description>JBoss Security Console</description>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ear-plugin</artifactId>
+ <configuration>
+ <version>5</version>
+ <modules>
+ <webModule>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>security-console-war</artifactId>
+ <contextRoot>/security-console</contextRoot>
+ </webModule>
+ <jarModule>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <includeInApplicationXml>true</includeInApplicationXml>
+ </jarModule>
+ <jarModule>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <includeInApplicationXml>true</includeInApplicationXml>
+ </jarModule>
+ <jarModule>
+ <groupId>org.jboss.el</groupId>
+ <artifactId>jboss-el</artifactId>
+ <includeInApplicationXml>true</includeInApplicationXml>
+ </jarModule>
+ <jarModule>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam-ui</artifactId>
+ <includeInApplicationXml>true</includeInApplicationXml>
+ </jarModule>
+ <jarModule>
+ <groupId>com.sun.facelets</groupId>
+ <artifactId>jsf-facelets</artifactId>
+ <includeInApplicationXml>true</includeInApplicationXml>
+ </jarModule>
+ <jarModule>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam</artifactId>
+ <includeInApplicationXml>true</includeInApplicationXml>
+ </jarModule>
+ <jarModule>
+ <groupId>org.ajax4jsf</groupId>
+ <artifactId>ajax4jsf</artifactId>
+ <includeInApplicationXml>true</includeInApplicationXml>
+ </jarModule>
+ <jarModule>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces</artifactId>
+ <includeInApplicationXml>true</includeInApplicationXml>
+ </jarModule>
+ </modules>
+ <jboss>
+ <version>4.2</version>
+ <loader-repository>
+ security-console.jboss.org:loader=security-console
+ </loader-repository>
+ </jboss>
+ </configuration>
+ </plugin>
+
+ <!-- Deploying the Security Console into the local Application Server -->
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>install</phase>
+ <configuration>
+ <tasks>
+ <echo message="Deploying to the local JBoss Application
Server........."/>
+ <copy file="target/security-console-${project.version}.ear"
+
tofile="${jboss.home}/server/${server.name}/deploy/security-console.ear"
overwrite="true"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam-ui</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.facelets</groupId>
+ <artifactId>jsf-facelets</artifactId>
+ </dependency>
+
+ <!-- richfaces dependencies -->
+ <dependency>
+ <groupId>org.ajax4jsf</groupId>
+ <artifactId>ajax4jsf</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- ejb module -->
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>security-console-ejb</artifactId>
+ <type>ejb</type>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- web module -->
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>security-console-war</artifactId>
+ <type>war</type>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
Added: modules/authorization/trunk/security-console/ejb/pom.xml
===================================================================
--- modules/authorization/trunk/security-console/ejb/pom.xml (rev
0)
+++ modules/authorization/trunk/security-console/ejb/pom.xml 2008-10-03 22:21:02 UTC (rev
12033)
@@ -0,0 +1,53 @@
+<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.authz</groupId>
+ <artifactId>security-console-aggregator</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>security-console-ejb</artifactId>
+ <packaging>ejb</packaging>
+ <name>JBoss Security Console EJB Module</name>
+ <url>http://www.jboss.org</url>
+ <description>JBoss Security Console EJB Module</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.ejb</groupId>
+ <artifactId>ejb-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam-ui</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-ejb-plugin</artifactId>
+ <configuration>
+ <ejbVersion>3.0</ejbVersion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added:
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/Register.java
===================================================================
---
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/Register.java
(rev 0)
+++
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/Register.java 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,10 @@
+//$Id: Register.java 2056 2006-09-28 00:36:56Z gavin $
+package org.jboss.seam.example.registration;
+
+import javax.ejb.Local;
+
+@Local
+public interface Register
+{
+ public String register();
+}
\ No newline at end of file
Added:
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/RegisterAction.java
===================================================================
---
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/RegisterAction.java
(rev 0)
+++
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/RegisterAction.java 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,48 @@
+//$Id: RegisterAction.java 5298 2007-06-20 00:08:47Z gavin $
+package org.jboss.seam.example.registration;
+
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.log.Log;
+
+@Stateless
+@Name("register")
+public class RegisterAction implements Register
+{
+
+ @In
+ private User user;
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @Logger
+ private static Log log;
+
+ public String register()
+ {
+ List existing = em.createQuery("select u.username from User u where
u.username=#{user.username}")
+ .getResultList();
+
+ if ( existing.size()==0 )
+ {
+ em.persist(user);
+ log.info("Registered new user #{user.username}");
+ return "/registered.jspx";
+ }
+ else
+ {
+ FacesMessages.instance().add("User #{user.username} already exists");
+ return null;
+ }
+ }
+
+}
Added:
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/User.java
===================================================================
---
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/User.java
(rev 0)
+++
modules/authorization/trunk/security-console/ejb/src/main/java/org/jboss/seam/example/registration/User.java 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,76 @@
+//$Id: User.java 2360 2006-10-25 20:17:46Z gavin $
+package org.jboss.seam.example.registration;
+
+import static org.jboss.seam.ScopeType.SESSION;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.hibernate.validator.Length;
+import org.hibernate.validator.NotNull;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+@Entity
+@Name("user")
+@Scope(SESSION)
+@Table(name="users")
+public class User implements Serializable
+{
+ private static final long serialVersionUID = 1881413500711441951L;
+
+ private String username;
+ private String password;
+ private String name;
+
+ public User(String name, String password, String username)
+ {
+ this.name = name;
+ this.password = password;
+ this.username = username;
+ }
+
+ public User() {}
+
+ @NotNull
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @NotNull @Length(min=5, max=15)
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ @Id @NotNull @Length(min=5, max=15)
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "User(" + username + ")";
+ }
+}
Added:
modules/authorization/trunk/security-console/ejb/src/main/resources/META-INF/ejb-jar.xml
===================================================================
---
modules/authorization/trunk/security-console/ejb/src/main/resources/META-INF/ejb-jar.xml
(rev 0)
+++
modules/authorization/trunk/security-console/ejb/src/main/resources/META-INF/ejb-jar.xml 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+ <interceptors>
+ <interceptor>
+
<interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
+ </interceptor>
+ </interceptors>
+
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+
<interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
+ </interceptor-binding>
+ </assembly-descriptor>
+</ejb-jar>
Added:
modules/authorization/trunk/security-console/ejb/src/main/resources/META-INF/persistence.xml
===================================================================
---
modules/authorization/trunk/security-console/ejb/src/main/resources/META-INF/persistence.xml
(rev 0)
+++
modules/authorization/trunk/security-console/ejb/src/main/resources/META-INF/persistence.xml 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="userDatabase">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto"
value="create-drop"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added:
modules/authorization/trunk/security-console/ejb/src/main/resources/seam.properties
===================================================================
Added: modules/authorization/trunk/security-console/pom.xml
===================================================================
--- modules/authorization/trunk/security-console/pom.xml (rev 0)
+++ modules/authorization/trunk/security-console/pom.xml 2008-10-03 22:21:02 UTC (rev
12033)
@@ -0,0 +1,22 @@
+<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.authz</groupId>
+ <artifactId>jboss-authz-parent</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>security-console-aggregator</artifactId>
+ <packaging>pom</packaging>
+ <name>JBoss Security Console</name>
+ <url>http://www.jboss.org</url>
+ <description>JBoss Security Console</description>
+
+
+ <modules>
+ <module>ejb</module>
+ <module>war</module>
+ <module>ear</module>
+ </modules>
+</project>
Added: modules/authorization/trunk/security-console/war/pom.xml
===================================================================
--- modules/authorization/trunk/security-console/war/pom.xml (rev
0)
+++ modules/authorization/trunk/security-console/war/pom.xml 2008-10-03 22:21:02 UTC (rev
12033)
@@ -0,0 +1,15 @@
+<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.authz</groupId>
+ <artifactId>security-console-aggregator</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>security-console-war</artifactId>
+ <packaging>war</packaging>
+ <name>JBoss Security Console War Module</name>
+ <url>http://www.jboss.org</url>
+ <description>JBoss Security Console War Module</description>
+</project>
Added:
modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/components.xml
===================================================================
---
modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/components.xml
(rev 0)
+++
modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/components.xml 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components
xmlns="http://jboss.com/products/seam/components"
+
xmlns:core="http://jboss.com/products/seam/core"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation=
+ "http://jboss.com/products/seam/core
http://jboss.com/products/seam/core-2.0.xsd
+
http://jboss.com/products/seam/components
http://jboss.com/products/seam/components-2.0.xsd">
+
+ <core:init jndi-pattern="security-console/#{ejbName}/local"/>
+
+</components>
Added:
modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/faces-config.xml
(rev 0)
+++
modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/faces-config.xml 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config version="1.2"
+
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+
+ <!-- Facelets support -->
+ <application>
+ <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
+ </application>
+
+</faces-config>
Added: modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/web.xml
===================================================================
--- modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/web.xml
(rev 0)
+++
modules/authorization/trunk/security-console/war/src/main/webapp/WEB-INF/web.xml 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
+
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <!-- Seam -->
+ <listener>
+ <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>Seam Resource Servlet</servlet-name>
+
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
+ </servlet>
+
+
+ <servlet-mapping>
+ <servlet-name>Seam Resource Servlet</servlet-name>
+ <url-pattern>/seam/resource/*</url-pattern>
+ </servlet-mapping>
+
+
+ <filter>
+ <filter-name>Seam Filter</filter-name>
+ <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>Seam Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+
+ <!-- RichFaces configuration -->
+ <context-param>
+ <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
+ <param-value>com.sun.facelets.FaceletViewHandler</param-value>
+ </context-param>
+
+
+ <!-- JSF configuration -->
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+
+
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.seam</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: modules/authorization/trunk/security-console/war/src/main/webapp/index.html
===================================================================
--- modules/authorization/trunk/security-console/war/src/main/webapp/index.html
(rev 0)
+++ modules/authorization/trunk/security-console/war/src/main/webapp/index.html 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,5 @@
+<html>
+<head>
+ <meta http-equiv="Refresh" content="0; URL=register.seam">
+</head>
+</html>
\ No newline at end of file
Added: modules/authorization/trunk/security-console/war/src/main/webapp/register.xhtml
===================================================================
--- modules/authorization/trunk/security-console/war/src/main/webapp/register.xhtml
(rev 0)
+++
modules/authorization/trunk/security-console/war/src/main/webapp/register.xhtml 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+
xmlns:rich="http://richfaces.ajax4jsf.org/rich"
+>
+ <head>
+ <title>Register New User</title>
+ </head>
+ <body>
+ <f:view>
+ <h:form>
+ <rich:panel header="Simple Echo">
+ <h:inputText size="50" value="#{user.username}" >
+ <a4j:support event="onkeyup"
reRender="rep"/>
+ </h:inputText>
+ <h:outputText value="#{user.username}"
id="rep"/>
+ </rich:panel>
+ </h:form>
+ </f:view>
+ </body>
+</html>
Added: modules/authorization/trunk/security-console/war/src/main/webapp/registered.xhtml
===================================================================
--- modules/authorization/trunk/security-console/war/src/main/webapp/registered.xhtml
(rev 0)
+++
modules/authorization/trunk/security-console/war/src/main/webapp/registered.xhtml 2008-10-03
22:21:02 UTC (rev 12033)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core">
+
+ <head>
+ <title>Successfully Registered New User</title>
+ </head>
+ <body>
+ <f:view>
+ Welcome, #{user.name}, you are successfully registered as #{user.username}.
+ </f:view>
+ </body>
+
+</html>