[jboss-cvs] JBossAS SVN: r86007 - in projects/security/security-xacml/trunk/jboss-xacml/src: test/java/org/jboss/test/security/xacml/config and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 17 13:03:32 EDT 2009


Author: anil.saldhana at jboss.com
Date: 2009-03-17 13:03:32 -0400 (Tue, 17 Mar 2009)
New Revision: 86007

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/test/java/org/jboss/test/security/xacml/config/JBossXACMLConfigUnitTestCase.java
Log:
SECURITY-382: JBossPDP to take in config metadata in ctr

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-03-17 16:50:48 UTC (rev 86006)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/java/org/jboss/security/xacml/core/JBossPDP.java	2009-03-17 17:03:32 UTC (rev 86007)
@@ -83,6 +83,7 @@
     */
    public JBossPDP()
    {
+	   createValidatingUnMarshaller();
    }
 
    /**
@@ -91,7 +92,7 @@
     */
    public JBossPDP(InputStream configFile)
    {
-      createValidatingUnMarshaller();
+      this();
       try
       {
          JAXBElement<?> jxb = (JAXBElement<?>) unmarshaller.unmarshal(configFile);
@@ -109,7 +110,7 @@
     */
    public JBossPDP(InputSource configFile)
    {
-      createValidatingUnMarshaller();
+	  this();
       try
       {
          JAXBElement<?> jxb = (JAXBElement<?>) unmarshaller.unmarshal(configFile);
@@ -127,7 +128,7 @@
     */
    public JBossPDP(Node configFile)
    {
-      createValidatingUnMarshaller();
+	  this();
       try
       {
          JAXBElement<?> jxb = (JAXBElement<?>) unmarshaller.unmarshal(configFile);
@@ -145,8 +146,8 @@
     */
    public JBossPDP(XMLStreamReader configFile)
    {
-      createValidatingUnMarshaller();
-      try
+	  this();
+	  try
       {
          JAXBElement<?> jxb = (JAXBElement<?>) unmarshaller.unmarshal(configFile);
          bootstrap((PDP) jxb.getValue());
@@ -163,7 +164,7 @@
     */
    public JBossPDP(URL configFileURL)
    {
-      createValidatingUnMarshaller();
+      this();
       try
       {
          JAXBElement<?> jxb = (JAXBElement<?>) unmarshaller.unmarshal(configFileURL.openStream());
@@ -174,6 +175,25 @@
          throw new RuntimeException(e);
       }
    }
+   
+   /**
+    * Create a PDP
+    * @param config JAXB model for configuration
+    */
+   public JBossPDP(JAXBElement<?> config)
+   {
+      Object object = config.getValue();
+      if(object instanceof PDP == false)
+         throw new IllegalArgumentException("Not PDP configuration");
+      try
+      {
+         bootstrap((PDP) object);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
 
    /**
     * @see PolicyDecisionPoint#setLocators(Set)

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-03-17 16:50:48 UTC (rev 86006)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/test/java/org/jboss/test/security/xacml/config/JBossXACMLConfigUnitTestCase.java	2009-03-17 17:03:32 UTC (rev 86007)
@@ -101,4 +101,23 @@
       PolicyDecisionPoint pdp = new JBossPDP(configFile);
       XACMLTestUtil.validateInteropCases(pdp);
    }
+   
+   /**
+    * SECURITY-382: JBossPDP to take in configuration metadata
+    * @throws Exception
+    */
+   public void testPDPConfigPassingJAXBConfig() throws Exception
+   {
+      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+      URL configFile = tcl.getResource("test/config/interopPolicySetConfig.xml");
+      JAXBContext jc = JAXBContext.newInstance("org.jboss.security.xacml.jaxb");
+      assertNotNull("JAXBContext is !null", jc);
+      Unmarshaller u = jc.createUnmarshaller();
+      JAXBElement<?> j = (JAXBElement<?>) u.unmarshal(configFile);
+      assertNotNull("JAXBElement is !null", j);
+      
+      assertNotNull("configFile != null", configFile);
+      PolicyDecisionPoint pdp = new JBossPDP(j);
+      XACMLTestUtil.validateInteropCases(pdp);
+   }
 }




More information about the jboss-cvs-commits mailing list