// throw new AxisFault(
// "ConversationClientHandler ::" + e1.getMessage());
// }
// We have successfully recieved the message element part.
SecurityContextToken sct = null;
RequestedProofToken proof = null;
log.debug("Trust communitcator successfully completed.");
try {
MessageElement tmpEle = null;
for (int i = 0; i < meArrRes.length; i++) {
tmpEle = meArrRes[i];
QName el =
new QName(tmpEle.getNamespaceURI(), tmpEle.getLocalName());
Element domEle = tmpEle.getAsDOM();
if (el.equals(RequestedSecurityToken.TOKEN)) {
log.debug("Recognized RequestedSecurityToken.");
NodeList ndList =
domEle.getElementsByTagNameNS(
SecurityContextToken.TOKEN.getNamespaceURI(),
SecurityContextToken.TOKEN.getLocalPart());
if (ndList.getLength() < 0) {
throw new AxisFault("Unspported yet ..");
}
sct = new SecurityContextToken((Element) ndList.item(0));
SOAPHeader soapHeader = sm.getSOAPHeader();
soapHeader.addChildElement(
"Security",
WSConstants.WSSE_PREFIX,
WSConstants.WSSE_NS);
Iterator it = soapHeader.getChildElements();
while (it.hasNext()) {
SOAPHeaderElement shSecElem;
if ((shSecElem = (SOAPHeaderElement) it.next())
.getLocalName()
.equals("Security")) {
MessageElement rstr =
new MessageElement(
RequestSecurityTokenResponse
.TOKEN
.getLocalPart(),
RequestSecurityTokenResponse
.TOKEN
.getPrefix(),
RequestSecurityTokenResponse
.TOKEN
.getNamespaceURI());
rstr.addChild(tmpEle);
shSecElem.addChildElement(rstr);
}
}
} else if (el.equals(RequestedProofToken.TOKEN)) {
SOAPPart sPart =
(org.apache.axis.SOAPPart) sm.getSOAPPart();
doc =
((org.apache.axis.message.SOAPEnvelope) sPart
.getEnvelope())
.getAsDocument();
//do decrytion - proof is encrypted with certificate of STS
proof = new RequestedProofToken(domEle);
proof.doDecryption(callbackHandler, serverCrypto);
byte[] bkArr = proof.getSharedSecret();
RequestedProofToken newProof = new RequestedProofToken(doc);
newProof.setSharedSecret(bkArr);
newProof.doEncryptProof(
doc,
serverCrypto,
this.serverAlias);
Element secHeader =
WSSecurityUtil.findWsseSecurityHeaderBlock(WSSConfig.getDefaultWSConfig(),
doc,
doc.getDocumentElement(),
true);
Element ele =
(Element) WSSecurityUtil.findElement(
secHeader,
RequestSecurityTokenResponse.TOKEN.getLocalPart(),
RequestSecurityTokenResponse
.TOKEN
.getNamespaceURI());
ele.appendChild(newProof.getElement());
ByteArrayOutputStream os = new ByteArrayOutputStream();
XMLUtils.outputDOM(doc, os, true);
String osStr = os.toString();
sPart.setCurrentMessage(osStr, SOAPPart.FORM_STRING);
}
} //for loop
this.initSessionInfo();
Integer keyFreq =
(Integer) this.configurator.get(ConvHandlerConstants.KEY_FREQ);
SecurityContextInfo sctInfo =
new SecurityContextInfo(sct, proof, keyFreq.intValue());
this.uuid = sct.getIdentifier();
dkcbHandler.addSecurtiyContext(uuid, sctInfo);
Boolean isFixedKey =
(Boolean) configurator.get(
ConvHandlerConstants.USE_FIXED_KEYLEN);