ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gi...@apache.org
Subject svn commit: r1337945 [2/5] - in /webservices/wss4j/branches/swssf: ./ cxf-integration/src/main/java/org/swssf/cxfIntegration/interceptor/ cxf-integration/src/test/java/org/swssf/cxfIntegration/test/integration/ cxf-integration/src/test/resources/ cxf-i...
Date Sun, 13 May 2012 17:27:13 GMT
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SecurityHeaderInputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SecurityHeaderInputProcessor.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SecurityHeaderInputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SecurityHeaderInputProcessor.java Sun May 13 17:27:10 2012
@@ -63,9 +63,11 @@ public class SecurityHeaderInputProcesso
     public XMLEvent processNextEvent(InputProcessorChain inputProcessorChain) throws XMLStreamException, XMLSecurityException {
 
         //buffer all events until the end of the security header
-        InputProcessorChain subInputProcessorChain = inputProcessorChain.createSubChain(this);
-        InternalSecurityHeaderBufferProcessor internalSecurityHeaderBufferProcessor = new InternalSecurityHeaderBufferProcessor(getSecurityProperties());
+        final InputProcessorChain subInputProcessorChain = inputProcessorChain.createSubChain(this);
+        final InternalSecurityHeaderBufferProcessor internalSecurityHeaderBufferProcessor
+                = new InternalSecurityHeaderBufferProcessor(getSecurityProperties());
         subInputProcessorChain.addProcessor(internalSecurityHeaderBufferProcessor);
+        final WSSDocumentContext documentContext = (WSSDocumentContext) subInputProcessorChain.getDocumentContext();
 
         boolean responsibleSecurityHeaderFound = false;
 
@@ -73,39 +75,38 @@ public class SecurityHeaderInputProcesso
         do {
             subInputProcessorChain.reset();
             xmlEvent = subInputProcessorChain.processHeaderEvent();
-
             eventCount++;
+            final int documentLevel = documentContext.getDocumentLevel();
 
             if (xmlEvent.isStartElement()) {
                 StartElement startElement = xmlEvent.asStartElement();
 
-                if (subInputProcessorChain.getDocumentContext().getDocumentLevel() == 1) {
-                    if (((WSSDocumentContext) subInputProcessorChain.getDocumentContext()).getSOAPMessageVersionNamespace() == null) {
+                if (documentLevel == 1) {
+                    if (documentContext.getSOAPMessageVersionNamespace() == null) {
                         throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "notASOAPMessage");
                     }
-                } else if (subInputProcessorChain.getDocumentContext().getDocumentLevel() == 3
-                        && ((WSSDocumentContext) subInputProcessorChain.getDocumentContext()).isInSOAPHeader()
+                } else if (documentLevel == 3
+                        && documentContext.isInSOAPHeader()
                         && startElement.getName().equals(WSSConstants.TAG_wsse_Security)) {
 
                     if (!WSSUtils.isResponsibleActorOrRole(startElement,
-                            ((WSSDocumentContext) subInputProcessorChain.getDocumentContext()).getSOAPMessageVersionNamespace(),
+                            documentContext.getSOAPMessageVersionNamespace(),
                             ((WSSSecurityProperties) getSecurityProperties()).getActor())) {
                         continue;
                     }
 
                     responsibleSecurityHeaderFound = true;
-
-                    ((WSSDocumentContext) subInputProcessorChain.getDocumentContext()).setInSecurityHeader(true);
+                    documentContext.setInSecurityHeader(true);
                     //minus one because the first event will be deqeued when finished security header. @see below
                     countOfEventsToResponsibleSecurityHeader = eventCount - 1;
 
-                } else if (subInputProcessorChain.getDocumentContext().getDocumentLevel() == 4
-                        && ((WSSDocumentContext) subInputProcessorChain.getDocumentContext()).isInSecurityHeader()) {
+                } else if (documentLevel == 4
+                        && documentContext.isInSecurityHeader()) {
                     startIndexForProcessor = eventCount - 1;
                 }
             } else if (xmlEvent.isEndElement()) {
                 EndElement endElement = xmlEvent.asEndElement();
-                if (responsibleSecurityHeaderFound && subInputProcessorChain.getDocumentContext().getDocumentLevel() == 2
+                if (responsibleSecurityHeaderFound && documentLevel == 2
                         && endElement.getName().equals(WSSConstants.TAG_wsse_Security)) {
 
                     //subInputProcessorChain.getDocumentContext().setInSecurityHeader(false);
@@ -127,8 +128,8 @@ public class SecurityHeaderInputProcesso
 
                     //return first event now;
                     return xmlEventList.pollLast();
-                } else if (subInputProcessorChain.getDocumentContext().getDocumentLevel() == 3
-                        && ((WSSDocumentContext) subInputProcessorChain.getDocumentContext()).isInSecurityHeader()) {
+                } else if (documentLevel == 3
+                        && documentContext.isInSecurityHeader()) {
                     //we are in the security header and the depth is +1, so every child
                     //element should have a responsible handler:
                     engageSecurityHeaderHandler(subInputProcessorChain, getSecurityProperties(),
@@ -139,7 +140,7 @@ public class SecurityHeaderInputProcesso
         } while (!(xmlEvent.isStartElement()
                 && xmlEvent.asStartElement().getName().getLocalPart().equals(WSSConstants.TAG_soap_Body_LocalName)
                 && xmlEvent.asStartElement().getName().getNamespaceURI().equals(
-                ((WSSDocumentContext) subInputProcessorChain.getDocumentContext()).getSOAPMessageVersionNamespace())
+                documentContext.getSOAPMessageVersionNamespace())
         ));
         //if we reach this state we didn't find a security header
         throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "missingSecurityHeader");
@@ -178,7 +179,7 @@ public class SecurityHeaderInputProcesso
         InternalSecurityHeaderBufferProcessor(XMLSecurityProperties securityProperties) {
             super(securityProperties);
             setPhase(WSSConstants.Phase.POSTPROCESSING);
-            getBeforeProcessors().add(SecurityHeaderInputProcessor.class.getName());
+            addBeforeProcessor(SecurityHeaderInputProcessor.class.getName());
         }
 
         @Override
@@ -207,8 +208,8 @@ public class SecurityHeaderInputProcesso
         public InternalSecurityHeaderReplayProcessor(XMLSecurityProperties securityProperties, int countOfEventsToResponsibleSecurityHeader, int countOfEventsUntilEndOfResponsibleSecurityHeader) {
             super(securityProperties);
             setPhase(WSSConstants.Phase.PREPROCESSING);
-            getBeforeProcessors().add(SecurityHeaderInputProcessor.class.getName());
-            getAfterProcessors().add(XMLEventReaderInputProcessor.class.getName());
+            addBeforeProcessor(SecurityHeaderInputProcessor.class.getName());
+            addAfterProcessor(XMLEventReaderInputProcessor.class.getName());
             this.countOfEventsToResponsibleSecurityHeader = countOfEventsToResponsibleSecurityHeader;
             this.countOfEventsUntilEndOfResponsibleSecurityHeader = countOfEventsUntilEndOfResponsibleSecurityHeader;
         }
@@ -224,18 +225,18 @@ public class SecurityHeaderInputProcesso
             if (!xmlEventList.isEmpty()) {
                 eventCount++;
 
+                final WSSDocumentContext documentContext = (WSSDocumentContext) inputProcessorChain.getDocumentContext();
                 if (eventCount == countOfEventsToResponsibleSecurityHeader) {
-                    ((WSSDocumentContext) inputProcessorChain.getDocumentContext()).setInSecurityHeader(true);
-                }
-                if (eventCount == countOfEventsUntilEndOfResponsibleSecurityHeader) {
-                    ((WSSDocumentContext) inputProcessorChain.getDocumentContext()).setInSecurityHeader(false);
+                    documentContext.setInSecurityHeader(true);
+                } else if (eventCount == countOfEventsUntilEndOfResponsibleSecurityHeader) {
+                    documentContext.setInSecurityHeader(false);
                 }
 
                 XMLEvent xmlEvent = xmlEventList.pollLast();
                 if (xmlEvent.isStartElement()) {
-                    inputProcessorChain.getDocumentContext().addPathElement(xmlEvent.asStartElement().getName());
+                    documentContext.addPathElement(xmlEvent.asStartElement().getName());
                 } else if (xmlEvent.isEndElement()) {
-                    inputProcessorChain.getDocumentContext().removePathElement();
+                    documentContext.removePathElement();
                 }
                 return xmlEvent;
 

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SignatureInputHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SignatureInputHandler.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SignatureInputHandler.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SignatureInputHandler.java Sun May 13 17:27:10 2012
@@ -45,8 +45,8 @@ import java.util.List;
 public class SignatureInputHandler extends AbstractSignatureInputHandler {
 
     @Override
-    protected SignatureVerifier newSignatureVerifier(InputProcessorChain inputProcessorChain,
-                                                     XMLSecurityProperties securityProperties,
+    protected SignatureVerifier newSignatureVerifier(final InputProcessorChain inputProcessorChain,
+                                                     final XMLSecurityProperties securityProperties,
                                                      final SignatureType signatureType) throws XMLSecurityException {
         if (signatureType.getSignedInfo() == null) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY);
@@ -66,7 +66,7 @@ public class SignatureInputHandler exten
         checkBSPCompliance(inputProcessorChain, signatureType);
 
         final WSSecurityContext securityContext = (WSSecurityContext) inputProcessorChain.getSecurityContext();
-        SignatureVerifier signatureVerifier = new SignatureVerifier(signatureType, inputProcessorChain.getSecurityContext(), securityProperties) {
+        final SignatureVerifier signatureVerifier = new SignatureVerifier(signatureType, inputProcessorChain.getSecurityContext(), securityProperties) {
             @Override
             protected void handleSecurityToken(SecurityToken securityToken) throws XMLSecurityException {
                 //we have to emit a TokenSecurityEvent here too since it could be an embedded token
@@ -91,26 +91,27 @@ public class SignatureInputHandler exten
 
     private void checkBSPCompliance(InputProcessorChain inputProcessorChain, SignatureType signatureType) throws WSSecurityException {
         String algorithm = signatureType.getSignedInfo().getSignatureMethod().getAlgorithm();
+        final WSSecurityContext securityContext = (WSSecurityContext) inputProcessorChain.getSecurityContext();
         if (!WSSConstants.NS_XMLDSIG_HMACSHA1.equals(algorithm) && !WSSConstants.NS_XMLDSIG_RSASHA1.equals(algorithm)) {
-            ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R5421);
+            securityContext.handleBSPRule(WSSConstants.BSPRule.R5421);
         }
         //todo test:
         BigInteger hmacOutputLength = XMLSecurityUtils.getQNameType(
                 signatureType.getSignedInfo().getSignatureMethod().getContent(),
                 WSSConstants.TAG_dsig_HMACOutputLength);
         if (hmacOutputLength != null) {
-            ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R5401);
+            securityContext.handleBSPRule(WSSConstants.BSPRule.R5401);
         }
 
         List<Object> keyInfoContent = signatureType.getKeyInfo().getContent();
         if (keyInfoContent.size() != 1) {
-            ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R5402);
+            securityContext.handleBSPRule(WSSConstants.BSPRule.R5402);
         }
 
         SecurityTokenReferenceType securityTokenReferenceType = XMLSecurityUtils.getQNameType(keyInfoContent,
                 WSSConstants.TAG_wsse_SecurityTokenReference);
         if (securityTokenReferenceType == null) {
-            ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R5417);
+            securityContext.handleBSPRule(WSSConstants.BSPRule.R5417);
         }
 
         Iterator<ObjectType> objectTypeIterator = signatureType.getObject().iterator();
@@ -118,27 +119,26 @@ public class SignatureInputHandler exten
             ObjectType objectType = objectTypeIterator.next();
             ManifestType manifestType = XMLSecurityUtils.getQNameType(objectType.getContent(), WSSConstants.TAG_dsig_Manifest);
             if (manifestType != null) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R5403);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R5403);
             }
         }
 
-
         CanonicalizationMethodType canonicalizationMethodType = signatureType.getSignedInfo().getCanonicalizationMethod();
         if (!WSSConstants.NS_C14N_EXCL.equals(canonicalizationMethodType.getAlgorithm())) {
-            ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R5404);
+            securityContext.handleBSPRule(WSSConstants.BSPRule.R5404);
         }
 
         InclusiveNamespaces inclusiveNamespacesType = XMLSecurityUtils.getQNameType(canonicalizationMethodType.getContent(),
                 WSSConstants.TAG_c14nExcl_InclusiveNamespaces);
         if (inclusiveNamespacesType != null && inclusiveNamespacesType.getPrefixList().size() == 0) {
-            ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R5406);
+            securityContext.handleBSPRule(WSSConstants.BSPRule.R5406);
         }
     }
 
     @Override
     protected void addSignatureReferenceInputProcessorToChain(InputProcessorChain inputProcessorChain,
                                                               XMLSecurityProperties securityProperties,
-                                                              SignatureType signatureType, SecurityToken securityToken) throws WSSecurityException {
+                                                              SignatureType signatureType, SecurityToken securityToken) throws XMLSecurityException {
         //add processors to verify references
         inputProcessorChain.addProcessor(
                 new SignatureReferenceVerifyInputProcessor(signatureType, securityToken, securityProperties,

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SignatureReferenceVerifyInputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SignatureReferenceVerifyInputProcessor.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SignatureReferenceVerifyInputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/SignatureReferenceVerifyInputProcessor.java Sun May 13 17:27:10 2012
@@ -45,7 +45,10 @@ import javax.xml.stream.events.XMLEvent;
 import java.lang.reflect.InvocationTargetException;
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchProviderException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author $Author$
@@ -68,9 +71,9 @@ public class SignatureReferenceVerifyInp
 
     public SignatureReferenceVerifyInputProcessor(
             SignatureType signatureType, SecurityToken securityToken,
-            XMLSecurityProperties securityProperties, WSSecurityContext securityContext) throws WSSecurityException {
+            XMLSecurityProperties securityProperties, WSSecurityContext securityContext) throws XMLSecurityException {
         super(signatureType, securityToken, securityProperties);
-        this.getAfterProcessors().add(SignatureReferenceVerifyInputProcessor.class.getName());
+        this.addAfterProcessor(SignatureReferenceVerifyInputProcessor.class.getName());
 
         checkBSPCompliance(securityContext);
     }
@@ -147,6 +150,7 @@ public class SignatureReferenceVerifyInp
         XMLEvent xmlEvent = inputProcessorChain.processEvent();
 
         if (xmlEvent.isStartElement()) {
+            final WSSDocumentContext documentContext = (WSSDocumentContext) inputProcessorChain.getDocumentContext();
             StartElement startElement = xmlEvent.asStartElement();
             ReferenceType referenceType = matchesReferenceId(startElement);
             if (referenceType != null) {
@@ -163,20 +167,20 @@ public class SignatureReferenceVerifyInp
                     inputProcessorChain.addProcessor(internalSignatureReferenceVerifier);
                 }
                 getProcessedReferences().add(referenceType);
-                inputProcessorChain.getDocumentContext().setIsInSignedContent(inputProcessorChain.getProcessors().indexOf(internalSignatureReferenceVerifier), internalSignatureReferenceVerifier);
+                documentContext.setIsInSignedContent(inputProcessorChain.getProcessors().indexOf(internalSignatureReferenceVerifier), internalSignatureReferenceVerifier);
 
                 //fire a SecurityEvent:
-                if (inputProcessorChain.getDocumentContext().getDocumentLevel() == 3
-                        && ((WSSDocumentContext) inputProcessorChain.getDocumentContext()).isInSOAPHeader()) {
+                if (documentContext.getDocumentLevel() == 3
+                        && documentContext.isInSOAPHeader()) {
                     SignedPartSecurityEvent signedPartSecurityEvent =
-                            new SignedPartSecurityEvent(getSecurityToken(), true, inputProcessorChain.getDocumentContext().getProtectionOrder());
-                    signedPartSecurityEvent.setElementPath(inputProcessorChain.getDocumentContext().getPath());
+                            new SignedPartSecurityEvent(getSecurityToken(), true, documentContext.getProtectionOrder());
+                    signedPartSecurityEvent.setElementPath(documentContext.getPath());
                     signedPartSecurityEvent.setXmlEvent(xmlEvent);
                     ((WSSecurityContext) inputProcessorChain.getSecurityContext()).registerSecurityEvent(signedPartSecurityEvent);
                 } else {
                     SignedElementSecurityEvent signedElementSecurityEvent =
-                            new SignedElementSecurityEvent(getSecurityToken(), true, inputProcessorChain.getDocumentContext().getProtectionOrder());
-                    signedElementSecurityEvent.setElementPath(inputProcessorChain.getDocumentContext().getPath());
+                            new SignedElementSecurityEvent(getSecurityToken(), true, documentContext.getProtectionOrder());
+                    signedElementSecurityEvent.setElementPath(documentContext.getPath());
                     signedElementSecurityEvent.setXmlEvent(xmlEvent);
                     ((WSSecurityContext) inputProcessorChain.getSecurityContext()).registerSecurityEvent(signedElementSecurityEvent);
                 }
@@ -196,7 +200,7 @@ public class SignatureReferenceVerifyInp
             }
             ElementAttributes elementAttributes = new ElementAttributes();
             if (timestampSecurityEvent.getExpires() != null) {
-                long lifeTime = timestampSecurityEvent.getExpires().getTime().getTime() - new Date().getTime();
+                long lifeTime = timestampSecurityEvent.getExpires().getTimeInMillis() - System.currentTimeMillis();
                 elementAttributes.setMaxLifeSeconds(lifeTime / 1000);
             } else {
                 elementAttributes.setMaxLifeSeconds(300);
@@ -223,7 +227,7 @@ public class SignatureReferenceVerifyInp
         InternalSignatureReferenceVerifier(WSSSecurityProperties securityProperties, InputProcessorChain inputProcessorChain,
                                            ReferenceType referenceType, QName startElement) throws XMLSecurityException {
             super(securityProperties, inputProcessorChain, referenceType, startElement);
-            this.getAfterProcessors().add(SignatureReferenceVerifyInputProcessor.class.getName());
+            this.addAfterProcessor(SignatureReferenceVerifyInputProcessor.class.getName());
         }
 
         protected AlgorithmType createMessageDigest(SecurityContext securityContext)
@@ -243,7 +247,7 @@ public class SignatureReferenceVerifyInp
             if (referenceType.getTransforms() == null || referenceType.getTransforms().getTransform().size() == 0) {
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_CHECK);
             }
-            List<TransformType> transformTypeList = (List<TransformType>) (List<?>) referenceType.getTransforms().getTransform();
+            List<TransformType> transformTypeList = referenceType.getTransforms().getTransform();
 
             String algorithm = null;
             Transformer parentTransformer = null;
@@ -261,7 +265,7 @@ public class SignatureReferenceVerifyInp
                         List<String> inclusiveNamespaces = inclusiveNamespacesType != null ? inclusiveNamespacesType.getPrefixList() : null;
                         if (WSSConstants.SOAPMESSAGE_NS10_STRTransform.equals(transformType.getAlgorithm())) {
                             if (inclusiveNamespaces == null) {
-                                inclusiveNamespaces = new ArrayList<String>();
+                                inclusiveNamespaces = new ArrayList<String>(1);
                             }
                             inclusiveNamespaces.add("#default");
                         }

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/TimestampInputHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/TimestampInputHandler.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/TimestampInputHandler.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/TimestampInputHandler.java Sun May 13 17:27:10 2012
@@ -27,9 +27,7 @@ import org.swssf.wss.securityEvent.Times
 import org.swssf.xmlsec.ext.*;
 
 import javax.xml.bind.JAXBElement;
-import javax.xml.datatype.DatatypeConfigurationException;
 import javax.xml.datatype.DatatypeConstants;
-import javax.xml.datatype.DatatypeFactory;
 import javax.xml.datatype.XMLGregorianCalendar;
 import javax.xml.stream.events.XMLEvent;
 import java.util.Calendar;
@@ -43,21 +41,13 @@ import java.util.Iterator;
  */
 public class TimestampInputHandler extends AbstractInputSecurityHeaderHandler {
 
-    private static final DatatypeFactory datatypeFactory;
-
-    static {
-        try {
-            datatypeFactory = DatatypeFactory.newInstance();
-        } catch (DatatypeConfigurationException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
     //Chapter 10 Security Timestamps: ...may only be present at most once per header (that is, per SOAP actor/role)
     @Override
     public void handle(final InputProcessorChain inputProcessorChain, final XMLSecurityProperties securityProperties,
                        Deque<XMLEvent> eventQueue, Integer index) throws XMLSecurityException {
 
+        final WSSSecurityProperties wssSecurityProperties = (WSSSecurityProperties) securityProperties;
+
         Boolean alreadyProcessed = inputProcessorChain.getSecurityContext().<Boolean>get(WSSConstants.TIMESTAMP_PROCESSED);
         if (Boolean.TRUE.equals(alreadyProcessed)) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, "invalidTimestamp",
@@ -80,7 +70,7 @@ public class TimestampInputHandler exten
             if (timestampType.getCreated() != null) {
                 XMLGregorianCalendar created;
                 try {
-                    created = datatypeFactory.newXMLGregorianCalendar(timestampType.getCreated().getValue());
+                    created = WSSConstants.datatypeFactory.newXMLGregorianCalendar(timestampType.getCreated().getValue());
                 } catch (IllegalArgumentException e) {
                     throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, e);
                 }
@@ -92,7 +82,7 @@ public class TimestampInputHandler exten
             if (timestampType.getExpires() != null) {
                 XMLGregorianCalendar expires;
                 try {
-                    expires = datatypeFactory.newXMLGregorianCalendar(timestampType.getExpires().getValue());
+                    expires = WSSConstants.datatypeFactory.newXMLGregorianCalendar(timestampType.getExpires().getValue());
                 } catch (IllegalArgumentException e) {
                     throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, e);
                 }
@@ -102,22 +92,22 @@ public class TimestampInputHandler exten
 
             Calendar rightNow = Calendar.getInstance();
             Calendar ttl = Calendar.getInstance();
-            ttl.add(Calendar.SECOND, -((WSSSecurityProperties) securityProperties).getTimestampTTL());
+            ttl.add(Calendar.SECOND, -wssSecurityProperties.getTimestampTTL());
 
-            if (exp != null && ((WSSSecurityProperties) securityProperties).isStrictTimestampCheck() && exp.before(rightNow)) {
-                logger.debug("Time now: " + datatypeFactory.newXMLGregorianCalendar(new GregorianCalendar()).toXMLFormat());
+            if (exp != null && wssSecurityProperties.isStrictTimestampCheck() && exp.before(rightNow)) {
+                logger.debug("Time now: " + WSSConstants.datatypeFactory.newXMLGregorianCalendar(new GregorianCalendar()).toXMLFormat());
                 throw new WSSecurityException(WSSecurityException.ErrorCode.MESSAGE_EXPIRED, "invalidTimestamp",
                         "The security semantics of the message have expired");
             }
 
-            if (crea != null && ((WSSSecurityProperties) securityProperties).isStrictTimestampCheck() && crea.before(ttl)) {
-                logger.debug("Time now: " + datatypeFactory.newXMLGregorianCalendar(new GregorianCalendar()).toXMLFormat());
+            if (crea != null && wssSecurityProperties.isStrictTimestampCheck() && crea.before(ttl)) {
+                logger.debug("Time now: " + WSSConstants.datatypeFactory.newXMLGregorianCalendar(new GregorianCalendar()).toXMLFormat());
                 throw new WSSecurityException(WSSecurityException.ErrorCode.MESSAGE_EXPIRED, "invalidTimestamp",
                         "The security semantics of the message have expired");
             }
 
             if (crea != null && crea.after(rightNow)) {
-                logger.debug("Time now: " + datatypeFactory.newXMLGregorianCalendar(new GregorianCalendar()).toXMLFormat());
+                logger.debug("Time now: " + WSSConstants.datatypeFactory.newXMLGregorianCalendar(new GregorianCalendar()).toXMLFormat());
                 throw new WSSecurityException(WSSecurityException.ErrorCode.MESSAGE_EXPIRED, "invalidTimestamp",
                         "The security semantics of the message is invalid");
             }
@@ -134,8 +124,9 @@ public class TimestampInputHandler exten
     }
 
     private void checkBSPCompliance(InputProcessorChain inputProcessorChain, TimestampType timestampType, Deque<XMLEvent> eventDeque, int index) throws WSSecurityException {
+        final WSSecurityContext securityContext = (WSSecurityContext) inputProcessorChain.getSecurityContext();
         if (timestampType.getCreated() == null) {
-            ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3203);
+            securityContext.handleBSPRule(WSSConstants.BSPRule.R3203);
         }
 
         Iterator<XMLEvent> xmlEventIterator = eventDeque.descendingIterator();
@@ -151,22 +142,22 @@ public class TimestampInputHandler exten
             if (xmlEvent.isStartElement()) {
                 if (xmlEvent.asStartElement().getName().equals(WSSConstants.TAG_wsu_Created)) {
                     if (createdIndex != -1) {
-                        ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3203);
+                        securityContext.handleBSPRule(WSSConstants.BSPRule.R3203);
                     }
                     if (expiresIndex != -1) {
-                        ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3221);
+                        securityContext.handleBSPRule(WSSConstants.BSPRule.R3221);
                     }
                     createdIndex = curIdx;
                 } else if (xmlEvent.asStartElement().getName().equals(WSSConstants.TAG_wsu_Expires)) {
                     if (expiresIndex != -1) {
-                        ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3224);
+                        securityContext.handleBSPRule(WSSConstants.BSPRule.R3224);
                     }
                     if (createdIndex == -1) {
-                        ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3221);
+                        securityContext.handleBSPRule(WSSConstants.BSPRule.R3221);
                     }
                     expiresIndex = curIdx;
                 } else {
-                    ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3222);
+                    securityContext.handleBSPRule(WSSConstants.BSPRule.R3222);
                 }
             }
             curIdx++;
@@ -175,43 +166,43 @@ public class TimestampInputHandler exten
         if (timestampType.getCreated() != null) {
             XMLGregorianCalendar createdCalendar;
             try {
-                createdCalendar = datatypeFactory.newXMLGregorianCalendar(timestampType.getCreated().getValue());
+                createdCalendar = WSSConstants.datatypeFactory.newXMLGregorianCalendar(timestampType.getCreated().getValue());
             } catch (IllegalArgumentException e) {
                 throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, e);
             }
             if (createdCalendar.getFractionalSecond().scale() > 3) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3220);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R3220);
             }
             if (createdCalendar.getSecond() > 59) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3213);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R3213);
             }
             String valueType = XMLSecurityUtils.getQNameAttribute(timestampType.getCreated().getOtherAttributes(), WSSConstants.ATT_NULL_ValueType);
             if (valueType != null) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3225);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R3225);
             }
             if (createdCalendar.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3217);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R3217);
             }
         }
         if (timestampType.getExpires() != null) {
             XMLGregorianCalendar expiresCalendar;
             try {
-                expiresCalendar = datatypeFactory.newXMLGregorianCalendar(timestampType.getExpires().getValue());
+                expiresCalendar = WSSConstants.datatypeFactory.newXMLGregorianCalendar(timestampType.getExpires().getValue());
             } catch (IllegalArgumentException e) {
                 throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, e);
             }
             if (expiresCalendar.getFractionalSecond().scale() > 3) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3229);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R3229);
             }
             if (expiresCalendar.getSecond() > 59) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3215);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R3215);
             }
             String valueType = XMLSecurityUtils.getQNameAttribute(timestampType.getExpires().getOtherAttributes(), WSSConstants.ATT_NULL_ValueType);
             if (valueType != null) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3226);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R3226);
             }
             if (expiresCalendar.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3223);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R3223);
             }
         }
     }

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/UsernameTokenInputHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/UsernameTokenInputHandler.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/UsernameTokenInputHandler.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/input/UsernameTokenInputHandler.java Sun May 13 17:27:10 2012
@@ -34,8 +34,6 @@ import org.swssf.xmlsec.ext.*;
 import org.swssf.xmlsec.impl.util.IDGenerator;
 
 import javax.xml.bind.JAXBElement;
