[jboss-cvs] JBossAS SVN: r71648 - in projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests: resources and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 2 18:14:52 EDT 2008


Author: anil.saldhana at jboss.com
Date: 2008-04-02 18:14:52 -0400 (Wed, 02 Apr 2008)
New Revision: 71648

Added:
   projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/org/jboss/test/security/xacml/saml/SAMLXACMLResponseUnitTestCase.java
   projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/log4j.xml
   projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/saml/samlxacmlresponse.xml
   projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/xacml/
   projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/xacml/xacmlResponseSample.xml
Modified:
   projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/org/jboss/test/security/xacml/saml/SAMLXACMLUnitTestCase.java
Log:
update test and resources

Added: projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/org/jboss/test/security/xacml/saml/SAMLXACMLResponseUnitTestCase.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/org/jboss/test/security/xacml/saml/SAMLXACMLResponseUnitTestCase.java	                        (rev 0)
+++ projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/org/jboss/test/security/xacml/saml/SAMLXACMLResponseUnitTestCase.java	2008-04-02 22:14:52 UTC (rev 71648)
@@ -0,0 +1,81 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2007, JBoss Inc., 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.test.security.xacml.saml;
+
+import java.util.List;
+
+import org.jboss.security.xacml.saml.integration.opensaml.impl.XACMLAuthzDecisionQueryTypeImplBuilder;
+import org.jboss.security.xacml.saml.integration.opensaml.impl.XACMLAuthzDecisionQueryTypeMarshaller;
+import org.jboss.security.xacml.saml.integration.opensaml.impl.XACMLAuthzDecisionQueryTypeUnMarshaller;
+import org.jboss.security.xacml.saml.integration.opensaml.impl.XACMLAuthzDecisionStatementTypeImplBuilder;
+import org.jboss.security.xacml.saml.integration.opensaml.impl.XACMLAuthzDecisionStatementTypeMarshaller;
+import org.jboss.security.xacml.saml.integration.opensaml.impl.XACMLAuthzDecisionStatementTypeUnMarshaller;
+import org.jboss.security.xacml.saml.integration.opensaml.request.JBossSAMLResponse;
+import org.jboss.security.xacml.saml.integration.opensaml.types.XACMLAuthzDecisionQueryType;
+import org.jboss.security.xacml.saml.integration.opensaml.types.XACMLAuthzDecisionStatementType;
+import org.opensaml.Configuration;
+import org.opensaml.common.SAMLObject;
+import org.opensaml.saml2.core.Assertion;
+import org.opensaml.saml2.core.Response;
+import org.opensaml.saml2.core.Statement;
+
+import junit.framework.TestCase;
+ 
+/**
+ *  Test reading of a saml response containing
+ *  xacml response
+ *  @author Anil.Saldhana at redhat.com
+ *  @since  Apr 2, 2008 
+ *  @version $Revision$
+ */
+public class SAMLXACMLResponseUnitTestCase extends TestCase
+{
+   protected void setUp() throws Exception
+   {
+     org.opensaml.DefaultBootstrap.bootstrap(); 
+     Configuration.registerObjectProvider(XACMLAuthzDecisionQueryType.DEFAULT_ELEMENT_NAME_XACML20, 
+           new XACMLAuthzDecisionQueryTypeImplBuilder(), 
+           new XACMLAuthzDecisionQueryTypeMarshaller(), 
+           new XACMLAuthzDecisionQueryTypeUnMarshaller(), 
+           null);
+     Configuration.registerObjectProvider(XACMLAuthzDecisionStatementType.DEFAULT_ELEMENT_NAME_XACML20, 
+           new XACMLAuthzDecisionStatementTypeImplBuilder(), 
+           new XACMLAuthzDecisionStatementTypeMarshaller(), 
+           new XACMLAuthzDecisionStatementTypeUnMarshaller(), 
+           null);
+   }
+   
+   public void testSAMLXACMLResponseRead() throws Exception
+   {
+      JBossSAMLResponse response = new JBossSAMLResponse();
+      SAMLObject samlObject = response.getSAMLResponse("src/tests/resources/saml/samlxacmlresponse.xml");
+      assertNotNull(samlObject); 
+      
+      //Verify that the xacml response does exist
+      Response samlResponse = (Response) samlObject;
+      Assertion assertion = samlResponse.getAssertions().get(0);
+      List<Statement> statements = assertion.getStatements();
+      assertTrue("statements > 0 ", statements.size() > 0);
+      Statement statement = statements.get(0);
+      assertNotNull("Statement != null", statement);
+   } 
+}
\ No newline at end of file

