本文整理汇总了Java中org.opensaml.xml.util.XMLHelper.constructElement方法的典型用法代码示例。如果您正苦于以下问题:Java XMLHelper.constructElement方法的具体用法?Java XMLHelper.constructElement怎么用?Java XMLHelper.constructElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.xml.util.XMLHelper
的用法示例。
在下文中一共展示了XMLHelper.constructElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postProcessApacheEncryptedKey
import org.opensaml.xml.util.XMLHelper; //导入方法依赖的package包/类
/**
*
* Post-process the Apache EncryptedKey, prior to marshalling to DOM and unmarshalling into an XMLObject.
*
* @param apacheEncryptedKey the Apache EncryptedKeyObject to post-process
* @param targetKey the key to encrypt
* @param encryptionKey the key with which to encrypt the target key
* @param encryptionAlgorithmURI the XML Encryption algorithm URI corresponding to the encryption key
* @param containingDocument the document that will own the resulting element
*
* @throws EncryptionException exception thrown on encryption errors
*/
protected void postProcessApacheEncryptedKey(org.apache.xml.security.encryption.EncryptedKey apacheEncryptedKey,
Key targetKey, Key encryptionKey, String encryptionAlgorithmURI, Document containingDocument)
throws EncryptionException {
// Workaround for XML-Security library issue. To maximize interop, explicitly express the library
// default of SHA-1 digest method input parameter to RSA-OAEP key transport algorithm.
// Check and only add if the library hasn't already done so, which it currently doesn't.
if (EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP.equals(encryptionAlgorithmURI)) {
boolean sawDigestMethod = false;
Iterator childIter = apacheEncryptedKey.getEncryptionMethod().getEncryptionMethodInformation();
while (childIter.hasNext()) {
Element child = (Element) childIter.next();
if (DigestMethod.DEFAULT_ELEMENT_NAME.equals(XMLHelper.getNodeQName(child))) {
sawDigestMethod = true;
break;
}
}
if (! sawDigestMethod) {
Element digestMethodElem = XMLHelper.constructElement(containingDocument,
DigestMethod.DEFAULT_ELEMENT_NAME);
XMLHelper.appendNamespaceDeclaration(digestMethodElem,
XMLConstants.XMLSIG_NS, XMLConstants.XMLSIG_PREFIX);
digestMethodElem.setAttributeNS(null, DigestMethod.ALGORITHM_ATTRIB_NAME,
SignatureConstants.ALGO_ID_DIGEST_SHA1);
apacheEncryptedKey.getEncryptionMethod().addEncryptionMethodInformation(digestMethodElem);
}
}
}
示例2: marshall
import org.opensaml.xml.util.XMLHelper; //导入方法依赖的package包/类
/** {@inheritDoc} */
public Element marshall(XMLObject xmlObject, Document document) throws MarshallingException {
Element domElement;
log.trace("Starting to marshall {}", xmlObject.getElementQName());
if (document == null) {
throw new MarshallingException("Given document may not be null");
}
checkXMLObjectIsTarget(xmlObject);
log.trace("Checking if {} contains a cached DOM representation", xmlObject.getElementQName());
domElement = xmlObject.getDOM();
if (domElement != null) {
prepareForAdoption(xmlObject);
if (domElement.getOwnerDocument() != document) {
log.trace("Adopting DOM of XMLObject into given Document");
XMLHelper.adoptElement(domElement, document);
}
log.trace("Setting DOM of XMLObject as document element of given Document");
setDocumentElement(document, domElement);
return domElement;
}
log.trace("{} does not contain a cached DOM representation. Creating Element to marshall into.",
xmlObject.getElementQName());
domElement = XMLHelper.constructElement(document, xmlObject.getElementQName());
log.trace("Setting created element as document root");
// we need to do this before the rest of the marshalling so that signing and other ID dependent operations have
// a path to the document root
setDocumentElement(document, domElement);
domElement = marshallInto(xmlObject, domElement);
log.trace("Setting created element to DOM cache for XMLObject {}", xmlObject.getElementQName());
xmlObject.setDOM(domElement);
xmlObject.releaseParentDOM(true);
return domElement;
}