本文整理汇总了Java中org.opensaml.xml.XMLObject.getDOM方法的典型用法代码示例。如果您正苦于以下问题:Java XMLObject.getDOM方法的具体用法?Java XMLObject.getDOM怎么用?Java XMLObject.getDOM使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.xml.XMLObject
的用法示例。
在下文中一共展示了XMLObject.getDOM方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logDecodedMessage
import org.opensaml.xml.XMLObject; //导入方法依赖的package包/类
/**
* Log the decoded message to the protocol message logger.
*
* @param messageContext the message context to process
*/
protected void logDecodedMessage(MessageContext messageContext) {
if(protocolMessageLog.isDebugEnabled() && messageContext.getInboundMessage() != null){
if (messageContext.getInboundMessage().getDOM() == null) {
XMLObject message = messageContext.getInboundMessage();
Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(message);
if (marshaller != null) {
try {
marshaller.marshall(message);
} catch (MarshallingException e) {
log.error("Unable to marshall message for logging purposes: " + e.getMessage());
}
}
else {
log.error("Unable to marshall message for logging purposes, no marshaller registered for message object: "
+ message.getElementQName());
}
if (message.getDOM() == null) {
return;
}
}
protocolMessageLog.debug("\n" + XMLHelper.prettyPrintXML(messageContext.getInboundMessage().getDOM()));
}
}
示例2: checkAndMarshall
import org.opensaml.xml.XMLObject; //导入方法依赖的package包/类
/**
* Ensure that the XMLObject is marshalled.
*
* @param xmlObject the object to check and marshall
* @throws DecryptionException thrown if there is an error when marshalling the XMLObject
*/
protected void checkAndMarshall(XMLObject xmlObject) throws DecryptionException {
Element targetElement = xmlObject.getDOM();
if (targetElement == null) {
Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(xmlObject);
if (marshaller == null) {
marshaller =
Configuration.getMarshallerFactory().getMarshaller(Configuration.getDefaultProviderQName());
if (marshaller == null) {
String errorMsg = "No marshaller available for " + xmlObject.getElementQName();
log.error(errorMsg);
throw new DecryptionException(errorMsg);
}
}
try {
targetElement = marshaller.marshall(xmlObject);
} catch (MarshallingException e) {
log.error("Error marshalling target XMLObject", e);
throw new DecryptionException("Error marshalling target XMLObject", e);
}
}
}
示例3: marshall
import org.opensaml.xml.XMLObject; //导入方法依赖的package包/类
/**
* Marshall an XMLObject. If the XMLObject already has a cached DOM via {@link XMLObject#getDOM()},
* that Element will be returned. Otherwise the object will be fully marshalled and that Element returned.
*
* @param xmlObject the XMLObject to marshall
* @return the marshalled Element
* @throws MarshallingException if there is a problem marshalling the XMLObject
*/
public static Element marshall(XMLObject xmlObject) throws MarshallingException {
Logger log = getLogger();
log.debug("Marshalling XMLObject");
if (xmlObject.getDOM() != null) {
log.debug("XMLObject already had cached DOM, returning that element");
return xmlObject.getDOM();
}
Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(xmlObject);
if (marshaller == null) {
log.error("Unable to marshall XMLOBject, no marshaller registered for object: "
+ xmlObject.getElementQName());
}
Element messageElem = marshaller.marshall(xmlObject);
if (log.isTraceEnabled()) {
log.trace("Marshalled XMLObject into DOM:");
log.trace(XMLHelper.nodeToString(messageElem));
}
return messageElem;
}
示例4: checkAndMarshall
import org.opensaml.xml.XMLObject; //导入方法依赖的package包/类
/**
* Ensure that the XMLObject is marshalled.
*
* @param xmlObject the object to check and marshall
* @throws EncryptionException thrown if there is an error when marshalling the XMLObject
*/
protected void checkAndMarshall(XMLObject xmlObject) throws EncryptionException {
Element targetElement = xmlObject.getDOM();
if (targetElement == null) {
Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(xmlObject);
try {
targetElement = marshaller.marshall(xmlObject);
} catch (MarshallingException e) {
log.error("Error marshalling target XMLObject", e);
throw new EncryptionException("Error marshalling target XMLObject", e);
}
}
}
示例5: marshall
import org.opensaml.xml.XMLObject; //导入方法依赖的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;
}