/*
* If the message context property conatins a document then this is
* a chained handler.
*/
SOAPPart sPart = (org.apache.axis.SOAPPart) message.getSOAPPart();
if ((doc = (Document) reqData.msgContext
.getProperty(WSHandlerConstants.SND_SECURITY)) == null) {
try {
doc = ((org.apache.axis.message.SOAPEnvelope) sPart
.getEnvelope()).getAsDocument();
} catch (Exception e) {
throw new AxisFault(
"WSDoAllSender: cannot get SOAP envlope from message"
+ e);
}
}
reqData.soapConstants = WSSecurityUtil.getSOAPConstants(doc
.getDocumentElement());
/*
* 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) {
reqData.sigCrypto = loadSignatureCrypto(reqData);
decodeSignatureParameter(reqData);
}
/*
* If we need to handle signed SAML token then we need may of 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) {
reqData.encCrypto = loadEncryptionCrypto(reqData);
decodeEncryptionParameter(reqData);
}
/*
* Here we have all necessary information to perform the requested
* action(s).
*/
for (int i = 0; i < actions.size(); i++) {
int actionToDo = ((Integer) actions.get(i)).intValue();
if (doDebug) {
log.debug("Performing Action: " + actionToDo);
}
String password = null;
switch (actionToDo) {
case WSConstants.UT:
performUTAction(actionToDo, mu, doc, reqData);
break;
case WSConstants.ENCR:
performENCRAction(mu, actionToDo, doc, reqData);
break;
case WSConstants.SIGN:
performSIGNAction(actionToDo, mu, doc, reqData);
break;
case WSConstants.ST_SIGNED:
performST_SIGNAction(actionToDo, mu, doc, reqData);
break;
case WSConstants.ST_UNSIGNED:
performSTAction(actionToDo, mu, doc, reqData);
break;
case WSConstants.TS:
performTSAction(actionToDo, mu, doc, reqData);
break;
case WSConstants.UT_SIGN:
performUT_SIGNAction(actionToDo, mu, doc, reqData);
break;
case WSConstants.NO_SERIALIZE:
reqData.noSerialization = true;
break;
}
}
/*
* 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.noSerialization) {
reqData.msgContext.setProperty(WSHandlerConstants.SND_SECURITY,
doc);
} else {
ByteArrayOutputStream os = new ByteArrayOutputStream();
XMLUtils.outputDOM(doc, os, true);
sPart.setCurrentMessage(os.toByteArray(), SOAPPart.FORM_BYTES);
if (doDebug) {
String osStr = null;
try {
osStr = os.toString("UTF-8");
} catch (UnsupportedEncodingException e) {