-import javax.xml.datatype.DatatypeConfigurationException;
-import javax.xml.datatype.DatatypeFactory;
 import javax.xml.datatype.XMLGregorianCalendar;
 import javax.xml.namespace.QName;
 import javax.xml.stream.events.XMLEvent;
@@ -51,16 +49,12 @@ public class UsernameTokenInputHandler e
 
     private static final String cacheRegionName = "usernameToken";
     private static JCS cache;
-    private static final DatatypeFactory datatypeFactory;
 
     static {
         try {
             cache = JCS.getInstance(cacheRegionName);
-            datatypeFactory = DatatypeFactory.newInstance();
         } catch (CacheException e) {
             throw new RuntimeException(e);
-        } catch (DatatypeConfigurationException e) {
-            throw new RuntimeException(e);
         }
     }
 
@@ -131,7 +125,7 @@ public class UsernameTokenInputHandler e
 
             XMLGregorianCalendar xmlGregorianCalendar;
             try {
-                xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(created);
+                xmlGregorianCalendar = WSSConstants.datatypeFactory.newXMLGregorianCalendar(created);
             } catch (IllegalArgumentException e) {
                 throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN);
             }
@@ -225,8 +219,9 @@ public class UsernameTokenInputHandler e
     private void checkBSPCompliance(InputProcessorChain inputProcessorChain, UsernameTokenType usernameTokenType,
                                     Deque<XMLEvent> eventDeque, int index) throws WSSecurityException {
 
+        final WSSecurityContext securityContext = (WSSecurityContext) inputProcessorChain.getSecurityContext();
         if (usernameTokenType.getAny() == null) {
-            ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R3031);
+            securityContext.handleBSPRule(WSSConstants.BSPRule.R3031);
         }
 
         Iterator<XMLEvent> xmlEventIterator = eventDeque.descendingIterator();