Modified: projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/org/jboss/test/security/xacml/saml/SAMLXACMLUnitTestCase.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/org/jboss/test/security/xacml/saml/SAMLXACMLUnitTestCase.java	2008-04-02 22:13:47 UTC (rev 71647)
+++ projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/org/jboss/test/security/xacml/saml/SAMLXACMLUnitTestCase.java	2008-04-02 22:14:52 UTC (rev 71648)
@@ -28,7 +28,7 @@
 import org.jboss.security.xacml.saml.integration.opensaml.impl.XACMLAuthzDecisionQueryTypeImplBuilder;
 import org.jboss.security.xacml.saml.integration.opensaml.impl.XACMLAuthzDecisionQueryTypeMarshaller;
 import org.jboss.security.xacml.saml.integration.opensaml.impl.XACMLAuthzDecisionQueryTypeUnMarshaller;
-import org.jboss.security.xacml.saml.integration.opensaml.request.SAMLRequest;
+import org.jboss.security.xacml.saml.integration.opensaml.request.JBossSAMLRequest;
 import org.jboss.security.xacml.saml.integration.opensaml.types.XACMLAuthzDecisionQueryType;
 import org.opensaml.Configuration;
 import org.opensaml.common.SAMLObject;
@@ -59,7 +59,7 @@
       //Install Custom Attributes
       PDPConfiguration.installSingleValueAttribute("urn:va:names:xacml:2.0:subject:ien");
       
-      SAMLRequest request = new SAMLRequest();
+      JBossSAMLRequest request = new JBossSAMLRequest();
       SAMLObject samlObject = request.getSAMLRequest("src/tests/resources/saml/xacmlrequest.xml");
       assertNotNull(samlObject);
       assertTrue(samlObject instanceof XACMLAuthzDecisionQueryType);
@@ -82,7 +82,7 @@
   
    public void testSAMLRequestRead() throws Exception
    {
-      SAMLRequest request = new SAMLRequest();
+      JBossSAMLRequest request = new JBossSAMLRequest();
       SAMLObject samlObject = request.getSAMLRequest("src/tests/resources/saml/samlrequest.xml");
       assertNotNull(samlObject);
    }

Added: projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/log4j.xml
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/log4j.xml	                        (rev 0)
+++ projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/log4j.xml	2008-04-02 22:14:52 UTC (rev 71648)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Log4j Configuration                                                  -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 34717 2005-08-08 18:15:31Z adrian $ -->
+
+<!--
+   | For more configuration infromation and examples see the Jakarta Log4j
+   | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+  <!-- ================================= -->
+  <!-- Preserve messages in a local file -->
+  <!-- ================================= -->
+
+  <appender name="FILE" class="org.apache.log4j.FileAppender">
+    <param name="Threshold" value="TRACE"/>
+    <param name="File" value="${basedir}/target/test.log" />
+    <param name="Append" value="true" />
+    <layout class="org.apache.log4j.PatternLayout">
+       <param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
+    </layout>           
+  </appender>
+
+  <!-- ============================== -->
+  <!-- Append messages to the console -->
+  <!-- ============================== -->
+
+  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+    <param name="Threshold" value="FATAL"/>
+    <param name="Target" value="System.out"/>
+
+    <layout class="org.apache.log4j.PatternLayout">
+      <!-- The default pattern: Date Priority [Category] Message\n -->
+      <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+    </layout>
+  </appender>
+  <!-- ================ -->
+  <!-- Limit categories -->
+  <!-- ================ -->
+
+  <category name="org.opensaml">
+    <priority value="TRACE"/>
+  </category>
+
+  <!-- ======================= -->
+  <!-- Setup the Root category -->
+  <!-- ======================= -->
+
+  <root>
+    <appender-ref ref="CONSOLE"/>
+    <appender-ref ref="FILE"/>
+  </root>
+  
+</log4j:configuration>

