ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1661915 - in /webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom: WSSecurityEngine.java util/WSSecurityUtil.java
Date Tue, 24 Feb 2015 12:17:10 GMT
Author: coheigea
Date: Tue Feb 24 12:17:10 2015
New Revision: 1661915

URL: http://svn.apache.org/r1661915
Log:
Optimisation to allow for the case when we already have the SOAP header

Modified:
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSSecurityEngine.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSSecurityEngine.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSSecurityEngine.java?rev=1661915&r1=1661914&r2=1661915&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSSecurityEngine.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSSecurityEngine.java
Tue Feb 24 12:17:10 2015
@@ -20,6 +20,7 @@
 package org.apache.wss4j.dom;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import javax.security.auth.callback.CallbackHandler;
@@ -383,9 +384,8 @@ public class WSSecurityEngine {
         Element securityHeader,
         RequestData requestData
     ) throws WSSecurityException {
-        List<WSSecurityEngineResult> returnResults = new ArrayList<>();
         if (securityHeader == null) {
-            return returnResults;
+            return Collections.emptyList();
         }
     
         if (requestData.getWssConfig() == null) {
@@ -405,6 +405,7 @@ public class WSSecurityEngine {
         final WSSConfig cfg = getWssConfig();
         Node node = securityHeader.getFirstChild();
         
+        List<WSSecurityEngineResult> returnResults = new ArrayList<>();
         boolean foundTimestamp = false;
         while (node != null) {
             Node nextSibling = node.getNextSibling();

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java?rev=1661915&r1=1661914&r2=1661915&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java
Tue Feb 24 12:17:10 2015
@@ -92,9 +92,20 @@ public final class WSSecurityUtil {
             return null;
         }
         
+        return getSecurityHeader(soapHeaderElement, actor, WSConstants.URI_SOAP12_ENV.equals(soapNamespace));
+    }
+    
+    /**
+     * Returns the first WS-Security header element for a given actor. Only one
+     * WS-Security header is allowed for an actor.
+     */
+    public static Element getSecurityHeader(Element soapHeader, String actor, boolean soap12)
throws WSSecurityException {
+        
         String actorLocal = WSConstants.ATTR_ACTOR;
-        if (WSConstants.URI_SOAP12_ENV.equals(soapNamespace)) {
+        String soapNamespace = WSConstants.URI_SOAP11_ENV;
+        if (soap12) {
             actorLocal = WSConstants.ATTR_ROLE;
+            soapNamespace = WSConstants.URI_SOAP12_ENV;
         }
         
         //
@@ -102,7 +113,7 @@ public final class WSSecurityUtil {
         //
         Element foundSecurityHeader = null;
         for (
-            Node currentChild = soapHeaderElement.getFirstChild(); 
+            Node currentChild = soapHeader.getFirstChild(); 
             currentChild != null; 
             currentChild = currentChild.getNextSibling()
         ) {



Mime
View raw message