Document doc = null;
Message message = msg.getCurrentMessage();
// Get the soap message as a Docuemnt
SOAPPart sPart = (org.apache.axis.SOAPPart) message.getSOAPPart();
try {
doc =
((org.apache.axis.message.SOAPEnvelope) sPart.getEnvelope())
.getAsDocument();
} catch (Exception e) {
e.printStackTrace();
}
// if((this.configurator = (HashMap)msg.getProperty("PolicyObject"))==null){
// log.debug("ConversationServerHandler :: I am configuring");
// initSessionInfo(); // load values to this.configurator from wsdd
// }
soapConstants = WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
ConversationEngine eng = new ConversationEngine(this.configurator);
// try {
// boolean trustEngineResult = false;
// if(!isInitTrustVerified){
// String tmpStr = null;
// if ((tmpStr = (String) getOption(ConvHandlerConstants.TOKEN_TRUST_VERIFY))
// != null) {
// if(Boolean.getBoolean(tmpStr)){
// String trustPropFile = (String) getOption(ConvHandlerConstants.TRUST_ENGINE_PROP);
// TrustEngine trstEngine = new TrustEngine(trustPropFile);
// System.out.println("call the engine here ...");
// trustEngineResult=true;
// }
// isInitTrustVerified = true;
// }
// }
// if(trustEngineResult){
// //getUUID and proof of possession
// //add it to the derived key token
// }
// } catch (WSTrustException e2) {
// // TODO Auto-generated catch block
// e2.printStackTrace();
// }
try {
Vector results = eng.processSecConvHeader(doc, "", dkcbHandler, (String)this.configurator.get(WSHandlerConstants.PW_CALLBACK_CLASS));
ConvEngineResult convResult = null;
String uuid = "";
/*put the actions into a stack to obtain LIFO behavior
* Rational for using the stack;
*
* Consider "Signature Encrypt"
* Then the ConvEngine Results will be in the order "Encrypt Signature"
* i.e. ConvEngine reusult containing ConvEngineResult.ENCRYPT_DERIVED_KEY
* will be before ConvEngineResult.SIGN_DERIVED_KEY
*
* Hense I need to read actions in the order of Last in First out - the stack
*
* This is same for "Encrypt Signature" visa versa.
*/
Stack stk = new Stack();
for(int i=0; i<actionsInt.length ; i++){
stk.push(new Integer(actionsInt[i]));
}
int act = -1;
boolean rstr = false;
for(int i=0; i<results.size(); i++){
convResult=(ConvEngineResult)results.get(i);
switch(convResult.getAction()){
case ConvEngineResult.SECURITY_TOKEN_RESPONSE :
log.debug("ConversationServerHandler :: Found RSTR result");
uuid = convResult.getUuid();
rstr = true;
break;
case ConvEngineResult.ENCRYPT_DERIVED_KEY :
log.debug("ConversationServerHandler :: Found dk_encrypt result");
// if(stk.isEmpty()){
// throw new AxisFault("Action mismatch");
// }
//
// act =((Integer)stk.pop()).intValue();
// if(act == ConversationConstants.DK_ENCRYPT){
// //fine do nothing
// }else{
// throw new AxisFault("Mismatch action order");
// }
break;
case ConvEngineResult.SIGN_DERIVED_KEY :
log.debug("ConversationServerHandler :: Found dk_sign result");
// if(stk.isEmpty()){
// throw new AxisFault("Action mismatch");
// }
// act =((Integer)stk.pop()).intValue();
// if(act == ConversationConstants.DK_SIGN){
// //fine do nothing
// }else{
// throw new AxisFault("Mismatch action order");
// }
break;
case ConvEngineResult.SCT :
log.debug("ConversationServerHandler :: Found SCT result");
uuid = convResult.getUuid();
break;
}
}
if(uuid.equals("")||(uuid==null)){
//throw new AxisFault("ConversationServerHandler :: Cannot find Session.");
}else{
msg.setProperty(ConversationConstants.IDENTIFIER,uuid);
}
//
// if(!rstr){
// if(!stk.isEmpty()){
// throw new AxisFault("Action mismatch. Required action missing");
// }
// }
} catch (ConversationException e1) {
e1.printStackTrace();
throw new AxisFault("CovnersationServerHandler :: "+e1.getMessage());
}
// Replace sPart with the new sPart.
ByteArrayOutputStream os = new ByteArrayOutputStream();
XMLUtils.outputDOM(doc, os, true);
String osStr = os.toString();
sPart.setCurrentMessage(osStr, SOAPPart.FORM_STRING);
//Following sets the headers as processed.
SOAPHeader sHeader = null;
try {
sHeader = message.getSOAPEnvelope().getHeader();