[jboss-cvs] JBossAS SVN: r86359 - in projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance: support and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 25 11:48:10 EDT 2009
Author: anil.saldhana at jboss.com
Date: 2009-03-25 11:48:10 -0400 (Wed, 25 Mar 2009)
New Revision: 86359
Added:
projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/ConformanceTestPolicyFinderModule.java
Modified:
projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/ConformanceUnitTestCase.java
projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/TestPDP.java
projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/TestPolicyFinderModule.java
Log:
SECURITY-401: xacml conformance for mandatory-schema components section
Modified: projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/ConformanceUnitTestCase.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/ConformanceUnitTestCase.java 2009-03-25 15:46:25 UTC (rev 86358)
+++ projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/ConformanceUnitTestCase.java 2009-03-25 15:48:10 UTC (rev 86359)
@@ -23,14 +23,16 @@
import java.io.FileInputStream;
import java.io.InputStream;
-import java.util.HashSet;
-import java.util.Set;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
import junit.framework.TestCase;
import org.jboss.security.xacml.sunxacml.ctx.ResponseCtx;
import org.jboss.security.xacml.sunxacml.ctx.Result;
import org.jboss.security.xacml.sunxacml.finder.PolicyFinderModule;
+import org.jboss.test.security.sunxacml.conformance.support.ConformanceTestPolicyFinderModule;
import org.jboss.test.security.sunxacml.conformance.support.TestAttributeFinderModule;
import org.jboss.test.security.sunxacml.conformance.support.TestPDP;
import org.jboss.test.security.sunxacml.conformance.support.TestPolicyFinderModule;
@@ -247,7 +249,7 @@
}
}
- /*public void testMandatoryConformance_Schema_1_through_3() throws Exception
+ public void testMandatoryConformance_Schema_1_through_3() throws Exception
{
TestPDP pdp = null;
for(int i =1; i<=3; i++)
@@ -259,8 +261,7 @@
fileName = mandatoryBase + "IIE00" + i + "Policy.xml";
String[] policies = new String[] {fileName};
- pdp = new TestPDP(policies);
- pdp.clearPolicyModules();
+ pdp = new TestPDP(policies);
pdp.addPolicyFinderModule(createTestPolicyFinderModule(i));
pdp.createInternalPDP();
@@ -288,13 +289,18 @@
@SuppressWarnings("unchecked")
private PolicyFinderModule createTestPolicyFinderModule(int i) throws Exception
{
- TestPolicyFinderModule tpfm = new TestPolicyFinderModule();
+ TestPolicyFinderModule tpfm = new ConformanceTestPolicyFinderModule();
- Set policyFiles = new HashSet();
- policyFiles.add(mandatoryBase + "IIE00" + i + "PolicyId1.xml");
- policyFiles.add(mandatoryBase + "IIE00" + i + "PolicySetId1.xml");
-
- tpfm.setPolicies(policyFiles);
+ String policyRefString = "urn:oasis:names:tc:xacml:1.0:conformance-test:IIE00"+i+":policy1";
+ URI policyRef = new URI(policyRefString);
+ Map policyRefs = new HashMap();
+ policyRefs.put(policyRef.toString(), mandatoryBase + "IIE00" + i + "PolicyId1.xml");
+ tpfm.setPolicyRefs(policyRefs, policyRef.toString());
+
+ URI policySetRef = new URI("urn:oasis:names:tc:xacml:1.0:conformance-test:IIE00"+i+":policyset1");
+ Map policySetRefs = new HashMap();
+ policySetRefs.put(policySetRef.toString(), mandatoryBase + "IIE00" + i + "PolicySetId1.xml");
+ tpfm.setPolicySetRefs(policySetRefs, policySetRef.toString());
return tpfm;
- }*/
+ }
}
\ No newline at end of file
Added: projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/ConformanceTestPolicyFinderModule.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/ConformanceTestPolicyFinderModule.java (rev 0)
+++ projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/ConformanceTestPolicyFinderModule.java 2009-03-25 15:48:10 UTC (rev 86359)
@@ -0,0 +1,82 @@
+/*
+ * 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.sunxacml.conformance.support;
+
+import java.net.URI;
+import java.util.ArrayList;
+
+import org.jboss.security.xacml.sunxacml.AbstractPolicy;
+import org.jboss.security.xacml.sunxacml.PolicyMetaData;
+import org.jboss.security.xacml.sunxacml.PolicyReference;
+import org.jboss.security.xacml.sunxacml.VersionConstraints;
+import org.jboss.security.xacml.sunxacml.ctx.Status;
+import org.jboss.security.xacml.sunxacml.finder.PolicyFinderResult;
+
+/**
+ * Override the findPolicy method
+ * @author Anil.Saldhana at redhat.com
+ * @since Mar 25, 2009
+ */
+public class ConformanceTestPolicyFinderModule extends TestPolicyFinderModule
+{
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public PolicyFinderResult findPolicy(URI idReference, int type, VersionConstraints constraints,
+ PolicyMetaData metaData)
+ {
+ String fileName = null;
+
+ // based on the type, see if we have any references available, and
+ // if we do then get the filename
+ if (type == PolicyReference.POLICY_REFERENCE) {
+ if (policyRefs == null)
+ return new PolicyFinderResult();
+
+ fileName = (String)(policyRefs.get(idReference.toString()));
+ } else {
+ if (policySetRefs == null)
+ return new PolicyFinderResult();
+
+ fileName = (String)(policySetRefs.get(idReference.toString()));
+ }
+
+ // if we had no mapping available, return with no referenced policy
+ if (fileName == null)
+ return new PolicyFinderResult();
+
+ // load the referenced policy
+ AbstractPolicy policy = loadPolicy(fileName, finder);
+
+ // if there was an error loading the policy, return the error
+ if (policy == null) {
+ ArrayList code = new ArrayList();
+ code.add(Status.STATUS_PROCESSING_ERROR);
+ Status status = new Status(code,
+ "couldn't load referenced policy");
+ return new PolicyFinderResult(status);
+ }
+
+ // return the referenced policy
+ return new PolicyFinderResult(policy);
+ }
+}
Modified: projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/TestPDP.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/TestPDP.java 2009-03-25 15:46:25 UTC (rev 86358)
+++ projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/TestPDP.java 2009-03-25 15:48:10 UTC (rev 86359)
@@ -106,12 +106,6 @@
policyFinder.setModules(modules);
}
- public void clearPolicyModules()
- {
- Set modules = new HashSet();
- policyFinder.setModules(modules);
- }
-
public void createInternalPDP()
{
pdp = new PDP(new PDPConfig(attributeFinder, policyFinder, null));
Modified: projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/TestPolicyFinderModule.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/TestPolicyFinderModule.java 2009-03-25 15:46:25 UTC (rev 86358)
+++ projects/security/security-xacml/trunk/jboss-sunxacml/src/test/java/org/jboss/test/security/sunxacml/conformance/support/TestPolicyFinderModule.java 2009-03-25 15:48:10 UTC (rev 86359)
@@ -78,20 +78,20 @@
{
// the finder that owns this module
- private PolicyFinder finder = null;
+ protected PolicyFinder finder = null;
// the policies we're currently using for request-based retrieval
- private Set policies = null;
+ protected Set policies = null;
// a map of URIs to policies for the reference-based policies we're
// currently providing, and the current namespace prefix
- private Map policyRefs = null;
- private String policyRefPrefix;
+ protected Map policyRefs = null;
+ protected String policyRefPrefix;
// a map of URIs to policies for the reference-based policy sets we're
// currently providing, and the current namespace prefix
- private Map policySetRefs = null;
- private String policySetRefPrefix;
+ protected Map policySetRefs = null;
+ protected String policySetRefPrefix;
/**
* Default constructor.
@@ -290,7 +290,7 @@
* Private helper that tries to load the given file-based policy, and
* returns null if any error occurs.
*/
- private AbstractPolicy loadPolicy(String filename, PolicyFinder finder) {
+ protected AbstractPolicy loadPolicy(String filename, PolicyFinder finder) {
try {
// create the factory
DocumentBuilderFactory factory =
More information about the jboss-cvs-commits
mailing list