@@ -243,17 +238,17 @@ public class UsernameTokenInputHandler e
             if (xmlEvent.isStartElement()) {
                 if (xmlEvent.asStartElement().getName().equals(WSSConstants.TAG_wsse_Password)) {
                     if (passwordIndex != -1) {
-                        ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R4222);
+                        securityContext.handleBSPRule(WSSConstants.BSPRule.R4222);
                     }
                     passwordIndex = curIdx;
                 } else if (xmlEvent.asStartElement().getName().equals(WSSConstants.TAG_wsu_Created)) {
                     if (createdIndex != -1) {
-                        ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R4223);
+                        securityContext.handleBSPRule(WSSConstants.BSPRule.R4223);
                     }
                     createdIndex = curIdx;
                 } else if (xmlEvent.asStartElement().getName().equals(WSSConstants.TAG_wsse_Nonce)) {
                     if (nonceIndex != -1) {
-                        ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R4225);
+                        securityContext.handleBSPRule(WSSConstants.BSPRule.R4225);
                     }
                     nonceIndex = curIdx;
                 }
@@ -264,16 +259,16 @@ public class UsernameTokenInputHandler e
         PasswordString passwordType = XMLSecurityUtils.getQNameType(usernameTokenType.getAny(), WSSConstants.TAG_wsse_Password);
         if (passwordType != null) {
             if (passwordType.getType() == null) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R4201);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R4201);
             }
         }
 
         EncodedString encodedNonce = XMLSecurityUtils.getQNameType(usernameTokenType.getAny(), WSSConstants.TAG_wsse_Nonce);
         if (encodedNonce != null) {
             if (encodedNonce.getEncodingType() == null) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R4220);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R4220);
             } else if (!WSSConstants.SOAPMESSAGE_NS10_BASE64_ENCODING.equals(encodedNonce.getEncodingType())) {
-                ((WSSecurityContext) inputProcessorChain.getSecurityContext()).handleBSPRule(WSSConstants.BSPRule.R4221);
+                securityContext.handleBSPRule(WSSConstants.BSPRule.R4221);
             }
         }
 

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/BinarySecurityTokenOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/BinarySecurityTokenOutputProcessor.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/BinarySecurityTokenOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/BinarySecurityTokenOutputProcessor.java Sun May 13 17:27:10 2012
@@ -151,7 +151,7 @@ public class BinarySecurityTokenOutputPr
                     FinalBinarySecurityTokenOutputProcessor finalBinarySecurityTokenOutputProcessor = new FinalBinarySecurityTokenOutputProcessor(binarySecurityToken);
                     finalBinarySecurityTokenOutputProcessor.setXMLSecurityProperties(getSecurityProperties());
                     finalBinarySecurityTokenOutputProcessor.setAction(getAction());
