Author: coheigea
Date: Wed Jun 13 13:10:54 2012
New Revision: 1349825

URL: http://svn.apache.org/viewvc?rev=1349825&view=rev
Log:
[CXF-4376] - STS encryptIssuedToken with the SymmetricKey KeyType does not work

Modified:
    
cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
    cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-encrypted-ut.xml
    
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/SymmetricBindingTest.java
    
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-encrypted-ut.xml
    
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/DoubleIt.wsdl
    
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-client.xml
    
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-service.xml

Modified: 
cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java?rev=1349825&r1=1349824&r2=1349825&view=diff
==============================================================================
--- 
cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
 (original)
+++ 
cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
 Wed Jun 13 13:10:54 2012
@@ -306,8 +306,7 @@ public class TokenIssueOperation extends
     }
 
     /**
-     * Construct a token containing the secret to return to the client. If 
encryptIssuedToken is set
-     * then the token is wrapped in an EncryptedKey DOM element, otherwise it 
is returned in a 
+     * Construct a token containing the secret to return to the client. The 
secret is returned in a 
      * BinarySecretType JAXBElement.
      */
     private Object constructSecretToken(
@@ -315,17 +314,17 @@ public class TokenIssueOperation extends
             EncryptionProperties encryptionProperties, 
             KeyRequirements keyRequirements
     ) throws WSSecurityException {
-        if (encryptIssuedToken) {
+        /*if (encryptIssuedToken) {
             return encryptSecret(secret, encryptionProperties, 
keyRequirements);
         } else {
-            BinarySecretType binarySecretType = 
QNameConstants.WS_TRUST_FACTORY.createBinarySecretType();
-            String nonce = 
"http://docs.oasis-open.org/ws-sx/ws-trust/200512/Nonce";;
-            binarySecretType.setType(nonce);
-            binarySecretType.setValue(secret);
-            JAXBElement<BinarySecretType> binarySecret = 
+        */
+        BinarySecretType binarySecretType = 
QNameConstants.WS_TRUST_FACTORY.createBinarySecretType();
+        String nonce = 
"http://docs.oasis-open.org/ws-sx/ws-trust/200512/Nonce";;
+        binarySecretType.setType(nonce);
+        binarySecretType.setValue(secret);
+        JAXBElement<BinarySecretType> binarySecret = 
                 
QNameConstants.WS_TRUST_FACTORY.createBinarySecret(binarySecretType);
-            return binarySecret;
-        }
+        return binarySecret;
     }
 
 }

Modified: 
cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-encrypted-ut.xml
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-encrypted-ut.xml?rev=1349825&r1=1349824&r2=1349825&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-encrypted-ut.xml 
(original)
+++ cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-encrypted-ut.xml 
Wed Jun 13 13:10:54 2012
@@ -51,7 +51,7 @@
        </bean>
 
        <util:list id="encryptedUtEndpoints">
-               
<value>http://localhost:(\d)*/doubleit/services/doubleitasymmetricsaml1encrypted
+               
<value>http://localhost:(\d)*/doubleit/services/doubleit(a)?symmetricsaml1encrypted
                </value>
        </util:list>
        

Modified: 
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/SymmetricBindingTest.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/SymmetricBindingTest.java?rev=1349825&r1=1349824&r2=1349825&view=diff
==============================================================================
--- 
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/SymmetricBindingTest.java
 (original)
+++ 
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/SymmetricBindingTest.java
 Wed Jun 13 13:10:54 2012
@@ -130,6 +130,32 @@ public class SymmetricBindingTest extend
         
         bus.shutdown(true);
     }
