You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2012/04/30 15:19:16 UTC

svn commit: r1332185 - /cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java

Author: coheigea
Date: Mon Apr 30 13:19:16 2012
New Revision: 1332185

URL: http://svn.apache.org/viewvc?rev=1332185&view=rev
Log:
[CXF-4277] - STSClient does not use returned KeyInfo size when creating a secret key

Modified:
    cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java

Modified: cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java?rev=1332185&r1=1332184&r2=1332185&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java (original)
+++ cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java Mon Apr 30 13:19:16 2012
@@ -1091,6 +1091,7 @@ public class STSClient implements Config
         Element lte = null;
         Element entropy = null;
         String tt = null;
+        String retKeySize = null;
 
         while (el != null) {
             String ln = el.getLocalName();
@@ -1109,6 +1110,8 @@ public class STSClient implements Config
                     entropy = el;
                 } else if ("TokenType".equals(ln)) {
                     tt = DOMUtils.getContent(el);
+                } else if ("KeySize".equals(ln)) {
+                    retKeySize = DOMUtils.getContent(el);
                 }
             }
             el = DOMUtils.getNextElement(el);
@@ -1154,9 +1157,18 @@ public class STSClient implements Config
                     // Right now we only use PSHA1 as the computed key algo
                     P_SHA1 psha1 = new P_SHA1();
 
-                    int length = (keySize > 0) ? keySize : 256;
-                    if (algorithmSuite != null) {
-                        length = (keySize > 0) ? keySize : algorithmSuite.getMaximumSymmetricKeyLength();
+                    int length = 0;
+                    if (retKeySize != null) {
+                        try {
+                            length = Integer.parseInt(retKeySize);
+                        } catch (NumberFormatException ex) {
+                            // do nothing
+                        }
+                    } else {
+                        length = keySize;
+                    }
+                    if (length <= 0) {
+                        length = 256;
                     }
                     try {
                         secret = psha1.createKey(requestorEntropy, serviceEntr, 0, length / 8);