-                    finalBinarySecurityTokenOutputProcessor.getBeforeProcessors().add(SignatureOutputProcessor.class.getName());
+                    finalBinarySecurityTokenOutputProcessor.addBeforeProcessor(SignatureOutputProcessor.class.getName());
                     finalBinarySecurityTokenOutputProcessor.init(outputProcessorChain);
                     binarySecurityToken.setProcessor(finalBinarySecurityTokenOutputProcessor);
                 }
@@ -161,7 +161,7 @@ public class BinarySecurityTokenOutputPr
                     FinalBinarySecurityTokenOutputProcessor finalBinarySecurityTokenOutputProcessor = new FinalBinarySecurityTokenOutputProcessor(binarySecurityToken);
                     finalBinarySecurityTokenOutputProcessor.setXMLSecurityProperties(getSecurityProperties());
                     finalBinarySecurityTokenOutputProcessor.setAction(getAction());
-                    finalBinarySecurityTokenOutputProcessor.getAfterProcessors().add(EncryptEndingOutputProcessor.class.getName());
+                    finalBinarySecurityTokenOutputProcessor.addAfterProcessor(EncryptEndingOutputProcessor.class.getName());
                     finalBinarySecurityTokenOutputProcessor.init(outputProcessorChain);
                     binarySecurityToken.setProcessor(finalBinarySecurityTokenOutputProcessor);
                 }
