[jboss-cvs] JBossAS SVN: r87008 - in projects/security/security-xacml/trunk/jboss-xacml/src: main/java/org/jboss/security/xacml/core and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 8 17:57:53 EDT 2009
Author: anil.saldhana at jboss.com
Date: 2009-04-08 17:57:53 -0400 (Wed, 08 Apr 2009)
New Revision: 87008
Added:
projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/core/JustLocatorUnitTestCase.java
projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/locators/TestPolicySetLocator.java
projects/security/security-xacml/trunk/jboss-xacml/src/test/resources/test/config/locator/
projects/security/security-xacml/trunk/jboss-xacml/src/test/resources/test/config/locator/justLocatorConfig.xml
Removed:
projects/security/security-xacml/trunk/jboss-xacml/src/test/resources/test/config/justLocatorsConfig.xml
Modified:
projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/bridge/JBossPolicyFinder.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/bridge/PolicySetFinderModule.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/core/JBossPDP.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/core/JBossXACMLPolicy.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/interfaces/PolicyLocator.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/jaxb/PDP.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/AbstractJBossPolicyLocator.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/JBossPolicyLocator.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/JBossPolicySetLocator.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/resources/schema/jbossxacml-2.0.xsd
projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/config/JBossXACMLConfigUnitTestCase.java
projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/core/JBossPDPUnitTestCase.java
Log:
SECURITY-407: just the locators
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/bridge/JBossPolicyFinder.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/bridge/JBossPolicyFinder.java 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/bridge/JBossPolicyFinder.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -40,4 +40,4 @@
{
super();
}
-}
+}
\ No newline at end of file
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/bridge/PolicySetFinderModule.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/bridge/PolicySetFinderModule.java 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/bridge/PolicySetFinderModule.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -143,4 +143,4 @@
this.policySet = ps;
this.policies = policies;
}
-}
+}
\ No newline at end of file
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/core/JBossPDP.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/core/JBossPDP.java 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/core/JBossPDP.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -245,6 +245,8 @@
private void bootstrap(PDP pdp) throws Exception
{
+ boolean justLocators = false;
+
PoliciesType policiesType = pdp.getPolicies();
//SECURITY-407: Just allow Locators
if(policiesType != null)
@@ -257,6 +259,10 @@
List<XACMLPolicy> policyList = this.addPolicies(policiesType.getPolicy());
policies.addAll(policyList);
}
+ else
+ {
+ justLocators = true;
+ }
//Take care of the locators
LocatorsType locatorsType = pdp.getLocators();
@@ -275,7 +281,8 @@
if(locator instanceof PolicyLocator)
{
PolicyLocator pl = (PolicyLocator)locator;
- pl.setPolicies(policies);
+ if(justLocators == false)
+ pl.setPolicies(policies);
this.policyLocators.add(pl);
}
else
@@ -291,6 +298,21 @@
this.resourceLocators.add(resourceLocator);
}
}
+
+ //Since we do not have any policies in the config file, we need to specify
+ //the policy finder
+ if(justLocators)
+ {
+ int len = this.policyLocators.size();
+ if(len > 0)
+ {
+ for(PolicyLocator pl: policyLocators)
+ {
+ pl.set(XACMLConstants.POLICY_FINDER, this.policyFinder);
+ }
+ }
+ }
+
this.bootstrapPDP();
}
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/core/JBossXACMLPolicy.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/core/JBossXACMLPolicy.java 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/core/JBossXACMLPolicy.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -107,6 +107,7 @@
{
if (theFinder == null)
throw new IllegalArgumentException("policy finder is null");
+ this.finder = theFinder;
policy = xpu.createPolicySet(is, theFinder);
map.put(XACMLConstants.POLICY_FINDER, theFinder);
}
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/interfaces/PolicyLocator.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/interfaces/PolicyLocator.java 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/interfaces/PolicyLocator.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -37,4 +37,10 @@
* @param policies
*/
void setPolicies(Set<XACMLPolicy> policies);
+
+ /**
+ * Get the set of policies that the locator can return
+ * @return
+ */
+ Set<XACMLPolicy> getPolicies();
}
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/jaxb/PDP.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/jaxb/PDP.java 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/jaxb/PDP.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -38,7 +38,7 @@
public class PDP
{
- @XmlElement(name = "Policies", required = true)
+ @XmlElement(name = "Policies", required = false)
protected PoliciesType policies;
@XmlElement(name = "Locators", required = true)
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/AbstractJBossPolicyLocator.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/AbstractJBossPolicyLocator.java 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/AbstractJBossPolicyLocator.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -21,6 +21,7 @@
*/
package org.jboss.security.xacml.locators;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -75,4 +76,15 @@
* @see PolicyLocator#setPolicies(Set)
*/
public abstract void setPolicies(Set<XACMLPolicy> policies);
+
+ /**
+ * @see PolicyLocator#getPolicies()
+ */
+ public Set<XACMLPolicy> getPolicies()
+ {
+ if(policies == null)
+ return Collections.emptySet();
+ else
+ return Collections.unmodifiableSet(policies);
+ }
}
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/JBossPolicyLocator.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/JBossPolicyLocator.java 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/JBossPolicyLocator.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -53,6 +53,8 @@
@Override
public void setPolicies(Set<XACMLPolicy> policies)
{
+ this.policies = policies;
+
for (XACMLPolicy xp : policies)
{
if (xp.getType() == XACMLPolicy.POLICY)
@@ -64,4 +66,4 @@
}
this.map.put(XACMLConstants.POLICY_FINDER_MODULE, pfml);
}
-}
+}
\ No newline at end of file
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/JBossPolicySetLocator.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/JBossPolicySetLocator.java 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/locators/JBossPolicySetLocator.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -53,6 +53,7 @@
@Override
public void setPolicies(Set<XACMLPolicy> policies)
{
+ this.policies = policies;
for (XACMLPolicy xp : policies)
{
if (xp.getType() == XACMLPolicy.POLICYSET)
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/resources/schema/jbossxacml-2.0.xsd
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/resources/schema/jbossxacml-2.0.xsd 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/resources/schema/jbossxacml-2.0.xsd 2009-04-08 21:57:53 UTC (rev 87008)
@@ -10,7 +10,7 @@
</xs:element>
<xs:complexType name="PDP">
<xs:sequence>
- <xs:element ref="ns:Policies" minOccurs="1"/>
+ <xs:element ref="ns:Policies" minOccurs="0"/>
<xs:element ref="ns:Locators" minOccurs="1"/>
</xs:sequence>
</xs:complexType>
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/config/JBossXACMLConfigUnitTestCase.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/config/JBossXACMLConfigUnitTestCase.java 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/config/JBossXACMLConfigUnitTestCase.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -160,7 +160,7 @@
*/
public void testPDPJustLocators() throws Exception
{
- String fileName = "test/config/justLocatorsConfig.xml";
+ String fileName = "test/config/locator/justLocatorConfig.xml";
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
URL configFile = tcl.getResource(fileName);
JAXBContext jc = JAXBContext.newInstance("org.jboss.security.xacml.jaxb");
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/core/JBossPDPUnitTestCase.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/core/JBossPDPUnitTestCase.java 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/core/JBossPDPUnitTestCase.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -47,15 +47,21 @@
* @version $Revision$
*/
public class JBossPDPUnitTestCase extends TestCase
-{
+{
/**Enable to see the xacml request in system out for the objects case**/
//Enable for request trace
private boolean debug = "true".equals(System.getProperty("debug", "false"));
+
+
+ public String getConfigFileName()
+ {
+ return "test/config/interopPolicySetConfig.xml";
+ }
public void testInteropTestWithXMLRequests() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream is = tcl.getResourceAsStream("test/config/interopPolicySetConfig.xml");
+ InputStream is = tcl.getResourceAsStream(getConfigFileName());
assertNotNull("InputStream != null", is);
PolicyDecisionPoint pdp = new JBossPDP(is);
assertNotNull("JBossPDP is != null", pdp);
@@ -77,7 +83,7 @@
public void testInteropTestWithObjects() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- InputStream is = tcl.getResourceAsStream("test/config/interopPolicySetConfig.xml");
+ InputStream is = tcl.getResourceAsStream(getConfigFileName());
assertNotNull("InputStream != null", is);
PolicyDecisionPoint pdp = new JBossPDP(is);
assertNotNull("JBossPDP is != null", pdp);
Added: projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/core/JustLocatorUnitTestCase.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/core/JustLocatorUnitTestCase.java (rev 0)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/core/JustLocatorUnitTestCase.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.security.xacml.core;
+
+
+/**
+ * SECURITY-407: Configuration should allow just a locator
+ * This unit test ensures that we can have a locator
+ * that can provide the policies
+ *
+ * @author Anil.Saldhana at redhat.com
+ * @since Apr 8, 2009
+ */
+public class JustLocatorUnitTestCase extends JBossPDPUnitTestCase
+{
+ public String getConfigFileName()
+ {
+ return "test/config/locator/justLocatorConfig.xml";
+ }
+}
\ No newline at end of file
Added: projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/locators/TestPolicySetLocator.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/locators/TestPolicySetLocator.java (rev 0)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/locators/TestPolicySetLocator.java 2009-04-08 21:57:53 UTC (rev 87008)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.security.xacml.locators;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.security.xacml.bridge.JBossPolicyFinder;
+import org.jboss.security.xacml.factories.PolicyFactory;
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+import org.jboss.security.xacml.interfaces.XACMLPolicy;
+import org.jboss.security.xacml.locators.JBossPolicySetLocator;
+
+/**
+ * Test Policy Set Locator for the Interop test case(JustLocatorUnitTestCase)
+ * @author Anil.Saldhana at redhat.com
+ * @since Apr 8, 2009
+ */
+public class TestPolicySetLocator extends JBossPolicySetLocator
+{
+ public TestPolicySetLocator()
+ {
+
+ }
+
+ @Override
+ public <T> void set(String key, T obj)
+ {
+ if(XACMLConstants.POLICY_FINDER.equals(key))
+ {
+ JBossPolicyFinder jbf = (JBossPolicyFinder) obj;
+ String policySetLocation = "test/policies/interop/xacml-policySet.xml";
+ String[] arr = new String[] {
+ "test/policies/interop/xacml-policy2.xml",
+ "test/policies/interop/xacml-policy3.xml",
+ "test/policies/interop/xacml-policy4.xml",
+ "test/policies/interop/xacml-policy5.xml"};
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+
+ XACMLPolicy policySet = null;
+ try
+ {
+ policySet = PolicyFactory.createPolicySet(tcl.getResourceAsStream(policySetLocation),jbf);
+ }
+ catch (Exception e1)
+ {
+ throw new RuntimeException(e1);
+ }
+
+ List<XACMLPolicy> policyList = new ArrayList<XACMLPolicy>();
+ for (String str:arr)
+ {
+ InputStream is = tcl.getResourceAsStream(str);
+ if(is == null)
+ throw new IllegalStateException("Inputstream is null");
+
+ try
+ {
+ policyList.add(PolicyFactory.createPolicy(is));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ policySet.setEnclosingPolicies(policyList);
+
+ Set<XACMLPolicy> set = new HashSet<XACMLPolicy>();
+ set.add(policySet);
+ this.setPolicies(set);
+ }
+ super.set(key, obj);
+ }
+}
\ No newline at end of file
Deleted: projects/security/security-xacml/trunk/jboss-xacml/src/test/resources/test/config/justLocatorsConfig.xml
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/test/resources/test/config/justLocatorsConfig.xml 2009-04-08 21:47:10 UTC (rev 87007)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/test/resources/test/config/justLocatorsConfig.xml 2009-04-08 21:57:53 UTC (rev 87008)
@@ -1,6 +0,0 @@
-<ns:jbosspdp xmlns:ns="urn:jboss:xacml:2.0">
- <ns:Locators>
- <ns:Locator Name="org.jboss.security.xacml.locators.JBossPolicyLocator">
- </ns:Locator>
- </ns:Locators>
-</ns:jbosspdp>
\ No newline at end of file
Added: projects/security/security-xacml/trunk/jboss-xacml/src/test/resources/test/config/locator/justLocatorConfig.xml
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/test/resources/test/config/locator/justLocatorConfig.xml (rev 0)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/test/resources/test/config/locator/justLocatorConfig.xml 2009-04-08 21:57:53 UTC (rev 87008)
@@ -0,0 +1,5 @@
+<ns:jbosspdp xmlns:ns="urn:jboss:xacml:2.0">
+ <ns:Locators>
+ <ns:Locator Name="org.jboss.test.security.xacml.locators.TestPolicySetLocator"/>
+ </ns:Locators>
+</ns:jbosspdp>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list