// The element to transform MUST be a SecurityTokenReference
// element.
//
SecurityTokenReference secRef = new SecurityTokenReference(str);
Canonicalizer canon = Canonicalizer.getInstance(canonAlgo);
ByteArrayOutputStream bos = null;
byte[] buf = null;
//
// Third and fourth step are performed by dereferenceSTR()
//
Object wsDocInfoObject = xc.getProperty(TRANSFORM_WS_DOC_INFO);
WSDocInfo wsDocInfo = null;
if (wsDocInfoObject instanceof WSDocInfo) {
wsDocInfo = (WSDocInfo)wsDocInfoObject;
}
if (wsDocInfo == null && doDebug) {
log.debug("STRTransform: no WSDocInfo found");
}
Document doc = str.getOwnerDocument();
Element dereferencedToken =
STRTransformUtil.dereferenceSTR(doc, secRef, wsDocInfo);
if (dereferencedToken != null) {
String type = dereferencedToken.getAttribute("ValueType");
if ((X509Security.X509_V3_TYPE.equals(type)
|| PKIPathSecurity.getType().equals(type))) {
//
// Add the WSSE/WSU namespaces to the element for C14n
//
WSSecurityUtil.setNamespace(
dereferencedToken, WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX
);
WSSecurityUtil.setNamespace(
dereferencedToken, WSConstants.WSU_NS, WSConstants.WSU_PREFIX
);
}
}
//
// C14n with specified algorithm. According to WSS Specification.
//
buf = canon.canonicalizeSubtree(dereferencedToken, "#default");
if (doDebug) {
bos = new ByteArrayOutputStream(buf.length);
bos.write(buf, 0, buf.length);
log.debug("after c14n: " + bos.toString());
}