@@ -217,7 +217,7 @@ public class BinarySecurityTokenOutputPr
 
         FinalBinarySecurityTokenOutputProcessor(SecurityToken securityToken) throws XMLSecurityException {
             super();
-            this.getAfterProcessors().add(BinarySecurityTokenOutputProcessor.class.getName());
+            this.addAfterProcessor(BinarySecurityTokenOutputProcessor.class.getName());
             this.securityToken = securityToken;
         }
 

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/DerivedKeyTokenOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/DerivedKeyTokenOutputProcessor.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/DerivedKeyTokenOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/DerivedKeyTokenOutputProcessor.java Sun May 13 17:27:10 2012
@@ -29,16 +29,17 @@ import org.swssf.xmlsec.ext.*;
 import org.swssf.xmlsec.impl.util.IDGenerator;
 
 import javax.crypto.spec.SecretKeySpec;
-import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Attribute;
 import javax.xml.stream.events.StartElement;
 import javax.xml.stream.events.XMLEvent;
 import java.io.UnsupportedEncodingException;
 import java.security.Key;
 import java.security.PublicKey;
 import java.security.cert.X509Certificate;
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -188,7 +189,7 @@ public class DerivedKeyTokenOutputProces
                     new FinalDerivedKeyTokenOutputProcessor(derivedKeySecurityToken, offset, length, new String(Base64.encodeBase64(nonce)));
             finalDerivedKeyTokenOutputProcessor.setXMLSecurityProperties(getSecurityProperties());
             finalDerivedKeyTokenOutputProcessor.setAction(getAction());
-            finalDerivedKeyTokenOutputProcessor.getBeforeProcessors().add(wrappingSecurityToken.getProcessor());
+            finalDerivedKeyTokenOutputProcessor.addBeforeProcessor(wrappingSecurityToken.getProcessor());
             finalDerivedKeyTokenOutputProcessor.init(outputProcessorChain);
             derivedKeySecurityToken.setProcessor(finalDerivedKeyTokenOutputProcessor);
         } finally {
@@ -221,20 +222,20 @@ public class DerivedKeyTokenOutputProces
                 if (((WSSDocumentContext) outputProcessorChain.getDocumentContext()).isInSecurityHeader() && startElement.getName().equals(WSSConstants.TAG_wsse_Security)) {
                     OutputProcessorChain subOutputProcessorChain = outputProcessorChain.createSubChain(this);
 
-                    Map<QName, String> attributes = new HashMap<QName, String>();
-                    attributes.put(WSSConstants.ATT_wsu_Id, securityToken.getId());
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_DerivedKeyToken, attributes);
+                    List<Attribute> attributes = new ArrayList<Attribute>(1);
+                    attributes.add(XMLSecurityConstants.XMLEVENTFACTORY.createAttribute(WSSConstants.ATT_wsu_Id, securityToken.getId()));
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_DerivedKeyToken, true, attributes);
 
                     createSecurityTokenReferenceStructureForDerivedKey(subOutputProcessorChain, securityToken,
                             ((WSSSecurityProperties) getSecurityProperties()).getDerivedKeyKeyIdentifierType(),
                             ((WSSSecurityProperties) getSecurityProperties()).getDerivedKeyTokenReference(), getSecurityProperties().isUseSingleCert());
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Offset, null);
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Offset, false, null);
                     createCharactersAndOutputAsEvent(subOutputProcessorChain, "" + offset);
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Offset);
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Length, null);
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Length, false, null);
                     createCharactersAndOutputAsEvent(subOutputProcessorChain, "" + length);
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Length);
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Nonce, null);
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Nonce, false, null);
                     createCharactersAndOutputAsEvent(subOutputProcessorChain, nonce);
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Nonce);
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_DerivedKeyToken);
@@ -252,14 +253,14 @@ public class DerivedKeyTokenOutputProces
                 boolean useSingleCertificate)
                 throws XMLStreamException, XMLSecurityException {
 
-            Map<QName, String> attributes = new HashMap<QName, String>();
-            attributes.put(WSSConstants.ATT_wsu_Id, IDGenerator.generateID(null));
+            List<Attribute> attributes = new ArrayList<Attribute>(2);
+            attributes.add(createAttribute(WSSConstants.ATT_wsu_Id, IDGenerator.generateID(null)));
             if (keyIdentifierType == WSSConstants.KeyIdentifierType.SECURITY_TOKEN_DIRECT_REFERENCE && !useSingleCertificate) {
-                attributes.put(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_X509PKIPathv1);
+                attributes.add(createAttribute(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_X509PKIPathv1));
             } else if (derivedKeyTokenReference == WSSConstants.DerivedKeyTokenReference.EncryptedKey) {
-                attributes.put(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_WSS_ENC_KEY_VALUE_TYPE);
+                attributes.add(createAttribute(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_WSS_ENC_KEY_VALUE_TYPE));
             }
-            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference, attributes);
+            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference, false, attributes);
 
             X509Certificate[] x509Certificates = securityToken.getKeyWrappingToken().getX509Certificates();
             String tokenId = securityToken.getKeyWrappingToken().getId();

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptEndingOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptEndingOutputProcessor.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptEndingOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptEndingOutputProcessor.java Sun May 13 17:27:10 2012
@@ -36,8 +36,8 @@ public class EncryptEndingOutputProcesso
 
     public EncryptEndingOutputProcessor() throws XMLSecurityException {
         super();
-        this.getAfterProcessors().add(EncryptOutputProcessor.class.getName());
-        this.getAfterProcessors().add(UsernameTokenOutputProcessor.class.getName());
+        this.addAfterProcessor(EncryptOutputProcessor.class.getName());
+        this.addAfterProcessor(UsernameTokenOutputProcessor.class.getName());
     }
 
     @Override

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptOutputProcessor.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptOutputProcessor.java Sun May 13 17:27:10 2012
@@ -18,6 +18,8 @@
  */
 package org.swssf.wss.impl.processor.output;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.swssf.wss.ext.WSSConstants;
 import org.swssf.wss.ext.WSSDocumentContext;
 import org.swssf.xmlsec.ext.OutputProcessorChain;
@@ -29,7 +31,6 @@ import org.swssf.xmlsec.impl.processor.o
 import org.swssf.xmlsec.impl.util.IDGenerator;
 
 import javax.crypto.NoSuchPaddingException;
-import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.events.Attribute;
 import javax.xml.stream.events.StartElement;
@@ -37,9 +38,9 @@ import javax.xml.stream.events.XMLEvent;
 import java.io.IOException;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.Map;
+import java.util.List;
 
 /**
  * Processor to encrypt XML structures
@@ -49,6 +50,8 @@ import java.util.Map;
  */
 public class EncryptOutputProcessor extends AbstractEncryptOutputProcessor {
 
+    private static final transient Log logger = LogFactory.getLog(EncryptOutputProcessor.class);
+
     public EncryptOutputProcessor() throws XMLSecurityException {
         super();
     }
@@ -121,23 +124,22 @@ public class EncryptOutputProcessor exte
                 throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IOException, XMLStreamException {
 
             super(encryptionPartDef, startElement, encoding);
-            this.getBeforeProcessors().add(EncryptEndingOutputProcessor.class.getName());
-            this.getBeforeProcessors().add(InternalEncryptionOutputProcessor.class.getName());
-            this.getAfterProcessors().add(EncryptOutputProcessor.class.getName());
+            this.addBeforeProcessor(EncryptEndingOutputProcessor.class.getName());
+            this.addBeforeProcessor(InternalEncryptionOutputProcessor.class.getName());
+            this.addAfterProcessor(EncryptOutputProcessor.class.getName());
         }
 
         /**
          * Creates the Data structure around the cipher data
          */
         protected void processEventInternal(OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException {
-            Map<QName, String> attributes = null;
 
             //WSS 1.1 EncryptedHeader Element:
             if (outputProcessorChain.getDocumentContext().getDocumentLevel() == 3
                     && ((WSSDocumentContext) outputProcessorChain.getDocumentContext()).isInSOAPHeader()) {
                 doEncryptedHeader = true;
 
-                attributes = new HashMap<QName, String>();
+                List<Attribute> attributes = new ArrayList<Attribute>(1);
 
                 @SuppressWarnings("unchecked")
                 Iterator<Attribute> attributeIterator = getStartElement().getAttributes();
@@ -146,27 +148,27 @@ public class EncryptOutputProcessor exte
                     if (!attribute.isNamespace() &&
                             (WSSConstants.NS_SOAP11.equals(attribute.getName().getNamespaceURI()) ||
                                     WSSConstants.NS_SOAP12.equals(attribute.getName().getNamespaceURI()))) {
-                        attributes.put(attribute.getName(), attribute.getValue());
+                        attributes.add(createAttribute(attribute.getName(), attribute.getValue()));
                     }
                 }
-                createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse11_EncryptedHeader, attributes);
+                createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse11_EncryptedHeader, true, attributes);
             }
 
