You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2006/09/21 07:56:17 UTC

svn commit: r448467 - in /webservices/axis2/trunk/java/modules/security: src/org/apache/rampart/builder/AsymmetricBindingBuilder.java test-resources/policy/rampart-asymm-binding-3-dk.xml test/org/apache/rampart/MessageBuilderTest.java

Author: ruchithf
Date: Wed Sep 20 22:56:16 2006
New Revision: 448467

URL: http://svn.apache.org/viewvc?view=rev&rev=448467
Log:
Added a test scenario to test asymm binding dk sig+encr

Added:
    webservices/axis2/trunk/java/modules/security/test-resources/policy/rampart-asymm-binding-3-dk.xml
Modified:
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/AsymmetricBindingBuilder.java
    webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTest.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=448467&r1=448466&r2=448467
==============================================================================
--- 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 Wed Sep 20 22:56:16 2006
@@ -301,7 +301,7 @@
                     sgndEndSuppTokens);
 
             // Setup signature parts
-            sigParts = addSignatureParts(sigSuppTokMap, rpd.getSignedParts());
+            sigParts = addSignatureParts(sigSuppTokMap, sigParts);
             sigParts = addSignatureParts(sgndEndSuppTokMap, sigParts);
         } else {
             // TODO: Add sig confirmation
@@ -345,6 +345,7 @@
                     }
                     
                     dkEncr.setExternalKey(encrKey.getEphemeralKey(), encrKey.getId());
+                    dkEncr.prepare(doc);
                     Element encrDKTokenElem = null;
                     encrDKTokenElem = dkEncr.getdktElement();
                     RampartUtil.insertSiblingAfter(rmd, this.encrTokenElement, encrDKTokenElem);
@@ -412,7 +413,6 @@
         Document doc = rmd.getDocument();
 
         sigToken = rpd.getInitiatorToken();
-        this.sigParts = RampartUtil.getSignedParts(rmd);
 
         if (sigToken.isDerivedKeys()) {
             // Set up the encrypted key to use
@@ -498,7 +498,7 @@
      */
     private void setupEncryptedKey(RampartMessageData rmd) throws RampartException {
         encrKey = this.getEncryptedKeyBuilder(rmd, sigToken);
-
+        
         Element bstElem = encrKey.getBinarySecurityTokenElement();
         if (bstElem != null) {
             // If a BST is available then use it
@@ -506,12 +506,9 @@
                     this.getInsertionLocation(), bstElem));
         }
 
-        if (Constants.INCLUDE_ALWAYS.equals(sigToken.getInclusion())
-                || Constants.INCLUDE_ONCE.equals(sigToken.getInclusion())) {
-            // Add the EncryptedKey
-            encrTokenElement = encrKey.getEncryptedKeyElement();
-            this.setInsertionLocation(RampartUtil.insertSiblingAfter(rmd,
-                    this.getInsertionLocation(), encrTokenElement));
-        }
+        // Add the EncryptedKey
+        this.encrTokenElement = encrKey.getEncryptedKeyElement();
+        this.setInsertionLocation(RampartUtil.insertSiblingAfter(rmd,
+                this.getInsertionLocation(), encrTokenElement));
     }
 }

Added: webservices/axis2/trunk/java/modules/security/test-resources/policy/rampart-asymm-binding-3-dk.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/test-resources/policy/rampart-asymm-binding-3-dk.xml?view=auto&rev=448467
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test-resources/policy/rampart-asymm-binding-3-dk.xml (added)
+++ webservices/axis2/trunk/java/modules/security/test-resources/policy/rampart-asymm-binding-3-dk.xml Wed Sep 20 22:56:16 2006
@@ -0,0 +1,77 @@
+<wsp:Policy  wsu:Id="6" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+	<wsp:ExactlyOne>
+		<wsp:All>
+			<sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+				<wsp:Policy>
+					<sp:InitiatorToken>
+						<wsp:Policy>
+							<sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+								<wsp:Policy>
+									<sp:WssX509V3Token10/>
+									<sp:RequireDerivedKeys />
+								</wsp:Policy>
+							</sp:X509Token>
+						</wsp:Policy>
+					</sp:InitiatorToken>
+					<sp:RecipientToken>
+						<wsp:Policy>
+							<sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+								<wsp:Policy>
+									<sp:WssX509V3Token10/>
+									<sp:RequireDerivedKeys />
+								</wsp:Policy>
+							</sp:X509Token>
+						</wsp:Policy>
+					</sp:RecipientToken>
+					<sp:AlgorithmSuite>
+						<wsp:Policy>
+							<sp:Basic256/>
+						</wsp:Policy>
+					</sp:AlgorithmSuite>
+					<sp:Layout>
+						<wsp:Policy>
+							<sp:Lax/>
+						</wsp:Policy>
+					</sp:Layout>
+					<sp:IncludeTimestamp/>
+					<sp:OnlySignEntireHeadersAndBody/>
+				</wsp:Policy>
+			</sp:AsymmetricBinding>
+			<sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+				<wsp:Policy>
+					<sp:MustSupportRefKeyIdentifier/>
+					<sp:MustSupportRefIssuerSerial/>
+				</wsp:Policy>
+			</sp:Wss10>
+			<sp:Trust10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+				<wsp:Policy>
+					<sp:MustSupportIssuedTokens/>
+					<sp:RequireClientEntropy/>
+					<sp:RequireServerEntropy/>
+				</wsp:Policy>
+			</sp:Trust10>
+			
+			<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> 
+				<ramp:user>alice</ramp:user>
+				<ramp:encryptionUser>bob</ramp:encryptionUser>
+				<ramp:passwordCallbackClass>org.apache.rampart.TestCBHandler</ramp:passwordCallbackClass>
+				
+				<ramp:signatureCrypto>
+					<ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
+						<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
+						<ramp:property name="org.apache.ws.security.crypto.merlin.file">interop/interop2.jks</ramp:property>
+						<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">password</ramp:property>
+					</ramp:crypto>
+				</ramp:signatureCrypto>
+				<ramp:encryptionCypto>
+					<ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
+						<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
+						<ramp:property name="org.apache.ws.security.crypto.merlin.file">interop/interop2.jks</ramp:property>
+						<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">password</ramp:property>
+					</ramp:crypto>
+				</ramp:encryptionCypto>
+			</ramp:RampartConfig>
+	
+		</wsp:All>
+	</wsp:ExactlyOne>
+</wsp:Policy>

Modified: webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTest.java?view=diff&rev=448467&r1=448466&r2=448467
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTest.java (original)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTest.java Wed Sep 20 22:56:16 2006
@@ -170,11 +170,30 @@
         }
     }
     
-    public void testAsymmBindingWithDK() {
+    public void testAsymmBindingWithSigDK() {
         try {
             MessageContext ctx = getMsgCtx();
             
             String policyXml = "test-resources/policy/rampart-asymm-binding-2-sig-dk.xml";
+            Policy policy = this.loadPolicy(policyXml);
+            
+            ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
+            
+            MessageBuilder builder = new MessageBuilder();
+            builder.build(ctx);
+            
+            System.out.println(ctx.getEnvelope());
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+    
+    public void testAsymmBindingWithDK() {
+        try {
+            MessageContext ctx = getMsgCtx();
+            
+            String policyXml = "test-resources/policy/rampart-asymm-binding-3-dk.xml";
             Policy policy = this.loadPolicy(policyXml);
             
             ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);



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