Added: projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/saml/samlxacmlresponse.xml
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/saml/samlxacmlresponse.xml	                        (rev 0)
+++ projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/saml/samlxacmlresponse.xml	2008-04-02 22:14:52 UTC (rev 71648)
@@ -0,0 +1,77 @@
+<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
+ID="response-id:1" Version="2.0" 
+IssueInstant="2008-03-19T22:17:13Z">
+<samlp:Status xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
+<samlp:StatusCode  xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
+Value="urn:oasis:names:tc:xacml:1.0:status:ok">
+</samlp:StatusCode>
+</samlp:Status>
+<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" 
+Version="2.0" ID="response-id:1" IssueInstant="2008-03-19T22:17:13Z">
+<saml:Issuer>issuer-1</saml:Issuer>
+<saml:Statement xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"  
+xsi:type="xacml-samlp:XACMLAuthzDecisionStatement" 
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
+xmlns:xacml-samlp="urn:oasis:xacml:2.0:saml:protocol:schema:os"
+xmlns:xacml-saml="urn:oasis:names:tc:xacml:2.0:saml:assertion:schema:os" >
+<xacml-context:Response xmlns:xacml-context="urn:oasis:names:tc:xacml:2.0:context:schema:os" >
+<xacml-context:Result >
+<xacml-context:Decision>Permit</xacml-context:Decision>
+<xacml-context:Status>
+<xacml-context:StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"></xacml-context:StatusCode>
+<xacml-context:StatusMessage>ok</xacml-context:StatusMessage> 
+</xacml-context:Status>
+<xacml:Obligations  xmlns:xacml="urn:oasis:names:tc:xacml:2.0:policy:schema:os" >
+<xacml:Obligation ObligationId="obligation-10" FulfillOn="Permit">
+</xacml:Obligation>
+<xacml:Obligation ObligationId="obligation-20" FulfillOn="Permit">
+<xacml:AttributeAssignment AttributeId="a-120" DataType="f-120" 
+xmlns:xacml="urn:oasis:names:tc:xacml:2.0:policy:schema:os"/>
+</xacml:Obligation>
+</xacml:Obligations>
+</xacml-context:Result>
+</xacml-context:Response>
+
+<xacml-context:Request xmlns:xacml-context="urn:oasis:names:tc:xacml:2.0:context:schema:os"  
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance/" 
+xsi:schemaLocation="urn:oasis:names:tc:xacml:2.0:context:schema:os http://docs.oasis-open.org/xacml/access_control-xacml-2.0-context-schema-os.xsd">
+<Subject SubjectCategory="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
+<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" 
+DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>100001</AttributeValue>
+</Attribute>
+<Attribute AttributeId="urn:va:names:xacml:2.0:subject:role" 
+DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>Chief Resident</AttributeValue>
+<AttributeValue>Doctor</AttributeValue>
+</Attribute>
+<Attribute AttributeId="urn:va:names:xacml:2.0:subject:hl7permission" 
+DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>PRD-017</AttributeValue>
+<AttributeValue>PRD-003</AttributeValue>
+<AttributeValue>PRD-010</AttributeValue>
+<AttributeValue>PRD-006</AttributeValue>
+</Attribute>
+<Attribute AttributeId="urn:va:names:xacml:2.0:subject:locality" 
+DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>Facility A</AttributeValue>
+</Attribute>
+</Subject>
+<xacml-context:Resource>
+<Attribute AttributeId="urn:va:names:xacml:2.0:record_type" 
+DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>patientchart</AttributeValue>
+</Attribute>
+</xacml-context:Resource>
+<xacml-context:Action>
+<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" 
+DataType="http://www.w3.org/2001/XMLSchema#string" >
+<AttributeValue>read</AttributeValue>
+</Attribute>
+</xacml-context:Action>
+<xacml-context:Environment></xacml-context:Environment>
+</xacml-context:Request>
+
+</saml:Statement>
+</saml:Assertion>
+</samlp:Response> 
\ No newline at end of file

Added: projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/xacml/xacmlResponseSample.xml
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/xacml/xacmlResponseSample.xml	                        (rev 0)
+++ projects/security/security-xacml/trunk/jboss-xacml-saml/src/tests/resources/xacml/xacmlResponseSample.xml	2008-04-02 22:14:52 UTC (rev 71648)
@@ -0,0 +1,8 @@
+<Response>
+<Result ResourceId="Anthony Gurrola">
+<Decision>Permit</Decision>
+<Status>
+<StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
+</Status>
+</Result>
+</Response>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list