You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2013/09/26 15:21:21 UTC
svn commit: r1526479 [2/3] - in /webservices/wss4j/trunk:
ws-security-common/src/main/java/org/apache/wss4j/common/
ws-security-dom/src/main/java/org/apache/wss4j/dom/
ws-security-dom/src/main/java/org/apache/wss4j/dom/action/
ws-security-dom/src/main/...
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/WSHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/WSHandler.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/WSHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/WSHandler.java Thu Sep 26 13:21:19 2013
@@ -35,11 +35,14 @@ import javax.security.auth.callback.Call
import javax.security.auth.callback.CallbackHandler;
import org.apache.wss4j.dom.WSConstants;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.dom.WSSecurityEngine;
import org.apache.wss4j.dom.WSSecurityEngineResult;
import org.apache.wss4j.dom.action.Action;
+import org.apache.wss4j.common.EncryptionActionToken;
+import org.apache.wss4j.common.SignatureActionToken;
+import org.apache.wss4j.common.SignatureEncryptionActionToken;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.crypto.AlgorithmSuite;
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoFactory;
@@ -69,20 +72,17 @@ public abstract class WSHandler {
/**
* Performs all defined security actions to set-up the SOAP request.
*
- *
- * @param doAction a set defining the actions to do
* @param doc the request as DOM document
* @param reqData a data storage to pass values around between methods
* @param actions a list holding the actions to do in the order defined
- * in the deployment file or property
+ * in the deployment file or property, plus an optional
+ * associated SecurityActionToken object for that Action
* @throws WSSecurityException
*/
- @SuppressWarnings("unchecked")
protected void doSenderAction(
- int doAction,
Document doc,
RequestData reqData,
- List<Integer> actions,
+ List<HandlerAction> actions,
boolean isRequest
) throws WSSecurityException {
@@ -92,16 +92,8 @@ public abstract class WSHandler {
if (wssConfig == null) {
wssConfig = secEngine.getWssConfig();
}
-
- boolean enableSigConf = decodeEnableSignatureConfirmation(reqData);
- wssConfig.setEnableSignatureConfirmation(
- enableSigConf || (doAction & WSConstants.SC) != 0
- );
wssConfig.setPasswordsAreEncoded(decodeUseEncodedPasswords(reqData));
-
- wssConfig.setPrecisionInMilliSeconds(
- decodeTimestampPrecision(reqData)
- );
+ wssConfig.setPrecisionInMilliSeconds(decodeTimestampPrecision(reqData));
reqData.setWssConfig(wssConfig);
Object mc = reqData.getMsgContext();
@@ -112,11 +104,9 @@ public abstract class WSHandler {
secHeader.insertSecurityHeader(doc);
reqData.setSecHeader(secHeader);
- reqData.setSoapConstants(
- WSSecurityUtil.getSOAPConstants(doc.getDocumentElement())
- );
+ reqData.setSoapConstants(WSSecurityUtil.getSOAPConstants(doc.getDocumentElement()));
wssConfig.setAddInclusivePrefixes(decodeAddInclusivePrefixes(reqData));
-
+
// Load CallbackHandler
if (reqData.getCallbackHandler() == null) {
CallbackHandler passwordCallbackHandler =
@@ -124,60 +114,64 @@ public abstract class WSHandler {
reqData.setCallbackHandler(passwordCallbackHandler);
}
- /*
- * Here we have action, username, password, and actor, mustUnderstand.
- * Now get the action specific parameters.
- */
- if ((doAction & WSConstants.UT) == WSConstants.UT) {
- decodeUTParameter(reqData);
- }
- /*
- * Here we have action, username, password, and actor, mustUnderstand.
- * Now get the action specific parameters.
- */
- if ((doAction & WSConstants.UT_SIGN) == WSConstants.UT_SIGN) {
- decodeUTParameter(reqData);
- decodeSignatureParameter(reqData);
- }
- /*
- * Get and check the Signature specific parameters first because they
- * may be used for encryption too.
- */
- if ((doAction & WSConstants.SIGN) == WSConstants.SIGN) {
- if (reqData.getSigCrypto() == null) {
- reqData.setSigCrypto(loadSignatureCrypto(reqData));
- }
- decodeSignatureParameter(reqData);
- }
- /*
- * If we need to handle signed SAML token then we may need the
- * Signature parameters. The handle procedure loads the signature crypto
- * file on demand, thus don't do it here.
- */
- if ((doAction & WSConstants.ST_SIGNED) == WSConstants.ST_SIGNED) {
- decodeSignatureParameter(reqData);
- }
- /*
- * Set and check the encryption specific parameters, if necessary take
- * over signature parameters username and crypto instance.
- */
- if ((doAction & WSConstants.ENCR) == WSConstants.ENCR) {
- if (reqData.getEncCrypto() == null) {
- reqData.setEncCrypto(loadEncryptionCrypto(reqData));
+ boolean enableSigConf = decodeEnableSignatureConfirmation(reqData);
+ wssConfig.setEnableSignatureConfirmation(enableSigConf);
+
+ // Perform configuration
+ for (HandlerAction actionToDo : actions) {
+ if (actionToDo.getAction() == WSConstants.SC) {
+ wssConfig.setEnableSignatureConfirmation(true);
+ } else if (actionToDo.getAction() == WSConstants.UT
+ && actionToDo.getActionToken() == null) {
+ decodeUTParameter(reqData);
+ } else if (actionToDo.getAction() == WSConstants.UT_SIGN
+ && actionToDo.getActionToken() == null) {
+ decodeUTParameter(reqData);
+ decodeSignatureParameter(reqData);
+ } else if (actionToDo.getAction() == WSConstants.SIGN
+ && actionToDo.getActionToken() == null) {
+ SignatureActionToken actionToken = reqData.getSignatureToken();
+ if (actionToken == null) {
+ actionToken = new SignatureActionToken();
+ reqData.setSignatureToken(actionToken);
+ }
+ if (actionToken.getCrypto() == null) {
+ actionToken.setCrypto(loadSignatureCrypto(reqData));
+ }
+ decodeSignatureParameter(reqData);
+ } else if (actionToDo.getAction() == WSConstants.ST_SIGNED
+ && actionToDo.getActionToken() == null) {
+ decodeSignatureParameter(reqData);
+ } else if (actionToDo.getAction() == WSConstants.ENCR
+ && actionToDo.getActionToken() == null) {
+ EncryptionActionToken actionToken = reqData.getEncryptionToken();
+ if (actionToken == null) {
+ actionToken = new EncryptionActionToken();
+ reqData.setEncryptionToken(actionToken);
+ }
+ if (actionToken.getCrypto() == null) {
+ actionToken.setCrypto(loadEncryptionCrypto(reqData));
+ }
+ decodeEncryptionParameter(reqData);
}
- decodeEncryptionParameter(reqData);
}
+
/*
* If after all the parsing no Signature parts defined, set here a
* default set. This is necessary because we add SignatureConfirmation
* and therefore the default (Body) must be set here. The default setting
* in WSSignEnvelope doesn't work because the vector is not empty anymore.
*/
- if (reqData.getSignatureParts().isEmpty()) {
+ SignatureActionToken signatureToken = reqData.getSignatureToken();
+ if (signatureToken == null) {
+ signatureToken = new SignatureActionToken();
+ reqData.setSignatureToken(signatureToken);
+ }
+ if (signatureToken.getParts().isEmpty()) {
WSEncryptionPart encP = new WSEncryptionPart(reqData.getSoapConstants()
.getBodyQName().getLocalPart(), reqData.getSoapConstants()
.getEnvelopeURI(), "Content");
- reqData.getSignatureParts().add(encP);
+ signatureToken.getParts().add(encP);
}
/*
* If SignatureConfirmation is enabled and this is a response then
@@ -189,44 +183,37 @@ public abstract class WSHandler {
String done =
(String)getProperty(reqData.getMsgContext(), WSHandlerConstants.SIG_CONF_DONE);
if (done == null) {
- wssConfig.getAction(WSConstants.SC).execute(this, WSConstants.SC, doc, reqData);
+ wssConfig.getAction(WSConstants.SC).execute(this, null, doc, reqData);
}
}
// See if the Signature and Timestamp actions (in that order) are defined, and if
// the Timestamp is to be signed. In this case we need to swap the actions, as the
// Timestamp must appear in the security header first for signature creation to work.
- List<Integer> actionsToPerform = actions;
- if (actions.contains(WSConstants.SIGN) && actions.contains(WSConstants.TS)
- && actions.indexOf(WSConstants.SIGN) < actions.indexOf(WSConstants.TS)) {
- boolean signTimestamp = false;
- for (WSEncryptionPart encP : reqData.getSignatureParts()) {
- if (WSConstants.WSU_NS.equals(encP.getNamespace())
- && "Timestamp".equals(encP.getName())) {
- signTimestamp = true;
- }
- }
- if (signTimestamp) {
- actionsToPerform = new ArrayList<Integer>(actions);
- Collections.copy(actionsToPerform, actions);
- int signatureIndex = actions.indexOf(WSConstants.SIGN);
- actionsToPerform.remove(signatureIndex);
- actionsToPerform.add(WSConstants.SIGN);
- reqData.setAppendSignatureAfterTimestamp(true);
- reqData.setOriginalSignatureActionPosition(signatureIndex);
- }
+ List<HandlerAction> actionsToPerform = actions;
+ HandlerAction signingAction = getSignatureActionThatSignsATimestamp(actions, reqData);
+
+ if (signingAction != null) {
+ actionsToPerform = new ArrayList<HandlerAction>(actions);
+ Collections.copy(actionsToPerform, actions);
+
+ int signatureIndex = actions.indexOf(WSConstants.SIGN);
+ actionsToPerform.remove(signingAction);
+ actionsToPerform.add(signingAction);
+ reqData.setAppendSignatureAfterTimestamp(true);
+ reqData.setOriginalSignatureActionPosition(signatureIndex);
}
/*
* Here we have all necessary information to perform the requested
* action(s).
*/
- for (Integer actionToDo : actionsToPerform) {
+ for (HandlerAction actionToDo : actionsToPerform) {
if (doDebug) {
- log.debug("Performing Action: " + actionToDo);
+ log.debug("Performing Action: " + actionToDo.getAction());
}
- switch (actionToDo) {
+ switch (actionToDo.getAction()) {
case WSConstants.UT:
case WSConstants.ENCR:
case WSConstants.SIGN:
@@ -234,7 +221,8 @@ public abstract class WSHandler {
case WSConstants.ST_UNSIGNED:
case WSConstants.TS:
case WSConstants.UT_SIGN:
- wssConfig.getAction(actionToDo).execute(this, actionToDo, doc, reqData);
+ wssConfig.getAction(actionToDo.getAction()).execute(
+ this, actionToDo.getActionToken(), doc, reqData);
break;
//
// Handle any "custom" actions, similarly,
@@ -244,7 +232,7 @@ public abstract class WSHandler {
default:
Action doit = null;
try {
- doit = wssConfig.getAction(actionToDo);
+ doit = wssConfig.getAction(actionToDo.getAction());
} catch (final WSSecurityException e) {
log.warn(
"Error trying to locate a custom action (" + actionToDo + ")",
@@ -252,7 +240,7 @@ public abstract class WSHandler {
);
}
if (doit != null) {
- doit.execute(this, actionToDo, doc, reqData);
+ doit.execute(this, actionToDo.getActionToken(), doc, reqData);
}
}
}
@@ -264,6 +252,7 @@ public abstract class WSHandler {
*/
if (wssConfig.isEnableSignatureConfirmation()
&& isRequest && reqData.getSignatureValues().size() > 0) {
+ @SuppressWarnings("unchecked")
List<byte[]> savedSignatures =
(List<byte[]>)getProperty(reqData.getMsgContext(), WSHandlerConstants.SEND_SIGV);
if (savedSignatures == null) {
@@ -275,8 +264,38 @@ public abstract class WSHandler {
savedSignatures.addAll(reqData.getSignatureValues());
}
}
+
+ private HandlerAction getSignatureActionThatSignsATimestamp(
+ List<HandlerAction> actions, RequestData reqData
+ ) {
+ for (HandlerAction action : actions) {
+ // Only applies if a Signature is before a Timestamp
+ if (action.getAction() == WSConstants.TS) {
+ return null;
+ } else if (action.getAction() == WSConstants.SIGN) {
+ if (action.getActionToken() != null
+ && ((SignatureEncryptionActionToken)action.getActionToken()).getParts() != null) {
+ for (WSEncryptionPart encP
+ : ((SignatureEncryptionActionToken)action.getActionToken()).getParts()) {
+ if (WSConstants.WSU_NS.equals(encP.getNamespace())
+ && "Timestamp".equals(encP.getName())) {
+ return action;
+ }
+ }
+ } else {
+ for (WSEncryptionPart encP : reqData.getSignatureToken().getParts()) {
+ if (WSConstants.WSU_NS.equals(encP.getNamespace())
+ && "Timestamp".equals(encP.getName())) {
+ return action;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
- protected void doReceiverAction(int doAction, RequestData reqData)
+ protected void doReceiverAction(List<Integer> actions, RequestData reqData)
throws WSSecurityException {
WSSConfig wssConfig = reqData.getWssConfig();
@@ -285,7 +304,7 @@ public abstract class WSHandler {
}
boolean enableSigConf = decodeEnableSignatureConfirmation(reqData);
wssConfig.setEnableSignatureConfirmation(
- enableSigConf || (doAction & WSConstants.SC) != 0
+ enableSigConf || actions.contains(WSConstants.SC)
);
wssConfig.setTimeStampStrict(decodeTimestampStrict(reqData));
String passwordType = decodePasswordType(reqData);
@@ -321,13 +340,12 @@ public abstract class WSHandler {
reqData.setCallbackHandler(passwordCallbackHandler);
}
- if ((doAction & WSConstants.SIGN) == WSConstants.SIGN
- || (doAction & WSConstants.ST_SIGNED) == WSConstants.ST_SIGNED
- || (doAction & WSConstants.ST_UNSIGNED) == WSConstants.ST_UNSIGNED) {
+ if (actions.contains(WSConstants.SIGN) || actions.contains(WSConstants.ST_SIGNED)
+ || actions.contains(WSConstants.ST_UNSIGNED)) {
decodeSignatureParameter2(reqData);
}
- if ((doAction & WSConstants.ENCR) == WSConstants.ENCR) {
+ if (actions.contains(WSConstants.ENCR)) {
decodeDecryptionParameter(reqData);
}
decodeRequireSignedEncryptedDataElements(reqData);
@@ -451,18 +469,12 @@ public abstract class WSHandler {
}
//
- // This indicates this is the last handler: the list holding the
- // stored Signature values must be empty, otherwise we have an error
+ // the list holding the stored Signature values must be empty, otherwise we have an error
//
- if (!reqData.isNoSerialization()) {
- if (doDebug) {
- log.debug("Check Signature confirmation - last handler");
- }
- if (savedSignatures != null && !savedSignatures.isEmpty()) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
- "Check Signature confirmation: the stored signature values list is not empty"
- );
- }
+ if (savedSignatures != null && !savedSignatures.isEmpty()) {
+ throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
+ "Check Signature confirmation: the stored signature values list is not empty"
+ );
}
}
@@ -505,15 +517,23 @@ public abstract class WSHandler {
}
}
+ // Convert various Signature configuration into a single SignatureActionToken to be set on
+ // the RequestData object
protected void decodeSignatureParameter(RequestData reqData)
throws WSSecurityException {
Object mc = reqData.getMsgContext();
String signatureUser = getString(WSHandlerConstants.SIGNATURE_USER, mc);
+ SignatureActionToken actionToken = reqData.getSignatureToken();
+ if (actionToken == null) {
+ actionToken = new SignatureActionToken();
+ reqData.setSignatureToken(actionToken);
+ }
+
if (signatureUser != null) {
- reqData.setSignatureUser(signatureUser);
+ actionToken.setUser(signatureUser);
} else {
- reqData.setSignatureUser(reqData.getUsername());
+ actionToken.setUser(reqData.getUsername());
}
String keyId = getString(WSHandlerConstants.SIG_KEY_ID, mc);
@@ -538,31 +558,31 @@ public abstract class WSHandler {
"WSHandler: Signature: illegal key identification"
);
}
- reqData.setSigKeyId(tmp);
+ actionToken.setKeyIdentifierId(tmp);
}
String algo = getString(WSHandlerConstants.SIG_ALGO, mc);
- reqData.setSigAlgorithm(algo);
+ actionToken.setSignatureAlgorithm(algo);
String digestAlgo = getString(WSHandlerConstants.SIG_DIGEST_ALGO, mc);
- reqData.setSigDigestAlgorithm(digestAlgo);
+ actionToken.setDigestAlgorithm(digestAlgo);
String c14nAlgo = getString(WSHandlerConstants.SIG_C14N_ALGO, mc);
- reqData.setSignatureC14nAlgorithm(c14nAlgo);
+ actionToken.setC14nAlgorithm(c14nAlgo);
String parts = getString(WSHandlerConstants.SIGNATURE_PARTS, mc);
if (parts != null) {
- splitEncParts(true, parts, reqData.getSignatureParts(), reqData);
+ splitEncParts(true, parts, actionToken.getParts(), reqData);
}
parts = getString(WSHandlerConstants.OPTIONAL_SIGNATURE_PARTS, mc);
if (parts != null) {
- splitEncParts(false, parts, reqData.getSignatureParts(), reqData);
+ splitEncParts(false, parts, actionToken.getParts(), reqData);
}
boolean useSingleCert = decodeUseSingleCertificate(reqData);
- reqData.setUseSingleCert(useSingleCert);
+ actionToken.setUseSingleCert(useSingleCert);
boolean includeSignatureToken = decodeIncludeSignatureToken(reqData);
- reqData.setIncludeSignatureToken(includeSignatureToken);
+ actionToken.setIncludeSignatureToken(includeSignatureToken);
}
protected void decodeAlgorithmSuite(RequestData reqData) throws WSSecurityException {
@@ -594,14 +614,21 @@ public abstract class WSHandler {
reqData.setAlgorithmSuite(algorithmSuite);
}
+ // Convert various Encryption configuration into a single EncryptionActionToken to be set on
+ // the RequestData object
protected void decodeEncryptionParameter(RequestData reqData)
throws WSSecurityException {
Object mc = reqData.getMsgContext();
- /*
- * If the following parameters are no used (they return null) then the
- * default values of WSS4J are used.
- */
+ EncryptionActionToken actionToken = reqData.getEncryptionToken();
+ if (actionToken == null) {
+ actionToken = new EncryptionActionToken();
+ reqData.setEncryptionToken(actionToken);
+ }
+ //
+ // If the following parameters are no used (they return null) then the
+ // default values of WSS4J are used.
+ //
String encKeyId = getString(WSHandlerConstants.ENC_KEY_ID, mc);
if (encKeyId != null) {
Integer id = WSHandlerConstants.getKeyIdentifier(encKeyId);
@@ -612,7 +639,7 @@ public abstract class WSHandler {
);
}
int tmp = id;
- reqData.setEncKeyId(tmp);
+ actionToken.setKeyIdentifierId(tmp);
if (!(tmp == WSConstants.ISSUER_SERIAL
|| tmp == WSConstants.X509_KEY_IDENTIFIER
|| tmp == WSConstants.SKI_KEY_IDENTIFIER
@@ -627,31 +654,31 @@ public abstract class WSHandler {
}
}
String encSymAlgo = getString(WSHandlerConstants.ENC_SYM_ALGO, mc);
- reqData.setEncSymmAlgo(encSymAlgo);
+ actionToken.setSymmetricAlgorithm(encSymAlgo);
String encKeyTransport =
getString(WSHandlerConstants.ENC_KEY_TRANSPORT, mc);
- reqData.setEncKeyTransport(encKeyTransport);
+ actionToken.setKeyTransportAlgorithm(encKeyTransport);
String digestAlgo = getString(WSHandlerConstants.ENC_DIGEST_ALGO, mc);
- reqData.setEncDigestAlgorithm(digestAlgo);
+ actionToken.setDigestAlgorithm(digestAlgo);
String mgfAlgo = getString(WSHandlerConstants.ENC_MGF_ALGO, mc);
- reqData.setEncMGFAlgorithm(mgfAlgo);
+ actionToken.setMgfAlgorithm(mgfAlgo);
String encSymEncKey = getString(WSHandlerConstants.ENC_SYM_ENC_KEY, mc);
if (encSymEncKey != null) {
boolean encSymEndKeyBoolean = Boolean.parseBoolean(encSymEncKey);
- reqData.setEncryptSymmetricEncryptionKey(encSymEndKeyBoolean);
+ actionToken.setEncSymmetricEncryptionKey(encSymEndKeyBoolean);
}
String encUser = getString(WSHandlerConstants.ENCRYPTION_USER, mc);
if (encUser != null) {
- reqData.setEncUser(encUser);
+ actionToken.setUser(encUser);
} else {
- reqData.setEncUser(reqData.getUsername());
+ actionToken.setUser(reqData.getUsername());
}
- if (reqData.getEncryptSymmetricEncryptionKey() && reqData.getEncUser() == null) {
+ if (actionToken.isEncSymmetricEncryptionKey() && actionToken.getUser() == null) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"empty", "WSHandler: Encryption: no username");
}
@@ -660,11 +687,11 @@ public abstract class WSHandler {
String encParts = getString(WSHandlerConstants.ENCRYPTION_PARTS, mc);
if (encParts != null) {
- splitEncParts(true, encParts, reqData.getEncryptParts(), reqData);
+ splitEncParts(true, encParts, actionToken.getParts(), reqData);
}
encParts = getString(WSHandlerConstants.OPTIONAL_ENCRYPTION_PARTS, mc);
if (encParts != null) {
- splitEncParts(false, encParts, reqData.getEncryptParts(), reqData);
+ splitEncParts(false, encParts, actionToken.getParts(), reqData);
}
}
@@ -1241,7 +1268,9 @@ public abstract class WSHandler {
@SuppressWarnings("unchecked")
private void handleSpecialUser(RequestData reqData) {
- if (!WSHandlerConstants.USE_REQ_SIG_CERT.equals(reqData.getEncUser())) {
+ EncryptionActionToken actionToken = reqData.getEncryptionToken();
+ if (actionToken == null
+ || !WSHandlerConstants.USE_REQ_SIG_CERT.equals(actionToken.getUser())) {
return;
}
List<WSHandlerResult> results =
@@ -1272,7 +1301,7 @@ public abstract class WSHandler {
if (wserAction == WSConstants.SIGN) {
X509Certificate cert =
(X509Certificate)wser.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
- reqData.setEncCert(cert);
+ actionToken.setCertificate(cert);
return;
}
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecBase.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecBase.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecBase.java Thu Sep 26 13:21:19 2013
@@ -19,8 +19,8 @@
package org.apache.wss4j.dom.message;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.dom.WSConstants;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.dom.util.WSSecurityUtil;
import org.w3c.dom.Document;
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java Thu Sep 26 13:21:19 2013
@@ -20,15 +20,14 @@
package org.apache.wss4j.dom.message;
import org.apache.wss4j.dom.WSConstants;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.common.derivedKey.ConversationConstants;
import org.apache.wss4j.common.derivedKey.ConversationException;
import org.apache.wss4j.dom.message.token.Reference;
import org.apache.wss4j.dom.message.token.SecurityTokenReference;
import org.apache.wss4j.dom.util.WSSecurityUtil;
-
import org.apache.xml.security.keys.KeyInfo;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java Thu Sep 26 13:21:19 2013
@@ -21,8 +21,8 @@ package org.apache.wss4j.dom.message;
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSDocInfo;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.common.derivedKey.ConversationConstants;
import org.apache.wss4j.common.derivedKey.ConversationException;
@@ -30,7 +30,6 @@ import org.apache.wss4j.dom.message.toke
import org.apache.wss4j.dom.message.token.SecurityTokenReference;
import org.apache.wss4j.dom.transform.STRTransform;
import org.apache.wss4j.dom.util.WSSecurityUtil;
-
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java Thu Sep 26 13:21:19 2013
@@ -20,8 +20,8 @@
package org.apache.wss4j.dom.message;
import org.apache.wss4j.dom.WSConstants;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoType;
import org.apache.wss4j.common.ext.WSSecurityException;
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java Thu Sep 26 13:21:19 2013
@@ -21,8 +21,8 @@ package org.apache.wss4j.dom.message;
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSDocInfo;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoType;
import org.apache.wss4j.common.ext.WSSecurityException;
@@ -37,7 +37,6 @@ import org.apache.wss4j.dom.message.toke
import org.apache.wss4j.dom.transform.STRTransform;
import org.apache.wss4j.dom.util.WSSecurityUtil;
import org.apache.xml.security.utils.Base64;
-
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java Thu Sep 26 13:21:19 2013
@@ -21,8 +21,8 @@ package org.apache.wss4j.dom.message;
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSDocInfo;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.dom.transform.STRTransform;
import org.apache.wss4j.dom.util.WSSecurityUtil;
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/saml/WSSecSignatureSAML.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/saml/WSSecSignatureSAML.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/saml/WSSecSignatureSAML.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/saml/WSSecSignatureSAML.java Thu Sep 26 13:21:19 2013
@@ -33,10 +33,11 @@ import javax.xml.crypto.dsig.dom.DOMSign
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec;
+import org.apache.wss4j.common.SignatureActionToken;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.saml.SamlAssertionWrapper;
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSDocInfo;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoType;
@@ -254,12 +255,14 @@ public class WSSecSignatureSAML extends
}
if (secretKey == null) {
RequestData data = new RequestData();
- data.setSigCrypto(userCrypto);
+ SignatureActionToken actionToken = new SignatureActionToken();
+ data.setSignatureToken(actionToken);
+ actionToken.setCrypto(userCrypto);
data.setWssConfig(getWsConfig());
SAMLKeyInfo samlKeyInfo =
SAMLUtil.getCredentialFromSubject(
samlAssertion, new WSSSAMLKeyInfoProcessor(data, wsDocInfo),
- data.getSigCrypto(), data.getCallbackHandler()
+ userCrypto, data.getCallbackHandler()
);
publicKey = samlKeyInfo.getPublicKey();
certs = samlKeyInfo.getCerts();
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java Thu Sep 26 13:21:19 2013
@@ -24,12 +24,13 @@ import org.apache.wss4j.dom.SOAP12Consta
import org.apache.wss4j.dom.SOAPConstants;
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSDataRef;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSecurityEngineResult;
import org.apache.wss4j.dom.WSSConfig;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.common.util.StringUtil;
import org.apache.wss4j.common.util.XMLUtils;
+import org.apache.wss4j.dom.handler.HandlerAction;
import org.apache.wss4j.dom.handler.WSHandlerConstants;
import org.apache.wss4j.dom.message.CallbackLookup;
import org.apache.xml.security.algorithms.JCEMapper;
@@ -936,46 +937,32 @@ public final class WSSecurityUtil {
return actionResultList;
}
- public static int decodeAction(
- String action,
- List<Integer> actions
- ) throws WSSecurityException {
-
- int doAction = 0;
+ public static List<Integer> decodeAction(String action) throws WSSecurityException {
+ List<Integer> actions = new ArrayList<Integer>();
if (action == null) {
- return doAction;
+ return actions;
}
String single[] = StringUtil.split(action, ' ');
for (int i = 0; i < single.length; i++) {
if (single[i].equals(WSHandlerConstants.NO_SECURITY)) {
- doAction = WSConstants.NO_SECURITY;
- return doAction;
+ return actions;
} else if (single[i].equals(WSHandlerConstants.USERNAME_TOKEN)) {
- doAction |= WSConstants.UT;
actions.add(WSConstants.UT);
} else if (single[i].equals(WSHandlerConstants.USERNAME_TOKEN_NO_PASSWORD)) {
- doAction |= WSConstants.UT_NOPASSWORD;
actions.add(WSConstants.UT_NOPASSWORD);
} else if (single[i].equals(WSHandlerConstants.SIGNATURE)) {
- doAction |= WSConstants.SIGN;
actions.add(WSConstants.SIGN);
} else if (single[i].equals(WSHandlerConstants.ENCRYPT)) {
- doAction |= WSConstants.ENCR;
actions.add(WSConstants.ENCR);
} else if (single[i].equals(WSHandlerConstants.SAML_TOKEN_UNSIGNED)) {
- doAction |= WSConstants.ST_UNSIGNED;
actions.add(WSConstants.ST_UNSIGNED);
} else if (single[i].equals(WSHandlerConstants.SAML_TOKEN_SIGNED)) {
- doAction |= WSConstants.ST_SIGNED;
actions.add(WSConstants.ST_SIGNED);
} else if (single[i].equals(WSHandlerConstants.TIMESTAMP)) {
- doAction |= WSConstants.TS;
actions.add(WSConstants.TS);
} else if (single[i].equals(WSHandlerConstants.USERNAME_TOKEN_SIGNATURE)) {
- doAction |= WSConstants.UT_SIGN;
actions.add(WSConstants.UT_SIGN);
} else if (single[i].equals(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION)) {
- doAction |= WSConstants.SC;
actions.add(WSConstants.SC);
} else {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
@@ -983,57 +970,45 @@ public final class WSSecurityUtil {
);
}
}
- return doAction;
+ return actions;
}
/**
* Decode an action String. This method should only be called on the outbound side.
* @param action The initial String of actions to perform
- * @param actions The list of created actions that will be performed
* @param wssConfig This object holds the list of custom actions to be performed.
- * @return The or'd integer of all the actions (apart from the custom actions)
+ * @return The list of HandlerAction Objects
* @throws WSSecurityException
*/
- public static int decodeAction(
+ public static List<HandlerAction> decodeHandlerAction(
String action,
- List<Integer> actions,
WSSConfig wssConfig
) throws WSSecurityException {
-
- int doAction = 0;
+ List<HandlerAction> actions = new ArrayList<HandlerAction>();
if (action == null) {
- return doAction;
+ return actions;
}
String single[] = StringUtil.split(action, ' ');
for (int i = 0; i < single.length; i++) {
if (single[i].equals(WSHandlerConstants.NO_SECURITY)) {
- doAction = WSConstants.NO_SECURITY;
- return doAction;
+ return actions;
} else if (single[i].equals(WSHandlerConstants.USERNAME_TOKEN)) {
- doAction |= WSConstants.UT;
- actions.add(WSConstants.UT);
+ actions.add(new HandlerAction(WSConstants.UT));
} else if (single[i].equals(WSHandlerConstants.SIGNATURE)) {
- doAction |= WSConstants.SIGN;
- actions.add(WSConstants.SIGN);
+ actions.add(new HandlerAction(WSConstants.SIGN));
} else if (single[i].equals(WSHandlerConstants.ENCRYPT)) {
- doAction |= WSConstants.ENCR;
- actions.add(WSConstants.ENCR);
+ actions.add(new HandlerAction(WSConstants.ENCR));
} else if (single[i].equals(WSHandlerConstants.SAML_TOKEN_UNSIGNED)) {
- doAction |= WSConstants.ST_UNSIGNED;
- actions.add(WSConstants.ST_UNSIGNED);
+ actions.add(new HandlerAction(WSConstants.ST_UNSIGNED));
} else if (single[i].equals(WSHandlerConstants.SAML_TOKEN_SIGNED)) {
- doAction |= WSConstants.ST_SIGNED;
- actions.add(WSConstants.ST_SIGNED);
+ actions.add(new HandlerAction(WSConstants.ST_SIGNED));
} else if (single[i].equals(WSHandlerConstants.TIMESTAMP)) {
- doAction |= WSConstants.TS;
- actions.add(WSConstants.TS);
+ actions.add(new HandlerAction(WSConstants.TS));
} else if (single[i].equals(WSHandlerConstants.USERNAME_TOKEN_SIGNATURE)) {
- doAction |= WSConstants.UT_SIGN;
- actions.add(WSConstants.UT_SIGN);
+ actions.add(new HandlerAction(WSConstants.UT_SIGN));
} else if (single[i].equals(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION)) {
- doAction |= WSConstants.SC;
- actions.add(WSConstants.SC);
+ actions.add(new HandlerAction(WSConstants.SC));
} else {
try {
int parsedAction = Integer.parseInt(single[i]);
@@ -1042,7 +1017,7 @@ public final class WSSecurityUtil {
"Unknown action defined: " + single[i]
);
}
- actions.add(parsedAction);
+ actions.add(new HandlerAction(parsedAction));
} catch (NumberFormatException ex) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
"Unknown action defined: " + single[i]
@@ -1050,7 +1025,7 @@ public final class WSSecurityUtil {
}
}
}
- return doAction;
+ return actions;
}
/**
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomAction.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomAction.java Thu Sep 26 13:21:19 2013
@@ -20,6 +20,7 @@
package org.apache.wss4j.dom.common;
import org.apache.wss4j.dom.action.Action;
+import org.apache.wss4j.common.SecurityActionToken;
import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.dom.handler.WSHandler;
import org.apache.wss4j.dom.handler.RequestData;
@@ -32,7 +33,7 @@ public class CustomAction implements Act
public void
execute(
WSHandler handler,
- int actionToDo,
+ SecurityActionToken action,
org.w3c.dom.Document doc,
RequestData reqData
) throws WSSecurityException {
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomHandler.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomHandler.java Thu Sep 26 13:21:19 2013
@@ -21,6 +21,7 @@ package org.apache.wss4j.dom.common;
import org.apache.wss4j.dom.WSSecurityEngineResult;
import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.dom.handler.HandlerAction;
import org.apache.wss4j.dom.handler.WSHandler;
import org.apache.wss4j.dom.handler.RequestData;
import org.w3c.dom.Document;
@@ -78,14 +79,12 @@ public class CustomHandler extends WSHan
}
public void send(
- int action,
Document doc,
RequestData reqData,
- List<Integer> actions,
+ List<HandlerAction> actions,
boolean request
) throws WSSecurityException {
doSenderAction(
- action,
doc,
reqData,
actions,
@@ -94,11 +93,11 @@ public class CustomHandler extends WSHan
}
public void receive(
- int action,
+ List<Integer> actions,
RequestData reqData
) throws WSSecurityException {
doReceiverAction(
- action,
+ actions,
reqData
);
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CallbackRefTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CallbackRefTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CallbackRefTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CallbackRefTest.java Thu Sep 26 13:21:19 2013
@@ -19,6 +19,8 @@
package org.apache.wss4j.dom.handler;
+import java.util.Collections;
+
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.dom.common.CustomHandler;
@@ -69,11 +71,11 @@ public class CallbackRefTest extends org
actions.add(WSConstants.UT);
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.UT);
handler.send(
- WSConstants.UT,
doc,
reqData,
- actions,
+ Collections.singletonList(action),
true
);
@@ -106,11 +108,11 @@ public class CallbackRefTest extends org
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
handler.setOption(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
+ HandlerAction action = new HandlerAction(WSConstants.UT);
handler.send(
- WSConstants.UT,
doc,
reqData,
- actions,
+ Collections.singletonList(action),
true
);
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomActionProcessorTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomActionProcessorTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomActionProcessorTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomActionProcessorTest.java Thu Sep 26 13:21:19 2013
@@ -37,8 +37,8 @@ import org.apache.wss4j.dom.message.WSSe
import org.apache.wss4j.dom.util.WSSecurityUtil;
import org.w3c.dom.Document;
+import java.util.Collections;
import java.util.List;
-import java.util.ArrayList;
/**
@@ -168,17 +168,14 @@ public class CustomActionProcessorTest e
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
- final List<Integer> actions = new ArrayList<Integer>();
- actions.add(action);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
reqData.setMsgContext("bread");
assertEquals(reqData.getMsgContext(), "bread");
handler.send(
- action,
doc,
reqData,
- actions,
+ Collections.singletonList(new HandlerAction(action)),
true
);
assertEquals(reqData.getMsgContext(), "crumb");
@@ -198,17 +195,14 @@ public class CustomActionProcessorTest e
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
- final List<Integer> actions = new ArrayList<Integer>();
- actions.add(action);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
reqData.setMsgContext("bread");
assertEquals(reqData.getMsgContext(), "bread");
handler.send(
- action,
doc,
reqData,
- actions,
+ Collections.singletonList(new HandlerAction(action)),
true
);
assertEquals(reqData.getMsgContext(), "crumb");
@@ -227,28 +221,15 @@ public class CustomActionProcessorTest e
String actionString =
WSHandlerConstants.TIMESTAMP + " " + Integer.valueOf(customAction).toString();
- List<Integer> actionList = new ArrayList<Integer>();
- //
- // This parsing will fail as it doesn't know what the custom action is
- //
- try {
- WSSecurityUtil.decodeAction(actionString, actionList);
- fail("Failure expected on unknown action");
- } catch (WSSecurityException ex) {
- // expected
- }
- actionList.clear();
-
//
// This parsing will fail as WSSConfig doesn't know what the custom action is
//
try {
- WSSecurityUtil.decodeAction(actionString, actionList, cfg);
+ WSSecurityUtil.decodeHandlerAction(actionString, cfg);
fail("Failure expected on unknown action");
} catch (WSSecurityException ex) {
// expected
}
- actionList.clear();
//
// This parsing will fail as the action String is badly formed
@@ -256,18 +237,17 @@ public class CustomActionProcessorTest e
try {
String badActionString =
WSHandlerConstants.TIMESTAMP + " " + "NewCustomAction";
- WSSecurityUtil.decodeAction(badActionString, actionList, cfg);
+ WSSecurityUtil.decodeHandlerAction(badActionString, cfg);
fail("Failure expected on unknown action");
} catch (WSSecurityException ex) {
// expected
}
- actionList.clear();
//
// This parsing should pass as WSSConfig has been configured with the custom action
//
cfg.setAction(customAction, org.apache.wss4j.dom.common.CustomAction.class);
- int actions = WSSecurityUtil.decodeAction(actionString, actionList, cfg);
+ List<HandlerAction> actionList = WSSecurityUtil.decodeHandlerAction(actionString, cfg);
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
@@ -277,7 +257,6 @@ public class CustomActionProcessorTest e
reqData.setMsgContext("bread");
assertEquals(reqData.getMsgContext(), "bread");
handler.send(
- actions,
doc,
reqData,
actionList,
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java Thu Sep 26 13:21:19 2013
@@ -78,12 +78,14 @@ public class SignatureConfirmationTest e
reqData.setMsgContext(msgContext);
reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.SIGN);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.SIGN);
handler.send(
- WSConstants.SIGN, doc, reqData, actions, true
+ doc,
+ reqData,
+ Collections.singletonList(action),
+ true
);
if (LOG.isDebugEnabled()) {
LOG.debug("After Signing....");
@@ -117,12 +119,14 @@ public class SignatureConfirmationTest e
reqData.setMsgContext(msgContext);
reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.SIGN);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.SIGN);
handler.send(
- WSConstants.SIGN, doc, reqData, actions, true
+ doc,
+ reqData,
+ Collections.singletonList(action),
+ true
);
if (LOG.isDebugEnabled()) {
LOG.debug("After Signing....");
@@ -154,12 +158,14 @@ public class SignatureConfirmationTest e
reqData.setMsgContext(msgContext);
reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.SIGN);
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.SIGN);
handler.send(
- WSConstants.SIGN, doc, reqData, actions, true
+ doc,
+ reqData,
+ Collections.singletonList(action),
+ true
);
if (LOG.isDebugEnabled()) {
LOG.debug("After Signing....");
@@ -179,15 +185,18 @@ public class SignatureConfirmationTest e
// Verify the inbound request, and create a response with a Signature Confirmation
//
List<WSSecurityEngineResult> results = verify(doc);
- actions.clear();
doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
msgContext = (java.util.Map<String, Object>)reqData.getMsgContext();
WSHandlerResult handlerResult = new WSHandlerResult(null, results);
List<WSHandlerResult> receivedResults = new ArrayList<WSHandlerResult>();
receivedResults.add(handlerResult);
msgContext.put(WSHandlerConstants.RECV_RESULTS, receivedResults);
+ action = new HandlerAction(WSConstants.NO_SECURITY);
handler.send(
- WSConstants.NO_SECURITY, doc, reqData, actions, false
+ doc,
+ reqData,
+ Collections.singletonList(action),
+ false
);
String outputString =
XMLUtils.PrettyDocumentToString(doc);
@@ -215,12 +224,14 @@ public class SignatureConfirmationTest e
reqData.setMsgContext(msgContext);
reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.SIGN);
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.SIGN);
handler.send(
- WSConstants.SIGN, doc, reqData, actions, true
+ doc,
+ reqData,
+ Collections.singletonList(action),
+ true
);
if (LOG.isDebugEnabled()) {
LOG.debug("After Signing....");
@@ -233,7 +244,6 @@ public class SignatureConfirmationTest e
// Verify the inbound request, and create a response with a Signature Confirmation
//
List<WSSecurityEngineResult> results = verify(doc);
- actions.clear();
doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
msgContext = (java.util.Map<String, Object>)reqData.getMsgContext();
WSHandlerResult handlerResult = new WSHandlerResult(null, results);
@@ -241,7 +251,10 @@ public class SignatureConfirmationTest e
receivedResults.add(handlerResult);
msgContext.put(WSHandlerConstants.RECV_RESULTS, receivedResults);
handler.send(
- WSConstants.NO_SECURITY, doc, reqData, actions, false
+ doc,
+ reqData,
+ Collections.singletonList(action),
+ false
);
String outputString =
XMLUtils.PrettyDocumentToString(doc);
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureUTAliasTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureUTAliasTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureUTAliasTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureUTAliasTest.java Thu Sep 26 13:21:19 2013
@@ -20,6 +20,7 @@
package org.apache.wss4j.dom.handler;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import javax.security.auth.callback.Callback;
@@ -80,13 +81,12 @@ public class SignatureUTAliasTest extend
messageContext.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
reqData.setMsgContext(messageContext);
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.UT);
- actions.add(WSConstants.SIGN);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
+ List<HandlerAction> actions = new ArrayList<HandlerAction>();
+ actions.add(new HandlerAction(WSConstants.UT));
+ actions.add(new HandlerAction(WSConstants.SIGN));
handler.send(
- WSConstants.UT | WSConstants.SIGN,
doc,
reqData,
actions,
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/UseReqSigCertTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/UseReqSigCertTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/UseReqSigCertTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/UseReqSigCertTest.java Thu Sep 26 13:21:19 2013
@@ -20,6 +20,7 @@
package org.apache.wss4j.dom.handler;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.apache.wss4j.common.ext.WSSecurityException;
@@ -55,7 +56,6 @@ public class UseReqSigCertTest extends o
@org.junit.Test
public void testIncludedCertificate() throws Exception {
final WSSConfig cfg = WSSConfig.getNewInstance();
- final int action = WSConstants.SIGN | WSConstants.TS;
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
reqData.setUsername("wss40");
@@ -69,15 +69,14 @@ public class UseReqSigCertTest extends o
);
reqData.setMsgContext(config);
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.SIGN);
- actions.add(WSConstants.TS);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
// Send the request
CustomHandler handler = new CustomHandler();
+ List<HandlerAction> actions = new ArrayList<HandlerAction>();
+ actions.add(new HandlerAction(WSConstants.SIGN));
+ actions.add(new HandlerAction(WSConstants.TS));
handler.send(
- action,
doc,
reqData,
actions,
@@ -103,7 +102,6 @@ public class UseReqSigCertTest extends o
@org.junit.Test
public void testIssuerSerial() throws Exception {
final WSSConfig cfg = WSSConfig.getNewInstance();
- final int action = WSConstants.SIGN | WSConstants.TS;
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
reqData.setUsername("wss40");
@@ -117,15 +115,14 @@ public class UseReqSigCertTest extends o
);
reqData.setMsgContext(config);
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.SIGN);
- actions.add(WSConstants.TS);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
// Send the request
CustomHandler handler = new CustomHandler();
+ List<HandlerAction> actions = new ArrayList<HandlerAction>();
+ actions.add(new HandlerAction(WSConstants.SIGN));
+ actions.add(new HandlerAction(WSConstants.TS));
handler.send(
- action,
doc,
reqData,
actions,
@@ -151,7 +148,6 @@ public class UseReqSigCertTest extends o
@org.junit.Test
public void testSKIKeyIdentifier() throws Exception {
final WSSConfig cfg = WSSConfig.getNewInstance();
- final int action = WSConstants.SIGN | WSConstants.TS;
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
reqData.setUsername("wss40");
@@ -165,15 +161,14 @@ public class UseReqSigCertTest extends o
);
reqData.setMsgContext(config);
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.SIGN);
- actions.add(WSConstants.TS);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
// Send the request
CustomHandler handler = new CustomHandler();
+ List<HandlerAction> actions = new ArrayList<HandlerAction>();
+ actions.add(new HandlerAction(WSConstants.SIGN));
+ actions.add(new HandlerAction(WSConstants.TS));
handler.send(
- action,
doc,
reqData,
actions,
@@ -198,7 +193,6 @@ public class UseReqSigCertTest extends o
private List<WSSecurityEngineResult> processRequest(Document doc) throws WSSecurityException {
final WSSConfig cfg = WSSConfig.getNewInstance();
- final int action = WSConstants.SIGN | WSConstants.TS;
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
@@ -207,14 +201,16 @@ public class UseReqSigCertTest extends o
reqData.setMsgContext(config);
CustomHandler handler = new CustomHandler();
- handler.receive(action, reqData);
+ List<Integer> receivedActions = new ArrayList<Integer>();
+ receivedActions.add(WSConstants.SIGN);
+ receivedActions.add(WSConstants.TS);
+ handler.receive(receivedActions, reqData);
WSSecurityEngine securityEngine = new WSSecurityEngine();
return securityEngine.processSecurityHeader(doc, "", reqData);
}
private void sendResponse(List<WSHandlerResult> handlerResults) throws Exception {
- final int action = WSConstants.ENCR;
final RequestData reqData = new RequestData();
java.util.Map<String, Object> config = new java.util.TreeMap<String, Object>();
@@ -228,11 +224,11 @@ public class UseReqSigCertTest extends o
// Send message
CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.ENCR);
handler.send(
- action,
doc,
reqData,
- actions,
+ Collections.singletonList(action),
true
);
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/WSHandlerGetPasswordTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/WSHandlerGetPasswordTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/WSHandlerGetPasswordTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/WSHandlerGetPasswordTest.java Thu Sep 26 13:21:19 2013
@@ -19,6 +19,8 @@
package org.apache.wss4j.dom.handler;
+import java.util.Collections;
+
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.dom.common.CustomHandler;
@@ -91,11 +93,11 @@ public class WSHandlerGetPasswordTest ex
actions.add(WSConstants.UT);
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.UT);
handler.send(
- WSConstants.UT,
doc,
reqData,
- actions,
+ Collections.singletonList(action),
true
);
@@ -132,11 +134,11 @@ public class WSHandlerGetPasswordTest ex
actions.add(WSConstants.UT);
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.UT);
handler.send(
- WSConstants.UT,
doc,
reqData,
- actions,
+ Collections.singletonList(action),
true
);
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptedDataInHeaderTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptedDataInHeaderTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptedDataInHeaderTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptedDataInHeaderTest.java Thu Sep 26 13:21:19 2013
@@ -25,13 +25,13 @@ import java.util.List;
import javax.security.auth.callback.CallbackHandler;
import org.apache.wss4j.dom.WSConstants;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.dom.WSSecurityEngine;
import org.apache.wss4j.dom.WSSecurityEngineResult;
import org.apache.wss4j.dom.common.KeystoreCallbackHandler;
import org.apache.wss4j.dom.common.SOAPUtil;
import org.apache.wss4j.dom.common.SecurityTestUtil;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoFactory;
import org.apache.wss4j.common.util.XMLUtils;
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionCRLTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionCRLTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionCRLTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionCRLTest.java Thu Sep 26 13:21:19 2013
@@ -19,6 +19,8 @@
package org.apache.wss4j.dom.message;
+import java.util.Collections;
+
import javax.security.auth.callback.CallbackHandler;
import org.w3c.dom.Document;
@@ -29,9 +31,11 @@ import org.apache.wss4j.dom.common.Custo
import org.apache.wss4j.dom.common.KeystoreCallbackHandler;
import org.apache.wss4j.dom.common.SOAPUtil;
import org.apache.wss4j.dom.common.SecurityTestUtil;
+import org.apache.wss4j.common.EncryptionActionToken;
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoFactory;
import org.apache.wss4j.common.util.XMLUtils;
+import org.apache.wss4j.dom.handler.HandlerAction;
import org.apache.wss4j.dom.handler.RequestData;
import org.apache.wss4j.dom.handler.WSHandlerConstants;
@@ -79,24 +83,23 @@ public class EncryptionCRLTest extends o
final WSSConfig cfg = WSSConfig.getNewInstance();
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
- reqData.setEncUser("wss40rev");
- reqData.setEncKeyId(WSConstants.BST_DIRECT_REFERENCE);
- reqData.setEncSymmAlgo(WSConstants.TRIPLE_DES);
- reqData.setEncCrypto(crypto);
+ EncryptionActionToken actionToken = new EncryptionActionToken();
+ actionToken.setUser("wss40rev");
+ actionToken.setKeyIdentifierId(WSConstants.BST_DIRECT_REFERENCE);
+ actionToken.setSymmetricAlgorithm(WSConstants.TRIPLE_DES);
+ actionToken.setCrypto(crypto);
+ reqData.setEncryptionToken(actionToken);
java.util.Map<String, Object> messageContext = new java.util.TreeMap<String, Object>();
messageContext.put(WSHandlerConstants.PW_CALLBACK_REF, keystoreCallbackHandler);
reqData.setMsgContext(messageContext);
reqData.setUsername("wss40rev");
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.ENCR);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
handler.send(
- WSConstants.ENCR,
doc,
reqData,
- actions,
+ Collections.singletonList(new HandlerAction(WSConstants.ENCR)),
true
);
@@ -120,27 +123,26 @@ public class EncryptionCRLTest extends o
final WSSConfig cfg = WSSConfig.getNewInstance();
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
- reqData.setEncUser("wss40rev");
- reqData.setEncKeyId(WSConstants.BST_DIRECT_REFERENCE);
- reqData.setEncSymmAlgo(WSConstants.TRIPLE_DES);
- reqData.setEncCrypto(crypto);
+ EncryptionActionToken actionToken = new EncryptionActionToken();
+ actionToken.setUser("wss40rev");
+ actionToken.setKeyIdentifierId(WSConstants.BST_DIRECT_REFERENCE);
+ actionToken.setSymmetricAlgorithm(WSConstants.TRIPLE_DES);
+ actionToken.setCrypto(crypto);
+ reqData.setEncryptionToken(actionToken);
java.util.Map<String, Object> messageContext = new java.util.TreeMap<String, Object>();
messageContext.put(WSHandlerConstants.PW_CALLBACK_REF, keystoreCallbackHandler);
reqData.setMsgContext(messageContext);
reqData.setUsername("wss40rev");
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.ENCR);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
handler.setOption(WSHandlerConstants.ENABLE_REVOCATION, "true");
try {
handler.send(
- WSConstants.ENCR,
- doc,
- reqData,
- actions,
- true
+ doc,
+ reqData,
+ Collections.singletonList(new HandlerAction(WSConstants.ENCR)),
+ true
);
fail ("Failure expected on a revoked certificate");
} catch (Exception ex) {
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionPartsTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionPartsTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionPartsTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionPartsTest.java Thu Sep 26 13:21:19 2013
@@ -21,7 +21,6 @@ package org.apache.wss4j.dom.message;
import org.apache.wss4j.dom.SOAPConstants;
import org.apache.wss4j.dom.WSDataRef;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.dom.WSSecurityEngine;
import org.apache.wss4j.dom.WSConstants;
@@ -29,6 +28,7 @@ import org.apache.wss4j.dom.WSSecurityEn
import org.apache.wss4j.dom.common.KeystoreCallbackHandler;
import org.apache.wss4j.dom.common.SOAPUtil;
import org.apache.wss4j.dom.common.SecurityTestUtil;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoFactory;
import org.apache.wss4j.common.ext.WSSecurityException;
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionTest.java Thu Sep 26 13:21:19 2013
@@ -23,7 +23,6 @@ import org.apache.wss4j.dom.SOAPConstant
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.dom.WSSecurityEngine;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSecurityEngineResult;
import org.apache.wss4j.dom.WSDataRef;
import org.apache.wss4j.dom.common.CustomHandler;
@@ -31,12 +30,14 @@ import org.apache.wss4j.dom.common.Keyst
import org.apache.wss4j.dom.common.SecretKeyCallbackHandler;
import org.apache.wss4j.dom.common.SOAPUtil;
import org.apache.wss4j.dom.common.SecurityTestUtil;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.bsp.BSPRule;
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoFactory;
import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.common.util.DOM2Writer;
import org.apache.wss4j.common.util.XMLUtils;
+import org.apache.wss4j.dom.handler.HandlerAction;
import org.apache.wss4j.dom.handler.RequestData;
import org.apache.wss4j.dom.handler.WSHandlerConstants;
import org.apache.wss4j.dom.str.STRParser.REFERENCE_TYPE;
@@ -429,15 +430,13 @@ public class EncryptionTest extends org.
reqData.setMsgContext(messageContext);
reqData.setUsername("");
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.ENCR);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.ENCR);
handler.send(
- WSConstants.ENCR,
doc,
reqData,
- actions,
+ Collections.singletonList(action),
true
);
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java Thu Sep 26 13:21:19 2013
@@ -20,7 +20,6 @@
package org.apache.wss4j.dom.message;
import org.apache.wss4j.dom.WSConstants;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.dom.WSSecurityEngine;
import org.apache.wss4j.dom.WSSecurityEngineResult;
@@ -28,6 +27,7 @@ import org.apache.wss4j.dom.common.Keyst
import org.apache.wss4j.dom.common.SAML1CallbackHandler;
import org.apache.wss4j.dom.common.SOAPUtil;
import org.apache.wss4j.dom.common.SecurityTestUtil;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoFactory;
import org.apache.wss4j.common.ext.WSSecurityException;
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordEncryptorTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordEncryptorTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordEncryptorTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordEncryptorTest.java Thu Sep 26 13:21:19 2013
@@ -19,6 +19,7 @@
package org.apache.wss4j.dom.message;
+import java.util.Collections;
import java.util.List;
import java.util.Properties;
@@ -38,6 +39,7 @@ import org.apache.wss4j.dom.common.Custo
import org.apache.wss4j.dom.common.KeystoreCallbackHandler;
import org.apache.wss4j.dom.common.SOAPUtil;
import org.apache.wss4j.dom.common.SecurityTestUtil;
+import org.apache.wss4j.dom.handler.HandlerAction;
import org.apache.wss4j.dom.handler.RequestData;
import org.apache.wss4j.dom.handler.WSHandlerConstants;
import org.w3c.dom.Document;
@@ -102,7 +104,6 @@ public class PasswordEncryptorTest exten
@org.junit.Test
public void testSignatureWSHandler() throws Exception {
final WSSConfig cfg = WSSConfig.getNewInstance();
- final int action = WSConstants.SIGN;
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
@@ -111,15 +112,13 @@ public class PasswordEncryptorTest exten
config.put(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
reqData.setMsgContext(config);
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(action);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.SIGN);
handler.send(
- action,
doc,
reqData,
- actions,
+ Collections.singletonList(action),
true
);
@@ -156,7 +155,6 @@ public class PasswordEncryptorTest exten
@org.junit.Test
public void testDecryptionWSHandler() throws Exception {
final WSSConfig cfg = WSSConfig.getNewInstance();
- final int action = WSConstants.ENCR;
final RequestData reqData = new RequestData();
reqData.setWssConfig(cfg);
reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
@@ -165,15 +163,13 @@ public class PasswordEncryptorTest exten
config.put(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
reqData.setMsgContext(config);
- final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(action);
final Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
CustomHandler handler = new CustomHandler();
+ HandlerAction action = new HandlerAction(WSConstants.ENCR);
handler.send(
- action,
doc,
reqData,
- actions,
+ Collections.singletonList(action),
true
);
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordTypeTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordTypeTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordTypeTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordTypeTest.java Thu Sep 26 13:21:19 2013
@@ -19,6 +19,8 @@
package org.apache.wss4j.dom.message;
+import java.util.Collections;
+
import org.apache.wss4j.dom.WSSecurityEngine;
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSSConfig;
@@ -28,6 +30,7 @@ import org.apache.wss4j.dom.common.Secur
import org.apache.wss4j.dom.common.UsernamePasswordCallbackHandler;
import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.common.util.XMLUtils;
+import org.apache.wss4j.dom.handler.HandlerAction;
import org.apache.wss4j.dom.handler.RequestData;
import org.apache.wss4j.dom.handler.WSHandlerConstants;
import org.w3c.dom.Document;
@@ -163,10 +166,13 @@ public class PasswordTypeTest extends or
reqData.setUsername("wernerd");
reqData.setMsgContext(config);
- java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
- actions.add(WSConstants.UT);
-
- handler.send(WSConstants.UT, doc, reqData, actions, true);
+ HandlerAction action = new HandlerAction(WSConstants.UT);
+ handler.send(
+ doc,
+ reqData,
+ Collections.singletonList(action),
+ true
+ );
if (LOG.isDebugEnabled()) {
LOG.debug("Username Token via WSHandler");
@@ -180,7 +186,7 @@ public class PasswordTypeTest extends or
//
config.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
reqData.setMsgContext(config);
- handler.receive(WSConstants.UT, reqData);
+ handler.receive(Collections.singletonList(WSConstants.UT), reqData);
WSSecurityEngine secEngine = new WSSecurityEngine();
secEngine.setWssConfig(reqData.getWssConfig());
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java Thu Sep 26 13:21:19 2013
@@ -25,7 +25,6 @@ import java.util.List;
import javax.security.auth.callback.CallbackHandler;
import org.apache.wss4j.dom.WSConstants;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.dom.WSSecurityEngine;
import org.apache.wss4j.dom.WSSecurityEngineResult;
@@ -34,6 +33,7 @@ import org.apache.wss4j.dom.common.SAML2
import org.apache.wss4j.dom.common.SOAPUtil;
import org.apache.wss4j.dom.common.SecurityTestUtil;
import org.apache.wss4j.dom.common.UsernamePasswordCallbackHandler;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.cache.MemoryReplayCache;
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoFactory;
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/RequireSignedEncryptedDataElementsTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/RequireSignedEncryptedDataElementsTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/RequireSignedEncryptedDataElementsTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/RequireSignedEncryptedDataElementsTest.java Thu Sep 26 13:21:19 2013
@@ -20,7 +20,6 @@
package org.apache.wss4j.dom.message;
import java.text.MessageFormat;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
@@ -242,7 +241,7 @@ public class RequireSignedEncryptedDataE
messageContext.put(WSHandlerConstants.REQUIRE_SIGNED_ENCRYPTED_DATA_ELEMENTS, Boolean.toString(reqSignedEncData));
reqData.setMsgContext(messageContext);
CustomHandler handler = new CustomHandler();
- handler.receive(WSSecurityUtil.decodeAction("Encrypt Signature", new LinkedList<Integer>()), reqData);
+ handler.receive(WSSecurityUtil.decodeAction("Encrypt Signature"), reqData);
reqData.setCallbackHandler(callbackHandler);
reqData.setSigVerCrypto(crypto);
reqData.setDecCrypto(crypto);
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/STRSignatureTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/STRSignatureTest.java?rev=1526479&r1=1526478&r2=1526479&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/STRSignatureTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/STRSignatureTest.java Thu Sep 26 13:21:19 2013
@@ -20,13 +20,13 @@
package org.apache.wss4j.dom.message;
import org.apache.wss4j.dom.SOAPConstants;
-import org.apache.wss4j.dom.WSEncryptionPart;
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.dom.util.WSSecurityUtil;
import org.apache.wss4j.dom.WSSecurityEngine;
import org.apache.wss4j.dom.common.SOAPUtil;
import org.apache.wss4j.dom.common.SecurityTestUtil;
+import org.apache.wss4j.common.WSEncryptionPart;
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoFactory;
import org.apache.wss4j.common.util.XMLUtils;