-            attributes = new HashMap<QName, String>();
-            attributes.put(WSSConstants.ATT_NULL_Id, getEncryptionPartDef().getEncRefId());
-            attributes.put(WSSConstants.ATT_NULL_Type, getEncryptionPartDef().getModifier().getModifier());
-            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_xenc_EncryptedData, attributes);
-
-            attributes = new HashMap<QName, String>();
-            attributes.put(WSSConstants.ATT_NULL_Algorithm, securityProperties.getEncryptionSymAlgorithm());
-            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_xenc_EncryptionMethod, attributes);
+            List<Attribute> attributes = new ArrayList<Attribute>(2);
+            attributes.add(createAttribute(WSSConstants.ATT_NULL_Id, getEncryptionPartDef().getEncRefId()));
+            attributes.add(createAttribute(WSSConstants.ATT_NULL_Type, getEncryptionPartDef().getModifier().getModifier()));
+            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_xenc_EncryptedData, true, attributes);
+
+            attributes = new ArrayList<Attribute>(1);
+            attributes.add(createAttribute(WSSConstants.ATT_NULL_Algorithm, securityProperties.getEncryptionSymAlgorithm()));
+            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_xenc_EncryptionMethod, false, attributes);
 
             createEndElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_xenc_EncryptionMethod);
-            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_dsig_KeyInfo, null);
+            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_dsig_KeyInfo, true, null);
             createKeyInfoStructure(outputProcessorChain);
             createEndElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_dsig_KeyInfo);