+    
+    // TODO Re-enable this when we pick up WSS4J 1.6.7
+    @org.junit.Test
+    @org.junit.Ignore
+    public void testUsernameTokenSAML1Encrypted() throws Exception {
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = SymmetricBindingTest.class.getResource("cxf-client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = SymmetricBindingTest.class.getResource("DoubleIt.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, 
"DoubleItSymmetricSAML1EncryptedPort");
+        DoubleItPortType symmetricSaml1Port = 
+            service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(symmetricSaml1Port, PORT);
+        if (standalone) {
+            TokenTestUtils.updateSTSPort((BindingProvider)symmetricSaml1Port, 
STSPORT2);
+        }
+
+        doubleIt(symmetricSaml1Port, 25);
+
+        bus.shutdown(true);
+    }
 
     private static void doubleIt(DoubleItPortType port, int numToDouble) {
         int resp = port.doubleIt(numToDouble);

Modified: 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-encrypted-ut.xml
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-encrypted-ut.xml?rev=1349825&r1=1349824&r2=1349825&view=diff
==============================================================================
--- 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-encrypted-ut.xml
 (original)
+++ 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-encrypted-ut.xml
 Wed Jun 13 13:10:54 2012
@@ -53,7 +53,7 @@
        </bean>
 
        <util:list id="encryptedUtEndpoints">
-               
<value>http://localhost:(\d)*/doubleit/services/doubleitasymmetricsaml1encrypted
+               
<value>http://localhost:(\d)*/doubleit/services/doubleit(a)?symmetricsaml1encrypted
                </value>
        </util:list>
        

Modified: 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/DoubleIt.wsdl
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/DoubleIt.wsdl?rev=1349825&r1=1349824&r2=1349825&view=diff
==============================================================================
--- 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/DoubleIt.wsdl
 (original)
+++ 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/DoubleIt.wsdl
 Wed Jun 13 13:10:54 2012
@@ -70,6 +70,10 @@
                        <soap:address
                                
location="http://localhost:8082/doubleit/services/doubleitsymmetricsaml2"; />
                </wsdl:port>
+               <wsdl:port name="DoubleItSymmetricSAML1EncryptedPort" 
binding="tns:DoubleItSymmetricSAML1Binding">
+            <soap:address
+                
location="http://localhost:8082/doubleit/services/doubleitsymmetricsaml1encrypted";
 />
+        </wsdl:port>
        </wsdl:service>
        
        <wsp:Policy wsu:Id="DoubleItSymmetricBindingSAML1Policy">

Modified: 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-client.xml
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-client.xml?rev=1349825&r1=1349824&r2=1349825&view=diff
==============================================================================
--- 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-client.xml
 (original)
+++ 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-client.xml
 Wed Jun 13 13:10:54 2012
@@ -89,5 +89,32 @@ http://cxf.apache.org/configuration/secu
        </jaxws:properties>
    </jaxws:client>
    
+   <jaxws:client 
name="{http://www.example.org/contract/DoubleIt}DoubleItSymmetricSAML1EncryptedPort";
 
+                  createdFromAPI="true">
+       <jaxws:properties>
+           <entry key="ws-security.sts.client">
+               <bean class="org.apache.cxf.ws.security.trust.STSClient">
+                   <constructor-arg ref="cxf"/>
+                   <property name="wsdlLocation" 
+                             
value="http://localhost:8080/SecurityTokenService/UTEncrypted?wsdl"/>
+                   <property name="serviceName" 
+                             
value="{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService"/>
+                   <property name="endpointName" 
+                             
value="{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}UTEncrypted_Port"/>
+                   <property name="properties">
+                       <map>
+                           <entry key="ws-security.username" value="alice"/>
+                           <entry key="ws-security.callback-handler" 
+                                  
value="org.apache.cxf.systest.sts.common.CommonCallbackHandler"/>
+                           <entry key="ws-security.encryption.properties" 
value="clientKeystore.properties"/> 
+                           <entry key="ws-security.encryption.username" 
value="mystskey"/>
+                           <entry key="ws-security.is-bsp-compliant" 
value="false"/>
+                       </map>
+                   </property>
+               </bean>            
+           </entry> 
+       </jaxws:properties>
+   </jaxws:client>
+   
 </beans>
 

Modified: 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-service.xml
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-service.xml?rev=1349825&r1=1349824&r2=1349825&view=diff
==============================================================================
--- 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-service.xml
 (original)
+++ 
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-service.xml
 Wed Jun 13 13:10:54 2012
@@ -71,5 +71,21 @@
       </jaxws:properties> 
    </jaxws:endpoint>
    
+   <jaxws:endpoint id="doubleitsymmetricsaml1encrypted"
+      implementor="org.apache.cxf.systest.sts.common.DoubleItPortTypeImpl"
+      endpointName="s:DoubleItSymmetricSAML1EncryptedPort"
+      serviceName="s:DoubleItService"
+      
address="http://localhost:${testutil.ports.Server}/doubleit/services/doubleitsymmetricsaml1encrypted";
+      wsdlLocation="org/apache/cxf/systest/sts/symmetric/DoubleIt.wsdl"
+      xmlns:s="http://www.example.org/contract/DoubleIt";>
+        
+      <jaxws:properties>
+         <entry key="ws-security.callback-handler" 
+                
value="org.apache.cxf.systest.sts.common.CommonCallbackHandler"/>
+         <entry key="ws-security.signature.properties" 
value="serviceKeystore.properties"/>
+         <entry key="ws-security.is-bsp-compliant" value="false"/>
+      </jaxws:properties> 
+   </jaxws:endpoint>
+   
 </beans>
 


Reply via email to