/*
- * 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.
#include <xmltooling/encryption/Encrypter.h>
#include <xmltooling/encryption/Decrypter.h>
#include <xmltooling/security/Credential.h>
+#include <xmltooling/signature/KeyInfo.h>
+#include <xmltooling/util/ParserPool.h>
#include <xsec/utils/XSECPlatformUtils.hpp>
algorithm = DSIGConstants::s_unicodeStrURIAES256_CBC;
Encrypter encrypter;
- Encrypter::EncryptionParams ep(algorithm, NULL, 0, NULL, compact);
+ Encrypter::EncryptionParams ep(algorithm, nullptr, 0, nullptr, compact);
Encrypter::KeyEncryptionParams kep(*KEK);
setEncryptedData(encrypter.encryptElement(xmlObject.getDOM(),ep,&kep));
}
if (XSECPlatformUtils::g_cryptoProvider->getRandom(keyBuffer,32)<32)
throw EncryptionException("Unable to generate encryption key; was PRNG seeded?");
Encrypter encrypter;
- Encrypter::EncryptionParams ep(algorithm, keyBuffer, 32, NULL, compact);
+ Encrypter::EncryptionParams ep(algorithm, keyBuffer, 32, nullptr, compact);
setEncryptedData(encrypter.encryptElement(xmlObject.getDOM(),ep));
getEncryptedData()->setId(SAMLConfig::getConfig().generateIdentifier());
if (plaintext->getNodeType()==DOMNode::ELEMENT_NODE) {
// Import the tree into a new Document that we can bind to the unmarshalled object.
XercesJanitor<DOMDocument> newdoc(XMLToolingConfig::getConfig().getParser().newDocument());
- DOMElement* treecopy = static_cast<DOMElement*>(newdoc->importNode(plaintext, true));
+ DOMElement* treecopy;
+ try {
+ treecopy = static_cast<DOMElement*>(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<XMLObject> ret(XMLObjectBuilder::buildOneFromElement(treecopy, true));
newdoc.release();