-            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_xenc_CipherData, null);
-            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_xenc_CipherValue, null);
+            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_xenc_CipherData, false, null);
+            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_xenc_CipherValue, false, null);
 
             /*
             <xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="EncDataId-1612925417"
@@ -190,12 +192,11 @@ public class EncryptOutputProcessor exte
 
         @Override
         protected void createKeyInfoStructure(OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException {
-            Map<QName, String> attributes;
-            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference, null);
+            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference, true, null);
 
-            attributes = new HashMap<QName, String>();
-            attributes.put(WSSConstants.ATT_NULL_URI, "#" + getEncryptionPartDef().getKeyId());
-            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_Reference, attributes);
+            List<Attribute> attributes = new ArrayList<Attribute>(1);
+            attributes.add(createAttribute(WSSConstants.ATT_NULL_URI, "#" + getEncryptionPartDef().getKeyId()));
+            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_Reference, false, attributes);
             createEndElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_Reference);
             createEndElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference);
         }

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptedKeyOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptedKeyOutputProcessor.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptedKeyOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/EncryptedKeyOutputProcessor.java Sun May 13 17:27:10 2012
@@ -29,8 +29,8 @@ import javax.crypto.Cipher;
 import javax.crypto.IllegalBlockSizeException;
 import javax.crypto.KeyGenerator;
 import javax.crypto.NoSuchPaddingException;
-import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Attribute;
 import javax.xml.stream.events.StartElement;
 import javax.xml.stream.events.XMLEvent;
 import java.security.InvalidKeyException;
@@ -38,8 +38,8 @@ import java.security.Key;
 import java.security.NoSuchAlgorithmException;
 import java.security.PublicKey;
 import java.security.cert.X509Certificate;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author $Author$
@@ -70,14 +70,18 @@ public class EncryptedKeyOutputProcessor
 
             //prepare the symmetric session key for all encryption parts
             String keyAlgorithm = JCEAlgorithmMapper.getJCERequiredKeyFromURI(securityProperties.getEncryptionSymAlgorithm());
-            int keyLength = JCEAlgorithmMapper.getKeyLengthFromURI(securityProperties.getEncryptionSymAlgorithm());
             KeyGenerator keyGen = null;
             try {
                 keyGen = KeyGenerator.getInstance(keyAlgorithm);
             } catch (NoSuchAlgorithmException e) {
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_ENCRYPTION, e);
             }
-            keyGen.init(keyLength);
+            //the sun JCE provider expects the real key size for 3DES (112 or 168 bit)
+            //whereas bouncy castle expects the block size of 128 or 192 bits
+            if (keyAlgorithm.contains("AES")) {
+                int keyLength = JCEAlgorithmMapper.getKeyLengthFromURI(securityProperties.getEncryptionSymAlgorithm());
+                keyGen.init(keyLength);
+            }
 
             final Key symmetricKey = keyGen.generateKey();
 
@@ -131,23 +135,23 @@ public class EncryptedKeyOutputProcessor
             if (action.equals(WSSConstants.ENCRYPT)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_ENCRYPTION, ekId);
                 if (wrappingSecurityToken.getProcessor() != null) {
-                    finalEncryptedKeyOutputProcessor.getBeforeProcessors().add(wrappingSecurityToken.getProcessor());
+                    finalEncryptedKeyOutputProcessor.addBeforeProcessor(wrappingSecurityToken.getProcessor());
                 } else {
-                    finalEncryptedKeyOutputProcessor.getAfterProcessors().add(org.swssf.wss.impl.processor.output.EncryptEndingOutputProcessor.class.getName());
+                    finalEncryptedKeyOutputProcessor.addAfterProcessor(EncryptEndingOutputProcessor.class.getName());
                 }
             } else if (action.equals(WSSConstants.SIGNATURE_WITH_DERIVED_KEY)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_DERIVED_KEY, ekId);
                 if (wrappingSecurityToken.getProcessor() != null) {
-                    finalEncryptedKeyOutputProcessor.getBeforeProcessors().add(wrappingSecurityToken.getProcessor());
+                    finalEncryptedKeyOutputProcessor.addBeforeProcessor(wrappingSecurityToken.getProcessor());
                 } else {
-                    finalEncryptedKeyOutputProcessor.getBeforeProcessors().add(org.swssf.wss.impl.processor.output.SignatureOutputProcessor.class.getName());
+                    finalEncryptedKeyOutputProcessor.addBeforeProcessor(SignatureOutputProcessor.class.getName());
                 }
             } else if (action.equals(WSSConstants.ENCRYPT_WITH_DERIVED_KEY)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_DERIVED_KEY, ekId);
                 if (wrappingSecurityToken.getProcessor() != null) {
-                    finalEncryptedKeyOutputProcessor.getBeforeProcessors().add(wrappingSecurityToken.getProcessor());
+                    finalEncryptedKeyOutputProcessor.addBeforeProcessor(wrappingSecurityToken.getProcessor());
                 } else {
-                    finalEncryptedKeyOutputProcessor.getAfterProcessors().add(org.swssf.wss.impl.processor.output.EncryptEndingOutputProcessor.class.getName());
+                    finalEncryptedKeyOutputProcessor.addAfterProcessor(EncryptEndingOutputProcessor.class.getName());
                 }
             }
             finalEncryptedKeyOutputProcessor.init(outputProcessorChain);
@@ -165,7 +169,7 @@ public class EncryptedKeyOutputProcessor
 
         FinalEncryptedKeyOutputProcessor(SecurityToken securityToken) throws XMLSecurityException {
             super();
-            this.getAfterProcessors().add(FinalEncryptedKeyOutputProcessor.class.getName());
+            this.addAfterProcessor(FinalEncryptedKeyOutputProcessor.class.getName());
             this.securityToken = securityToken;
         }
 
@@ -200,19 +204,19 @@ public class EncryptedKeyOutputProcessor
 
                     X509Certificate x509Certificate = securityToken.getKeyWrappingToken().getX509Certificates()[0];
 
-                    Map<QName, String> attributes = new HashMap<QName, String>();
-                    attributes.put(WSSConstants.ATT_NULL_Id, securityToken.getId());
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_EncryptedKey, attributes);
-
-                    attributes = new HashMap<QName, String>();
-                    attributes.put(WSSConstants.ATT_NULL_Algorithm, getSecurityProperties().getEncryptionKeyTransportAlgorithm());
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_EncryptionMethod, attributes);
+                    List<Attribute> attributes = new ArrayList<Attribute>(1);
+                    attributes.add(createAttribute(WSSConstants.ATT_NULL_Id, securityToken.getId()));
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_EncryptedKey, true, attributes);
+
+                    attributes = new ArrayList<Attribute>(1);
+                    attributes.add(createAttribute(WSSConstants.ATT_NULL_Algorithm, getSecurityProperties().getEncryptionKeyTransportAlgorithm()));
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_EncryptionMethod, false, attributes);
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_EncryptionMethod);
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_dsig_KeyInfo, null);
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_dsig_KeyInfo, true, null);
                     createSecurityTokenReferenceStructureForEncryptedKey(subOutputProcessorChain, securityToken, ((WSSSecurityProperties) getSecurityProperties()).getEncryptionKeyIdentifierType(), getSecurityProperties().isUseSingleCert());
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_dsig_KeyInfo);
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_CipherData, null);
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_CipherValue, null);
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_CipherData, false, null);
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_xenc_CipherValue, false, null);
 
                     try {
                         //encrypt the symmetric session key with the public key from the receiver:
@@ -263,12 +267,12 @@ public class EncryptedKeyOutputProcessor
                 boolean useSingleCertificate)
                 throws XMLStreamException, XMLSecurityException {
 
-            Map<QName, String> attributes = new HashMap<QName, String>();
-            attributes.put(WSSConstants.ATT_wsu_Id, IDGenerator.generateID(null));
+            List<Attribute> attributes = new ArrayList<Attribute>(2);
+            attributes.add(createAttribute(WSSConstants.ATT_wsu_Id, IDGenerator.generateID(null)));
             if (keyIdentifierType == WSSConstants.KeyIdentifierType.SECURITY_TOKEN_DIRECT_REFERENCE && !useSingleCertificate) {
-                attributes.put(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_X509PKIPathv1);
+                attributes.add(createAttribute(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_X509PKIPathv1));
             }
-            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference, attributes);
+            createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference, false, attributes);
 
             X509Certificate[] x509Certificates = securityToken.getKeyWrappingToken().getX509Certificates();
             String tokenId = securityToken.getKeyWrappingToken().getId();

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SAMLTokenOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SAMLTokenOutputProcessor.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SAMLTokenOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SAMLTokenOutputProcessor.java Sun May 13 17:27:10 2012
@@ -35,15 +35,16 @@ import org.w3c.dom.*;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Namespace;
 import javax.xml.stream.events.StartElement;
 import javax.xml.stream.events.XMLEvent;
 import java.security.Key;
 import java.security.PrivateKey;
 import java.security.PublicKey;
 import java.security.cert.X509Certificate;
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @author $Author$
@@ -250,8 +251,8 @@ public class SAMLTokenOutputProcessor ex
                                       String securityTokenReferenceId, String binarySecurityTokenReferenceId,
                                       boolean senderVouches) throws XMLSecurityException {
             super();
-            this.getAfterProcessors().add(UsernameTokenOutputProcessor.class.getName());
-            this.getAfterProcessors().add(SAMLTokenOutputProcessor.class.getName());
+            this.addAfterProcessor(UsernameTokenOutputProcessor.class.getName());
+            this.addAfterProcessor(SAMLTokenOutputProcessor.class.getName());
             this.samlAssertionWrapper = samlAssertionWrapper;
             this.securityTokenReferenceId = securityTokenReferenceId;
             this.senderVouches = senderVouches;
@@ -280,21 +281,21 @@ public class SAMLTokenOutputProcessor ex
     }
 
     private void outputSecurityTokenReference(OutputProcessorChain outputProcessorChain, SAMLAssertionWrapper samlAssertionWrapper, String referenceId, String tokenId) throws XMLStreamException, XMLSecurityException {
-        Map<QName, String> attributes = new HashMap<QName, String>();
+        List<Attribute> attributes = new ArrayList<Attribute>(2);
         if (samlAssertionWrapper.getSAMLVersion() == SAMLVersion.VERSION_11) {
-            attributes.put(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_SAML11_TOKEN_PROFILE_TYPE);
+            attributes.add(createAttribute(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_SAML11_TOKEN_PROFILE_TYPE));
         } else {
-            attributes.put(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_SAML20_TOKEN_PROFILE_TYPE);
+            attributes.add(createAttribute(WSSConstants.ATT_wsse11_TokenType, WSSConstants.NS_SAML20_TOKEN_PROFILE_TYPE));
         }
-        attributes.put(WSSConstants.ATT_wsu_Id, referenceId);
-        createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference, attributes);
-        attributes = new HashMap<QName, String>();
+        attributes.add(createAttribute(WSSConstants.ATT_wsu_Id, referenceId));
+        createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference, false, attributes);
+        attributes = new ArrayList<Attribute>(1);
         if (samlAssertionWrapper.getSAMLVersion() == SAMLVersion.VERSION_11) {
-            attributes.put(WSSConstants.ATT_NULL_ValueType, WSSConstants.NS_SAML10_TYPE);
+            attributes.add(createAttribute(WSSConstants.ATT_NULL_ValueType, WSSConstants.NS_SAML10_TYPE));
         } else {
-            attributes.put(WSSConstants.ATT_NULL_ValueType, WSSConstants.NS_SAML20_TYPE);
+            attributes.add(createAttribute(WSSConstants.ATT_NULL_ValueType, WSSConstants.NS_SAML20_TYPE));
         }
-        createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_KeyIdentifier, attributes);
+        createStartElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_KeyIdentifier, false, attributes);
         createCharactersAndOutputAsEvent(outputProcessorChain, tokenId);
         createEndElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_KeyIdentifier);
         createEndElementAndOutputAsEvent(outputProcessorChain, WSSConstants.TAG_wsse_SecurityTokenReference);
@@ -303,17 +304,17 @@ public class SAMLTokenOutputProcessor ex
     //todo serialize directly from SAML XMLObject?
     private void outputSamlAssertion(Element element, OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException {
 
-        Map<QName, String> attributes = new HashMap<QName, String>();
-        Map<QName, String> namespaces = new HashMap<QName, String>();
         NamedNodeMap namedNodeMap = element.getAttributes();
+        List<Attribute> attributes = new ArrayList<Attribute>(namedNodeMap.getLength());
+        List<Namespace> namespaces = new ArrayList<Namespace>(namedNodeMap.getLength());
         for (int i = 0; i < namedNodeMap.getLength(); i++) {
             Attr attribute = (Attr) namedNodeMap.item(i);
-            if ("xmlns".equals(attribute.getPrefix()) || "xmlns".equals(attribute.getLocalName())) {
-                namespaces.put(new QName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix()), attribute.getValue());
-            } else if (attribute.getPrefix() == null) {
-                attributes.put(new QName(attribute.getNamespaceURI(), attribute.getLocalName()), attribute.getValue());
+            if (attribute.getPrefix() == null) {
+                attributes.add(createAttribute(new QName(attribute.getNamespaceURI(), attribute.getLocalName()), attribute.getValue()));
+            } else if ("xmlns".equals(attribute.getPrefix()) || "xmlns".equals(attribute.getLocalName())) {
+                namespaces.add(createNamespace(attribute.getLocalName(), attribute.getValue()));
             } else {
-                attributes.put(new QName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix()), attribute.getValue());
+                attributes.add(createAttribute(new QName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix()), attribute.getValue()));
             }
         }
 

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SecurityContextTokenOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SecurityContextTokenOutputProcessor.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SecurityContextTokenOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SecurityContextTokenOutputProcessor.java Sun May 13 17:27:10 2012
@@ -25,15 +25,15 @@ import org.swssf.wss.impl.securityToken.
 import org.swssf.xmlsec.ext.*;
 import org.swssf.xmlsec.impl.util.IDGenerator;
 
-import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Attribute;
 import javax.xml.stream.events.StartElement;
 import javax.xml.stream.events.XMLEvent;
 import java.security.Key;
 import java.security.PublicKey;
 import java.security.cert.X509Certificate;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author $Author$
@@ -123,16 +123,16 @@ public class SecurityContextTokenOutputP
             if (action.equals(WSSConstants.SIGNATURE_WITH_DERIVED_KEY)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_DERIVED_KEY, wsuId);
                 if (wrappingSecurityToken.getProcessor() != null) {
-                    finalSecurityContextTokenOutputProcessor.getBeforeProcessors().add(wrappingSecurityToken.getProcessor());
+                    finalSecurityContextTokenOutputProcessor.addBeforeProcessor(wrappingSecurityToken.getProcessor());
                 } else {
-                    finalSecurityContextTokenOutputProcessor.getBeforeProcessors().add(org.swssf.wss.impl.processor.output.SignatureOutputProcessor.class.getName());
+                    finalSecurityContextTokenOutputProcessor.addBeforeProcessor(SignatureOutputProcessor.class.getName());
                 }
             } else if (action.equals(WSSConstants.ENCRYPT_WITH_DERIVED_KEY)) {
                 outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_DERIVED_KEY, wsuId);
                 if (wrappingSecurityToken.getProcessor() != null) {
-                    finalSecurityContextTokenOutputProcessor.getBeforeProcessors().add(wrappingSecurityToken.getProcessor());
+                    finalSecurityContextTokenOutputProcessor.addBeforeProcessor(wrappingSecurityToken.getProcessor());
                 } else {
-                    finalSecurityContextTokenOutputProcessor.getAfterProcessors().add(org.swssf.wss.impl.processor.output.EncryptEndingOutputProcessor.class.getName());
+                    finalSecurityContextTokenOutputProcessor.addAfterProcessor(EncryptEndingOutputProcessor.class.getName());
                 }
             }
 
@@ -165,10 +165,10 @@ public class SecurityContextTokenOutputP
                 if (((WSSDocumentContext) outputProcessorChain.getDocumentContext()).isInSecurityHeader() && startElement.getName().equals(WSSConstants.TAG_wsse_Security)) {
                     OutputProcessorChain subOutputProcessorChain = outputProcessorChain.createSubChain(this);
 
-                    Map<QName, String> attributes = new HashMap<QName, String>();
-                    attributes.put(WSSConstants.ATT_wsu_Id, securityToken.getId());
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_SecurityContextToken, attributes);
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Identifier, null);
+                    List<Attribute> attributes = new ArrayList<Attribute>(1);
+                    attributes.add(createAttribute(WSSConstants.ATT_wsu_Id, securityToken.getId()));
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_SecurityContextToken, true, attributes);
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Identifier, false, null);
                     createCharactersAndOutputAsEvent(subOutputProcessorChain, identifier);
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_Identifier);
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsc0502_SecurityContextToken);

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SecurityHeaderOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SecurityHeaderOutputProcessor.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SecurityHeaderOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SecurityHeaderOutputProcessor.java Sun May 13 17:27:10 2012
@@ -26,12 +26,12 @@ import org.swssf.xmlsec.ext.XMLSecurityE
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Attribute;
 import javax.xml.stream.events.EndElement;
 import javax.xml.stream.events.StartElement;
 import javax.xml.stream.events.XMLEvent;
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Processor to build the Security Header structure
@@ -91,7 +91,7 @@ public class SecurityHeaderOutputProcess
                 //create subchain and output soap-header and securityHeader
                 OutputProcessorChain subOutputProcessorChain = outputProcessorChain.createSubChain(this);
                 createStartElementAndOutputAsEvent(subOutputProcessorChain,
-                        new QName(soapMessageVersion, WSSConstants.TAG_soap_Header_LocalName, WSSConstants.PREFIX_SOAPENV), null);
+                        new QName(soapMessageVersion, WSSConstants.TAG_soap_Header_LocalName, WSSConstants.PREFIX_SOAPENV), true, null);
                 buildSecurityHeader(soapMessageVersion, subOutputProcessorChain);
                 createEndElementAndOutputAsEvent(subOutputProcessorChain,
                         new QName(soapMessageVersion, WSSConstants.TAG_soap_Header_LocalName, WSSConstants.PREFIX_SOAPENV));
@@ -126,17 +126,17 @@ public class SecurityHeaderOutputProcess
     }
 
     private void buildSecurityHeader(String soapMessageVersion, OutputProcessorChain subOutputProcessorChain) throws XMLStreamException, XMLSecurityException {
-        Map<QName, String> attributes = new HashMap<QName, String>();
+        List<Attribute> attributes = new ArrayList<Attribute>(1);
         final String actor = ((WSSSecurityProperties) getSecurityProperties()).getActor();
-        if (actor != null && !"".equals(actor)) {
+        if (actor != null && !actor.isEmpty()) {
             if (WSSConstants.NS_SOAP11.equals(soapMessageVersion)) {
-                attributes.put(WSSConstants.ATT_soap11_Actor, actor);
+                attributes.add(createAttribute(WSSConstants.ATT_soap11_Actor, actor));
             } else {
-                attributes.put(WSSConstants.ATT_soap12_Role, actor);
+                attributes.add(createAttribute(WSSConstants.ATT_soap12_Role, actor));
             }
         }
         ((WSSDocumentContext) subOutputProcessorChain.getDocumentContext()).setInSecurityHeader(true);
-        createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsse_Security, attributes);
+        createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsse_Security, true, attributes);
         createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsse_Security);
         ((WSSDocumentContext) subOutputProcessorChain.getDocumentContext()).setInSecurityHeader(false);
     }

Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SignatureConfirmationOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SignatureConfirmationOutputProcessor.java?rev=1337945&r1=1337944&r2=1337945&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SignatureConfirmationOutputProcessor.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/main/java/org/swssf/wss/impl/processor/output/SignatureConfirmationOutputProcessor.java Sun May 13 17:27:10 2012
@@ -28,13 +28,12 @@ import org.swssf.xmlsec.ext.OutputProces
 import org.swssf.xmlsec.ext.XMLSecurityException;
 import org.swssf.xmlsec.impl.util.IDGenerator;
 
-import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Attribute;
 import javax.xml.stream.events.StartElement;
 import javax.xml.stream.events.XMLEvent;
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @author $Author$
@@ -44,8 +43,8 @@ public class SignatureConfirmationOutput
 
     public SignatureConfirmationOutputProcessor() throws XMLSecurityException {
         super();
-        getBeforeProcessors().add(SignatureOutputProcessor.class.getName());
-        getBeforeProcessors().add(EncryptOutputProcessor.class.getName());
+        addBeforeProcessor(SignatureOutputProcessor.class.getName());
+        addBeforeProcessor(EncryptOutputProcessor.class.getName());
     }
 
     @Override
@@ -65,18 +64,18 @@ public class SignatureConfirmationOutput
                         aSignatureFound = true;
                         SignatureValueSecurityEvent signatureValueSecurityEvent = (SignatureValueSecurityEvent) securityEvent;
 
-                        Map<QName, String> attributes = new HashMap<QName, String>();
-                        attributes.put(WSSConstants.ATT_wsu_Id, IDGenerator.generateID(null));
-                        attributes.put(WSSConstants.ATT_NULL_Value, new Base64(76, new byte[]{'\n'}).encodeToString(signatureValueSecurityEvent.getSignatureValue()));
-                        createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsse11_SignatureConfirmation, attributes);
+                        List<Attribute> attributes = new ArrayList<Attribute>(2);
+                        attributes.add(createAttribute(WSSConstants.ATT_wsu_Id, IDGenerator.generateID(null)));
+                        attributes.add(createAttribute(WSSConstants.ATT_NULL_Value, new Base64(76, new byte[]{'\n'}).encodeToString(signatureValueSecurityEvent.getSignatureValue())));
+                        createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsse11_SignatureConfirmation, true, attributes);
                         createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsse11_SignatureConfirmation);
                     }
                 }
 
                 if (!aSignatureFound) {
-                    Map<QName, String> attributes = new HashMap<QName, String>();
-                    attributes.put(WSSConstants.ATT_wsu_Id, IDGenerator.generateID(null));
-                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsse11_SignatureConfirmation, attributes);
+                    List<Attribute> attributes = new ArrayList<Attribute>(1);
+                    attributes.add(createAttribute(WSSConstants.ATT_wsu_Id, IDGenerator.generateID(null)));
+                    createStartElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsse11_SignatureConfirmation, true, attributes);
                     createEndElementAndOutputAsEvent(subOutputProcessorChain, WSSConstants.TAG_wsse11_SignatureConfirmation);
                 }
 



Mime
View raw message