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 2013/12/09 16:52:34 UTC

svn commit: r1549599 - in /webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output: EncryptOutputProcessor.java WSSSignatureOutputProcessor.java

Author: coheigea
Date: Mon Dec  9 15:52:33 2013
New Revision: 1549599

URL: http://svn.apache.org/r1549599
Log:
Try to find a secure part by Id first. Required for a use-case of signing/encrypting two BinarySecurityTokens (Kerberos SignedSupportingToken + Asymmetric ProtectTokens)

Modified:
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java?rev=1549599&r1=1549598&r2=1549599&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java Mon Dec  9 15:52:33 2013
@@ -128,6 +128,43 @@ public class EncryptOutputProcessor exte
 
         outputProcessorChain.processEvent(xmlSecEvent);
     }
+    
+    @Override
+    protected SecurePart securePartMatches(XMLSecStartElement xmlSecStartElement, Map<Object, SecurePart> secureParts) {
+    
+        if (xmlSecStartElement.getOnElementDeclaredAttributes().size() >= 0) {
+            Attribute attribute = xmlSecStartElement.getAttributeByName(WSSConstants.ATT_wsu_Id);
+            if (attribute != null) {
+                SecurePart securePart = secureParts.get(attribute.getValue());
+                if (securePart != null) {
+                    return securePart;
+                }
+            }
+            attribute = xmlSecStartElement.getAttributeByName(WSSConstants.ATT_NULL_Id);
+            if (attribute != null) {
+                SecurePart securePart = secureParts.get(attribute.getValue());
+                if (securePart != null) {
+                    return securePart;
+                }
+            }
+            attribute = xmlSecStartElement.getAttributeByName(WSSConstants.ATT_NULL_ID);
+            if (attribute != null) {
+                SecurePart securePart = secureParts.get(attribute.getValue());
+                if (securePart != null) {
+                    return securePart;
+                }
+            }
+            attribute = xmlSecStartElement.getAttributeByName(WSSConstants.ATT_NULL_AssertionID);
+            if (attribute != null) {
+                SecurePart securePart = secureParts.get(attribute.getValue());
+                if (securePart != null) {
+                    return securePart;
+                }
+            }
+        }
+        
+        return secureParts.get(xmlSecStartElement.getName());
+    }
 
     @Override
     public void doFinalInternal(OutputProcessorChain outputProcessorChain) throws XMLSecurityException {

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java?rev=1549599&r1=1549598&r2=1549599&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java Mon Dec  9 15:52:33 2013
@@ -250,41 +250,39 @@ public class WSSSignatureOutputProcessor
 
     @Override
     protected SecurePart securePartMatches(XMLSecStartElement xmlSecStartElement, Map<Object, SecurePart> secureParts) {
-        SecurePart securePart = secureParts.get(xmlSecStartElement.getName());
-        if (securePart == null) {
-            if (xmlSecStartElement.getOnElementDeclaredAttributes().size() == 0) {
-                return null;
-            }
+    
+        if (xmlSecStartElement.getOnElementDeclaredAttributes().size() >= 0) {
             Attribute attribute = xmlSecStartElement.getAttributeByName(WSSConstants.ATT_wsu_Id);
             if (attribute != null) {
-                securePart = secureParts.get(attribute.getValue());
+                SecurePart securePart = secureParts.get(attribute.getValue());
                 if (securePart != null) {
                     return securePart;
                 }
             }
             attribute = xmlSecStartElement.getAttributeByName(WSSConstants.ATT_NULL_Id);
             if (attribute != null) {
-                securePart = secureParts.get(attribute.getValue());
+                SecurePart securePart = secureParts.get(attribute.getValue());
                 if (securePart != null) {
                     return securePart;
                 }
             }
             attribute = xmlSecStartElement.getAttributeByName(WSSConstants.ATT_NULL_ID);
             if (attribute != null) {
-                securePart = secureParts.get(attribute.getValue());
+                SecurePart securePart = secureParts.get(attribute.getValue());
                 if (securePart != null) {
                     return securePart;
                 }
             }
             attribute = xmlSecStartElement.getAttributeByName(WSSConstants.ATT_NULL_AssertionID);
             if (attribute != null) {
-                securePart = secureParts.get(attribute.getValue());
+                SecurePart securePart = secureParts.get(attribute.getValue());
                 if (securePart != null) {
                     return securePart;
                 }
             }
         }
-        return securePart;
+        
+        return secureParts.get(xmlSecStartElement.getName());
     }
 
     class InternalWSSSignatureOutputProcessor extends InternalSignatureOutputProcessor {