// The element to transform MUST be a SecurityTokenReference
// element.
//
SecurityTokenReference secRef = new SecurityTokenReference(str, new BSPEnforcer());
Canonicalizer canon = Canonicalizer.getInstance(canonAlgo);
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) {
log.debug("STRTransform: no WSDocInfo found");
}
Document doc = str.getOwnerDocument();
Element dereferencedToken =
STRTransformUtil.dereferenceSTR(doc, secRef, wsDocInfo);
if (dereferencedToken != null) {
String type = dereferencedToken.getAttributeNS(null, "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", true);
if (log.isDebugEnabled()) {
log.debug("after c14n: " + new String(buf, "UTF-8"));
}
if (os != null) {