Author: muthulee
Date: Tue Jul 31 21:27:04 2007
New Revision: 561642

URL: http://svn.apache.org/viewvc?view=rev&rev=561642
Log:
Adding a test case that uses the DataCallback

Added:
    
webservices/rampart/trunk/java/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java
    
webservices/rampart/trunk/java/modules/rampart-integration/src/test/java/org/apache/rahas/SAMLDataProvider.java
    
webservices/rampart/trunk/java/modules/rampart-integration/src/test/resources/rahas/s5-services.xml
Modified:
    webservices/rampart/trunk/java/modules/rampart-integration/pom.xml

Modified: webservices/rampart/trunk/java/modules/rampart-integration/pom.xml
URL: 
http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-integration/pom.xml?view=diff&rev=561642&r1=561641&r2=561642
==============================================================================
--- webservices/rampart/trunk/java/modules/rampart-integration/pom.xml 
(original)
+++ webservices/rampart/trunk/java/modules/rampart-integration/pom.xml Tue Jul 
31 21:27:04 2007
@@ -341,6 +341,27 @@
                                       
tofile="target/test-resources/default_security_client_repo/modules/addressing-SNAPSHOT.mar"/>
                                 <copy file="src/test/resources/conf/axis2.xml"
                                       
tofile="target/test-resources/default_security_client_repo/conf/axis2.xml"/>
+                               <!--
+                               RahasSAMLTokenAttributeTest
+                               -->
+                               <mkdir 
dir="target/test-resources/rahas_service_repo_5"/>
+                                <mkdir 
dir="target/test-resources/rahas_service_repo_5/conf"/>
+                                <mkdir 
dir="target/test-resources/rahas_service_repo_5/services"/>
+                                <mkdir 
dir="target/test-resources/rahas_service_repo_5/modules"/>
+                                <copy 
file="target/artifacts/rampart-SNAPSHOT.mar"
+                                      
tofile="target/test-resources/rahas_service_repo_5/modules/rampart-SNAPSHOT.mar"/>
+                                <copy 
file="target/artifacts/rahas-SNAPSHOT.mar"
+                                      
tofile="target/test-resources/rahas_service_repo_5/modules/rahas-SNAPSHOT.mar"/>
+                                <copy 
file="target/artifacts/addressing-SNAPSHOT.mar"
+                                      
tofile="target/test-resources/rahas_service_repo_5/modules/addressing-SNAPSHOT.mar"/>
+                                <!-- copy the services.xml and create the aar 
-->
+                                <copy overwrite="yes"
+                                      
file="src/test/resources/rahas/s5-services.xml"
+                                      
tofile="target/temp-rahas/META-INF/services.xml"/>
+                                <jar 
jarfile="target/test-resources/rahas_service_repo_5/services/SecureService.aar"
+                                     basedir="target/temp-rahas"/>
+
+                               <!--RahasAttributeTest END-->
                                 <!-- Scenario 1 -->
                                 <mkdir 
dir="target/test-resources/scenario1_client_repo"/>
                                 <mkdir 
dir="target/test-resources/scenario1_client_repo/conf"/>

Added: 
webservices/rampart/trunk/java/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java
URL: 
http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java?view=auto&rev=561642
==============================================================================
--- 
webservices/rampart/trunk/java/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java
 (added)
+++ 
webservices/rampart/trunk/java/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java
 Tue Jul 31 21:27:04 2007
