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 2012/01/31 16:44:44 UTC
svn commit: r1238672 [1/2] - in
/webservices/wss4j/branches/swssf/streaming-ws-security: ./
src/test/java/org/swssf/wss/test/ src/test/java/org/swssf/wss/test/saml/
src/test/java/org/swssf/wss/test/utils/
Author: coheigea
Date: Tue Jan 31 15:44:44 2012
New Revision: 1238672
URL: http://svn.apache.org/viewvc?rev=1238672&view=rev
Log:
Removing JAX-RPC stuff from WSS4J interop handler
Modified:
webservices/wss4j/branches/swssf/streaming-ws-security/pom.xml
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/AbstractTestBase.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/EncDecryptionTest.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/InteroperabilityTest.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SecurityContextTokenTest.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SignatureConfirmationTest.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SignatureTest.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/TimestampTest.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/UsernameTokenTest.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/VulnerabliltyVectorsTest.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/saml/SAMLTokenHOKTest.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/saml/SAMLTokenReferenceTest.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/saml/SAMLTokenSVTest.java
webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/utils/SOAPUtil.java
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/pom.xml
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/pom.xml?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/pom.xml (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/pom.xml Tue Jan 31 15:44:44 2012
@@ -227,12 +227,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>javax.xml</groupId>
- <artifactId>jaxrpc-api</artifactId>
- <version>1.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/AbstractTestBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/AbstractTestBase.java?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/AbstractTestBase.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/AbstractTestBase.java Tue Jan 31 15:44:44 2012
@@ -21,20 +21,17 @@ package org.swssf.wss.test;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.WSConstants;
-import org.apache.ws.security.WSSConfig;
import org.apache.ws.security.WSSecurityEngineResult;
-import org.apache.ws.security.action.SignatureAction;
import org.apache.ws.security.handler.RequestData;
import org.apache.ws.security.handler.WSHandler;
import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.ws.security.handler.WSHandlerResult;
-import org.apache.ws.security.message.WSSecSignature;
import org.apache.ws.security.util.WSSecurityUtil;
-import org.apache.xml.security.utils.XMLUtils;
import org.swssf.wss.WSSec;
import org.swssf.wss.ext.*;
import org.swssf.wss.securityEvent.SecurityEvent;
import org.swssf.wss.securityEvent.SecurityEventListener;
+import org.swssf.wss.test.utils.SOAPUtil;
import org.swssf.xmlsec.test.utils.StAX2DOM;
import org.swssf.xmlsec.test.utils.XmlReaderToWriter;
import org.testng.Assert;
@@ -43,31 +40,19 @@ import org.w3c.dom.Element;
import javax.security.auth.callback.CallbackHandler;
import javax.xml.namespace.NamespaceContext;
-import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.rpc.Call;
-import javax.xml.rpc.JAXRPCException;
-import javax.xml.rpc.handler.HandlerInfo;
-import javax.xml.rpc.handler.MessageContext;
-import javax.xml.rpc.handler.soap.SOAPMessageContext;
-import javax.xml.soap.*;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.Source;
import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamSource;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.LogManager;
@@ -133,22 +118,18 @@ public abstract class AbstractTestBase {
}
protected Document doOutboundSecurityWithWSS4J(InputStream sourceDocument, String action, Properties properties) throws org.apache.ws.security.WSSecurityException {
- return doOutboundSecurityWithWSS4J(sourceDocument, action, properties, SOAPConstants.SOAP_1_1_PROTOCOL);
+ Map<String, Object> context = doOutboundSecurityWithWSS4J_1(sourceDocument, action, properties);
+ return (Document) context.get(SECURED_DOCUMENT);
}
- protected Document doOutboundSecurityWithWSS4J(InputStream sourceDocument, String action, Properties properties, String soapProtocol) throws org.apache.ws.security.WSSecurityException {
- MessageContext messageContext = doOutboundSecurityWithWSS4J_1(sourceDocument, action, properties, soapProtocol);
- return (Document) messageContext.getProperty(SECURED_DOCUMENT);
- }
-
- @SuppressWarnings("unchecked")
- protected MessageContext doOutboundSecurityWithWSS4J_1(InputStream sourceDocument, String action, final Properties properties, String soapProtocol) throws org.apache.ws.security.WSSecurityException {
+ protected Map<String, Object> doOutboundSecurityWithWSS4J_1(
+ InputStream sourceDocument, String action, final Properties properties
+ ) throws org.apache.ws.security.WSSecurityException {
CustomWSS4JHandler wss4JHandler = new CustomWSS4JHandler();
- HandlerInfo handlerInfo = new HandlerInfo();
- wss4JHandler.init(handlerInfo);
- final MessageContext messageContext = getMessageContext(sourceDocument, soapProtocol);
- handlerInfo.getHandlerConfig().put(WSHandlerConstants.ACTION, action);
- handlerInfo.getHandlerConfig().put(WSHandlerConstants.USER, "transmitter");
+ final Map<String, Object> messageContext = getMessageContext(sourceDocument);
+ messageContext.put(WSHandlerConstants.ACTION, action);
+ messageContext.put(WSHandlerConstants.USER, "transmitter");
+
Properties sigProperties = new Properties();
sigProperties.setProperty("org.apache.ws.security.crypto.provider", "org.apache.ws.security.components.crypto.Merlin");
sigProperties.setProperty("org.apache.ws.security.crypto.merlin.file", "transmitter.jks");
@@ -156,8 +137,8 @@ public abstract class AbstractTestBase {
sigProperties.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", "default");
//sigProperties.setProperty("org.apache.ws.security.crypto.merlin.keystore.alias", "transmitter");
wss4JHandler.setPassword(messageContext, "default");
- messageContext.setProperty(WSHandlerConstants.SIG_PROP_REF_ID, "" + sigProperties.hashCode());
- messageContext.setProperty("" + sigProperties.hashCode(), sigProperties);
+ messageContext.put(WSHandlerConstants.SIG_PROP_REF_ID, "" + sigProperties.hashCode());
+ messageContext.put("" + sigProperties.hashCode(), sigProperties);
Properties encProperties = new Properties();
encProperties.setProperty("org.apache.ws.security.crypto.provider", "org.apache.ws.security.components.crypto.Merlin");
@@ -166,89 +147,47 @@ public abstract class AbstractTestBase {
encProperties.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", "default");
//sigProperties.setProperty("org.apache.ws.security.crypto.merlin.keystore.alias", "transmitter");
wss4JHandler.setPassword(messageContext, "default");
- messageContext.setProperty(WSHandlerConstants.ENCRYPTION_USER, "receiver");
- messageContext.setProperty(WSHandlerConstants.ENC_PROP_REF_ID, "" + encProperties.hashCode());
- messageContext.setProperty("" + encProperties.hashCode(), encProperties);
+ messageContext.put(WSHandlerConstants.ENCRYPTION_USER, "receiver");
+ messageContext.put(WSHandlerConstants.ENC_PROP_REF_ID, "" + encProperties.hashCode());
+ messageContext.put("" + encProperties.hashCode(), encProperties);
- Enumeration enumeration = properties.propertyNames();
+ Enumeration<?> enumeration = properties.propertyNames();
while (enumeration.hasMoreElements()) {
String s = (String) enumeration.nextElement();
- messageContext.setProperty(s, properties.get(s));
+ messageContext.put(s, properties.get(s));
}
RequestData requestData = new RequestData();
requestData.setMsgContext(messageContext);
requestData.setNoSerialization(true);
requestData.setCallbackHandler(new WSS4JCallbackHandlerImpl());
- WSSConfig wssConfig = WSSConfig.getNewInstance();
- wssConfig.setAction(new Integer(WSConstants.SIGN), new SignatureAction() {
- @Override
- public void execute(WSHandler handler, int actionToDo, Document doc, RequestData reqData) throws org.apache.ws.security.WSSecurityException {
-
- CallbackHandler callbackHandler = handler.getPasswordCallbackHandler(reqData);
- org.apache.ws.security.WSPasswordCallback passwordCallback = handler.getPasswordCB(reqData.getSignatureUser(), actionToDo, callbackHandler, reqData);
-
- WSSecSignature wsSign = new WSSecSignature();
- wsSign.setWsConfig(reqData.getWssConfig());
-
- if (reqData.getSigKeyId() != 0) {
- wsSign.setKeyIdentifierType(reqData.getSigKeyId());
- }
- if (reqData.getSigAlgorithm() != null) {
- wsSign.setSignatureAlgorithm(reqData.getSigAlgorithm());
- }
- if (reqData.getSigDigestAlgorithm() != null) {
- wsSign.setDigestAlgo(reqData.getSigDigestAlgorithm());
- }
- if (properties.getProperty("CanonicalizationAlgo") != null) {
- wsSign.setSigCanonicalization(properties.getProperty("CanonicalizationAlgo"));
- }
-
- wsSign.setUserInfo(reqData.getSignatureUser(), passwordCallback.getPassword());
- if (reqData.getSignatureParts().size() > 0) {
- wsSign.setParts(reqData.getSignatureParts());
- }
-
- try {
- wsSign.build(doc, reqData.getSigCrypto(), reqData.getSecHeader());
- reqData.getSignatureValues().add(wsSign.getSignatureValue());
- } catch (org.apache.ws.security.WSSecurityException e) {
- throw new org.apache.ws.security.WSSecurityException("Error during Signature: ", e);
- }
- }
- });
- requestData.setWssConfig(wssConfig);
+
wss4JHandler.doSender(messageContext, requestData, true);
return messageContext;
}
protected Document doInboundSecurityWithWSS4J(Document document, String action) throws Exception {
- MessageContext messageContext = doInboundSecurityWithWSS4J_1(document, action);
- return ((Document) messageContext.getProperty(SECURED_DOCUMENT));
- }
-
- protected MessageContext doInboundSecurityWithWSS4J_1(Document document, String action) throws Exception {
- return doInboundSecurityWithWSS4J_1(document, action, SOAPConstants.SOAP_1_1_PROTOCOL);
+ Map<String, Object> messageContext = doInboundSecurityWithWSS4J_1(document, action);
+ return ((Document) messageContext.get(SECURED_DOCUMENT));
}
- protected MessageContext doInboundSecurityWithWSS4J_1(Document document, String action, String soapProtocol) throws Exception {
- return doInboundSecurityWithWSS4J_1(document, action, SOAPConstants.SOAP_1_1_PROTOCOL, new Properties(), false);
+ protected Map<String, Object> doInboundSecurityWithWSS4J_1(Document document, String action) throws Exception {
+ return doInboundSecurityWithWSS4J_1(document, action, new Properties(), false);
}
- @SuppressWarnings("unchecked")
- protected MessageContext doInboundSecurityWithWSS4J_1(Document document, String action, String soapProtocol, Properties properties, boolean client) throws Exception {
+ protected Map<String, Object> doInboundSecurityWithWSS4J_1(
+ Document document, String action, Properties properties, boolean client
+ ) throws Exception {
CustomWSS4JHandler wss4JHandler = new CustomWSS4JHandler();
- HandlerInfo handlerInfo = new HandlerInfo();
- wss4JHandler.init(handlerInfo);
- MessageContext messageContext = getMessageContext(document, soapProtocol);
- handlerInfo.getHandlerConfig().put(WSHandlerConstants.ACTION, action);
+ Map<String, Object> messageContext = getMessageContext(document);
+ messageContext.put(WSHandlerConstants.ACTION, action);
if (client) {
- handlerInfo.getHandlerConfig().put(WSHandlerConstants.USER, "transmitter");
+ messageContext.put(WSHandlerConstants.USER, "transmitter");
} else {
- handlerInfo.getHandlerConfig().put(WSHandlerConstants.USER, "receiver");
+ messageContext.put(WSHandlerConstants.USER, "receiver");
}
- handlerInfo.getHandlerConfig().putAll(properties);
+
//handlerInfo.getHandlerConfig().put(WSHandlerConstants.ACTOR, "receiver");
Properties sigProperties = new Properties();
sigProperties.setProperty("org.apache.ws.security.crypto.provider", "org.apache.ws.security.components.crypto.Merlin");
@@ -261,12 +200,13 @@ public abstract class AbstractTestBase {
sigProperties.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", "default");
//sigProperties.setProperty("org.apache.ws.security.crypto.merlin.keystore.alias", "transmitter");
wss4JHandler.setPassword(messageContext, "default");
- messageContext.setProperty(WSHandlerConstants.SIG_PROP_REF_ID, "" + sigProperties.hashCode());
- messageContext.setProperty("" + sigProperties.hashCode(), sigProperties);
+
+ messageContext.put(WSHandlerConstants.SIG_PROP_REF_ID, "" + sigProperties.hashCode());
+ messageContext.put("" + sigProperties.hashCode(), sigProperties);
if (properties.get(WSHandlerConstants.PW_CALLBACK_REF) != null) {
- messageContext.setProperty(WSHandlerConstants.PW_CALLBACK_REF, properties.get(WSHandlerConstants.PW_CALLBACK_REF));
+ messageContext.put(WSHandlerConstants.PW_CALLBACK_REF, properties.get(WSHandlerConstants.PW_CALLBACK_REF));
} else {
- messageContext.setProperty(WSHandlerConstants.PW_CALLBACK_REF, new WSS4JCallbackHandlerImpl());
+ messageContext.put(WSHandlerConstants.PW_CALLBACK_REF, new WSS4JCallbackHandlerImpl());
}
Properties decProperties = new Properties();
@@ -280,13 +220,13 @@ public abstract class AbstractTestBase {
decProperties.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", "default");
//sigProperties.setProperty("org.apache.ws.security.crypto.merlin.keystore.alias", "transmitter");
wss4JHandler.setPassword(messageContext, "default");
- messageContext.setProperty(WSHandlerConstants.DEC_PROP_REF_ID, "" + decProperties.hashCode());
- messageContext.setProperty("" + decProperties.hashCode(), decProperties);
+ messageContext.put(WSHandlerConstants.DEC_PROP_REF_ID, "" + decProperties.hashCode());
+ messageContext.put("" + decProperties.hashCode(), decProperties);
- Enumeration enumeration = properties.propertyNames();
+ Enumeration<?> enumeration = properties.propertyNames();
while (enumeration.hasMoreElements()) {
String s = (String) enumeration.nextElement();
- messageContext.setProperty(s, properties.get(s));
+ messageContext.put(s, properties.get(s));
}
RequestData requestData = new RequestData();
@@ -296,62 +236,20 @@ public abstract class AbstractTestBase {
return messageContext;
}
- private MessageContext getMessageContext(InputStream inputStream, String soapProtocol) {
- return getMessageContext(new StreamSource(inputStream), soapProtocol);
+ private Map<String, Object> getMessageContext(InputStream inputStream) {
+ Map<String, Object> context = new HashMap<String, Object>();
+ try {
+ context.put(SECURED_DOCUMENT, SOAPUtil.toSOAPPart(inputStream));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return context;
}
- private MessageContext getMessageContext(Document document, String soapProtocol) {
- return getMessageContext(new DOMSource(document), soapProtocol);
- }
-
- @SuppressWarnings("unchecked")
- private MessageContext getMessageContext(final Source inSource, final String soapProtocol) {
- MessageContext messageContext = new SOAPMessageContext() {
-
- private Map properties = new HashMap();
-
- public void setProperty(String s, Object o) {
- properties.put(s, o);
- }
-
- public Object getProperty(String s) {
- return properties.get(s);
- }
-
- public void removeProperty(String s) {
- properties.remove(s);
- }
-
- public boolean containsProperty(String s) {
- return properties.containsKey(s);
- }
-
- public Iterator getPropertyNames() {
- return properties.keySet().iterator();
- }
-
- public SOAPMessage getMessage() {
- try {
- //MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
- MessageFactory messageFactory = MessageFactory.newInstance(soapProtocol);
- SOAPMessage soapMessage = messageFactory.createMessage();
- soapMessage.getSOAPPart().setContent(inSource);
- setProperty(SECURED_DOCUMENT, soapMessage.getSOAPHeader().getOwnerDocument());
- return soapMessage;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public void setMessage(SOAPMessage soapMessage) {
- throw new UnsupportedOperationException();
- }
-
- public String[] getRoles() {
- return new String[0]; //To change body of implemented methods use File | Settings | File Templates.
- }
- };
- return messageContext;
+ private Map<String, Object> getMessageContext(Document document) {
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put(SECURED_DOCUMENT, document);
+ return context;
}
protected XPathExpression getXPath(String expression) throws XPathExpressionException {
@@ -391,7 +289,7 @@ public abstract class AbstractTestBase {
}
}
- public Iterator getPrefixes(String namespaceURI) {
+ public Iterator<String> getPrefixes(String namespaceURI) {
return null;
}
}
@@ -399,39 +297,27 @@ public abstract class AbstractTestBase {
return xPath.compile(expression);
}
- @SuppressWarnings("unchecked")
class CustomWSS4JHandler extends WSHandler {
private final Log log = LogFactory.getLog(CustomWSS4JHandler.class.getName());
private final boolean doDebug = log.isDebugEnabled();
- private HandlerInfo handlerInfo;
-
- /**
- * Initializes the instance of the handler.
- */
- public void init(HandlerInfo hi) {
- handlerInfo = hi;
- }
/**
* Handles incoming web service requests and outgoing responses
*/
- public boolean doSender(MessageContext mc, RequestData reqData, boolean isRequest) throws org.apache.ws.security.WSSecurityException {
+ public boolean doSender(Map<String, Object> mc, RequestData reqData, boolean isRequest)
+ throws org.apache.ws.security.WSSecurityException {
reqData.getSignatureParts().clear();
reqData.getEncryptParts().clear();
- reqData.setNoSerialization(true);
/*
- * Get the action first.
- */
- Vector actions = new Vector();
- String action = (String) getOption(WSHandlerConstants.ACTION);
+ * Get the action first.
+ */
+ String action = (String) mc.get(WSHandlerConstants.ACTION);
if (action == null) {
- action = (String) mc.getProperty(WSHandlerConstants.ACTION);
- }
- if (action == null) {
- throw new JAXRPCException("WSS4JHandler: No action defined");
+ throw new org.apache.ws.security.WSSecurityException("WSS4JHandler: No action defined");
}
+ List<Integer> actions = new ArrayList<Integer>();
int doAction = WSSecurityUtil.decodeAction(action, actions);
if (doAction == WSConstants.NO_SECURITY) {
return true;
@@ -443,8 +329,7 @@ public abstract class AbstractTestBase {
*/
reqData.setUsername((String) getOption(WSHandlerConstants.USER));
if (reqData.getUsername() == null || reqData.getUsername().equals("")) {
- reqData.setUsername((String) mc.getProperty(WSHandlerConstants.USER));
- mc.setProperty(WSHandlerConstants.USER, null);
+ reqData.setUsername((String) mc.get(WSHandlerConstants.USER));
}
/*
@@ -455,10 +340,12 @@ public abstract class AbstractTestBase {
if (((doAction & (WSConstants.SIGN | WSConstants.UT | WSConstants.UT_SIGN)) != 0)
&& (reqData.getUsername() == null || reqData.getUsername().equals(""))) {
/*
- * We need a username - if none throw an JAXRPCException. For encryption
- * there is a specific parameter to get a username.
- */
- throw new JAXRPCException("WSS4JHandler: Empty username for specified action");
+ * We need a username - if none throw a WSSecurityException. For encryption
+ * there is a specific parameter to get a username.
+ */
+ throw new org.apache.ws.security.WSSecurityException(
+ "WSS4JHandler: Empty username for specified action"
+ );
}
if (doDebug) {
log.debug("Action: " + doAction);
@@ -468,35 +355,13 @@ public abstract class AbstractTestBase {
* Now get the SOAP part from the request message and convert it into a
* Document.
*
- * This forces Axis to serialize the SOAP request into FORM_STRING.
- * This string is converted into a document.
- *
- * During the FORM_STRING serialization Axis performs multi-ref of
- * complex data types (if requested), generates and inserts references
- * for attachments and so on. The resulting Document MUST be the
- * complete and final SOAP request as Axis would send it over the wire.
- * Therefore this must shall be the last (or only) handler in a chain.
- *
* Now we can perform our security operations on this request.
*/
- Document doc = null;
- SOAPMessage message = ((SOAPMessageContext) mc).getMessage();
- Boolean propFormOptimization = (Boolean) mc.getProperty("axis.form.optimization");
- log.debug("Form optimization: " + propFormOptimization);
- /*
- * If the message context property contains a document then this is a
- * chained handler.
- */
- SOAPPart sPart = message.getSOAPPart();
- if ((doc = (Document) mc.getProperty(SECURED_DOCUMENT)) == null) {
- try {
- doc = messageToDocument(message);
- } catch (Exception e) {
- if (doDebug) {
- log.debug(e.getMessage(), e);
- }
- throw new JAXRPCException("WSS4JHandler: cannot get SOAP envlope from message", e);
- }
+ Document doc = (Document) mc.get(SECURED_DOCUMENT);
+ if (doc == null) {
+ throw new org.apache.ws.security.WSSecurityException(
+ "WSS4JHandler: cannot get SOAP envlope from message"
+ );
}
if (doDebug) {
log.debug("WSS4JHandler: orginal SOAP request: ");
@@ -504,127 +369,70 @@ public abstract class AbstractTestBase {
}
doSenderAction(doAction, doc, reqData, actions, isRequest);
- /*
- * If required convert the resulting document into a message first. The
- * outputDOM() method performs the necessary c14n call. After that we
- * extract it as a string for further processing.
- *
- * Set the resulting byte array as the new SOAP message.
- *
- * If noSerialization is false, this handler shall be the last (or only)
- * one in a handler chain. If noSerialization is true, just set the
- * processed Document in the transfer property. The next Axis WSS4J
- * handler takes it and performs additional security processing steps.
- *
- */
- if (reqData.isNoSerialization()) {
- mc.setProperty(SECURED_DOCUMENT, doc);
- } else {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- XMLUtils.outputDOM(doc, os, true);
- if (doDebug) {
- String osStr = null;
- try {
- osStr = os.toString("UTF-8");
- } catch (UnsupportedEncodingException e) {
- if (doDebug) {
- log.debug(e.getMessage(), e);
- }
- osStr = os.toString();
- }
- log.debug("Send request:");
- log.debug(osStr);
- }
-
- try {
- sPart.setContent(new StreamSource(new ByteArrayInputStream(os.toByteArray())));
- } catch (SOAPException se) {
- if (doDebug) {
- log.debug(se.getMessage(), se);
- }
- throw new JAXRPCException("Couldn't set content on SOAPPart" + se.getMessage(), se);
- }
- mc.setProperty(SECURED_DOCUMENT, null);
- }
- if (doDebug) {
- log.debug("WSS4JHandler: exit invoke()");
- }
+ mc.put(SECURED_DOCUMENT, doc);
+
return true;
}
@SuppressWarnings("unchecked")
- public boolean doReceiver(MessageContext mc, RequestData reqData, boolean isRequest) throws org.apache.ws.security.WSSecurityException {
- Vector actions = new Vector();
- String action = (String) getOption(WSHandlerConstants.ACTION);
- if (action == null) {
- action = (String) mc.getProperty(WSHandlerConstants.ACTION);
- }
+ public boolean doReceiver(Map<String, Object> mc, RequestData reqData, boolean isRequest)
+ throws org.apache.ws.security.WSSecurityException {
+ String action = (String) mc.get(WSHandlerConstants.ACTION);
if (action == null) {
- throw new JAXRPCException("WSS4JHandler: No action defined");
+ throw new org.apache.ws.security.WSSecurityException("WSS4JHandler: No action defined");
}
+ List<Integer> actions = new ArrayList<Integer>();
int doAction = WSSecurityUtil.decodeAction(action, actions);
- String actor = (String) getOption(WSHandlerConstants.ACTOR);
+ String actor = (String) mc.get(WSHandlerConstants.ACTOR);
- SOAPMessage message = ((SOAPMessageContext) mc).getMessage();
- //SOAPPart sPart = message.getSOAPPart();
-
- Document doc = null;
- try {
- doc = message.getSOAPHeader().getOwnerDocument();
- } catch (SOAPException e) {
- throw new JAXRPCException(e);
- }
+ Document doc = (Document) mc.get(SECURED_DOCUMENT);
/*
- * Check if it's a fault. Don't process faults.
- *
- */
+ * Check if it's a fault. Don't process faults.
+ */
org.apache.ws.security.SOAPConstants soapConstants =
- WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
- if (WSSecurityUtil
- .findElement(doc.getDocumentElement(),
- "Fault",
- soapConstants.getEnvelopeURI())
- != null) {
+ WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
+ if (WSSecurityUtil.findElement(
+ doc.getDocumentElement(), "Fault", soapConstants.getEnvelopeURI()) != null
+ ) {
return false;
}
/*
- * To check a UsernameToken or to decrypt an encrypted message we need
- * a password.
- */
-
- CallbackHandler cbHandler = null;
- //if ((doAction & (WSConstants.ENCR | WSConstants.UT | WSConstants.UT_SIGN)) != 0) {
- cbHandler = getPasswordCallbackHandler(reqData);
- //}
+ * To check a UsernameToken or to decrypt an encrypted message we need
+ * a password.
+ */
+ CallbackHandler cbHandler = getPasswordCallbackHandler(reqData);
reqData.setCallbackHandler(cbHandler);
/*
- * Get and check the Signature specific parameters first because they
- * may be used for encryption too.
- */
+ * Get and check the Signature specific parameters first because they
+ * may be used for encryption too.
+ */
doReceiverAction(doAction, reqData);
Element elem = WSSecurityUtil.getSecurityHeader(doc, actor);
- List wsResult = null;
+ List<WSSecurityEngineResult> wsResult = null;
try {
- wsResult =
- secEngine.processSecurityHeader(elem, reqData);
+ wsResult = secEngine.processSecurityHeader(elem, reqData);
} catch (org.apache.ws.security.WSSecurityException ex) {
if (doDebug) {
log.debug(ex.getMessage(), ex);
}
- throw new JAXRPCException("WSS4JHandler: security processing failed",
- ex);
+ throw new org.apache.ws.security.WSSecurityException(
+ "WSS4JHandler: security processing failed", ex
+ );
}
- if (wsResult == null || wsResult.size() == 0) { // no security header found
+ if (wsResult == null || wsResult.size() == 0) {
+ // no security header found
if (doAction == WSConstants.NO_SECURITY) {
return true;
} else {
- throw new JAXRPCException("WSS4JHandler: Request does not contain required Security header");
+ throw new org.apache.ws.security.WSSecurityException(
+ "WSS4JHandler: Request does not contain required Security header"
+ );
}
}
if (reqData.getWssConfig().isEnableSignatureConfirmation() && !isRequest) {
@@ -636,97 +444,25 @@ public abstract class AbstractTestBase {
}
/*
- * After setting the new current message, probably modified because
- * of decryption, we need to locate the security header. That is,
- * we force Axis (with getSOAPEnvelope()) to parse the string, build
- * the new header. Then we examine, look up the security header
- * and set the header as processed.
- *
- * Please note: find all header elements that contain the same
- * actor that was given to processSecurityHeader(). Then
- * check if there is a security header with this actor.
- */
-
- SOAPHeader sHeader = null;
- try {
- sHeader = message.getSOAPPart().getEnvelope().getHeader();
- } catch (Exception ex) {
- if (doDebug) {
- log.debug(ex.getMessage(), ex);
- }
- throw new JAXRPCException("WSS4JHandler: cannot get SOAP header after security processing", ex);
- }
-
- /*
- * Now we can check the certificate used to sign the message.
- * In the following implementation the certificate is only trusted
- * if either it itself or the certificate of the issuer is installed
- * in the keystore.
- *
- * Note: the method verifyTrust(X509Certificate) allows custom
- * implementations with other validation algorithms for subclasses.
- */
-
- // Extract the signature action result from the action vector
-
- WSSecurityEngineResult actionResult = WSSecurityUtil.fetchActionResult(wsResult, WSConstants.SIGN);
-
-/*
- if (actionResult != null) {
- X509Certificate returnCert =
- (X509Certificate) actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
-
- if (returnCert != null && !verifyTrust(returnCert, reqData)) {
- throw new JAXRPCException("WSS4JHandler: The certificate used for the signature is not trusted");
- }
- }
-*/
-
- /*
- * Perform further checks on the timestamp that was transmitted in the header.
- * In the following implementation the timestamp is valid if it was
- * created after (now-ttl), where ttl is set on server side, not by the client.
- *
- * Note: the method verifyTimestamp(Timestamp) allows custom
- * implementations with other validation algorithms for subclasses.
- */
-
- // Extract the timestamp action result from the action vector
- actionResult = WSSecurityUtil.fetchActionResult(wsResult, WSConstants.TS);
-
-/*
- if (actionResult != null) {
- Timestamp timestamp =
- (Timestamp) actionResult.get(WSSecurityEngineResult.TAG_TIMESTAMP);
-
- if (timestamp != null && reqData.getWssConfig().isTimeStampStrict()
- && !verifyTimestamp(timestamp, decodeTimeToLive(reqData))) {
- throw new JAXRPCException("WSS4JHandler: The timestamp could not be validated");
- }
- }
-*/
-
- /*
- * now check the security actions: do they match, in right order?
- */
+ * now check the security actions: do they match, in right order?
+ */
if (!checkReceiverResults(wsResult, actions)) {
- throw new JAXRPCException("WSS4JHandler: security processing failed (actions mismatch)");
+ throw new org.apache.ws.security.WSSecurityException(
+ "WSS4JHandler: security processing failed (actions mismatch)"
+ );
}
/*
- * All ok up to this point. Now construct and setup the
- * security result structure. The service may fetch this
- * and check it.
- */
- Vector results = null;
- if ((results = (Vector) mc.getProperty(WSHandlerConstants.RECV_RESULTS))
- == null) {
- results = new Vector();
- mc.setProperty(WSHandlerConstants.RECV_RESULTS, results);
- }
- WSHandlerResult rResult =
- new WSHandlerResult(actor,
- wsResult);
+ * All ok up to this point. Now construct and setup the
+ * security result structure. The service may fetch this
+ * and check it.
+ */
+ List<WSHandlerResult> results = null;
+ if ((results = (List<WSHandlerResult>) mc.get(WSHandlerConstants.RECV_RESULTS)) == null) {
+ results = new ArrayList<WSHandlerResult>();
+ mc.put(WSHandlerConstants.RECV_RESULTS, results);
+ }
+ WSHandlerResult rResult = new WSHandlerResult(actor, wsResult);
results.add(0, rResult);
if (doDebug) {
log.debug("WSS4JHandler: exit invoke()");
@@ -736,7 +472,7 @@ public abstract class AbstractTestBase {
}
protected boolean checkReceiverResults(
- List<WSSecurityEngineResult> wsResult, List<Integer> actions
+ List<WSSecurityEngineResult> wsResult, List<Integer> actions
) {
List<WSSecurityEngineResult> wsSecurityEngineResults = new ArrayList<WSSecurityEngineResult>();
for (WSSecurityEngineResult result : wsResult) {
@@ -764,76 +500,36 @@ public abstract class AbstractTestBase {
return false;
}
}
-/*
+ /*
if (ai != size) {
return false;
}
-*/
+ */
return true;
}
- protected boolean checkReceiverResultsAnyOrder(
- List<WSSecurityEngineResult> wsResult, List<Integer> actions
- ) {
- List<Integer> recordedActions = new ArrayList<Integer>(actions.size());
- for (Integer action : actions) {
- recordedActions.add(action);
- }
-
- for (WSSecurityEngineResult result : wsResult) {
- final Integer actInt = (Integer) result.get(WSSecurityEngineResult.TAG_ACTION);
- int act = actInt.intValue();
- if (act == WSConstants.SC || act == WSConstants.BST) {
- continue;
- }
-
- if (!recordedActions.remove(actInt)) {
- if (actInt == 8192) {
- if (!recordedActions.remove(new Integer(1))) {
- return false;
- }
- } else {
- return false;
- }
- }
- }
-
- return recordedActions.isEmpty();
- }
-
- /**
- * Utility method to convert SOAPMessage to org.w3c.dom.Document
- */
- public Document messageToDocument(SOAPMessage message) {
- try {
- Source content = message.getSOAPPart().getContent();
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- DocumentBuilder builder = dbf.newDocumentBuilder();
- return builder.parse(org.apache.ws.security.util.XMLUtils.sourceToInputSource(content));
- } catch (Exception ex) {
- throw new JAXRPCException("messageToDocument: cannot convert SOAPMessage into Document", ex);
- }
- }
-
public Object getOption(String key) {
- return handlerInfo.getHandlerConfig().get(key);
+ return null;
}
+ @SuppressWarnings("unchecked")
public Object getProperty(Object msgContext, String key) {
- return ((MessageContext) msgContext).getProperty(key);
+ return ((Map<String, Object>) msgContext).get(key);
}
+ @SuppressWarnings("unchecked")
public void setProperty(Object msgContext, String key, Object value) {
- ((MessageContext) msgContext).setProperty(key, value);
+ ((Map<String, Object>) msgContext).put(key, value);
}
+ @SuppressWarnings("unchecked")
public String getPassword(Object msgContext) {
- return (String) ((MessageContext) msgContext).getProperty(Call.PASSWORD_PROPERTY);
+ return (String) ((Map<String, Object>) msgContext).get("password");
}
+ @SuppressWarnings("unchecked")
public void setPassword(Object msgContext, String password) {
- ((MessageContext) msgContext).setProperty(Call.PASSWORD_PROPERTY, password);
+ ((Map<String, Object>) msgContext).put("password", password);
}
}
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/EncDecryptionTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/EncDecryptionTest.java?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/EncDecryptionTest.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/EncDecryptionTest.java Tue Jan 31 15:44:44 2012
@@ -28,7 +28,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import javax.xml.soap.SOAPConstants;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
@@ -295,7 +294,7 @@ public class EncDecryptionTest extends A
//done encryption; now test decryption:
{
String action = WSHandlerConstants.ENCRYPT;
- Document doc = doInboundSecurityWithWSS4J(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
+ doInboundSecurityWithWSS4J(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
}
}
@@ -714,7 +713,7 @@ public class EncDecryptionTest extends A
String action = WSHandlerConstants.ENCRYPT;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/InteroperabilityTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/InteroperabilityTest.java?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/InteroperabilityTest.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/InteroperabilityTest.java Tue Jan 31 15:44:44 2012
@@ -32,9 +32,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import javax.xml.rpc.JAXRPCException;
-import javax.xml.rpc.handler.MessageContext;
-import javax.xml.soap.SOAPConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
@@ -45,6 +42,7 @@ import javax.xml.xpath.XPathExpression;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
/**
@@ -114,7 +112,7 @@ public class InteroperabilityTest extend
String action = WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.SIGNATURE_PARTS, "{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://www.w3.org/2003/05/soap-envelope}Body;");
- Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties, SOAPConstants.SOAP_1_2_PROTOCOL);
+ Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
@@ -318,7 +316,7 @@ public class InteroperabilityTest extend
ByteArrayOutputStream baos = doOutboundSecurity(securityProperties, sourceDocument);
String action = WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
- Document document = doInboundSecurityWithWSS4J(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
+ doInboundSecurityWithWSS4J(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
}
@Test
@@ -337,7 +335,7 @@ public class InteroperabilityTest extend
ByteArrayOutputStream baos = doOutboundSecurity(securityProperties, sourceDocument);
String action = WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.TIMESTAMP;
- Document document = doInboundSecurityWithWSS4J(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
+ doInboundSecurityWithWSS4J(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
}
@Test
@@ -356,7 +354,7 @@ public class InteroperabilityTest extend
ByteArrayOutputStream baos = doOutboundSecurity(securityProperties, sourceDocument);
String action = WSHandlerConstants.SIGNATURE;
- Document document = doInboundSecurityWithWSS4J(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
+ doInboundSecurityWithWSS4J(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
}
@Test(invocationCount = 1)
@@ -434,8 +432,8 @@ public class InteroperabilityTest extend
String action = WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.SIGNATURE_PARTS, "{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body;");
- MessageContext messageContext = doOutboundSecurityWithWSS4J_1(sourceDocument, action, properties, SOAPConstants.SOAP_1_1_PROTOCOL);
- Document securedDocument = (Document) messageContext.getProperty(SECURED_DOCUMENT);
+ Map<String, Object> messageContext = doOutboundSecurityWithWSS4J_1(sourceDocument, action, properties);
+ Document securedDocument = (Document) messageContext.get(SECURED_DOCUMENT);
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
@@ -505,7 +503,7 @@ public class InteroperabilityTest extend
{
String action = WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
Properties properties = new Properties();
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, true);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, true);
}
}
@@ -547,7 +545,7 @@ public class InteroperabilityTest extend
String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
@@ -591,7 +589,7 @@ public class InteroperabilityTest extend
String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
//done signature; now test sig-verification:
@@ -805,7 +803,7 @@ public class InteroperabilityTest extend
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.ACTOR, "test");
properties.setProperty(WSHandlerConstants.SIGNATURE_PARTS, "{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://www.w3.org/2003/05/soap-envelope}Body;");
- Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties, SOAPConstants.SOAP_1_2_PROTOCOL);
+ Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
@@ -858,14 +856,14 @@ public class InteroperabilityTest extend
String action = WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.SIGNATURE_PARTS, "{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://www.w3.org/2003/05/soap-envelope}Body;");
- Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties, SOAPConstants.SOAP_1_2_PROTOCOL);
+ Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
properties.setProperty(WSHandlerConstants.ACTOR, "test");
- securedDocument = doOutboundSecurityWithWSS4J(new ByteArrayInputStream(baos.toByteArray()), action, properties, SOAPConstants.SOAP_1_2_PROTOCOL);
+ securedDocument = doOutboundSecurityWithWSS4J(new ByteArrayInputStream(baos.toByteArray()), action, properties);
transformer = TRANSFORMER_FACTORY.newTransformer();
baos.reset();
@@ -910,7 +908,7 @@ public class InteroperabilityTest extend
String action = WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.ACTOR, "test");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
@Test(invocationCount = 1)
@@ -933,9 +931,9 @@ public class InteroperabilityTest extend
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.ACTOR, "anotherTest");
try {
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
- Assert.fail("Expected JAXRPCException");
- } catch (JAXRPCException e) {
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
+ Assert.fail("Expected WSSecurityException");
+ } catch (org.apache.ws.security.WSSecurityException e) {
Assert.assertEquals(e.getMessage(), "WSS4JHandler: Request does not contain required Security header");
}
}
@@ -960,7 +958,7 @@ public class InteroperabilityTest extend
String action = WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.ACTOR, "test");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_2_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
@Test(invocationCount = 1)
@@ -985,6 +983,6 @@ public class InteroperabilityTest extend
String action = WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.ACTOR, "test");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_2_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SecurityContextTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SecurityContextTokenTest.java?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SecurityContextTokenTest.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SecurityContextTokenTest.java Tue Jan 31 15:44:44 2012
@@ -44,7 +44,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import javax.xml.crypto.dsig.SignatureMethod;
-import javax.xml.soap.SOAPConstants;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.dom.DOMSource;
@@ -113,7 +112,7 @@ public class SecurityContextTokenTest ex
Properties properties = new Properties();
WSS4JCallbackHandlerImpl callbackHandler = new WSS4JCallbackHandlerImpl(secret);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
@@ -205,7 +204,7 @@ public class SecurityContextTokenTest ex
Properties properties = new Properties();
WSS4JCallbackHandlerImpl callbackHandler = new WSS4JCallbackHandlerImpl(secret);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
@@ -252,7 +251,7 @@ public class SecurityContextTokenTest ex
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
}
}
@@ -298,7 +297,7 @@ public class SecurityContextTokenTest ex
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
}
}
@@ -459,7 +458,7 @@ public class SecurityContextTokenTest ex
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
}
}
}
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SignatureConfirmationTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SignatureConfirmationTest.java?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SignatureConfirmationTest.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SignatureConfirmationTest.java Tue Jan 31 15:44:44 2012
@@ -19,6 +19,7 @@
package org.swssf.wss.test;
import org.apache.ws.security.handler.WSHandlerConstants;
+import org.apache.ws.security.handler.WSHandlerResult;
import org.swssf.wss.WSSec;
import org.swssf.wss.ext.*;
import org.swssf.wss.securityEvent.SecurityEvent;
@@ -31,8 +32,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import javax.xml.rpc.handler.MessageContext;
-import javax.xml.soap.SOAPConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
@@ -43,8 +42,8 @@ import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
-import java.util.Vector;
/**
* @author $Author$
@@ -52,19 +51,20 @@ import java.util.Vector;
*/
public class SignatureConfirmationTest extends AbstractTestBase {
+ @SuppressWarnings("unchecked")
@Test
public void testDefaultConfigurationInbound() throws Exception {
- List sigv;
+ List<byte[]> sigv;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
{
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
String action = WSHandlerConstants.SIGNATURE;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
- MessageContext messageContext = doOutboundSecurityWithWSS4J_1(sourceDocument, action, properties, SOAPConstants.SOAP_1_1_PROTOCOL);
- sigv = (List) messageContext.getProperty(WSHandlerConstants.SEND_SIGV);
- Document securedDocument = (Document) messageContext.getProperty(SECURED_DOCUMENT);
+ Map<String, Object> messageContext = doOutboundSecurityWithWSS4J_1(sourceDocument, action, properties);
+ sigv = (List<byte[]>) messageContext.get(WSHandlerConstants.SEND_SIGV);
+ Document securedDocument = (Document) messageContext.get(SECURED_DOCUMENT);
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
@@ -138,10 +138,11 @@ public class SignatureConfirmationTest e
String action = WSHandlerConstants.SIGNATURE;
Properties properties = new Properties();
properties.put(WSHandlerConstants.SEND_SIGV, sigv);
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, true);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, true);
}
}
+ @SuppressWarnings("unchecked")
@Test
public void testDefaultConfigurationOutbound() throws Exception {
@@ -175,16 +176,14 @@ public class SignatureConfirmationTest e
Assert.assertEquals(nodeList.getLength(), 1);
}
- Vector wsHandlerResult;
+ List<WSHandlerResult> wsHandlerResult;
//done signature; now test sig-verification:
{
String action = WSHandlerConstants.SIGNATURE;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
- MessageContext messageContext = doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
- wsHandlerResult = (Vector) messageContext.getProperty(WSHandlerConstants.RECV_RESULTS);
-
- Document document = (Document) messageContext.getProperty(SECURED_DOCUMENT);
+ Map<String, Object> messageContext = doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
+ wsHandlerResult = (List<WSHandlerResult>) messageContext.get(WSHandlerConstants.RECV_RESULTS);
}
//so we have a request generated, now do the response:
@@ -194,8 +193,8 @@ public class SignatureConfirmationTest e
String action = WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION + " " + WSHandlerConstants.SIGNATURE;
Properties properties = new Properties();
properties.put(WSHandlerConstants.RECV_RESULTS, wsHandlerResult);
- MessageContext messageContext = doOutboundSecurityWithWSS4J_1(sourceDocument, action, properties, SOAPConstants.SOAP_1_1_PROTOCOL);
- Document securedDocument = (Document) messageContext.getProperty(SECURED_DOCUMENT);
+ Map<String, Object> messageContext = doOutboundSecurityWithWSS4J_1(sourceDocument, action, properties);
+ Document securedDocument = (Document) messageContext.get(SECURED_DOCUMENT);
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
@@ -270,9 +269,7 @@ public class SignatureConfirmationTest e
//done signature; now test sig-verification:
{
String action = WSHandlerConstants.SIGNATURE;
- Properties properties = new Properties();
- MessageContext messageContext = doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
- Document document = (Document) messageContext.getProperty(SECURED_DOCUMENT);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
}
//so we have a request generated, now do the response:
@@ -281,8 +278,8 @@ public class SignatureConfirmationTest e
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
String action = WSHandlerConstants.SIGNATURE;
Properties properties = new Properties();
- MessageContext messageContext = doOutboundSecurityWithWSS4J_1(sourceDocument, action, properties, SOAPConstants.SOAP_1_1_PROTOCOL);
- Document securedDocument = (Document) messageContext.getProperty(SECURED_DOCUMENT);
+ Map<String, Object> messageContext = doOutboundSecurityWithWSS4J_1(sourceDocument, action, properties);
+ Document securedDocument = (Document) messageContext.get(SECURED_DOCUMENT);
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
@@ -311,7 +308,7 @@ public class SignatureConfirmationTest e
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())), securityEventList, null);
try {
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Assert.assertNotNull(e.getCause());
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SignatureTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SignatureTest.java?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SignatureTest.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/SignatureTest.java Tue Jan 31 15:44:44 2012
@@ -35,7 +35,6 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import javax.xml.soap.SOAPConstants;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.dom.DOMSource;
@@ -217,7 +216,7 @@ public class SignatureTest extends Abstr
String action = WSHandlerConstants.SIGNATURE;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
@@ -594,7 +593,7 @@ public class SignatureTest extends Abstr
String action = WSHandlerConstants.SIGNATURE;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/TimestampTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/TimestampTest.java?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/TimestampTest.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/TimestampTest.java Tue Jan 31 15:44:44 2012
@@ -196,7 +196,7 @@ public class TimestampTest extends Abstr
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
try {
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Assert.assertNotNull(e.getCause());
@@ -237,7 +237,7 @@ public class TimestampTest extends Abstr
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
try {
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Assert.assertNotNull(e.getCause());
@@ -289,7 +289,7 @@ public class TimestampTest extends Abstr
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
try {
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Assert.assertNotNull(e.getCause());
@@ -327,7 +327,7 @@ public class TimestampTest extends Abstr
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
}
}
@@ -360,7 +360,7 @@ public class TimestampTest extends Abstr
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
try {
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Assert.assertNotNull(e.getCause());
@@ -400,7 +400,7 @@ public class TimestampTest extends Abstr
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
try {
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Throwable throwable = e.getCause();
@@ -486,7 +486,7 @@ public class TimestampTest extends Abstr
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
try {
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Throwable throwable = e.getCause();
@@ -526,7 +526,7 @@ public class TimestampTest extends Abstr
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
try {
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Throwable throwable = e.getCause();
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/UsernameTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/UsernameTokenTest.java?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/UsernameTokenTest.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/UsernameTokenTest.java Tue Jan 31 15:44:44 2012
@@ -115,7 +115,7 @@ public class UsernameTokenTest extends A
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
try {
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Assert.assertNotNull(e.getCause());
@@ -169,7 +169,7 @@ public class UsernameTokenTest extends A
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())), new ArrayList<SecurityEvent>(), securityEventListener);
try {
- Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
+ StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Assert.assertEquals(e.getMessage(), "org.swssf.wss.ext.WSSecurityException: Wrong username");
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/VulnerabliltyVectorsTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/VulnerabliltyVectorsTest.java?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/VulnerabliltyVectorsTest.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/VulnerabliltyVectorsTest.java Tue Jan 31 15:44:44 2012
@@ -101,7 +101,7 @@ public class VulnerabliltyVectorsTest ex
securityProperties.loadDecryptionKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
try {
- Document document = doInboundSecurity(securityProperties, xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
+ doInboundSecurity(securityProperties, xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Throwable throwable = e.getCause();
@@ -187,7 +187,7 @@ public class VulnerabliltyVectorsTest ex
inSecurityProperties.loadDecryptionKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
try {
- Document document = doInboundSecurity(inSecurityProperties, xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
+ doInboundSecurity(inSecurityProperties, xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Assert.fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
Throwable throwable = e.getCause();
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/saml/SAMLTokenHOKTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/saml/SAMLTokenHOKTest.java?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/saml/SAMLTokenHOKTest.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/saml/SAMLTokenHOKTest.java Tue Jan 31 15:44:44 2012
@@ -38,7 +38,6 @@ import org.testng.annotations.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
-import javax.xml.soap.SOAPConstants;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.dom.DOMSource;
@@ -93,7 +92,7 @@ public class SAMLTokenHOKTest extends Ab
String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.SAML_TOKEN_SIGNED;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
@@ -225,7 +224,7 @@ public class SAMLTokenHOKTest extends Ab
String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.SAML_TOKEN_SIGNED;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
Modified: webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/saml/SAMLTokenReferenceTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/saml/SAMLTokenReferenceTest.java?rev=1238672&r1=1238671&r2=1238672&view=diff
==============================================================================
--- webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/saml/SAMLTokenReferenceTest.java (original)
+++ webservices/wss4j/branches/swssf/streaming-ws-security/src/test/java/org/swssf/wss/test/saml/SAMLTokenReferenceTest.java Tue Jan 31 15:44:44 2012
@@ -38,7 +38,6 @@ import org.testng.annotations.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
-import javax.xml.soap.SOAPConstants;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.dom.DOMSource;
@@ -90,7 +89,7 @@ public class SAMLTokenReferenceTest exte
String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.SAML_TOKEN_UNSIGNED;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
@@ -172,7 +171,7 @@ public class SAMLTokenReferenceTest exte
String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.SAML_TOKEN_SIGNED;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "true");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
@@ -392,7 +391,7 @@ public class SAMLTokenReferenceTest exte
String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.SAML_TOKEN_UNSIGNED;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}
@@ -476,7 +475,7 @@ public class SAMLTokenReferenceTest exte
String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.SAML_TOKEN_SIGNED;
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
- doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, SOAPConstants.SOAP_1_1_PROTOCOL, properties, false);
+ doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
}