protected Element createTokenOrReferenceElement(String enclosingTagName, SecurityTokenOrReference token) throws TrustException {
Element element = doc.createElementNS(TrustConstants.WST_NS, enclosingTagName);
Element tokenElement = token.getElement();
if (tokenElement == null)
throw new EmptyTokenOrReference("SecurityTokenOrReference specified does not contain " +
"a security token element or reference element.");
element.appendChild(tokenElement);
return element;
}