}
DigesterOutputStream dos;
dos = new DigesterOutputStream(md);
// OutputStream os = new UnsyncBufferedOutputStream(dos);
StAXEXC14nCanonicalizerImpl canonicalizer = new StAXEXC14nCanonicalizerImpl();
canonicalizer.setBodyPrologue(bodyPrologue);
canonicalizer.setBodyEpilogue(bodyEpilogue);
//TODO:share canonicalizers .
canonicalizer.setStream(dos);
if(logger.isLoggable(Level.FINEST)){
canonicalizer.setStream(new ByteArrayOutputStream());
}
List trList = ref.getTransforms();
if(trList.size() >1){
logger.log(Level.SEVERE, LogStringsMessages.WSS_1714_UNSUPPORTED_TRANSFORM_ERROR());
throw new XWSSecurityException("Only EXC14n Transform is supported");
}
Transform tr = (Transform) trList.get(0);
ExcC14NParameterSpec spec = (ExcC14NParameterSpec)tr.getParameterSpec();
if(spec != null){
canonicalizer.setInclusivePrefixList(spec.getPrefixList());
}
if(parentNS != null && parentNS.size() >0){
Iterator<Map.Entry<String, String>> itr = parentNS.entrySet().iterator();
while(itr.hasNext()){
Map.Entry<String, String> entry = itr.next();
String prefix = entry.getKey();
try {
String uri = entry.getValue();
canonicalizer.writeNamespace(prefix,uri);
} catch (XMLStreamException ex) {
logger.log(Level.SEVERE, LogStringsMessages.WSS_1715_ERROR_CANONICALIZING_BODY(), ex);
}
}
}
try {
if(!payLoad){
bodyTag.writeStart(canonicalizer);
// the space characters between soap:Body and payload element must be preserved for payload signature!
canonicalizer.setBodyPrologueTime(true);
}
} catch (XMLStreamException ex) {
logger.log(Level.SEVERE, LogStringsMessages.WSS_1715_ERROR_CANONICALIZING_BODY(), ex);
throw new XWSSecurityException("Error occurred while canonicalizing BodyTag"+ex);
}