Author: sohil.shah(a)jboss.com
Date: 2008-12-12 17:27:01 -0500 (Fri, 12 Dec 2008)
New Revision: 12379
Added:
modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/pap/HttpPolicyStore.java
modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/pap/TestHttpPolicyDeployer.java
modules/authorization/trunk/http-authz/src/test/resources/META-INF/
modules/authorization/trunk/http-authz/src/test/resources/META-INF/jboss-beans.xml
modules/authorization/trunk/http-authz/src/test/resources/http-policy.xml
Removed:
modules/authorization/trunk/PAP/src/main/resources/META-INF/
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/pap/server/
modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/pap/FileSystemPolicyStore.java
Modified:
modules/authorization/trunk/PAP/pom.xml
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/policy/PolicyDeployer.java
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/server/Server.java
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/spi/PolicyStore.java
modules/authorization/trunk/PEP/pom.xml
modules/authorization/trunk/http-authz/pom.xml
Log:
code backup
Modified: modules/authorization/trunk/PAP/pom.xml
===================================================================
--- modules/authorization/trunk/PAP/pom.xml 2008-12-12 19:54:33 UTC (rev 12378)
+++ modules/authorization/trunk/PAP/pom.xml 2008-12-12 22:27:01 UTC (rev 12379)
@@ -74,8 +74,10 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
<configuration>
- <includes>
+ <includes>
+ <!--
<include>**/TestHierarchialPolicy.java</include>
+ -->
</includes>
</configuration>
</plugin>
Modified:
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/policy/PolicyDeployer.java
===================================================================
---
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/policy/PolicyDeployer.java 2008-12-12
19:54:33 UTC (rev 12378)
+++
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/policy/PolicyDeployer.java 2008-12-12
22:27:01 UTC (rev 12379)
@@ -77,6 +77,7 @@
try
{
is = new BufferedInputStream(url.openStream());
+ bos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024]; //using a 1K buffer
int bytesRead = -1;
Modified:
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/server/Server.java
===================================================================
---
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/server/Server.java 2008-12-12
19:54:33 UTC (rev 12378)
+++
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/server/Server.java 2008-12-12
22:27:01 UTC (rev 12379)
@@ -32,7 +32,7 @@
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
-public class Server
+public final class Server
{
private static Kernel kernel;
@@ -40,17 +40,7 @@
{
}
-
- public void start()
- {
- System.out.println("PAP Server successfully started.......");
- }
-
- public void stop()
- {
- }
-
public static void bootstrap()
{
try
@@ -69,17 +59,17 @@
}
}
- public static Server getInstance()
+ public static Object lookup(String serviceId)
{
- Server server = null;
+ Object service = null;
KernelController kernelController = kernel.getController();
- ControllerContext controllerContext =
kernelController.getInstalledContext("PAP://Server");
+ ControllerContext controllerContext =
kernelController.getInstalledContext(serviceId);
if(controllerContext != null)
{
- server = (Server)controllerContext.getTarget();
+ service = controllerContext.getTarget();
}
- return server;
+ return service;
}
}
Modified:
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/spi/PolicyStore.java
===================================================================
---
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/spi/PolicyStore.java 2008-12-12
19:54:33 UTC (rev 12378)
+++
modules/authorization/trunk/PAP/src/main/java/org/jboss/security/authz/pap/spi/PolicyStore.java 2008-12-12
22:27:01 UTC (rev 12379)
@@ -22,9 +22,6 @@
******************************************************************************/
package org.jboss.security.authz.pap.spi;
-import java.util.List;
-
-
import org.jboss.security.authz.model.Policy;
import org.jboss.security.authz.model.PolicyException;
@@ -47,7 +44,7 @@
*
* @return all the stored Policies
*/
- public List<Policy> readAllPolicies() throws PolicyException;
+ public Policy[] readAllPolicies() throws PolicyException;
/**
* Saves a Policy into storage. If this policy already exists in storage, then it
updates it
Modified: modules/authorization/trunk/PEP/pom.xml
===================================================================
--- modules/authorization/trunk/PEP/pom.xml 2008-12-12 19:54:33 UTC (rev 12378)
+++ modules/authorization/trunk/PEP/pom.xml 2008-12-12 22:27:01 UTC (rev 12379)
@@ -59,7 +59,9 @@
<version>2.3.1</version>
<configuration>
<includes>
+ <!--
<include>**/TestPDP.java</include>
+ -->
</includes>
</configuration>
</plugin>
Modified: modules/authorization/trunk/http-authz/pom.xml
===================================================================
--- modules/authorization/trunk/http-authz/pom.xml 2008-12-12 19:54:33 UTC (rev 12378)
+++ modules/authorization/trunk/http-authz/pom.xml 2008-12-12 22:27:01 UTC (rev 12379)
@@ -35,7 +35,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- </dependency>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -45,7 +51,10 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
<configuration>
- <includes>
+ <includes>
+ <!--
+ <include>**/TestHttpPolicyConfig.java</include>
+ -->
</includes>
</configuration>
</plugin>
Deleted:
modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/pap/FileSystemPolicyStore.java
===================================================================
---
modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/pap/FileSystemPolicyStore.java 2008-12-12
19:54:33 UTC (rev 12378)
+++
modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/pap/FileSystemPolicyStore.java 2008-12-12
22:27:01 UTC (rev 12379)
@@ -1,32 +0,0 @@
-/******************************************************************************
- * 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.http.pap;
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- *
- */
-public class FileSystemPolicyStore
-{
-
-}
Added:
modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/pap/HttpPolicyStore.java
===================================================================
---
modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/pap/HttpPolicyStore.java
(rev 0)
+++
modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/pap/HttpPolicyStore.java 2008-12-12
22:27:01 UTC (rev 12379)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * 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.http.pap;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.PolicyException;
+import org.jboss.security.authz.pap.spi.PolicyStore;
+
+/**
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class HttpPolicyStore implements PolicyStore
+{
+ /**
+ * TODO: this method of Policy Storage is only for testing. Eventually this should be
replaced by
+ * a Database based Policy Storage Implementation
+ */
+ private Map<String, Policy> policies;
+
+ public HttpPolicyStore()
+ {
+ this.policies = new HashMap<String, Policy>();
+ }
+
+ /**
+ * Read a stored Policy identified by the unique policyUri
+ *
+ * @param policyUri
+ * @return a stored Policy
+ */
+ public Policy readPolicy(String policyUri) throws PolicyException
+ {
+ return this.policies.get(policyUri);
+ }
+
+ /**
+ * Returns all the stored Policies for the system
+ *
+ * @return all the stored Policies
+ */
+ public Policy[] readAllPolicies() throws PolicyException
+ {
+ return this.policies.values().toArray(new Policy[0]);
+ }
+
+ /**
+ * Saves a Policy into storage. If this policy already exists in storage, then it
updates it
+ *
+ * @param policy Policy to be saved into storage
+ */
+ public void savePolicy(Policy policy) throws PolicyException
+ {
+ this.policies.put(policy.getPolicyUri(), policy);
+ }
+
+ /**
+ * Deletes the specified Policy from storage
+ *
+ * @param policyUri unique identifier for the Policy
+ */
+ public void deletePolicy(String policyUri) throws PolicyException
+ {
+ this.policies.remove(policyUri);
+ }
+}
Added:
modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/pap/TestHttpPolicyDeployer.java
===================================================================
---
modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/pap/TestHttpPolicyDeployer.java
(rev 0)
+++
modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/pap/TestHttpPolicyDeployer.java 2008-12-12
22:27:01 UTC (rev 12379)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * 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.http.pap;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.pap.server.Server;
+import org.jboss.security.authz.pap.policy.PolicyDeployer;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class TestHttpPolicyDeployer extends TestCase
+{
+ private static Logger log = Logger.getLogger(TestHttpPolicyDeployer.class);
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ Server.bootstrap();
+ }
+
+ public void testPolicyDeploy() throws Exception
+ {
+ PolicyDeployer httpPolicyDeployer =
(PolicyDeployer)Server.lookup("http://PolicyDeployer");
+
+
httpPolicyDeployer.deploy(Thread.currentThread().getContextClassLoader().getResource("http-policy.xml"));
+
+ Policy[] policies = httpPolicyDeployer.getStore().readAllPolicies();
+ for(int i=0; i<policies.length; i++)
+ {
+
log.info("-------------------------------------------------------------");
+ log.info(policies[i].generateXACMLPolicy());
+
log.info("-------------------------------------------------------------");
+ }
+ }
+}
Added: modules/authorization/trunk/http-authz/src/test/resources/META-INF/jboss-beans.xml
===================================================================
--- modules/authorization/trunk/http-authz/src/test/resources/META-INF/jboss-beans.xml
(rev 0)
+++
modules/authorization/trunk/http-authz/src/test/resources/META-INF/jboss-beans.xml 2008-12-12
22:27:01 UTC (rev 12379)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer:2.0
bean-deployer_2_0.xsd"
+ xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="http://PolicyDeployer"
class="org.jboss.security.authz.pap.policy.PolicyDeployer">
+ <property name="configuration"><inject
bean="http://PolicyConfig"/></property>
+ <property name="store"><inject
bean="http://PolicyStore"/></property>
+ </bean>
+
+ <bean name="http://PolicyConfig"
class="org.jboss.security.authz.http.pap.HttpPolicyConfig"/>
+ <bean name="http://PolicyStore"
class="org.jboss.security.authz.http.pap.HttpPolicyStore"/>
+</deployment>
\ No newline at end of file
Added: modules/authorization/trunk/http-authz/src/test/resources/http-policy.xml
===================================================================
--- modules/authorization/trunk/http-authz/src/test/resources/http-policy.xml
(rev 0)
+++ modules/authorization/trunk/http-authz/src/test/resources/http-policy.xml 2008-12-12
22:27:01 UTC (rev 12379)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-acl>
+ <acl-rule id="simplePolicy">
+ <resource>
+ <request-uri>/portal/admin-tool/modifyLayout</request-uri>
+ <params>
+ <param>
+ <name>page</name>
+ <value>marketing_index.html</value>
+ </param>
+ <param>
+ <name>action</name>
+ <value>update</value>
+ </param>
+ </params>
+ </resource>
+ <conditions>
+ <condition>
+ <roles>
+ <role-name>Root-Admin</role-name>
+ <role-name>Marketing Team</role-name>
+ </roles>
+ </condition>
+ </conditions>
+ </acl-rule>
+ <acl-rule id="complexPolicy">
+ <resource>
+ <request-uri>/portal/admin-tool/modifyLayout</request-uri>
+ <params>
+ <param>
+ <name>page</name>
+ <value>marketing_index.html</value>
+ </param>
+ <param>
+ <name>action</name>
+ <value>update</value>
+ </param>
+ </params>
+ </resource>
+ <conditions>
+ <condition>
+ <roles>
+ <role-name>Root-Admin</role-name>
+ </roles>
+ </condition>
+ <condition>
+ <ip-address>
+ <ip-range>192.168.xxx.xxx</ip-range>
+ </ip-address>
+ </condition>
+ </conditions>
+ </acl-rule>
+</web-acl>
\ No newline at end of file