From: Scott Cantor Date: Mon, 15 Feb 2010 15:51:42 +0000 (+0000) Subject: Wrap importNode call in exception handler. X-Git-Tag: 2.4RC1~73 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=commitdiff_plain;h=049c65f08c639b8bce39b5861b7fc82fcec669b7 Wrap importNode call in exception handler. --- diff --git a/saml/saml2/core/impl/Assertions.cpp b/saml/saml2/core/impl/Assertions.cpp index 794f504..60c6085 100644 --- a/saml/saml2/core/impl/Assertions.cpp +++ b/saml/saml2/core/impl/Assertions.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009 Internet2 + * Copyright 2001-2010 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -164,7 +164,18 @@ XMLObject* EncryptedElementType::decrypt(const CredentialResolver& credResolver, if (plaintext->getNodeType()==DOMNode::ELEMENT_NODE) { // Import the tree into a new Document that we can bind to the unmarshalled object. XercesJanitor newdoc(XMLToolingConfig::getConfig().getParser().newDocument()); - DOMElement* treecopy = static_cast(newdoc->importNode(plaintext, true)); + DOMElement* treecopy; + try { + treecopy = static_cast(newdoc->importNode(plaintext, true)); + } + catch (XMLException& ex) { + frag->release(); + auto_ptr_char temp(ex.getMessage()); + throw DecryptionException( + string("Error importing decypted DOM into new document: ") + (temp.get() ? temp.get() : "no message") + ); + } + frag->release(); newdoc->appendChild(treecopy); auto_ptr ret(XMLObjectBuilder::buildOneFromElement(treecopy, true)); newdoc.release();