You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2019/02/04 11:56:13 UTC

svn commit: r1852904 - in /webservices/wss4j/trunk: ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/ ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/ ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/

Author: coheigea
Date: Mon Feb  4 11:56:13 2019
New Revision: 1852904

URL: http://svn.apache.org/viewvc?rev=1852904&view=rev
Log:
Some changes to list iteration

Modified:
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/RequestData.java
    webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyUtils.java
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SecurityHeaderOutputProcessor.java

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/RequestData.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/RequestData.java?rev=1852904&r1=1852903&r2=1852904&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/RequestData.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/RequestData.java Mon Feb  4 11:56:13 2019
@@ -22,7 +22,6 @@ package org.apache.wss4j.dom.handler;
 import java.security.cert.Certificate;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -497,10 +496,6 @@ public class RequestData {
         ignoredBSPRules.addAll(bspRules);
     }
 
-    public List<BSPRule> getIgnoredBSPRules() {
-        return Collections.unmodifiableList(ignoredBSPRules);
-    }
-
     public BSPEnforcer getBSPEnforcer() {
         if (disableBSPEnforcement) {
             return new BSPEnforcer(true);

Modified: webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyUtils.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyUtils.java?rev=1852904&r1=1852903&r2=1852904&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyUtils.java (original)
+++ webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyUtils.java Mon Feb  4 11:56:13 2019
@@ -21,7 +21,7 @@ package org.apache.wss4j.policy.stax;
 import org.apache.wss4j.policy.model.XPath;
 
 import javax.xml.namespace.QName;
-import java.util.LinkedList;
+import java.util.ArrayList;
 import java.util.List;
 
 public final class PolicyUtils {
@@ -31,7 +31,7 @@ public final class PolicyUtils {
     }
 
     public static List<QName> getElementPath(XPath xPath) {
-        List<QName> elements = new LinkedList<>();
+        List<QName> elements = new ArrayList<>();
         String[] xPathElements = xPath.getXPath().split("/");
         for (int j = 0; j < xPathElements.length; j++) {
             String xPathElement = xPathElements[j];

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SecurityHeaderOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SecurityHeaderOutputProcessor.java?rev=1852904&r1=1852903&r2=1852904&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SecurityHeaderOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SecurityHeaderOutputProcessor.java Mon Feb  4 11:56:13 2019
@@ -66,14 +66,9 @@ public class SecurityHeaderOutputProcess
                     //set correct namespace on secure parts
                     List<SecurePart> encryptionParts = securityProperties.getEncryptionSecureParts();
                     if (!encryptionParts.isEmpty()) {
-                        for (int i = 0; i < encryptionParts.size(); i++) {
-                            SecurePart securePart = encryptionParts.get(i);
+                        for (SecurePart securePart : encryptionParts) {
                             // Check to see if the wrong SOAP NS was used
-                            SecurePart convertedPart = convertSecurePart(securePart, soapMessageVersion);
-                            if (securePart != convertedPart) {
-                                securePart = convertedPart;
-                                encryptionParts.set(i, securePart);
-                            }
+                            changeSOAPNamespace(securePart, soapMessageVersion);
 
                             if (securePart.getIdToSign() == null) {
                                 outputProcessorChain.getSecurityContext().putAsMap(
@@ -92,14 +87,9 @@ public class SecurityHeaderOutputProcess
                     }
                     List<SecurePart> signatureParts = securityProperties.getSignatureSecureParts();
                     if (!signatureParts.isEmpty()) {
-                        for (int i = 0; i < signatureParts.size(); i++) {
-                            SecurePart securePart = signatureParts.get(i);
+                        for (SecurePart securePart : signatureParts) {
                             // Check to see if the wrong SOAP NS was used
-                            SecurePart convertedPart = convertSecurePart(securePart, soapMessageVersion);
-                            if (securePart != convertedPart) {
-                                securePart = convertedPart;
-                                signatureParts.set(i, securePart);
-                            }
+                            changeSOAPNamespace(securePart, soapMessageVersion);
 
                             if (securePart.getIdToSign() == null) {
                                 outputProcessorChain.getSecurityContext().putAsMap(
@@ -168,33 +158,23 @@ public class SecurityHeaderOutputProcess
         }
     }
 
-    private SecurePart convertSecurePart(SecurePart securePart, String soapVersion) {
+    private void changeSOAPNamespace(SecurePart securePart, String soapVersion) {
         final QName secureName = securePart.getName();
-        if (secureName == null) {
-            return securePart;
-        }
-
-        QName newName = secureName;
+        if (secureName != null) {
+            QName newName = secureName;
 
-        if (WSSConstants.NS_SOAP11.equals(secureName.getNamespaceURI())
-            && WSSConstants.NS_SOAP12.equals(soapVersion)) {
-            newName = new QName(soapVersion, secureName.getLocalPart(), secureName.getPrefix());
-        } else if (WSSConstants.NS_SOAP12.equals(secureName.getNamespaceURI())
-            && WSSConstants.NS_SOAP11.equals(soapVersion)) {
-            newName = new QName(soapVersion, secureName.getLocalPart(), secureName.getPrefix());
+            if (WSSConstants.NS_SOAP11.equals(secureName.getNamespaceURI())
+                && WSSConstants.NS_SOAP12.equals(soapVersion)) {
+                newName = new QName(soapVersion, secureName.getLocalPart(), secureName.getPrefix());
+            } else if (WSSConstants.NS_SOAP12.equals(secureName.getNamespaceURI())
+                && WSSConstants.NS_SOAP11.equals(soapVersion)) {
+                newName = new QName(soapVersion, secureName.getLocalPart(), secureName.getPrefix());
+            }
+
+            if (!secureName.equals(newName)) {
+                securePart.setName(newName);
+            }
         }
-
-        if (!secureName.equals(newName)) {
-            SecurePart newPart =
-                new SecurePart(newName, securePart.isGenerateXPointer(), securePart.getModifier(),
-                               securePart.getTransforms(), securePart.getDigestMethod());
-            newPart.setExternalReference(securePart.getExternalReference());
-            newPart.setIdToReference(securePart.getIdToReference());
-            newPart.setIdToSign(securePart.getIdToSign());
-            return newPart;
-        }
-
-        return securePart;
     }
 
     private void buildSecurityHeader(