@@ -0,0 +1,103 @@
+package org.apache.rahas;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.neethi.Policy;
+import org.apache.rampart.handler.config.InflowConfiguration;
+import org.apache.rampart.handler.config.OutflowConfiguration;
+import org.apache.ws.secpolicy.Constants;
+import org.opensaml.XML;
+
+public class RahasSAMLTokenAttributeTest  extends TestClient{
+    
+       public RahasSAMLTokenAttributeTest(String name) {
+        super(name);
+    }
+    
+    public OMElement getRequest() {
+        try {
+            OMElement rstElem = 
TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_02);
+            TrustUtil.createRequestTypeElement(RahasConstants.VERSION_05_02, 
rstElem, RahasConstants.REQ_TYPE_ISSUE);
+            OMElement tokenTypeElem = 
TrustUtil.createTokenTypeElement(RahasConstants.VERSION_05_02, rstElem);
+            tokenTypeElem.setText(RahasConstants.TOK_TYPE_SAML_10);
+            
+            TrustUtil.createAppliesToElement(rstElem, 
"http://localhost:5555/axis2/services/SecureService";, this.getWSANamespace());
+            TrustUtil.createKeyTypeElement(RahasConstants.VERSION_05_02,
+                    rstElem, RahasConstants.KEY_TYPE_SYMM_KEY);
+            TrustUtil.createKeySizeElement(RahasConstants.VERSION_05_02, 
rstElem, 256);
+            
+            return rstElem;
+            
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public OutflowConfiguration getClientOutflowConfiguration() {
+        OutflowConfiguration ofc = new OutflowConfiguration();
+
+        ofc.setActionItems("UsernameToken Timestamp");
+        ofc.setUser("joe");
+        ofc.setPasswordCallbackClass(PWCallback.class.getName());
+        return ofc;
+    }
+
+    public InflowConfiguration getClientInflowConfiguration() {
+        InflowConfiguration ifc = new InflowConfiguration();
+
+        ifc.setActionItems("Timestamp");
+        
+        return ifc;
+    }
+
+    public String getServiceRepo() {
+        return "rahas_service_repo_5";
+    }
+
+    public String getRequestAction() throws TrustException {
+        return TrustUtil.getActionValue(RahasConstants.VERSION_05_02, 
RahasConstants.RST_ACTION_ISSUE);
+    }
+
+    public void validateRsponse(OMElement resp) {
+        OMElement rst = resp.getFirstChildWithName(new 
QName(RahasConstants.WST_NS_05_02,
+                                                             
RahasConstants.IssuanceBindingLocalNames.
+                                                                     
REQUESTED_SECURITY_TOKEN));
+        assertNotNull("RequestedSecurityToken missing", rst);
+        OMElement elem = rst.getFirstChildWithName(new QName(XML.SAML_NS, 
"Assertion"));
+        assertNotNull("Missing SAML Assertoin", elem);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.rahas.TestClient#getServicePolicy()
+     */
+    public Policy getServicePolicy() throws Exception {
+        return 
this.getPolicy("test-resources/rahas/policy/service-policy-transport-binding.xml");
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.rahas.TestClient#getSTSPolicy()
+     */
+    public Policy getSTSPolicy() throws Exception {
+        return 
this.getPolicy("test-resources/rahas/policy/sts-policy-transport-binding.xml");
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.rahas.TestClient#getRSTTemplate()
+     */
+    public OMElement getRSTTemplate() throws TrustException {
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+        OMElement elem = 
factory.createOMElement(Constants.RST_TEMPLATE.getLocalPart(), 
factory.createOMNamespace(Constants.RST_TEMPLATE.getNamespaceURI(),"wsp"));
+        
+        TrustUtil.createTokenTypeElement(RahasConstants.VERSION_05_02, 
elem).setText(RahasConstants.TOK_TYPE_SAML_10);
+        TrustUtil.createKeyTypeElement(RahasConstants.VERSION_05_02, elem, 
RahasConstants.KEY_TYPE_BEARER);
+        
+        return elem;
+    }
+    
+    public int getTrstVersion() {
+        return RahasConstants.VERSION_05_02;
+    }
+}

Added: 
webservices/rampart/trunk/java/modules/rampart-integration/src/test/java/org/apache/rahas/SAMLDataProvider.java
URL: 
http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-integration/src/test/java/org/apache/rahas/SAMLDataProvider.java?view=auto&rev=561642
==============================================================================
--- 
webservices/rampart/trunk/java/modules/rampart-integration/src/test/java/org/apache/rahas/SAMLDataProvider.java
 (added)
+++ 
webservices/rampart/trunk/java/modules/rampart-integration/src/test/java/org/apache/rahas/SAMLDataProvider.java
 Tue Jul 31 21:27:04 2007
@@ -0,0 +1,31 @@
+package org.apache.rahas;
+
+import java.util.Arrays;
+
+import org.apache.rahas.impl.util.SAMLAttributeCallback;
+import org.apache.rahas.impl.util.SAMLCallback;
+import org.apache.rahas.impl.util.SAMLCallbackHandler;
+import org.apache.rahas.impl.util.SAMLNameIdentifierCallback;
+import org.opensaml.SAMLAttribute;
+import org.opensaml.SAMLException;
+import org.opensaml.SAMLNameIdentifier;
+
+public class SAMLDataProvider implements SAMLCallbackHandler{
+       
+       public void handle(SAMLCallback callback) throws SAMLException{
+               
+               if(callback.getCallbackType() == SAMLCallback.ATTR_CALLBACK){
+                       SAMLAttributeCallback cb = 
(SAMLAttributeCallback)callback;
+                       SAMLAttribute attribute = new SAMLAttribute("Name",
+                     "https://rahas.apache.org/saml/attrns";, null, -1, Arrays
+                             .asList(new String[] { "Custom/Rahas" }));
+                       cb.addAttributes(attribute);
+               }else if(callback.getCallbackType() == 
SAMLCallback.NAME_IDENTIFIER_CALLBACK){
+                       SAMLNameIdentifierCallback cb = 
(SAMLNameIdentifierCallback)callback;
+                       SAMLNameIdentifier nameId = new SAMLNameIdentifier(
+                       "David", null, SAMLNameIdentifier.FORMAT_EMAIL);
+                       cb.setNameId(nameId);
+               }
+               
+       }
+}

Added: 
webservices/rampart/trunk/java/modules/rampart-integration/src/test/resources/rahas/s5-services.xml
URL: 
http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-integration/src/test/resources/rahas/s5-services.xml?view=auto&rev=561642
==============================================================================
--- 
webservices/rampart/trunk/java/modules/rampart-integration/src/test/resources/rahas/s5-services.xml
 (added)
+++ 
webservices/rampart/trunk/java/modules/rampart-integration/src/test/resources/rahas/s5-services.xml
 Tue Jul 31 21:27:04 2007
@@ -0,0 +1,70 @@
+<service name="SecureService">
+
+       <module ref="rampart"/>
+       <module ref="rahas"/>
+
+       <parameter locked="false" 
name="ServiceClass">org.apache.rahas.Service</parameter>
+
+       <operation name="echo">
+               <messageReceiver 
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+               <actionMapping>urn:echo</actionMapping>
+       </operation>
+
+    <parameter name="saml-issuer-config">
+               <saml-issuer-config>
+                       <issuerName>Test_STS</issuerName>
+                       <issuerKeyAlias>ip</issuerKeyAlias>
+                       <issuerKeyPassword>password</issuerKeyPassword>
+            <cryptoProperties>
+               <crypto 
provider="org.apache.ws.security.components.crypto.Merlin">
+                    <property 
name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</property>
+                    <property 
name="org.apache.ws.security.crypto.merlin.file">rahas-sts.jks</property>
+                    <property 
name="org.apache.ws.security.crypto.merlin.keystore.password">password</property>
+                </crypto>
+            </cryptoProperties>
+            <timeToLive>300000</timeToLive>
+                       <keySize>256</keySize>
+                       <addRequestedAttachedRef />
+                       <addRequestedUnattachedRef />
+           
<dataCallbackHandlerClass>org.apache.rahas.SAMLDataProvider</dataCallbackHandlerClass>
+            <!--
+               Key computation mechanism
+               1 - Use Request Entropy
+               2 - Provide Entropy
+               3 - Use Own Key
+            -->
+            <keyComputation>2</keyComputation>
+
+            <!--
+               proofKeyType element is valid only if the keyComputation is set 
to 3
+               i.e. Use Own Key
+
+               Valid values are: EncryptedKey & BinarySecret
+            -->
+            <proofKeyType>BinarySecret</proofKeyType>
+            <trusted-services>
+                               <service 
alias="bob">http://localhost:5555/axis2/services/SecureService</service>
+                               <service 
alias="bob1">http://localhost:5555/axis2/services/SecureService1</service>
+                               <service 
alias="bob2">http://localhost:5555/axis2/services/SecureService2</service>
+                               <service 
alias="bob3">http://localhost:5555/axis2/services/SecureService3</service>
+                       </trusted-services>
+               </saml-issuer-config>
+    </parameter>
+
+       <parameter name="InflowSecurity">
+      <action>
+        <items>UsernameToken Timestamp</items>
+               <passwordCallbackClass 
xmlns="">org.apache.rahas.PWCallback</passwordCallbackClass>
+      </action>
+    </parameter>
+
+    <parameter name="OutflowSecurity">
+      <action>
+        <items>Timestamp</items>
+        <user>ip</user>
+           <passwordCallbackClass 
xmlns="">org.apache.rahas.PWCallback</passwordCallbackClass>
+               <enableSignatureConfirmation>false</enableSignatureConfirmation>
+      </action>
+    </parameter>
+
+</service>


Reply via email to