axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruchi...@apache.org
Subject svn commit: r448555 - in /webservices/axis2/trunk/java/modules/security: src/org/apache/rampart/builder/ test/org/apache/rampart/
Date Thu, 21 Sep 2006 14:07:38 GMT
Author: ruchithf
Date: Thu Sep 21 07:07:37 2006
New Revision: 448555

URL: http://svn.apache.org/viewvc?view=rev&rev=448555
Log:
Updated the tests to go through the security header adn check the elements and the order

Modified:
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/AsymmetricBindingBuilder.java
    webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java
    webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTestBase.java
    webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/TransportBindingBuilderTest.java

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/AsymmetricBindingBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/AsymmetricBindingBuilder.java?view=diff&rev=448555&r1=448554&r2=448555
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/AsymmetricBindingBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/AsymmetricBindingBuilder.java
Thu Sep 21 07:07:37 2006
@@ -407,7 +407,10 @@
 
         if (sigToken.isDerivedKeys()) {
             // Set up the encrypted key to use
-            setupEncryptedKey(rmd);
+            if(this.encrKey == null) {
+                setupEncryptedKey(rmd);
+            }
+            
             WSSecDKSign dkSign = new WSSecDKSign();
             dkSign.setExternalKey(encrKey.getEphemeralKey(), encrKey.getId());
 

Modified: webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java?view=diff&rev=448555&r1=448554&r2=448555
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java
(original)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java
Thu Sep 21 07:07:37 2006
@@ -18,6 +18,12 @@
 
 import org.apache.axis2.context.MessageContext;
 import org.apache.neethi.Policy;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.conversation.ConversationConstants;
+
+import javax.xml.namespace.QName;
+
+import java.util.ArrayList;
 
 public class AsymmetricBindingBuilderTest extends MessageBuilderTestBase {
     
@@ -33,7 +39,13 @@
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
             
-            System.out.println(ctx.getEnvelope());
+            ArrayList list = new ArrayList();
+            
+            list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
+            list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
+            list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
+            
+            this.verifySecHeader(list.iterator(), ctx.getEnvelope());
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());
@@ -53,7 +65,13 @@
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
             
-            System.out.println(ctx.getEnvelope());
+            ArrayList list = new ArrayList();
+            
+            list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
+            list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
+            list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
+            
+            this.verifySecHeader(list.iterator(), ctx.getEnvelope());
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());
@@ -72,7 +90,17 @@
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
             
-            System.out.println(ctx.getEnvelope());
+            ArrayList list = new ArrayList();
+            
+            list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
+            list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
+            list.add(new QName(WSConstants.WSSE_NS, WSConstants.BINARY_TOKEN_LN));
+            list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
+            list.add(new QName(ConversationConstants.WSC_NS_05_02, ConversationConstants.DERIVED_KEY_TOKEN_LN));
+            list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
+            
+            this.verifySecHeader(list.iterator(), ctx.getEnvelope());
+            
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());
@@ -91,7 +119,18 @@
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
             
-            System.out.println(ctx.getEnvelope());
+            ArrayList list = new ArrayList();
+            
+            list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
+            list.add(new QName(WSConstants.WSSE_NS, WSConstants.BINARY_TOKEN_LN));
+            list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
+            list.add(new QName(ConversationConstants.WSC_NS_05_02, ConversationConstants.DERIVED_KEY_TOKEN_LN));
+            list.add(new QName(WSConstants.ENC_NS, WSConstants.REF_LIST_LN));
+            list.add(new QName(ConversationConstants.WSC_NS_05_02, ConversationConstants.DERIVED_KEY_TOKEN_LN));
+            list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
+            
+            this.verifySecHeader(list.iterator(), ctx.getEnvelope());
+            
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());
@@ -110,7 +149,17 @@
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
             
-            System.out.println(ctx.getEnvelope());
+            ArrayList list = new ArrayList();
+            
+            list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
+            list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
+            list.add(new QName(ConversationConstants.WSC_NS_05_02, ConversationConstants.DERIVED_KEY_TOKEN_LN));
+            list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
+            list.add(new QName(ConversationConstants.WSC_NS_05_02, ConversationConstants.DERIVED_KEY_TOKEN_LN));
+            list.add(new QName(WSConstants.ENC_NS, WSConstants.REF_LIST_LN));
+             
+            this.verifySecHeader(list.iterator(), ctx.getEnvelope());
+            
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());
@@ -130,7 +179,14 @@
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
             
-            System.out.println(ctx.getEnvelope());
+            ArrayList list = new ArrayList();
+            
+            list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
+            list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
+            list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
+            list.add(new QName(WSConstants.ENC_NS, WSConstants.REF_LIST_LN));
+             
+            this.verifySecHeader(list.iterator(), ctx.getEnvelope());
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());

Modified: webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTestBase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTestBase.java?view=diff&rev=448555&r1=448554&r2=448555
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTestBase.java
(original)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTestBase.java
Thu Sep 21 07:07:37 2006
@@ -16,7 +16,9 @@
 
 package org.apache.rampart;
 
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
@@ -24,6 +26,7 @@
 import org.apache.axis2.description.OutInAxisOperation;
 import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyEngine;
+import org.apache.ws.security.WSConstants;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.FactoryConfigurationError;
@@ -32,6 +35,8 @@
 import javax.xml.stream.XMLStreamReader;
 
 import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
 
 import junit.framework.TestCase;
 
@@ -49,11 +54,6 @@
         super(arg0);
     }
 
-    
-    
-
-
-
     /**
      * @throws XMLStreamException
      * @throws FactoryConfigurationError
@@ -72,6 +72,29 @@
     protected Policy loadPolicy(String xmlPath) throws Exception {
         StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
         return PolicyEngine.getPolicy(builder.getDocumentElement());
+    }
+    
+    protected void verifySecHeader(Iterator qnameList, SOAPEnvelope env) {
+        Iterator secHeaderChildren = env.getHeader().getFirstChildWithName(
+                new QName(WSConstants.WSSE_NS, 
+                        WSConstants.WSSE_LN)).getChildElements();
+        
+        while (secHeaderChildren.hasNext()) {
+            OMElement  element = (OMElement ) secHeaderChildren.next();
+            if(qnameList.hasNext()) {
+                if(!element.getQName().equals(qnameList.next())) {
+                    fail("Incorrect Element" + element);
+                } 
+            } else {
+                fail("Extra child in the security header: " + element.toString());
+            }
+        }
+        
+        if(qnameList.hasNext()) {
+            fail("Incorrect number of children in the security header: " +
+                    "next expected element"
+                    + ((QName) qnameList.next()).toString());
+        }
     }
     
 }

Modified: webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/TransportBindingBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/TransportBindingBuilderTest.java?view=diff&rev=448555&r1=448554&r2=448555
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/TransportBindingBuilderTest.java
(original)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/TransportBindingBuilderTest.java
Thu Sep 21 07:07:37 2006
@@ -99,5 +99,7 @@
             fail(e.getMessage());
         }
     }
+
+    
     
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message