[cpp-xmltooling] branch master updated: CPPXT-130 - auto_ptr cleanup
Scott Cantor
cantor.2 at osu.edu
Fri Apr 6 17:10:28 EDT 2018
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository cpp-xmltooling.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-xmltooling.git;a=commit;h=e2054dacceec0f1d9329dfa955db3d7d9d002099
The following commit(s) were added to refs/heads/master by this push:
new e2054da CPPXT-130 - auto_ptr cleanup
e2054da is described below
commit e2054dacceec0f1d9329dfa955db3d7d9d002099
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Apr 6 17:10:11 2018 -0400
CPPXT-130 - auto_ptr cleanup
https://issues.shibboleth.net/jira/browse/CPPXT-130
Also added const to some Credential APIs.
---
xmltooling/AbstractDOMCachingXMLObject.cpp | 12 ++++---
xmltooling/AbstractXMLObject.h | 4 +--
xmltooling/XMLObjectBuilder.cpp | 7 ++--
xmltooling/XMLToolingConfig.h | 13 +++----
xmltooling/base.h | 26 +++++---------
xmltooling/encryption/Decrypter.h | 8 ++---
xmltooling/encryption/impl/Decrypter.cpp | 41 +++++++++++-----------
xmltooling/encryption/impl/Encrypter.cpp | 21 +++++------
xmltooling/impl/AnyElement.cpp | 3 +-
xmltooling/impl/MemoryStorageService.cpp | 9 ++---
xmltooling/internal.h | 8 ++---
xmltooling/io/AbstractXMLObjectUnmarshaller.cpp | 11 +++---
xmltooling/security/BasicX509Credential.h | 12 +++----
xmltooling/security/Credential.h | 4 +--
xmltooling/security/DataSealer.h | 3 +-
xmltooling/security/X509Credential.h | 9 -----
.../security/impl/AbstractPKIXTrustEngine.cpp | 15 ++++----
xmltooling/security/impl/BasicX509Credential.cpp | 38 ++++++++------------
xmltooling/security/impl/DataSealer.cpp | 9 ++---
.../security/impl/ExplicitKeyTrustEngine.cpp | 2 +-
.../security/impl/FilesystemCredentialResolver.cpp | 35 +++++++++---------
xmltooling/security/impl/InlineKeyResolver.cpp | 16 ++++-----
xmltooling/security/impl/PKIXPathValidator.cpp | 5 +--
.../security/impl/StaticDataSealerKeyStrategy.cpp | 5 +--
xmltooling/security/impl/StaticPKIXTrustEngine.cpp | 4 ++-
.../impl/VersionedDataSealerKeyStrategy.cpp | 5 +--
xmltooling/signature/Signature.h | 8 ++---
xmltooling/signature/impl/SignatureValidator.cpp | 6 ++--
xmltooling/signature/impl/XMLSecSignatureImpl.cpp | 32 ++++++++---------
xmltooling/util/ParserPool.h | 5 +--
xmltooling/util/ReloadableXMLFile.cpp | 10 +++---
xmltooling/util/Threads.h | 21 -----------
xmltoolingtest/ComplexXMLObjectTest.h | 2 +-
xmltoolingtest/DataSealerTest.h | 4 +--
xmltoolingtest/EncryptionTest.h | 4 +--
xmltoolingtest/ExceptionTest.h | 2 +-
xmltoolingtest/FilesystemCredentialResolverTest.h | 2 +-
xmltoolingtest/InlineKeyResolverTest.h | 40 ++++++++++-----------
xmltoolingtest/KeyInfoTest.h | 8 ++---
xmltoolingtest/MarshallingTest.h | 6 ++--
xmltoolingtest/MemoryStorageServiceTest.h | 2 +-
xmltoolingtest/NonVisibleNamespaceTest.h | 4 +--
xmltoolingtest/SOAPTest.h | 2 +-
xmltoolingtest/SecurityHelperTest.h | 38 ++++++++++----------
xmltoolingtest/SignatureTest.h | 18 +++++-----
xmltoolingtest/TemplateEngineTest.h | 8 +----
xmltoolingtest/UnmarshallingTest.h | 10 +++---
xmltoolingtest/XMLObjectBaseTestCase.h | 8 ++---
xmltoolingtest/xmltoolingtest.h | 6 ++--
49 files changed, 268 insertions(+), 303 deletions(-)
diff --git a/xmltooling/AbstractDOMCachingXMLObject.cpp b/xmltooling/AbstractDOMCachingXMLObject.cpp
index 061df1a..e6a81d6 100644
--- a/xmltooling/AbstractDOMCachingXMLObject.cpp
+++ b/xmltooling/AbstractDOMCachingXMLObject.cpp
@@ -37,6 +37,8 @@ using namespace xmltooling;
using namespace xercesc;
using namespace std;
+using boost::scoped_ptr;
+
AbstractDOMCachingXMLObject::AbstractDOMCachingXMLObject() : m_dom(nullptr), m_document(nullptr)
{
}
@@ -156,10 +158,12 @@ XMLObject* AbstractDOMCachingXMLObject::clone() const
// Seemed to work, so now we unmarshall the DOM to produce the clone.
const XMLObjectBuilder* b=XMLObjectBuilder::getBuilder(domCopy);
if (!b) {
- auto_ptr<QName> q(XMLHelper::getNodeQName(domCopy));
- m_log.error(
- "DOM clone failed, unable to locate builder for element (%s)", q->toString().c_str()
- );
+ if (m_log.isErrorEnabled()) {
+ scoped_ptr<QName> q(XMLHelper::getNodeQName(domCopy));
+ m_log.error(
+ "DOM clone failed, unable to locate builder for element (%s)", q->toString().c_str()
+ );
+ }
domCopy->getOwnerDocument()->release();
throw UnmarshallingException("Unable to locate builder for cloned element.");
}
diff --git a/xmltooling/AbstractXMLObject.h b/xmltooling/AbstractXMLObject.h
index aff1ab2..607c7e1 100644
--- a/xmltooling/AbstractXMLObject.h
+++ b/xmltooling/AbstractXMLObject.h
@@ -31,7 +31,7 @@
#include <xmltooling/QName.h>
#include <xmltooling/XMLObject.h>
-#include <memory>
+#include <boost/scoped_ptr.hpp>
#include <xercesc/util/XMLDateTime.hpp>
#if defined (_MSC_VER)
@@ -191,7 +191,7 @@ namespace xmltooling {
private:
XMLObject* m_parent;
QName m_elementQname;
- std::auto_ptr<QName> m_typeQname;
+ boost::scoped_ptr<QName> m_typeQname;
};
};
diff --git a/xmltooling/XMLObjectBuilder.cpp b/xmltooling/XMLObjectBuilder.cpp
index 2433f59..0721bab 100644
--- a/xmltooling/XMLObjectBuilder.cpp
+++ b/xmltooling/XMLObjectBuilder.cpp
@@ -36,6 +36,7 @@ using namespace std;
using xercesc::DOMDocument;
using xercesc::DOMElement;
+using boost::scoped_ptr;
map<QName,XMLObjectBuilder*> XMLObjectBuilder::m_map;
XMLObjectBuilder* XMLObjectBuilder::m_default = nullptr;
@@ -55,7 +56,7 @@ XMLObject* XMLObjectBuilder::buildFromQName(const QName& q) const
XMLObject* XMLObjectBuilder::buildFromElement(DOMElement* element, bool bindDocument) const
{
- auto_ptr<QName> schemaType(XMLHelper::getXSIType(element));
+ scoped_ptr<QName> schemaType(XMLHelper::getXSIType(element));
auto_ptr<XMLObject> ret(
buildObject(element->getNamespaceURI(),element->getLocalName(),element->getPrefix(),schemaType.get())
);
@@ -87,7 +88,7 @@ const XMLObjectBuilder* XMLObjectBuilder::getBuilder(const DOMElement* domElemen
#endif
Category& log=Category::getInstance(XMLTOOLING_LOGCAT ".XMLObjectBuilder");
- auto_ptr<QName> schemaType(XMLHelper::getXSIType(domElement));
+ scoped_ptr<QName> schemaType(XMLHelper::getXSIType(domElement));
const XMLObjectBuilder* xmlObjectBuilder = schemaType.get() ? getBuilder(*(schemaType.get())) : nullptr;
if (xmlObjectBuilder) {
if (log.isDebugEnabled()) {
@@ -96,7 +97,7 @@ const XMLObjectBuilder* XMLObjectBuilder::getBuilder(const DOMElement* domElemen
return xmlObjectBuilder;
}
- auto_ptr<QName> elementName(XMLHelper::getNodeQName(domElement));
+ scoped_ptr<QName> elementName(XMLHelper::getNodeQName(domElement));
xmlObjectBuilder = getBuilder(*(elementName.get()));
if (xmlObjectBuilder) {
if (log.isDebugEnabled()) {
diff --git a/xmltooling/XMLToolingConfig.h b/xmltooling/XMLToolingConfig.h
index 21fa4ef..b5a2f46 100644
--- a/xmltooling/XMLToolingConfig.h
+++ b/xmltooling/XMLToolingConfig.h
@@ -33,6 +33,7 @@
#include <memory>
#include <string>
+#include <boost/scoped_ptr.hpp>
#include <xercesc/dom/DOM.hpp>
#if defined (_MSC_VER)
@@ -76,23 +77,23 @@ namespace xmltooling {
#ifndef XMLTOOLING_NO_XMLSEC
/** Global KeyInfoResolver instance. */
- std::auto_ptr<KeyInfoResolver> m_keyInfoResolver;
+ boost::scoped_ptr<KeyInfoResolver> m_keyInfoResolver;
/** Global ReplayCache instance. */
- std::auto_ptr<ReplayCache> m_replayCache;
+ boost::scoped_ptr<ReplayCache> m_replayCache;
/* Global DataSealer instance. */
- std::auto_ptr<DataSealer> m_dataSealer;
+ boost::scoped_ptr<DataSealer> m_dataSealer;
#endif
/** Global PathResolver instance. */
- std::auto_ptr<PathResolver> m_pathResolver;
+ boost::scoped_ptr<PathResolver> m_pathResolver;
/** Global TemplateEngine instance. */
- std::auto_ptr<TemplateEngine> m_templateEngine;
+ boost::scoped_ptr<TemplateEngine> m_templateEngine;
/** Global URLEncoder instance for use by URL-related functions. */
- std::auto_ptr<URLEncoder> m_urlEncoder;
+ boost::scoped_ptr<URLEncoder> m_urlEncoder;
public:
virtual ~XMLToolingConfig();
diff --git a/xmltooling/base.h b/xmltooling/base.h
index f61d748..27ae365 100644
--- a/xmltooling/base.h
+++ b/xmltooling/base.h
@@ -1205,7 +1205,7 @@
*/
#define PROC_QNAME_ATTRIB(proper,ucase,namespaceURI) \
if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
- std::auto_ptr<xmltooling::QName> q(xmltooling::XMLHelper::getAttributeValueAsQName(attribute)); \
+ boost::scoped_ptr<xmltooling::QName> q(xmltooling::XMLHelper::getAttributeValueAsQName(attribute)); \
set##proper(q.get()); \
return; \
}
@@ -1376,10 +1376,8 @@
xmltooling::XMLObject* clone() const { \
std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
- if (ret) { \
- domClone.release(); \
- return ret; \
- } \
+ if (ret) \
+ return domClone.release(); \
return new cname##Impl(*this); \
}
@@ -1400,10 +1398,8 @@
xmltooling::XMLObject* clone() const { \
std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
- if (ret) { \
- domClone.release(); \
- return ret; \
- } \
+ if (ret) \
+ return domClone.release(); \
return new cname##Impl(*this); \
}
@@ -1420,10 +1416,8 @@
xmltooling::XMLObject* clone() const { \
std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
- if (ret) { \
- domClone.release(); \
- return ret; \
- } \
+ if (ret) \
+ return domClone.release(); \
std::auto_ptr<cname##Impl> ret2(new cname##Impl(*this)); \
ret2->_clone(*this); \
return ret2.release(); \
@@ -1447,10 +1441,8 @@
xmltooling::XMLObject* clone() const { \
std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
- if (ret) { \
- domClone.release(); \
- return ret; \
- } \
+ if (ret) \
+ return domClone.release(); \
std::auto_ptr<cname##Impl> ret2(new cname##Impl(*this)); \
ret2->_clone(*this); \
return ret2.release(); \
diff --git a/xmltooling/encryption/Decrypter.h b/xmltooling/encryption/Decrypter.h
index 5f26258..5e37608 100644
--- a/xmltooling/encryption/Decrypter.h
+++ b/xmltooling/encryption/Decrypter.h
@@ -99,10 +99,10 @@ namespace xmlencryption {
* DOM can also be imported into a separately owned document.
*
* @param encryptedData the data to decrypt
- * @param key the decryption key to use (it will not be freed internally)
+ * @param key the decryption key to use
* @return the decrypted DOM fragment
*/
- xercesc::DOMDocumentFragment* decryptData(const EncryptedData& encryptedData, XSECCryptoKey* key);
+ xercesc::DOMDocumentFragment* decryptData(const EncryptedData& encryptedData, const XSECCryptoKey* key);
/**
* Decrypts the supplied information and returns the resulting as a DOM
@@ -126,9 +126,9 @@ namespace xmlencryption {
*
* @param out output stream to receive the decrypted data
* @param encryptedData the data to decrypt
- * @param key the decryption key to use (it will not be freed internally)
+ * @param key the decryption key to use
*/
- void decryptData(std::ostream& out, const EncryptedData& encryptedData, XSECCryptoKey* key);
+ void decryptData(std::ostream& out, const EncryptedData& encryptedData, const XSECCryptoKey* key);
/**
* Decrypts the supplied information to an output stream.
diff --git a/xmltooling/encryption/impl/Decrypter.cpp b/xmltooling/encryption/impl/Decrypter.cpp
index a31a107..8d4a302 100644
--- a/xmltooling/encryption/impl/Decrypter.cpp
+++ b/xmltooling/encryption/impl/Decrypter.cpp
@@ -46,6 +46,7 @@ using namespace xmlencryption;
using namespace xmlsignature;
using namespace xmltooling;
using namespace xercesc;
+using boost::scoped_ptr;
using namespace std;
@@ -76,7 +77,7 @@ void Decrypter::setKEKResolver(const CredentialResolver* resolver, CredentialCri
m_criteria=criteria;
}
-DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData, XSECCryptoKey* key)
+DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData, const XSECCryptoKey* key)
{
if (encryptedData.getDOM() == nullptr)
throw DecryptionException("The object must be marshalled before decryption.");
@@ -144,7 +145,7 @@ DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData,
}
// Loop over them and try each one.
- XSECCryptoKey* key;
+ const XSECCryptoKey* key;
for (vector<const Credential*>::const_iterator cred = creds.begin(); cred != creds.end(); ++cred) {
try {
key = (*cred)->getPrivateKey();
@@ -152,7 +153,7 @@ DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData,
continue;
return decryptData(encryptedData, key);
}
- catch(DecryptionException& ex) {
+ catch(const DecryptionException& ex) {
logging::Category::getInstance(XMLTOOLING_LOGCAT ".Decrypter").warn(ex.what());
}
}
@@ -175,13 +176,13 @@ DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData,
if (!encKey)
throw DecryptionException("Unable to locate an encrypted key.");
- auto_ptr<XSECCryptoKey> keywrapper(decryptKey(*encKey, algorithm));
- if (!keywrapper.get())
+ scoped_ptr<XSECCryptoKey> keywrapper(decryptKey(*encKey, algorithm));
+ if (!keywrapper)
throw DecryptionException("Unable to decrypt the encrypted key.");
return decryptData(encryptedData, keywrapper.get());
}
-void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, XSECCryptoKey* key)
+void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, const XSECCryptoKey* key)
{
if (encryptedData.getDOM() == nullptr)
throw DecryptionException("The object must be marshalled before decryption.");
@@ -206,18 +207,18 @@ void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, XS
try {
m_cipher->setKey(key->clone());
- auto_ptr<XSECBinTXFMInputStream> in(m_cipher->decryptToBinInputStream(encryptedData.getDOM()));
+ scoped_ptr<XSECBinTXFMInputStream> in(m_cipher->decryptToBinInputStream(encryptedData.getDOM()));
XMLByte buf[8192];
XMLSize_t count = in->readBytes(buf, sizeof(buf));
while (count > 0)
out.write(reinterpret_cast<char*>(buf),count);
}
- catch(XSECException& e) {
+ catch(const XSECException& e) {
auto_ptr_char temp(e.getMsg());
throw DecryptionException(string("XMLSecurity exception while decrypting: ") + temp.get());
}
- catch(XSECCryptoException& e) {
+ catch(const XSECCryptoException& e) {
throw DecryptionException(string("XMLSecurity exception while decrypting: ") + e.getMsg());
}
}
@@ -249,7 +250,7 @@ void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, co
}
// Loop over them and try each one.
- XSECCryptoKey* key;
+ const XSECCryptoKey* key;
for (vector<const Credential*>::const_iterator cred = creds.begin(); cred != creds.end(); ++cred) {
try {
key = (*cred)->getPrivateKey();
@@ -257,7 +258,7 @@ void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, co
continue;
return decryptData(out, encryptedData, key);
}
- catch(DecryptionException& ex) {
+ catch(const DecryptionException& ex) {
logging::Category::getInstance(XMLTOOLING_LOGCAT ".Decrypter").warn(ex.what());
}
}
@@ -280,8 +281,8 @@ void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, co
if (!encKey)
throw DecryptionException("Unable to locate an encrypted key.");
- auto_ptr<XSECCryptoKey> keywrapper(decryptKey(*encKey, algorithm));
- if (!keywrapper.get())
+ scoped_ptr<XSECCryptoKey> keywrapper(decryptKey(*encKey, algorithm));
+ if (!keywrapper)
throw DecryptionException("Unable to decrypt the encrypted key.");
decryptData(out, encryptedData, keywrapper.get());
}
@@ -300,11 +301,11 @@ XSECCryptoKey* Decrypter::decryptKey(const EncryptedKey& encryptedKey, const XML
if (!handler)
throw DecryptionException("Unrecognized algorithm, no way to build object around decrypted key.");
}
- catch(XSECException& e) {
+ catch(const XSECException& e) {
auto_ptr_char temp(e.getMsg());
throw DecryptionException(string("XMLSecurity exception while decrypting key: ") + temp.get());
}
- catch(XSECCryptoException& e) {
+ catch(const XSECCryptoException& e) {
throw DecryptionException(string("XMLSecurity exception while decrypting key: ") + e.getMsg());
}
@@ -357,15 +358,15 @@ XSECCryptoKey* Decrypter::decryptKey(const EncryptedKey& encryptedKey, const XML
// Try to wrap the key.
return handler->createKeyForURI(algorithm, buffer, keySize);
}
- catch(XSECException& e) {
+ catch(const XSECException& e) {
auto_ptr_char temp(e.getMsg());
throw DecryptionException(string("XMLSecurity exception while decrypting key: ") + temp.get());
}
- catch(XSECCryptoException& e) {
+ catch(const XSECCryptoException& e) {
throw DecryptionException(string("XMLSecurity exception while decrypting key: ") + e.getMsg());
}
}
- catch(DecryptionException& ex) {
+ catch(const DecryptionException& ex) {
logging::Category::getInstance(XMLTOOLING_LOGCAT ".Decrypter").warn(ex.what());
}
}
@@ -383,11 +384,11 @@ XSECCryptoKey* Decrypter::decryptKey(const EncryptedKey& encryptedKey, const XML
throw DecryptionException("Unable to generate random data; was PRNG seeded?");
return handler->createKeyForURI(algorithm, buffer, mapped.second);
}
- catch(XSECException& e) {
+ catch(const XSECException& e) {
auto_ptr_char temp(e.getMsg());
throw DecryptionException(string("XMLSecurity exception while generating key: ") + temp.get());
}
- catch (XSECCryptoException& e) {
+ catch (const XSECCryptoException& e) {
throw DecryptionException(string("XMLSecurity exception while generating key: ") + e.getMsg());
}
}
diff --git a/xmltooling/encryption/impl/Encrypter.cpp b/xmltooling/encryption/impl/Encrypter.cpp
index 1f3b458..6f361fc 100644
--- a/xmltooling/encryption/impl/Encrypter.cpp
+++ b/xmltooling/encryption/impl/Encrypter.cpp
@@ -42,6 +42,7 @@ using namespace xmlencryption;
using namespace xmlsignature;
using namespace xmltooling;
using namespace xercesc;
+using boost::scoped_ptr;
using namespace std;
Encrypter::EncryptionParams::EncryptionParams(
@@ -92,9 +93,8 @@ void Encrypter::checkParams(EncryptionParams& encParams, KeyEncryptionParams* ke
}
}
- XSECCryptoKey* key=nullptr;
if (encParams.m_credential) {
- key = encParams.m_credential->getPrivateKey();
+ const XSECCryptoKey* key = encParams.m_credential->getPrivateKey();
if (!key)
throw EncryptionException("Credential in EncryptionParams structure did not supply a private/secret key.");
// Set the encryption key.
@@ -103,11 +103,12 @@ void Encrypter::checkParams(EncryptionParams& encParams, KeyEncryptionParams* ke
else {
// We have to have a raw key now, so we need to build a wrapper around it.
const XSECAlgorithmHandler* handler =XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(encParams.m_algorithm);
- if (handler != nullptr)
- key = handler->createKeyForURI(
- encParams.m_algorithm,const_cast<unsigned char*>(encParams.m_keyBuffer),encParams.m_keyBufferSize
- );
+ if (!handler)
+ throw EncryptionException("Unable to obtain internal algorithm handle, unknown algorithm?");
+ XSECCryptoKey* key = handler->createKeyForURI(
+ encParams.m_algorithm,const_cast<unsigned char*>(encParams.m_keyBuffer),encParams.m_keyBufferSize
+ );
if (!key)
throw EncryptionException("Unable to build wrapper for key, unknown algorithm?");
// Overwrite the length if known.
@@ -238,7 +239,7 @@ EncryptedData* Encrypter::decorateAndUnmarshall(EncryptionParams& encParams, Key
// Are we doing a key encryption?
if (kencParams) {
- XSECCryptoKey* kek = kencParams->m_credential.getPublicKey();
+ const XSECCryptoKey* kek = kencParams->m_credential.getPublicKey();
if (!kek)
throw EncryptionException("Credential in KeyEncryptionParams structure did not supply a public key.");
if (!kencParams->m_algorithm)
@@ -248,7 +249,7 @@ EncryptedData* Encrypter::decorateAndUnmarshall(EncryptionParams& encParams, Key
m_cipher->setKEK(kek->clone());
// ownership of this belongs to us, for some reason...
- auto_ptr<XENCEncryptedKey> encKey(
+ scoped_ptr<XENCEncryptedKey> encKey(
m_cipher->encryptKey(encParams.m_keyBuffer, encParams.m_keyBufferSize, kencParams->m_algorithm)
);
EncryptedKey* xmlEncKey=nullptr;
@@ -292,7 +293,7 @@ EncryptedKey* Encrypter::encryptKey(
m_cipher=nullptr;
}
- XSECCryptoKey* kek = kencParams.m_credential.getPublicKey();
+ const XSECCryptoKey* kek = kencParams.m_credential.getPublicKey();
if (!kek)
throw EncryptionException("Credential in KeyEncryptionParams structure did not supply a public key.");
@@ -303,7 +304,7 @@ EncryptedKey* Encrypter::encryptKey(
m_cipher=XMLToolingInternalConfig::getInternalConfig().m_xsecProvider->newCipher(doc);
m_cipher->setExclusiveC14nSerialisation(false);
m_cipher->setKEK(kek->clone());
- auto_ptr<XENCEncryptedKey> encKey(m_cipher->encryptKey(keyBuffer, keyBufferSize, kencParams.m_algorithm));
+ scoped_ptr<XENCEncryptedKey> encKey(m_cipher->encryptKey(keyBuffer, keyBufferSize, kencParams.m_algorithm));
EncryptedKey* xmlEncKey=nullptr;
auto_ptr<XMLObject> xmlObjectKey(XMLObjectBuilder::buildOneFromElement(encKey->getElement()));
diff --git a/xmltooling/impl/AnyElement.cpp b/xmltooling/impl/AnyElement.cpp
index 72c833d..fe829c3 100644
--- a/xmltooling/impl/AnyElement.cpp
+++ b/xmltooling/impl/AnyElement.cpp
@@ -68,8 +68,7 @@ XMLObject* AnyElementImpl::clone() const {
auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
AnyElementImpl* ret=dynamic_cast<AnyElementImpl*>(domClone.get());
if (ret) {
- domClone.release();
- return ret;
+ return domClone.release();
}
auto_ptr<AnyElementImpl> ret2(new AnyElementImpl(*this));
diff --git a/xmltooling/impl/MemoryStorageService.cpp b/xmltooling/impl/MemoryStorageService.cpp
index 785bfc6..e92f59c 100644
--- a/xmltooling/impl/MemoryStorageService.cpp
+++ b/xmltooling/impl/MemoryStorageService.cpp
@@ -36,6 +36,7 @@
using namespace xmltooling::logging;
using namespace xmltooling;
+using boost::scoped_ptr;
using namespace std;
using xercesc::DOMElement;
@@ -116,9 +117,9 @@ namespace xmltooling {
}
map<string,Context> m_contextMap;
- auto_ptr<RWLock> m_lock;
- auto_ptr<CondWait> shutdown_wait;
- auto_ptr<Thread> cleanup_thread;
+ scoped_ptr<RWLock> m_lock;
+ scoped_ptr<CondWait> shutdown_wait;
+ scoped_ptr<Thread> cleanup_thread;
static void* cleanup_fn(void*);
bool shutdown;
int m_cleanupInterval;
@@ -162,7 +163,7 @@ void* MemoryStorageService::cleanup_fn(void* pv)
NDC ndc("cleanup");
#endif
- auto_ptr<Mutex> mutex(Mutex::create());
+ scoped_ptr<Mutex> mutex(Mutex::create());
mutex->lock();
cache->m_log.info("cleanup thread started...running every %d seconds", cache->m_cleanupInterval);
diff --git a/xmltooling/internal.h b/xmltooling/internal.h
index 4fcee44..dce3a0c 100644
--- a/xmltooling/internal.h
+++ b/xmltooling/internal.h
@@ -127,7 +127,7 @@ namespace xmltooling {
bool isXMLAlgorithmSupported(const XMLCh* xmlAlgorithm, XMLSecurityAlgorithmType type=ALGTYPE_UNK);
void registerXMLAlgorithms();
- std::auto_ptr<XSECProvider> m_xsecProvider;
+ boost::scoped_ptr<XSECProvider> m_xsecProvider;
private:
typedef std::map<XMLSecurityAlgorithmType, std::map< xstring,std::pair<std::string,unsigned int> > > algmap_t;
algmap_t m_algorithmMap;
@@ -135,11 +135,11 @@ namespace xmltooling {
private:
int m_initCount;
- std::auto_ptr<Mutex> m_lock;
+ boost::scoped_ptr<Mutex> m_lock;
std::map<std::string,Mutex*> m_namedLocks;
std::vector<void*> m_libhandles;
- std::auto_ptr<ParserPool> m_parserPool;
- std::auto_ptr<ParserPool> m_validatingPool;
+ boost::scoped_ptr<ParserPool> m_parserPool;
+ boost::scoped_ptr<ParserPool> m_validatingPool;
};
#ifndef XMLTOOLING_NO_XMLSEC
diff --git a/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp b/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp
index eac4187..669e99a 100644
--- a/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp
+++ b/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp
@@ -37,6 +37,7 @@
using namespace xmlconstants;
using namespace xmltooling;
using namespace xercesc;
+using boost::scoped_ptr;
using namespace std;
AbstractXMLObjectUnmarshaller::AbstractXMLObjectUnmarshaller()
@@ -185,13 +186,15 @@ void AbstractXMLObjectUnmarshaller::unmarshallContent(const DOMElement* domEleme
if (childNode->getNodeType() == DOMNode::ELEMENT_NODE) {
const XMLObjectBuilder* builder = XMLObjectBuilder::getBuilder(static_cast<DOMElement*>(childNode));
if (!builder) {
- auto_ptr<QName> cname(XMLHelper::getNodeQName(childNode));
- m_log.error("no default builder installed, found unknown child element (%s)", cname->toString().c_str());
+ if (m_log.isErrorEnabled()) {
+ scoped_ptr<QName> cname(XMLHelper::getNodeQName(childNode));
+ m_log.error("no default builder installed, found unknown child element (%s)", cname->toString().c_str());
+ }
throw UnmarshallingException("Unmarshaller found unknown child element, but no default builder was found.");
}
if (m_log.isDebugEnabled()) {
- auto_ptr<QName> cname(XMLHelper::getNodeQName(childNode));
+ scoped_ptr<QName> cname(XMLHelper::getNodeQName(childNode));
m_log.debug("unmarshalling child element (%s)", cname->toString().c_str());
}
@@ -222,6 +225,6 @@ void AbstractXMLObjectUnmarshaller::processChildElement(XMLObject* child, const
void AbstractXMLObjectUnmarshaller::processAttribute(const DOMAttr* attribute)
{
- auto_ptr<QName> q(XMLHelper::getNodeQName(attribute));
+ scoped_ptr<QName> q(XMLHelper::getNodeQName(attribute));
throw UnmarshallingException("Invalid attribute: $1",params(1,q->toString().c_str()));
}
diff --git a/xmltooling/security/BasicX509Credential.h b/xmltooling/security/BasicX509Credential.h
index 7dd2108..7bf97a4 100644
--- a/xmltooling/security/BasicX509Credential.h
+++ b/xmltooling/security/BasicX509Credential.h
@@ -32,6 +32,7 @@
#include <set>
#include <vector>
#include <string>
+#include <boost/scoped_ptr.hpp>
namespace xmlsignature {
class XMLTOOL_API KeyInfo;
@@ -71,7 +72,7 @@ namespace xmltooling {
BasicX509Credential(XSECCryptoKey* key, const std::vector<XSECCryptoX509*>& certs, const std::vector<XSECCryptoX509CRL*>& crls);
/** The private/secret key/keypair. */
- XSECCryptoKey* m_key;
+ boost::scoped_ptr<XSECCryptoKey> m_key;
/** Key names (derived from credential, KeyInfo, or both). */
std::set<std::string> m_keyNames;
@@ -95,10 +96,10 @@ namespace xmltooling {
std::vector<XSECCryptoX509CRL*> m_crls;
/** The KeyInfo object representing the information. */
- xmlsignature::KeyInfo* m_keyInfo;
+ boost::scoped_ptr<xmlsignature::KeyInfo> m_keyInfo;
/** The KeyInfo object representing the information in compact form. */
- xmlsignature::KeyInfo* m_compactKeyInfo;
+ boost::scoped_ptr<xmlsignature::KeyInfo> m_compactKeyInfo;
/**
* Initializes (or reinitializes) a ds:KeyInfo to represent the Credential.
@@ -114,12 +115,11 @@ namespace xmltooling {
unsigned int getUsage() const;
const char* getAlgorithm() const;
unsigned int getKeySize() const;
- XSECCryptoKey* getPrivateKey() const;
- XSECCryptoKey* getPublicKey() const;
+ const XSECCryptoKey* getPrivateKey() const;
+ const XSECCryptoKey* getPublicKey() const;
const std::set<std::string>& getKeyNames() const;
xmlsignature::KeyInfo* getKeyInfo(bool compact=false) const;
const std::vector<XSECCryptoX509*>& getEntityCertificateChain() const;
- XSECCryptoX509CRL* getCRL() const;
const std::vector<XSECCryptoX509CRL*>& getCRLs() const;
const char* getSubjectName() const;
const char* getIssuerName() const;
diff --git a/xmltooling/security/Credential.h b/xmltooling/security/Credential.h
index 2cce6b7..4fbb719 100644
--- a/xmltooling/security/Credential.h
+++ b/xmltooling/security/Credential.h
@@ -110,14 +110,14 @@ namespace xmltooling {
*
* @return a secret or private key
*/
- virtual XSECCryptoKey* getPrivateKey() const=0;
+ virtual const XSECCryptoKey* getPrivateKey() const=0;
/**
* Returns a secret or public key to use for verification or encryption operations.
*
* @return a secret or public key
*/
- virtual XSECCryptoKey* getPublicKey() const=0;
+ virtual const XSECCryptoKey* getPublicKey() const=0;
/**
* Returns names representing the Credential.
diff --git a/xmltooling/security/DataSealer.h b/xmltooling/security/DataSealer.h
index 0d074ec..de617bc 100644
--- a/xmltooling/security/DataSealer.h
+++ b/xmltooling/security/DataSealer.h
@@ -32,6 +32,7 @@
#include <ctime>
#include <string>
+#include <boost/scoped_ptr.hpp>
class XSECCryptoSymmetricKey;
@@ -122,7 +123,7 @@ namespace xmltooling {
private:
logging::Category& m_log;
- std::auto_ptr<DataSealerKeyStrategy> m_strategy;
+ boost::scoped_ptr<DataSealerKeyStrategy> m_strategy;
};
};
diff --git a/xmltooling/security/X509Credential.h b/xmltooling/security/X509Credential.h
index a29f438..a479278 100644
--- a/xmltooling/security/X509Credential.h
+++ b/xmltooling/security/X509Credential.h
@@ -73,15 +73,6 @@ namespace xmltooling {
virtual const std::vector<XSECCryptoX509*>& getEntityCertificateChain() const=0;
/**
- * @deprecated
- *
- * Gets a CRL associated with the credential.
- *
- * @return CRL associated with the credential
- */
- virtual XSECCryptoX509CRL* getCRL() const=0;
-
- /**
* Gets an immutable collection of all CRLs associated with the credential.
*
* @return CRLs associated with the credential
diff --git a/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp b/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp
index 54ceada..e9cee8c 100644
--- a/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp
+++ b/xmltooling/security/impl/AbstractPKIXTrustEngine.cpp
@@ -49,6 +49,7 @@
using namespace xmlsignature;
using namespace xmltooling::logging;
using namespace xmltooling;
+using boost::scoped_ptr;
using namespace std;
namespace xmltooling {
@@ -375,7 +376,7 @@ bool AbstractPKIXTrustEngine::validateWithCRLs(
log.debug("performing certificate path validation...");
- auto_ptr<PKIXValidationInfoIterator> pkix(getPKIXValidationInfoIterator(credResolver, criteria));
+ scoped_ptr<PKIXValidationInfoIterator> pkix(getPKIXValidationInfoIterator(credResolver, criteria));
while (pkix->next()) {
PKIXParams params(*this, *pkix.get(), inlineCRLs);
for (vector< boost::shared_ptr<OpenSSLPathValidator> >::const_iterator v = m_pathValidators.begin(); v != m_pathValidators.end(); ++v) {
@@ -448,8 +449,8 @@ bool AbstractPKIXTrustEngine::validate(
// Pull the certificate chain out of the signature.
X509Credential* x509cred;
- auto_ptr<Credential> cred(inlineResolver->resolve(&sig,X509Credential::RESOLVE_CERTS|X509Credential::RESOLVE_CRLS));
- if (!cred.get() || !(x509cred=dynamic_cast<X509Credential*>(cred.get()))) {
+ scoped_ptr<Credential> cred(inlineResolver->resolve(&sig,X509Credential::RESOLVE_CERTS|X509Credential::RESOLVE_CRLS));
+ if (!cred || !(x509cred=dynamic_cast<X509Credential*>(cred.get()))) {
log.error("unable to perform PKIX validation, signature does not contain any certificates");
return false;
}
@@ -467,7 +468,7 @@ bool AbstractPKIXTrustEngine::validate(
SignatureValidator keyValidator;
for (vector<XSECCryptoX509*>::const_iterator i=certs.begin(); !certEE && i!=certs.end(); ++i) {
try {
- auto_ptr<XSECCryptoKey> key((*i)->clonePublicKey());
+ scoped_ptr<XSECCryptoKey> key((*i)->clonePublicKey());
keyValidator.setKey(key.get());
keyValidator.validate(&sig);
log.debug("signature verified with key inside signature, attempting certificate validation...");
@@ -526,8 +527,8 @@ bool AbstractPKIXTrustEngine::validate(
// Pull the certificate chain out of the signature.
X509Credential* x509cred;
- auto_ptr<Credential> cred(inlineResolver->resolve(keyInfo,X509Credential::RESOLVE_CERTS));
- if (!cred.get() || !(x509cred=dynamic_cast<X509Credential*>(cred.get()))) {
+ scoped_ptr<Credential> cred(inlineResolver->resolve(keyInfo,X509Credential::RESOLVE_CERTS));
+ if (!cred || !(x509cred=dynamic_cast<X509Credential*>(cred.get()))) {
log.error("unable to perform PKIX validation, KeyInfo does not contain any certificates");
return false;
}
@@ -544,7 +545,7 @@ bool AbstractPKIXTrustEngine::validate(
XSECCryptoX509* certEE=nullptr;
for (vector<XSECCryptoX509*>::const_iterator i=certs.begin(); !certEE && i!=certs.end(); ++i) {
try {
- auto_ptr<XSECCryptoKey> key((*i)->clonePublicKey());
+ scoped_ptr<XSECCryptoKey> key((*i)->clonePublicKey());
if (Signature::verifyRawSignature(key.get(), sigAlgorithm, sig, in, in_len)) {
log.debug("signature verified with key inside signature, attempting certificate validation...");
certEE=(*i);
diff --git a/xmltooling/security/impl/BasicX509Credential.cpp b/xmltooling/security/impl/BasicX509Credential.cpp
index 551e140..c93cabf 100644
--- a/xmltooling/security/impl/BasicX509Credential.cpp
+++ b/xmltooling/security/impl/BasicX509Credential.cpp
@@ -119,20 +119,15 @@ BasicX509Credential::BasicX509Credential(XSECCryptoKey* key, const vector<XSECCr
BasicX509Credential::~BasicX509Credential()
{
- delete m_key;
if (m_ownCerts)
for_each(m_xseccerts.begin(), m_xseccerts.end(), xmltooling::cleanup<XSECCryptoX509>());
for_each(m_crls.begin(), m_crls.end(), xmltooling::cleanup<XSECCryptoX509CRL>());
- delete m_keyInfo;
- delete m_compactKeyInfo;
}
void BasicX509Credential::initKeyInfo(unsigned int types)
{
- delete m_keyInfo;
- m_keyInfo = nullptr;
- delete m_compactKeyInfo;
- m_compactKeyInfo = nullptr;
+ m_keyInfo.reset();
+ m_compactKeyInfo.reset();
// Default will disable X509IssuerSerial due to schema validation issues.
if (types == 0)
@@ -141,7 +136,7 @@ void BasicX509Credential::initKeyInfo(unsigned int types)
if (types & KEYINFO_KEY_NAME) {
const set<string>& names = getKeyNames();
if (!names.empty()) {
- m_compactKeyInfo = KeyInfoBuilder::buildKeyInfo();
+ m_compactKeyInfo.reset(KeyInfoBuilder::buildKeyInfo());
VectorOf(KeyName) knames = m_compactKeyInfo->getKeyNames();
for (set<string>::const_iterator n = names.begin(); n!=names.end(); ++n) {
if (*n == m_subjectName)
@@ -157,7 +152,7 @@ void BasicX509Credential::initKeyInfo(unsigned int types)
if (types & KEYINFO_X509_SUBJECTNAME || types & KEYINFO_X509_ISSUERSERIAL) {
if (!m_subjectName.empty() || (!m_issuerName.empty() && !m_serial.empty())) {
if (!m_compactKeyInfo)
- m_compactKeyInfo = KeyInfoBuilder::buildKeyInfo();
+ m_compactKeyInfo.reset(KeyInfoBuilder::buildKeyInfo());
X509Data* x509Data=X509DataBuilder::buildX509Data();
m_compactKeyInfo->getX509Datas().push_back(x509Data);
if (types & KEYINFO_X509_SUBJECTNAME && !m_subjectName.empty()) {
@@ -183,7 +178,7 @@ void BasicX509Credential::initKeyInfo(unsigned int types)
}
if (types & KEYINFO_X509_CERTIFICATE && !m_xseccerts.empty()) {
- m_keyInfo = m_compactKeyInfo ? m_compactKeyInfo->cloneKeyInfo() : KeyInfoBuilder::buildKeyInfo();
+ m_keyInfo.reset(m_compactKeyInfo ? m_compactKeyInfo->cloneKeyInfo() : KeyInfoBuilder::buildKeyInfo());
if (m_keyInfo->getX509Datas().empty())
m_keyInfo->getX509Datas().push_back(X509DataBuilder::buildX509Data());
for (vector<XSECCryptoX509*>::const_iterator x = m_xseccerts.begin(); x!=m_xseccerts.end(); ++x) {
@@ -196,7 +191,7 @@ void BasicX509Credential::initKeyInfo(unsigned int types)
if (types & KEYINFO_X509_DIGEST && !m_xseccerts.empty()) {
if (!m_compactKeyInfo)
- m_compactKeyInfo = KeyInfoBuilder::buildKeyInfo();
+ m_compactKeyInfo.reset(KeyInfoBuilder::buildKeyInfo());
if (m_compactKeyInfo->getX509Datas().empty())
m_compactKeyInfo->getX509Datas().push_back(X509DataBuilder::buildX509Data());
safeBuffer& buf=m_xseccerts.front()->getDEREncodingSB();
@@ -246,7 +241,7 @@ const char* BasicX509Credential::getAlgorithm() const
return "HMAC";
case XSECCryptoKey::KEY_SYMMETRIC: {
- switch (static_cast<XSECCryptoSymmetricKey*>(m_key)->getSymmetricKeyType()) {
+ switch (static_cast<XSECCryptoSymmetricKey*>(m_key.get())->getSymmetricKeyType()) {
case XSECCryptoSymmetricKey::KEY_3DES_192:
return "DESede";
case XSECCryptoSymmetricKey::KEY_AES_128:
@@ -269,12 +264,12 @@ unsigned int BasicX509Credential::getKeySize() const
case XSECCryptoKey::KEY_RSA_PRIVATE:
case XSECCryptoKey::KEY_RSA_PUBLIC:
case XSECCryptoKey::KEY_RSA_PAIR: {
- XSECCryptoKeyRSA* rkey = static_cast<XSECCryptoKeyRSA*>(m_key);
+ XSECCryptoKeyRSA* rkey = static_cast<XSECCryptoKeyRSA*>(m_key.get());
return 8 * rkey->getLength();
}
case XSECCryptoKey::KEY_SYMMETRIC: {
- switch (static_cast<XSECCryptoSymmetricKey*>(m_key)->getSymmetricKeyType()) {
+ switch (static_cast<XSECCryptoSymmetricKey*>(m_key.get())->getSymmetricKeyType()) {
case XSECCryptoSymmetricKey::KEY_3DES_192:
return 192;
case XSECCryptoSymmetricKey::KEY_AES_128:
@@ -290,26 +285,26 @@ unsigned int BasicX509Credential::getKeySize() const
return 0;
}
-XSECCryptoKey* BasicX509Credential::getPrivateKey() const
+const XSECCryptoKey* BasicX509Credential::getPrivateKey() const
{
if (m_key) {
XSECCryptoKey::KeyType type = m_key->getKeyType();
if (type != XSECCryptoKey::KEY_RSA_PUBLIC
- && type != XSECCryptoKey::KEY_DSA_PUBLIC
+ && type != XSECCryptoKey::KEY_DSA_PUBLIC
&& type != XSECCryptoKey::KEY_EC_PUBLIC)
- return m_key;
+ return m_key.get();
}
return nullptr;
}
-XSECCryptoKey* BasicX509Credential::getPublicKey() const
+const XSECCryptoKey* BasicX509Credential::getPublicKey() const
{
if (m_key) {
XSECCryptoKey::KeyType type = m_key->getKeyType();
if (type != XSECCryptoKey::KEY_RSA_PRIVATE
&& type != XSECCryptoKey::KEY_DSA_PRIVATE
&& type != XSECCryptoKey::KEY_EC_PRIVATE)
- return m_key;
+ return m_key.get();
}
return nullptr;
}
@@ -331,11 +326,6 @@ const vector<XSECCryptoX509*>& BasicX509Credential::getEntityCertificateChain()
return m_xseccerts;
}
-XSECCryptoX509CRL* BasicX509Credential::getCRL() const
-{
- return m_crls.empty() ? nullptr : m_crls.front();
-}
-
const vector<XSECCryptoX509CRL*>& BasicX509Credential::getCRLs() const
{
return m_crls;
diff --git a/xmltooling/security/impl/DataSealer.cpp b/xmltooling/security/impl/DataSealer.cpp
index b467a5f..6002866 100644
--- a/xmltooling/security/impl/DataSealer.cpp
+++ b/xmltooling/security/impl/DataSealer.cpp
@@ -47,6 +47,7 @@ using xercesc::Base64;
using xercesc::DOMDocument;
using xercesc::Janitor;
using xercesc::XMLDateTime;
+using boost::scoped_ptr;
using namespace std;
namespace xmltooling {
@@ -146,7 +147,7 @@ string DataSealer::wrap(const char* s, time_t exp) const
DOMDocument* dummydoc = XMLToolingConfig::getConfig().getParser().newDocument();
Janitor<DOMDocument> docjan(dummydoc);
- auto_ptr<XSECEnv> env(new XSECEnv(dummydoc));
+ scoped_ptr<XSECEnv> env(new XSECEnv(dummydoc));
TXFMChar* ct = new TXFMChar(dummydoc);
ct->setInput(deflated, len);
@@ -154,7 +155,7 @@ string DataSealer::wrap(const char* s, time_t exp) const
safeBuffer ciphertext;
try {
- auto_ptr<XENCEncryptionMethod> method(XENCEncryptionMethod::create(env.get(), algorithm));
+ scoped_ptr<XENCEncryptionMethod> method(XENCEncryptionMethod::create(env.get(), algorithm));
if (!handler->encryptToSafeBuffer(&tx, method.get(), defaultKey.second, dummydoc, ciphertext)) {
throw XMLSecurityException("Data encryption failed.");
}
@@ -218,7 +219,7 @@ string DataSealer::unwrap(const char* s) const
DOMDocument* dummydoc = XMLToolingConfig::getConfig().getParser().newDocument();
Janitor<DOMDocument> docjan(dummydoc);
- auto_ptr<XSECEnv> env(new XSECEnv(dummydoc));
+ scoped_ptr<XSECEnv> env(new XSECEnv(dummydoc));
TXFMChar* ct = new TXFMChar(dummydoc);
ct->setInput(++delim);
@@ -229,7 +230,7 @@ string DataSealer::unwrap(const char* s) const
unsigned int len = 0;
safeBuffer plaintext;
try {
- auto_ptr<XENCEncryptionMethod> method(XENCEncryptionMethod::create(env.get(), algorithm));
+ scoped_ptr<XENCEncryptionMethod> method(XENCEncryptionMethod::create(env.get(), algorithm));
len = handler->decryptToSafeBuffer(&tx, method.get(), requiredKey.second, dummydoc, plaintext);
}
catch (XSECException& ex) {
diff --git a/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp b/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp
index 82aa094..8ad2de1 100644
--- a/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp
+++ b/xmltooling/security/impl/ExplicitKeyTrustEngine.cpp
@@ -259,7 +259,7 @@ bool ExplicitKeyTrustEngine::validate(
return false;
for (vector<const Credential*>::const_iterator c=credentials.begin(); c != credentials.end(); ++c) {
- XSECCryptoKey* key = (*c)->getPublicKey();
+ const XSECCryptoKey* key = (*c)->getPublicKey();
if (!key)
continue;
if (key->getProviderName() != DSIGConstants::s_unicodeStrPROVOpenSSL) {
diff --git a/xmltooling/security/impl/FilesystemCredentialResolver.cpp b/xmltooling/security/impl/FilesystemCredentialResolver.cpp
index 38c451c..1f408a2 100644
--- a/xmltooling/security/impl/FilesystemCredentialResolver.cpp
+++ b/xmltooling/security/impl/FilesystemCredentialResolver.cpp
@@ -55,6 +55,7 @@ using namespace std;
using xercesc::DOMElement;
using xercesc::chLatin_f;
using xercesc::chDigit_0;
+using boost::scoped_ptr;
namespace xmltooling {
@@ -70,7 +71,7 @@ namespace xmltooling {
nkey = SecurityHelper::loadKeyFromFile(source.c_str(), format.c_str(), password);
}
else {
- auto_ptr<SOAPTransport> t(getTransport());
+ scoped_ptr<SOAPTransport> t(getTransport());
log.info("loading private key from URL (%s)", source.c_str());
nkey = SecurityHelper::loadKeyFromURL(*t.get(), backing.c_str(), format.c_str(), password);
}
@@ -96,7 +97,7 @@ namespace xmltooling {
SecurityHelper::loadCertificatesFromFile(ncerts, source.c_str(), format.c_str(), password);
}
else {
- auto_ptr<SOAPTransport> t(getTransport());
+ scoped_ptr<SOAPTransport> t(getTransport());
log.info("loading certificate(s) from URL (%s)", source.c_str());
SecurityHelper::loadCertificatesFromURL(ncerts, *t.get(), backing.c_str(), format.c_str(), password);
}
@@ -122,7 +123,7 @@ namespace xmltooling {
SecurityHelper::loadCRLsFromFile(ncrls, source.c_str(), format.c_str());
}
else {
- auto_ptr<SOAPTransport> t(getTransport());
+ scoped_ptr<SOAPTransport> t(getTransport());
log.info("loading CRL(s) from URL (%s)", source.c_str());
SecurityHelper::loadCRLsFromURL(ncrls, *t.get(), backing.c_str(), format.c_str());
}
@@ -157,8 +158,8 @@ namespace xmltooling {
private:
Credential* getCredential();
- RWLock* m_lock;
- Credential* m_credential;
+ scoped_ptr<RWLock> m_lock;
+ auto_ptr<Credential> m_credential;
string m_keypass,m_certpass;
unsigned int m_keyinfomask,m_usage;
bool m_extractNames;
@@ -238,7 +239,7 @@ namespace xmltooling {
};
FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
- : m_lock(nullptr), m_credential(nullptr), m_keyinfomask(XMLHelper::getAttrInt(e, 0, keyInfoMask)),
+ : m_keyinfomask(XMLHelper::getAttrInt(e, 0, keyInfoMask)),
m_usage(Credential::UNSPECIFIED_CREDENTIAL), m_extractNames(true)
{
#ifdef _DEBUG
@@ -435,9 +436,8 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
}
// Load it all into a credential object and then create the lock.
- auto_ptr<Credential> credential(getCredential());
- m_lock = RWLock::create();
- m_credential = credential.release();
+ m_credential.reset(getCredential());
+ m_lock.reset(RWLock::create());
if (m_credential->getPrivateKey() == nullptr) {
log.info("no private key resolved, usable for verification/trust only");
}
@@ -445,15 +445,13 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
FilesystemCredentialResolver::~FilesystemCredentialResolver()
{
- delete m_credential;
- delete m_lock;
}
Credential* FilesystemCredentialResolver::getCredential()
{
// First, verify that the key and certificate match.
if (m_key.key && !m_certs.empty()) {
- auto_ptr<XSECCryptoKey> temp(m_certs.front().certs.front()->clonePublicKey());
+ scoped_ptr<XSECCryptoKey> temp(m_certs.front().certs.front()->clonePublicKey());
if (!SecurityHelper::matches(*m_key.key, *temp.get()))
throw XMLSecurityException("FilesystemCredentialResolver given mismatched key/certificate, check for consistency.");
}
@@ -511,7 +509,7 @@ Lockable* FilesystemCredentialResolver::lock()
bool writelock = false, updated = false;
- if (m_key.stale(log, m_lock)) {
+ if (m_key.stale(log, m_lock.get())) {
writelock = true;
try {
m_key.load(log, m_keypass.c_str());
@@ -532,7 +530,7 @@ Lockable* FilesystemCredentialResolver::lock()
}
for (vector<ManagedCert>::iterator i = m_certs.begin(); i != m_certs.end(); ++i) {
- if (i->stale(log, writelock ? nullptr : m_lock)) {
+ if (i->stale(log, writelock ? nullptr : m_lock.get())) {
writelock = true;
try {
i->load(log, (i==m_certs.begin()) ? m_certpass.c_str() : nullptr);
@@ -554,7 +552,7 @@ Lockable* FilesystemCredentialResolver::lock()
}
for (vector<ManagedCRL>::iterator j = m_crls.begin(); j != m_crls.end(); ++j) {
- if (j->stale(log, writelock ? nullptr : m_lock)) {
+ if (j->stale(log, writelock ? nullptr : m_lock.get())) {
writelock = true;
try {
j->load(log);
@@ -578,8 +576,7 @@ Lockable* FilesystemCredentialResolver::lock()
if (updated) {
try {
auto_ptr<Credential> credential(getCredential());
- delete m_credential;
- m_credential = credential.release();
+ m_credential = credential; // swap via auto_ptr
}
catch (exception& ex) {
log.crit("maintaining existing credentials, error reloading: %s", ex.what());
@@ -595,7 +592,7 @@ Lockable* FilesystemCredentialResolver::lock()
const Credential* FilesystemCredentialResolver::resolve(const CredentialCriteria* criteria) const
{
- return (criteria ? (criteria->matches(*m_credential) ? m_credential : nullptr) : m_credential);
+ return (criteria ? (criteria->matches(*m_credential) ? m_credential.get() : nullptr) : m_credential.get());
}
vector<const Credential*>::size_type FilesystemCredentialResolver::resolve(
@@ -603,7 +600,7 @@ vector<const Credential*>::size_type FilesystemCredentialResolver::resolve(
) const
{
if (!criteria || criteria->matches(*m_credential)) {
- results.push_back(m_credential);
+ results.push_back(m_credential.get());
return 1;
}
return 0;
diff --git a/xmltooling/security/impl/InlineKeyResolver.cpp b/xmltooling/security/impl/InlineKeyResolver.cpp
index 3e0635d..78e1324 100644
--- a/xmltooling/security/impl/InlineKeyResolver.cpp
+++ b/xmltooling/security/impl/InlineKeyResolver.cpp
@@ -123,7 +123,7 @@ namespace xmltooling {
bool resolveKey(const KeyInfo* keyInfo, bool followRefs=false);
bool resolveCRLs(const KeyInfo* keyInfo, bool followRefs=false);
- auto_ptr<KeyInfoCredentialContext> m_credctx;
+ scoped_ptr<KeyInfoCredentialContext> m_credctx;
};
static const XMLCh keyInfoReferences[] = UNICODE_LITERAL_17(k,e,y,I,n,f,o,R,e,f,e,r,e,n,c,e,s);
@@ -194,13 +194,13 @@ void InlineCredential::resolve(const KeyInfo* keyInfo, int types, bool followRef
if (types & X509Credential::RESOLVE_CERTS) {
// If we have a cert, just use it.
if (!m_xseccerts.empty())
- m_key = m_xseccerts.front()->clonePublicKey();
+ m_key.reset(m_xseccerts.front()->clonePublicKey());
else
resolveKey(keyInfo, followRefs);
}
// Otherwise try directly for a key and then go for certs if none is found.
else if (!resolveKey(keyInfo, followRefs) && resolveCerts(keyInfo, followRefs)) {
- m_key = m_xseccerts.front()->clonePublicKey();
+ m_key.reset(m_xseccerts.front()->clonePublicKey());
}
}
@@ -269,7 +269,7 @@ bool InlineCredential::resolveKey(const KeyInfo* keyInfo, bool followRefs)
auto_ptr<XSECCryptoKeyRSA> rsa(XSECPlatformUtils::g_cryptoProvider->keyRSA());
rsa->loadPublicModulusBase64BigNums(mod.get(), strlen(mod.get()));
rsa->loadPublicExponentBase64BigNums(exp.get(), strlen(exp.get()));
- m_key = rsa.release();
+ m_key.reset(rsa.release());
return true;
}
DSAKeyValue* dsakv = i->getDSAKeyValue();
@@ -290,7 +290,7 @@ bool InlineCredential::resolveKey(const KeyInfo* keyInfo, bool followRefs)
auto_ptr_char g(dsakv->getG()->getValue());
dsa->loadGBase64BigNums(g.get(), strlen(g.get()));
}
- m_key = dsa.release();
+ m_key.reset(dsa.release());
return true;
}
@@ -303,7 +303,7 @@ bool InlineCredential::resolveKey(const KeyInfo* keyInfo, bool followRefs)
auto_ptr_char val(eckv->getPublicKey()->getValue());
if (uri.get() && val.get()) {
ec->loadPublicKeyBase64(uri.get(), val.get(), XMLString::stringLen(val.get()));
- m_key = ec.release();
+ m_key.reset(ec.release());
return true;
}
}
@@ -327,7 +327,7 @@ bool InlineCredential::resolveKey(const KeyInfo* keyInfo, bool followRefs)
for (indirect_iterator<vector<DEREncodedKeyValue*>::const_iterator> j = make_indirect_iterator(derValues.begin());
j != make_indirect_iterator(derValues.end()); ++j) {
log.debug("resolving ds11:DEREncodedKeyValue");
- m_key = SecurityHelper::fromDEREncoding(j->getValue());
+ m_key.reset(SecurityHelper::fromDEREncoding(j->getValue()));
if (m_key)
return true;
log.warn("failed to resolve ds11:DEREncodedKeyValue");
@@ -502,7 +502,7 @@ void InlineCredential::resolve(DSIGKeyInfoList* keyInfo, int types, bool followR
// Default resolver handles RSA/DSAKeyValue and X509Certificate elements.
try {
XSECKeyInfoResolverDefault def;
- m_key = def.resolveKey(keyInfo);
+ m_key.reset(def.resolveKey(keyInfo));
}
catch(XSECException& e) {
auto_ptr_char temp(e.getMsg());
diff --git a/xmltooling/security/impl/PKIXPathValidator.cpp b/xmltooling/security/impl/PKIXPathValidator.cpp
index 90cee59..dacd195 100644
--- a/xmltooling/security/impl/PKIXPathValidator.cpp
+++ b/xmltooling/security/impl/PKIXPathValidator.cpp
@@ -49,6 +49,7 @@ using namespace xmltooling::logging;
using namespace xmltooling;
using namespace std;
+using boost::scoped_ptr;
namespace {
static int XMLTOOL_DLLLOCAL error_callback(int ok, X509_STORE_CTX* ctx)
@@ -377,7 +378,7 @@ bool PKIXPathValidator::validate(X509* EE, STACK_OF(X509)* untrusted, const Path
// Only consider URIs, and stop after the first one we find.
if (gen->type == GEN_URI) {
const char* cdpuri = (const char*)gen->d.ia5->data;
- auto_ptr<XSECCryptoX509CRL> crl(getRemoteCRLs(cdpuri));
+ scoped_ptr<XSECCryptoX509CRL> crl(getRemoteCRLs(cdpuri));
if (crl.get() && crl->getProviderName()==DSIGConstants::s_unicodeStrPROVOpenSSL &&
(isFreshCRL(crl.get()) || (ii == sk_DIST_POINT_num(dps)-1 && iii == sk_GENERAL_NAME_num(dp->distpoint->name.fullname)-1))) {
// owned by store
@@ -507,7 +508,7 @@ XSECCryptoX509CRL* PKIXPathValidator::getRemoteCRLs(const char* cdpuri) const
if (difftime(now, ts) > m_minRefreshDelay) {
SOAPTransport::Address addr("AbstractPKIXTrustEngine", cdpuri, cdpuri);
string scheme(addr.m_endpoint, strchr(addr.m_endpoint,':') - addr.m_endpoint);
- auto_ptr<SOAPTransport> soap(XMLToolingConfig::getConfig().SOAPTransportManager.newPlugin(scheme.c_str(), addr));
+ scoped_ptr<SOAPTransport> soap(XMLToolingConfig::getConfig().SOAPTransportManager.newPlugin(scheme.c_str(), addr));
soap->send();
istream& msg = soap->receive();
Lock glock(m_lock);
diff --git a/xmltooling/security/impl/StaticDataSealerKeyStrategy.cpp b/xmltooling/security/impl/StaticDataSealerKeyStrategy.cpp
index d9421ca..8ba834a 100644
--- a/xmltooling/security/impl/StaticDataSealerKeyStrategy.cpp
+++ b/xmltooling/security/impl/StaticDataSealerKeyStrategy.cpp
@@ -34,6 +34,7 @@
using namespace xmltooling;
using xercesc::Base64;
using xercesc::DOMElement;
+using boost::scoped_ptr;
using namespace std;
namespace xmltooling {
@@ -51,7 +52,7 @@ namespace xmltooling {
private:
string m_name;
- auto_ptr<XSECCryptoSymmetricKey> m_key;
+ scoped_ptr<XSECCryptoSymmetricKey> m_key;
};
DataSealerKeyStrategy* XMLTOOL_DLLLOCAL StaticDataSealerKeyStrategyFactory(const DOMElement* const & e)
@@ -89,7 +90,7 @@ StaticDataSealerKeyStrategy::StaticDataSealerKeyStrategy(const DOMElement* e)
XMLString::release((char**)&decoded);
}
- if (!m_key.get()) {
+ if (!m_key) {
throw XMLSecurityException("No key attribute specified.");
}
}
diff --git a/xmltooling/security/impl/StaticPKIXTrustEngine.cpp b/xmltooling/security/impl/StaticPKIXTrustEngine.cpp
index 0994ee6..427be9b 100644
--- a/xmltooling/security/impl/StaticPKIXTrustEngine.cpp
+++ b/xmltooling/security/impl/StaticPKIXTrustEngine.cpp
@@ -40,6 +40,8 @@ using namespace xmltooling;
using namespace xercesc;
using namespace std;
+using boost::scoped_ptr;
+
namespace xmltooling {
static const XMLCh _CredentialResolver[] = UNICODE_LITERAL_18(C,r,e,d,e,n,t,i,a,l,R,e,s,o,l,v,e,r);
@@ -64,7 +66,7 @@ namespace xmltooling {
private:
int m_depth;
- auto_ptr<CredentialResolver> m_credResolver;
+ scoped_ptr<CredentialResolver> m_credResolver;
friend class XMLTOOL_DLLLOCAL StaticPKIXIterator;
};
diff --git a/xmltooling/security/impl/VersionedDataSealerKeyStrategy.cpp b/xmltooling/security/impl/VersionedDataSealerKeyStrategy.cpp
index 3ff8de1..85c3082 100644
--- a/xmltooling/security/impl/VersionedDataSealerKeyStrategy.cpp
+++ b/xmltooling/security/impl/VersionedDataSealerKeyStrategy.cpp
@@ -43,6 +43,7 @@ using namespace xmltooling::logging;
using namespace xmltooling;
using xercesc::Base64;
using xercesc::DOMElement;
+using boost::scoped_ptr;
using namespace std;
namespace xmltooling {
@@ -65,7 +66,7 @@ namespace xmltooling {
void load(ifstream& in);
Category& m_log;
- auto_ptr<RWLock> m_lock;
+ scoped_ptr<RWLock> m_lock;
mutable map< string, boost::shared_ptr<XSECCryptoSymmetricKey> > m_keyMap;
string m_default;
};
@@ -120,7 +121,7 @@ void VersionedDataSealerKeyStrategy::load()
load(in);
}
else {
- auto_ptr<SOAPTransport> t(getTransport());
+ scoped_ptr<SOAPTransport> t(getTransport());
// Fetch the data.
t->send();
diff --git a/xmltooling/signature/Signature.h b/xmltooling/signature/Signature.h
index 3245b7e..ec2eb45 100644
--- a/xmltooling/signature/Signature.h
+++ b/xmltooling/signature/Signature.h
@@ -159,7 +159,7 @@ namespace xmlsignature {
* <p>Allows specialized applications to create raw signatures over any input using
* the same cryptography layer as XML Signatures use.
*
- * @param key key to sign with, will <strong>NOT</strong> be freed
+ * @param key key to sign with
* @param sigAlgorithm XML signature algorithm identifier
* @param in input data
* @param in_len size of input data in bytes
@@ -168,7 +168,7 @@ namespace xmlsignature {
* @return size in bytes of base64-encoded signature
*/
static unsigned int createRawSignature(
- XSECCryptoKey* key,
+ const XSECCryptoKey* key,
const XMLCh* sigAlgorithm,
const char* in,
unsigned int in_len,
@@ -182,7 +182,7 @@ namespace xmlsignature {
* <p>Allows specialized applications to verify raw signatures over any input using
* the same cryptography layer as XML Signatures use.
*
- * @param key key to verify with, will <strong>NOT</strong> be freed
+ * @param key key to verify with
* @param sigAlgorithm XML signature algorithm identifier
* @param signature base64-encoded signature value
* @param in input data
@@ -190,7 +190,7 @@ namespace xmlsignature {
* @return true iff signature verifies
*/
static bool verifyRawSignature(
- XSECCryptoKey* key,
+ const XSECCryptoKey* key,
const XMLCh* sigAlgorithm,
const char* signature,
const char* in,
diff --git a/xmltooling/signature/impl/SignatureValidator.cpp b/xmltooling/signature/impl/SignatureValidator.cpp
index f69d299..5a841c9 100644
--- a/xmltooling/signature/impl/SignatureValidator.cpp
+++ b/xmltooling/signature/impl/SignatureValidator.cpp
@@ -76,7 +76,7 @@ void SignatureValidator::validate(const Signature* sigObj) const
else if (!m_key && !m_credential)
throw ValidationException("No Credential or key set on Validator.");
- XSECCryptoKey* key = m_key ? m_key : (m_credential ? m_credential->getPublicKey() : nullptr);
+ const XSECCryptoKey* key = m_key ? m_key : (m_credential ? m_credential->getPublicKey() : nullptr);
if (!key)
throw ValidationException("Credential did not contain a verification key.");
@@ -85,11 +85,11 @@ void SignatureValidator::validate(const Signature* sigObj) const
if (!sig->verify())
throw ValidationException("Digital signature does not validate with the supplied key.");
}
- catch(XSECException& e) {
+ catch(const XSECException& e) {
auto_ptr_char temp(e.getMsg());
throw ValidationException(string("Caught an XMLSecurity exception verifying signature: ") + temp.get());
}
- catch(XSECCryptoException& e) {
+ catch(const XSECCryptoException& e) {
throw ValidationException(string("Caught an XMLSecurity exception verifying signature: ") + e.getMsg());
}
}
diff --git a/xmltooling/signature/impl/XMLSecSignatureImpl.cpp b/xmltooling/signature/impl/XMLSecSignatureImpl.cpp
index ab2ba53..40abe9c 100644
--- a/xmltooling/signature/impl/XMLSecSignatureImpl.cpp
+++ b/xmltooling/signature/impl/XMLSecSignatureImpl.cpp
@@ -214,7 +214,7 @@ void XMLSecSignatureImpl::sign(const Credential* credential)
else if (!m_reference)
throw SignatureException("No ContentReference object set for signature creation.");
- XSECCryptoKey* key = credential ? credential->getPrivateKey() : m_key;
+ const XSECCryptoKey* key = credential ? credential->getPrivateKey() : m_key;
if (!key)
throw SignatureException("No signing key available for signature creation.");
@@ -229,11 +229,11 @@ void XMLSecSignatureImpl::sign(const Credential* credential)
m_signature->setSigningKey(key->clone());
m_signature->sign();
}
- catch(XSECException& e) {
+ catch(const XSECException& e) {
auto_ptr_char temp(e.getMsg());
throw SignatureException(string("Caught an XMLSecurity exception while signing: ") + temp.get());
}
- catch(XSECCryptoException& e) {
+ catch(const XSECCryptoException& e) {
throw SignatureException(string("Caught an XMLSecurity exception while signing: ") + e.getMsg());
}
}
@@ -319,13 +319,13 @@ DOMElement* XMLSecSignatureImpl::marshall(DOMDocument* document, const vector<Si
);
m_signature->load();
}
- catch(XSECException& e) {
+ catch(const XSECException& e) {
if (bindDocument)
document->release();
auto_ptr_char temp(e.getMsg());
throw MarshallingException(string("Caught an XMLSecurity exception while loading signature: ") + temp.get());
}
- catch(XSECCryptoException& e) {
+ catch(const XSECCryptoException& e) {
if (bindDocument)
document->release();
throw MarshallingException(string("Caught an XMLSecurity exception while loading signature: ") + e.getMsg());
@@ -402,7 +402,7 @@ DOMElement* XMLSecSignatureImpl::marshall(DOMElement* parentElement, const vecto
try {
cachedDOM=static_cast<DOMElement*>(parentElement->getOwnerDocument()->importNode(internalDoc->getDocumentElement(),true));
}
- catch (XMLException& ex) {
+ catch (const XMLException& ex) {
internalDoc->release();
auto_ptr_char temp(ex.getMessage());
throw XMLParserException(
@@ -418,11 +418,11 @@ DOMElement* XMLSecSignatureImpl::marshall(DOMElement* parentElement, const vecto
);
m_signature->load();
}
- catch(XSECException& e) {
+ catch(const XSECException& e) {
auto_ptr_char temp(e.getMsg());
throw MarshallingException(string("Caught an XMLSecurity exception while loading signature: ") + temp.get());
}
- catch(XSECCryptoException& e) {
+ catch(const XSECCryptoException& e) {
throw MarshallingException(string("Caught an XMLSecurity exception while loading signature: ") + e.getMsg());
}
}
@@ -456,11 +456,11 @@ XMLObject* XMLSecSignatureImpl::unmarshall(DOMElement* element, bool bindDocumen
);
m_signature->load();
}
- catch(XSECException& e) {
+ catch(const XSECException& e) {
auto_ptr_char temp(e.getMsg());
throw UnmarshallingException(string("Caught an XMLSecurity exception while loading signature: ") + temp.get());
}
- catch(XSECCryptoException& e) {
+ catch(const XSECCryptoException& e) {
throw UnmarshallingException(string("Caught an XMLSecurity exception while loading signature: ") + e.getMsg());
}
@@ -511,7 +511,7 @@ const XMLCh Signature::LOCAL_NAME[] = UNICODE_LITERAL_9(S,i,g,n,a,t,u,r,e);
// Raw signature methods.
unsigned int Signature::createRawSignature(
- XSECCryptoKey* key, const XMLCh* sigAlgorithm, const char* in, unsigned int in_len, char* out, unsigned int out_len
+ const XSECCryptoKey* key, const XMLCh* sigAlgorithm, const char* in, unsigned int in_len, char* out, unsigned int out_len
)
{
try {
@@ -547,17 +547,17 @@ unsigned int Signature::createRawSignature(
*out = 0;
return ret_len;
}
- catch(XSECException& e) {
+ catch(const XSECException& e) {
auto_ptr_char temp(e.getMsg());
throw SignatureException(string("Caught an XMLSecurity exception while creating raw signature: ") + temp.get());
}
- catch(XSECCryptoException& e) {
+ catch(const XSECCryptoException& e) {
throw SignatureException(string("Caught an XMLSecurity exception while creating raw signature: ") + e.getMsg());
}
}
bool Signature::verifyRawSignature(
- XSECCryptoKey* key, const XMLCh* sigAlgorithm, const char* signature, const char* in, unsigned int in_len
+ const XSECCryptoKey* key, const XMLCh* sigAlgorithm, const char* signature, const char* in, unsigned int in_len
)
{
try {
@@ -577,11 +577,11 @@ bool Signature::verifyRawSignature(
// Verify the chain.
return handler->verifyBase64Signature(&tx, sigAlgorithm, signature, 0, key);
}
- catch(XSECException& e) {
+ catch(const XSECException& e) {
auto_ptr_char temp(e.getMsg());
throw SignatureException(string("Caught an XMLSecurity exception while verifying raw signature: ") + temp.get());
}
- catch(XSECCryptoException& e) {
+ catch(const XSECCryptoException& e) {
throw SignatureException(string("Caught an XMLSecurity exception while verifying raw signature: ") + e.getMsg());
}
}
diff --git a/xmltooling/util/ParserPool.h b/xmltooling/util/ParserPool.h
index dd42c28..93079b3 100644
--- a/xmltooling/util/ParserPool.h
+++ b/xmltooling/util/ParserPool.h
@@ -34,6 +34,7 @@
#include <stack>
#include <string>
#include <istream>
+#include <boost/scoped_ptr.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/InputSource.hpp>
#include <xercesc/util/BinInputStream.hpp>
@@ -163,8 +164,8 @@ namespace xmltooling {
bool m_namespaceAware,m_schemaAware;
std::stack<xercesc::DOMLSParser*> m_pool;
- std::auto_ptr<Mutex> m_lock;
- std::auto_ptr<xercesc::SecurityManager> m_security;
+ boost::scoped_ptr<Mutex> m_lock;
+ boost::scoped_ptr<xercesc::SecurityManager> m_security;
};
/**
diff --git a/xmltooling/util/ReloadableXMLFile.cpp b/xmltooling/util/ReloadableXMLFile.cpp
index 9f402cd..af96989 100644
--- a/xmltooling/util/ReloadableXMLFile.cpp
+++ b/xmltooling/util/ReloadableXMLFile.cpp
@@ -69,6 +69,8 @@ using namespace xmltooling;
using namespace xercesc;
using namespace std;
+using boost::scoped_ptr;
+
static const XMLCh id[] = UNICODE_LITERAL_2(i,d);
static const XMLCh uri[] = UNICODE_LITERAL_3(u,r,i);
static const XMLCh url[] = UNICODE_LITERAL_3(u,r,l);
@@ -276,7 +278,7 @@ void* ReloadableXMLFile::reload_fn(void* pv)
NDC ndc("reload");
#endif
- auto_ptr<Mutex> mutex(Mutex::create());
+ scoped_ptr<Mutex> mutex(Mutex::create());
mutex->lock();
if (r->m_local)
@@ -456,7 +458,7 @@ pair<bool,DOMElement*> ReloadableXMLFile::load(bool backup, string backingFile)
throw XMLSecurityException("Signature validation required, but no signature found.");
// Wrap and unmarshall the signature for the duration of the check.
- auto_ptr<Signature> sigobj(dynamic_cast<Signature*>(SignatureBuilder::buildOneFromElement(sigel))); // don't bind to document
+ scoped_ptr<Signature> sigobj(dynamic_cast<Signature*>(SignatureBuilder::buildOneFromElement(sigel))); // don't bind to document
validateSignature(*sigobj.get());
}
catch (exception&) {
@@ -626,10 +628,10 @@ void ReloadableXMLFile::validateSignature(Signature& sigObj) const
}
}
else if (m_trust) {
- auto_ptr<CredentialResolver> dummy(
+ scoped_ptr<CredentialResolver> dummy(
XMLToolingConfig::getConfig().CredentialResolverManager.newPlugin(DUMMY_CREDENTIAL_RESOLVER, nullptr)
);
- if (m_trust->validate(sigObj, *(dummy.get()), &cc))
+ if (m_trust->validate(sigObj, *dummy, &cc))
return;
throw XMLSecurityException("TrustEngine unable to verify signature.");
}
diff --git a/xmltooling/util/Threads.h b/xmltooling/util/Threads.h
index 7e795b9..c1f07c3 100644
--- a/xmltooling/util/Threads.h
+++ b/xmltooling/util/Threads.h
@@ -311,16 +311,6 @@ namespace xmltooling
*
* @param mtx mutex to lock
*/
- Lock(const std::auto_ptr<Mutex>& mtx) : mutex(mtx.get()) {
- if (mutex)
- mutex->lock();
- }
-
- /**
- * Locks and wraps the designated mutex.
- *
- * @param mtx mutex to lock
- */
Lock(const boost::scoped_ptr<Mutex>& mtx) : mutex(mtx.get()) {
if (mutex)
mutex->lock();
@@ -372,17 +362,6 @@ namespace xmltooling
* @param lock lock to acquire
* @param lockit true if the lock should be acquired here, false if already acquired
*/
- SharedLock(const std::auto_ptr<RWLock>& lock, bool lockit=true) : rwlock(lock.get()) {
- if (rwlock && lockit)
- rwlock->rdlock();
- }
-
- /**
- * Locks and wraps the designated shared lock.
- *
- * @param lock lock to acquire
- * @param lockit true if the lock should be acquired here, false if already acquired
- */
SharedLock(const boost::scoped_ptr<RWLock>& lock, bool lockit=true) : rwlock(lock.get()) {
if (rwlock && lockit)
rwlock->rdlock();
diff --git a/xmltoolingtest/ComplexXMLObjectTest.h b/xmltoolingtest/ComplexXMLObjectTest.h
index 351289d..1dabd49 100644
--- a/xmltoolingtest/ComplexXMLObjectTest.h
+++ b/xmltoolingtest/ComplexXMLObjectTest.h
@@ -45,7 +45,7 @@ public:
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<ElementProxy> wcObject(
+ scoped_ptr<ElementProxy> wcObject(
dynamic_cast<ElementProxy*>(b->buildFromDocument(doc, false))
);
TS_ASSERT(wcObject.get()!=nullptr);
diff --git a/xmltoolingtest/DataSealerTest.h b/xmltoolingtest/DataSealerTest.h
index 6fb85a5..994a24f 100644
--- a/xmltoolingtest/DataSealerTest.h
+++ b/xmltoolingtest/DataSealerTest.h
@@ -60,7 +60,7 @@ public:
TSM_ASSERT_EQUALS("Wrong key type", key.second->getSymmetricKeyType(), XSECCryptoSymmetricKey::KEY_AES_256);
keyStrategy->unlock();
- auto_ptr<DataSealer> sealer(new DataSealer(keyStrategy.get()));
+ scoped_ptr<DataSealer> sealer(new DataSealer(keyStrategy.get()));
keyStrategy.release();
string data = "this is a test";
@@ -108,7 +108,7 @@ public:
keyStrategy->unlock();
- auto_ptr<DataSealer> sealer(new DataSealer(keyStrategy.get()));
+ scoped_ptr<DataSealer> sealer(new DataSealer(keyStrategy.get()));
keyStrategy.release();
string data = "this is a test";
diff --git a/xmltoolingtest/EncryptionTest.h b/xmltoolingtest/EncryptionTest.h
index b70c70f..dd4b5e7 100644
--- a/xmltoolingtest/EncryptionTest.h
+++ b/xmltoolingtest/EncryptionTest.h
@@ -69,14 +69,14 @@ public:
Encrypter encrypter;
Encrypter::EncryptionParams ep;
Encrypter::KeyEncryptionParams kep(*cred);
- auto_ptr<EncryptedData> encData(encrypter.encryptElement(doc->getDocumentElement(),ep,&kep));
+ scoped_ptr<EncryptedData> encData(encrypter.encryptElement(doc->getDocumentElement(),ep,&kep));
string buf;
XMLHelper::serialize(encData->marshall(), buf);
//TS_TRACE(buf.c_str());
istringstream is(buf);
DOMDocument* doc2=XMLToolingConfig::getConfig().getValidatingParser().parse(is);
- auto_ptr<EncryptedData> encData2(
+ scoped_ptr<EncryptedData> encData2(
dynamic_cast<EncryptedData*>(XMLObjectBuilder::buildOneFromElement(doc2->getDocumentElement(),true))
);
diff --git a/xmltoolingtest/ExceptionTest.h b/xmltoolingtest/ExceptionTest.h
index a3bd6ae..24e3dca 100644
--- a/xmltoolingtest/ExceptionTest.h
+++ b/xmltoolingtest/ExceptionTest.h
@@ -46,7 +46,7 @@ public:
params(1,"OpenSSLCryptoProvider::getRandom - OpenSSL random not properly initialised"));
string buf=e7.toString();
- auto_ptr<XMLToolingException> ptr(XMLToolingException::fromString(buf.c_str()));
+ scoped_ptr<XMLToolingException> ptr(XMLToolingException::fromString(buf.c_str()));
TS_ASSERT(typeid(*ptr)==typeid(MarshallingException));
TS_ASSERT(!strcmp(ptr->what(),"Foo is a bar."));
}
diff --git a/xmltoolingtest/FilesystemCredentialResolverTest.h b/xmltoolingtest/FilesystemCredentialResolverTest.h
index 534f293..6419e78 100644
--- a/xmltoolingtest/FilesystemCredentialResolverTest.h
+++ b/xmltoolingtest/FilesystemCredentialResolverTest.h
@@ -39,7 +39,7 @@ public:
DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in);
XercesJanitor<DOMDocument> janitor(doc);
- auto_ptr<CredentialResolver> credResolver(
+ scoped_ptr<CredentialResolver> credResolver(
XMLToolingConfig::getConfig().CredentialResolverManager.newPlugin(
CHAINING_CREDENTIAL_RESOLVER,doc->getDocumentElement()
)
diff --git a/xmltoolingtest/InlineKeyResolverTest.h b/xmltoolingtest/InlineKeyResolverTest.h
index 86633b7..a6fc990 100644
--- a/xmltoolingtest/InlineKeyResolverTest.h
+++ b/xmltoolingtest/InlineKeyResolverTest.h
@@ -70,10 +70,10 @@ public:
TS_ASSERT(doc!=nullptr);
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
+ scoped_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
TS_ASSERT(kiObject.get()!=nullptr);
- auto_ptr<X509Credential> cred(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get())));
+ scoped_ptr<X509Credential> cred(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get())));
TSM_ASSERT("Unable to resolve KeyInfo into Credential.", cred.get()!=nullptr);
TSM_ASSERT("Unable to resolve public key.", cred->getPublicKey()!=nullptr);
@@ -90,11 +90,11 @@ public:
TS_ASSERT(doc!=nullptr);
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
+ scoped_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
TS_ASSERT(kiObject.get()!=nullptr);
- auto_ptr<X509Credential> credFromKeyInfo(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get())));
- OpenSSLCryptoKeyDSA* keyInfoDSA = dynamic_cast<OpenSSLCryptoKeyDSA*>(credFromKeyInfo->getPublicKey());
+ scoped_ptr<X509Credential> credFromKeyInfo(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get())));
+ const OpenSSLCryptoKeyDSA* keyInfoDSA = dynamic_cast<const OpenSSLCryptoKeyDSA*>(credFromKeyInfo->getPublicKey());
path = data_path + "FileSystemCredentialResolver.xml";
ifstream in(path.c_str());
@@ -107,7 +107,7 @@ public:
CredentialCriteria cc;
cc.setUsage(Credential::SIGNING_CREDENTIAL);
cc.setKeyAlgorithm("DSA");
- OpenSSLCryptoKeyDSA* fileResolverDSA = dynamic_cast<OpenSSLCryptoKeyDSA*>(cresolver->resolve(&cc)->getPublicKey());
+ const OpenSSLCryptoKeyDSA* fileResolverDSA = dynamic_cast<const OpenSSLCryptoKeyDSA*>(cresolver->resolve(&cc)->getPublicKey());
unsigned char toSign[] = "Nibble A Happy WartHog";
const int bufferSize = 1024;
@@ -132,13 +132,13 @@ public:
TS_ASSERT(doc!=nullptr);
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
+ scoped_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
TS_ASSERT(kiObject.get()!=nullptr);
- auto_ptr<X509Credential> credFromKeyInfo(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get())));
- OpenSSLCryptoKeyEC* sslCredFromKeyInfo= dynamic_cast<OpenSSLCryptoKeyEC*>(credFromKeyInfo->getPublicKey());
+ scoped_ptr<X509Credential> credFromKeyInfo(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get())));
+ const OpenSSLCryptoKeyEC* sslCredFromKeyInfo= dynamic_cast<const OpenSSLCryptoKeyEC*>(credFromKeyInfo->getPublicKey());
- const EC_KEY* keyInfoEC = dynamic_cast<OpenSSLCryptoKeyEC*>(credFromKeyInfo->getPublicKey())->getOpenSSLEC();
+ const EC_KEY* keyInfoEC = dynamic_cast<const OpenSSLCryptoKeyEC*>(credFromKeyInfo->getPublicKey())->getOpenSSLEC();
path = data_path + "FileSystemCredentialResolver.xml";
ifstream in(path.c_str());
@@ -151,7 +151,7 @@ public:
CredentialCriteria cc;
cc.setUsage(Credential::SIGNING_CREDENTIAL);
cc.setKeyAlgorithm("EC");
- OpenSSLCryptoKeyEC* fileResolverCryptoKeyEC = dynamic_cast<OpenSSLCryptoKeyEC*>(cresolver->resolve(&cc)->getPublicKey());
+ const OpenSSLCryptoKeyEC* fileResolverCryptoKeyEC = dynamic_cast<const OpenSSLCryptoKeyEC*>(cresolver->resolve(&cc)->getPublicKey());
const EC_KEY* fileResolverEC= fileResolverCryptoKeyEC->getOpenSSLEC();
unsigned char toSign[] = "NibbleAHappyWartHog";
@@ -171,17 +171,17 @@ public:
TS_ASSERT(doc!=nullptr);
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
+ scoped_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
TS_ASSERT(kiObject.get()!=nullptr);
- auto_ptr<X509Credential> cred(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get())));
- auto_ptr<X509Credential> key(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get(), Credential::RESOLVE_KEYS)));
+ scoped_ptr<X509Credential> cred(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get())));
+ scoped_ptr<X509Credential> key(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get(), Credential::RESOLVE_KEYS)));
- OpenSSLCryptoKeyRSA* sslCred = dynamic_cast<OpenSSLCryptoKeyRSA*>(cred->getPublicKey());
- OpenSSLCryptoKeyRSA* sslKey = dynamic_cast<OpenSSLCryptoKeyRSA*>(key->getPublicKey());
+ const OpenSSLCryptoKeyRSA* sslCred = dynamic_cast<const OpenSSLCryptoKeyRSA*>(cred->getPublicKey());
+ const OpenSSLCryptoKeyRSA* sslKey = dynamic_cast<const OpenSSLCryptoKeyRSA*>(key->getPublicKey());
- RSA* rsaCred = sslCred->getOpenSSLRSA();
- RSA* rsaKey = sslKey->getOpenSSLRSA();
+ const RSA* rsaCred = sslCred->getOpenSSLRSA();
+ const RSA* rsaKey = sslKey->getOpenSSLRSA();
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
BIGNUM* n = rsaCred->n;
@@ -228,10 +228,10 @@ public:
TS_ASSERT(doc!=nullptr);
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
+ scoped_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
TS_ASSERT(kiObject.get()!=nullptr);
- auto_ptr<X509Credential> cred(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get())));
+ scoped_ptr<X509Credential> cred(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get())));
TSM_ASSERT("Unable to resolve KeyInfo into Credential.", cred.get()!=nullptr);
TSM_ASSERT("Unable to resolve public key.", cred->getPublicKey()!=nullptr);
diff --git a/xmltoolingtest/KeyInfoTest.h b/xmltoolingtest/KeyInfoTest.h
index f5cb63e..3bd0f19 100644
--- a/xmltoolingtest/KeyInfoTest.h
+++ b/xmltoolingtest/KeyInfoTest.h
@@ -47,7 +47,7 @@ public:
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
+ scoped_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
TS_ASSERT(kiObject.get()!=nullptr);
TSM_ASSERT_EQUALS("Number of child elements was not expected value",
4, kiObject->getOrderedChildren().size());
@@ -71,7 +71,7 @@ public:
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
+ scoped_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
TS_ASSERT(kiObject.get()!=nullptr);
TSM_ASSERT_EQUALS("Number of child elements was not expected value",
2, kiObject->getOrderedChildren().size());
@@ -92,7 +92,7 @@ public:
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
+ scoped_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
TS_ASSERT(kiObject.get()!=nullptr);
TS_ASSERT_THROWS(SchemaValidators.validate(kiObject.get()),ValidationException);
}
@@ -106,7 +106,7 @@ public:
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
+ scoped_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
TS_ASSERT(kiObject.get()!=nullptr);
TSM_ASSERT_EQUALS("Number of child elements was not expected value",
1, kiObject->getKeyValues().size());
diff --git a/xmltoolingtest/MarshallingTest.h b/xmltoolingtest/MarshallingTest.h
index a5ee426..2132fba 100644
--- a/xmltoolingtest/MarshallingTest.h
+++ b/xmltoolingtest/MarshallingTest.h
@@ -39,7 +39,7 @@ public:
}
void testMarshallingWithAttributes() {
- auto_ptr<SimpleXMLObject> sxObject(SimpleXMLObjectBuilder::buildSimpleXMLObject());
+ scoped_ptr<SimpleXMLObject> sxObject(SimpleXMLObjectBuilder::buildSimpleXMLObject());
TS_ASSERT(sxObject.get()!=nullptr);
auto_ptr_XMLCh expected("Firefly");
sxObject->setId(expected.get());
@@ -56,7 +56,7 @@ public:
}
void testMarshallingWithElementContent() {
- auto_ptr<SimpleXMLObject> sxObject(SimpleXMLObjectBuilder::buildSimpleXMLObject());
+ scoped_ptr<SimpleXMLObject> sxObject(SimpleXMLObjectBuilder::buildSimpleXMLObject());
TS_ASSERT(sxObject.get()!=nullptr);
auto_ptr_XMLCh expected("Sample Content");
sxObject->setValue(expected.get());
@@ -77,7 +77,7 @@ public:
const SimpleXMLObjectBuilder* b=dynamic_cast<const SimpleXMLObjectBuilder*>(XMLObjectBuilder::getBuilder(qname));
TS_ASSERT(b!=nullptr);
- auto_ptr<SimpleXMLObject> sxObject(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
+ scoped_ptr<SimpleXMLObject> sxObject(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
TS_ASSERT(sxObject.get()!=nullptr);
VectorOf(SimpleXMLObject) kids=sxObject->getSimpleXMLObjects();
kids.push_back(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
diff --git a/xmltoolingtest/MemoryStorageServiceTest.h b/xmltoolingtest/MemoryStorageServiceTest.h
index 6c9608d..4e0d691 100644
--- a/xmltoolingtest/MemoryStorageServiceTest.h
+++ b/xmltoolingtest/MemoryStorageServiceTest.h
@@ -31,7 +31,7 @@ public:
}
void testMemoryService() {
- auto_ptr<StorageService> storage(
+ scoped_ptr<StorageService> storage(
XMLToolingConfig::getConfig().StorageServiceManager.newPlugin(MEMORY_STORAGE_SERVICE,nullptr)
);
diff --git a/xmltoolingtest/NonVisibleNamespaceTest.h b/xmltoolingtest/NonVisibleNamespaceTest.h
index 7962e77..86c4b23 100644
--- a/xmltoolingtest/NonVisibleNamespaceTest.h
+++ b/xmltoolingtest/NonVisibleNamespaceTest.h
@@ -43,7 +43,7 @@ public:
xmltooling::QName qtype(SimpleXMLObject::NAMESPACE,SimpleXMLObject::TYPE_NAME,SimpleXMLObject::NAMESPACE_PREFIX);
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(qtype);
TS_ASSERT(b!=nullptr);
- auto_ptr<SimpleXMLObject> sxObject(
+ scoped_ptr<SimpleXMLObject> sxObject(
dynamic_cast<SimpleXMLObject*>(b->buildObject(SimpleXMLObject::NAMESPACE, SimpleXMLObject::LOCAL_NAME, nullptr, &qtype))
);
TS_ASSERT(sxObject.get()!=nullptr);
@@ -83,7 +83,7 @@ public:
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<SimpleXMLObject> sxObject(
+ scoped_ptr<SimpleXMLObject> sxObject(
dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc))
);
TS_ASSERT(sxObject.get()!=nullptr);
diff --git a/xmltoolingtest/SOAPTest.h b/xmltoolingtest/SOAPTest.h
index a7ed68a..e3750d7 100644
--- a/xmltoolingtest/SOAPTest.h
+++ b/xmltoolingtest/SOAPTest.h
@@ -39,7 +39,7 @@ public:
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<Envelope> envObject(dynamic_cast<Envelope*>(b->buildFromDocument(doc)));
+ scoped_ptr<Envelope> envObject(dynamic_cast<Envelope*>(b->buildFromDocument(doc)));
TS_ASSERT(envObject.get()!=nullptr);
TSM_ASSERT("SOAP Envelope missing Body", envObject->getBody() != nullptr);
TSM_ASSERT_EQUALS("SOAP Body missing Fault", 1, envObject->getBody()->getOrderedChildren().size());
diff --git a/xmltoolingtest/SecurityHelperTest.h b/xmltoolingtest/SecurityHelperTest.h
index 545ca48..4b24d45 100644
--- a/xmltoolingtest/SecurityHelperTest.h
+++ b/xmltoolingtest/SecurityHelperTest.h
@@ -44,30 +44,30 @@ public:
void testKeysFromFiles() {
string pathname = data_path + "key.pem";
- auto_ptr<XSECCryptoKey> key1(SecurityHelper::loadKeyFromFile(pathname.c_str()));
+ scoped_ptr<XSECCryptoKey> key1(SecurityHelper::loadKeyFromFile(pathname.c_str()));
pathname = data_path + "key.der";
- auto_ptr<XSECCryptoKey> key2(SecurityHelper::loadKeyFromFile(pathname.c_str()));
+ scoped_ptr<XSECCryptoKey> key2(SecurityHelper::loadKeyFromFile(pathname.c_str()));
pathname = data_path + "test.pfx";
- auto_ptr<XSECCryptoKey> key3(SecurityHelper::loadKeyFromFile(pathname.c_str(), nullptr, "password"));
+ scoped_ptr<XSECCryptoKey> key3(SecurityHelper::loadKeyFromFile(pathname.c_str(), nullptr, "password"));
TSM_ASSERT("PEM/DER keys did not match", SecurityHelper::matches(*key1.get(), *key2.get()));
TSM_ASSERT("DER/PKCS12 keys did not match", SecurityHelper::matches(*key2.get(), *key3.get()));
pathname = data_path + "key2.pem";
- auto_ptr<XSECCryptoKey> key4(SecurityHelper::loadKeyFromFile(pathname.c_str()));
+ scoped_ptr<XSECCryptoKey> key4(SecurityHelper::loadKeyFromFile(pathname.c_str()));
TSM_ASSERT("Different keys matched", !SecurityHelper::matches(*key3.get(), *key4.get()));
}
void testKeysFromURLs() {
string pathname = data_path + "key.pem.bak";
- auto_ptr<SOAPTransport> t1(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/key.pem"));
- auto_ptr<XSECCryptoKey> key1(SecurityHelper::loadKeyFromURL(*t1.get(), pathname.c_str()));
+ scoped_ptr<SOAPTransport> t1(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/key.pem"));
+ scoped_ptr<XSECCryptoKey> key1(SecurityHelper::loadKeyFromURL(*t1.get(), pathname.c_str()));
pathname = data_path + "key.der.bak";
- auto_ptr<SOAPTransport> t2(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/key.der"));
- auto_ptr<XSECCryptoKey> key2(SecurityHelper::loadKeyFromURL(*t2.get(), pathname.c_str()));
+ scoped_ptr<SOAPTransport> t2(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/key.der"));
+ scoped_ptr<XSECCryptoKey> key2(SecurityHelper::loadKeyFromURL(*t2.get(), pathname.c_str()));
pathname = data_path + "test.pfx.bak";
- auto_ptr<SOAPTransport> t3(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/test.pfx"));
- auto_ptr<XSECCryptoKey> key3(SecurityHelper::loadKeyFromURL(*t3.get(), pathname.c_str(), nullptr, "password"));
+ scoped_ptr<SOAPTransport> t3(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/test.pfx"));
+ scoped_ptr<XSECCryptoKey> key3(SecurityHelper::loadKeyFromURL(*t3.get(), pathname.c_str(), nullptr, "password"));
TSM_ASSERT("PEM/DER keys did not match", SecurityHelper::matches(*key1.get(), *key2.get()));
TSM_ASSERT("DER/PKCS12 keys did not match", SecurityHelper::matches(*key2.get(), *key3.get()));
@@ -83,9 +83,9 @@ public:
TSM_ASSERT_EQUALS("Wrong certificate count", certs.size(), 3);
- auto_ptr<XSECCryptoKey> key1(certs[0]->clonePublicKey());
- auto_ptr<XSECCryptoKey> key2(certs[1]->clonePublicKey());
- auto_ptr<XSECCryptoKey> key3(certs[2]->clonePublicKey());
+ scoped_ptr<XSECCryptoKey> key1(certs[0]->clonePublicKey());
+ scoped_ptr<XSECCryptoKey> key2(certs[1]->clonePublicKey());
+ scoped_ptr<XSECCryptoKey> key3(certs[2]->clonePublicKey());
TSM_ASSERT("PEM/DER keys did not match", SecurityHelper::matches(*key1.get(), *key2.get()));
TSM_ASSERT("DER/PKCS12 keys did not match", SecurityHelper::matches(*key2.get(), *key3.get()));
@@ -111,20 +111,20 @@ public:
void testCertificatesFromURLs() {
string pathname = data_path + "cert.pem.bak";
- auto_ptr<SOAPTransport> t1(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/cert.pem"));
+ scoped_ptr<SOAPTransport> t1(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/cert.pem"));
SecurityHelper::loadCertificatesFromURL(certs, *t1.get(), pathname.c_str());
pathname = data_path + "cert.der.bak";
- auto_ptr<SOAPTransport> t2(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/cert.der"));
+ scoped_ptr<SOAPTransport> t2(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/cert.der"));
SecurityHelper::loadCertificatesFromURL(certs, *t2.get(), pathname.c_str());
pathname = data_path + "test.pfx.bak";
- auto_ptr<SOAPTransport> t3(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/test.pfx"));
+ scoped_ptr<SOAPTransport> t3(getTransport("https://wiki.shibboleth.net/confluence/download/attachments/3277026/test.pfx"));
SecurityHelper::loadCertificatesFromURL(certs, *t3.get(), pathname.c_str(), nullptr, "password");
TSM_ASSERT_EQUALS("Wrong certificate count", certs.size(), 3);
- auto_ptr<XSECCryptoKey> key1(certs[0]->clonePublicKey());
- auto_ptr<XSECCryptoKey> key2(certs[0]->clonePublicKey());
- auto_ptr<XSECCryptoKey> key3(certs[0]->clonePublicKey());
+ scoped_ptr<XSECCryptoKey> key1(certs[0]->clonePublicKey());
+ scoped_ptr<XSECCryptoKey> key2(certs[0]->clonePublicKey());
+ scoped_ptr<XSECCryptoKey> key3(certs[0]->clonePublicKey());
TSM_ASSERT("PEM/DER keys did not match", SecurityHelper::matches(*key1.get(), *key2.get()));
TSM_ASSERT("DER/PKCS12 keys did not match", SecurityHelper::matches(*key2.get(), *key3.get()));
diff --git a/xmltoolingtest/SignatureTest.h b/xmltoolingtest/SignatureTest.h
index 452f8bb..46841e5 100644
--- a/xmltoolingtest/SignatureTest.h
+++ b/xmltoolingtest/SignatureTest.h
@@ -111,7 +111,7 @@ public:
cc.setKeyAlgorithm("EC");
Locker locker(m_resolver);
- XSECCryptoKeyEC* ecCred = dynamic_cast<XSECCryptoKeyEC*>(m_resolver->resolve(&cc)->getPrivateKey());
+ const XSECCryptoKeyEC* ecCred = dynamic_cast<const XSECCryptoKeyEC*>(m_resolver->resolve(&cc)->getPrivateKey());
unsigned char toSign[] = "NibbleAHappyWartHog";
const int bufferSize = 1024;
@@ -135,7 +135,7 @@ public:
cc.setKeyAlgorithm("RSA");
Locker locker(m_resolver);
- XSECCryptoKeyRSA* rsaCred = dynamic_cast<XSECCryptoKeyRSA*>(m_resolver->resolve(&cc)->getPrivateKey());
+ const XSECCryptoKeyRSA* rsaCred = dynamic_cast<const XSECCryptoKeyRSA*>(m_resolver->resolve(&cc)->getPrivateKey());
unsigned char toSign[] = "Nibble A Happy WartHog";
const int bufferSize = 1024;
@@ -157,7 +157,7 @@ public:
cc.setKeyAlgorithm("DSA");
Locker locker(m_resolver);
- XSECCryptoKeyDSA* dsaCred = dynamic_cast<XSECCryptoKeyDSA*>(m_resolver->resolve(&cc)->getPrivateKey());
+ const XSECCryptoKeyDSA* dsaCred = dynamic_cast<const XSECCryptoKeyDSA*>(m_resolver->resolve(&cc)->getPrivateKey());
unsigned char toSign[] = "NibbleAHappyWartHog";
const int bufferSize = 1024;
@@ -178,7 +178,7 @@ public:
const SimpleXMLObjectBuilder* b=dynamic_cast<const SimpleXMLObjectBuilder*>(XMLObjectBuilder::getBuilder(qname));
TS_ASSERT(b!=nullptr);
- auto_ptr<SimpleXMLObject> sxObject(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
+ scoped_ptr<SimpleXMLObject> sxObject(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
TS_ASSERT(sxObject.get()!=nullptr);
VectorOf(SimpleXMLObject) kids=sxObject->getSimpleXMLObjects();
kids.push_back(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
@@ -220,7 +220,7 @@ public:
istringstream in(buf);
DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in);
- auto_ptr<SimpleXMLObject> sxObject2(dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc)));
+ scoped_ptr<SimpleXMLObject> sxObject2(dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc)));
TS_ASSERT(sxObject2.get()!=nullptr);
TS_ASSERT(sxObject2->getSignature()!=nullptr);
@@ -240,7 +240,7 @@ public:
const SimpleXMLObjectBuilder* b=dynamic_cast<const SimpleXMLObjectBuilder*>(XMLObjectBuilder::getBuilder(qname));
TS_ASSERT(b!=nullptr);
- auto_ptr<SimpleXMLObject> sxObject(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
+ scoped_ptr<SimpleXMLObject> sxObject(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
TS_ASSERT(sxObject.get()!=nullptr);
VectorOf(SimpleXMLObject) kids=sxObject->getSimpleXMLObjects();
kids.push_back(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
@@ -282,7 +282,7 @@ public:
istringstream in(buf);
DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in);
- auto_ptr<SimpleXMLObject> sxObject2(dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc)));
+ scoped_ptr<SimpleXMLObject> sxObject2(dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc)));
TS_ASSERT(sxObject2.get()!=nullptr);
TS_ASSERT(sxObject2->getSignature()!=nullptr);
@@ -301,7 +301,7 @@ public:
const SimpleXMLObjectBuilder* b=dynamic_cast<const SimpleXMLObjectBuilder*>(XMLObjectBuilder::getBuilder(qname));
TS_ASSERT(b!=nullptr);
- auto_ptr<SimpleXMLObject> sxObject(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
+ scoped_ptr<SimpleXMLObject> sxObject(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
TS_ASSERT(sxObject.get()!=nullptr);
VectorOf(SimpleXMLObject) kids=sxObject->getSimpleXMLObjects();
kids.push_back(dynamic_cast<SimpleXMLObject*>(b->buildObject()));
@@ -342,7 +342,7 @@ public:
istringstream in(buf);
DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in);
- auto_ptr<SimpleXMLObject> sxObject2(dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc)));
+ scoped_ptr<SimpleXMLObject> sxObject2(dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc)));
TS_ASSERT(sxObject2.get()!=nullptr);
TS_ASSERT(sxObject2->getSignature()!=nullptr);
diff --git a/xmltoolingtest/TemplateEngineTest.h b/xmltoolingtest/TemplateEngineTest.h
index 9d8f76b..b3c1702 100644
--- a/xmltoolingtest/TemplateEngineTest.h
+++ b/xmltoolingtest/TemplateEngineTest.h
@@ -26,14 +26,8 @@
class TemplateEngineTest : public CxxTest::TestSuite {
public:
- void setUp() {
- }
-
- void tearDown() {
- }
-
void testTemplateEngine() {
- auto_ptr<TemplateEngine> engine(new TemplateEngine());
+ scoped_ptr<TemplateEngine> engine(new TemplateEngine());
TemplateEngine::TemplateParameters p;
p.m_map["foo1"] = "bar1";
diff --git a/xmltoolingtest/UnmarshallingTest.h b/xmltoolingtest/UnmarshallingTest.h
index 70e3d66..7917675 100644
--- a/xmltoolingtest/UnmarshallingTest.h
+++ b/xmltoolingtest/UnmarshallingTest.h
@@ -87,7 +87,7 @@ public:
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<SimpleXMLObject> sxObject(
+ scoped_ptr<SimpleXMLObject> sxObject(
dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc))
);
TS_ASSERT(sxObject.get()!=nullptr);
@@ -105,7 +105,7 @@ public:
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<SimpleXMLObject> sxObject(
+ scoped_ptr<SimpleXMLObject> sxObject(
dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc))
);
TS_ASSERT(sxObject.get()!=nullptr);
@@ -123,7 +123,7 @@ public:
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<SimpleXMLObject> sxObject(
+ scoped_ptr<SimpleXMLObject> sxObject(
dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc))
);
TS_ASSERT(sxObject.get()!=nullptr);
@@ -143,13 +143,13 @@ public:
const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<SimpleXMLObject> sxObject(
+ scoped_ptr<SimpleXMLObject> sxObject(
dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc))
);
TS_ASSERT(sxObject.get()!=nullptr);
sxObject->releaseThisAndChildrenDOM();
- auto_ptr<SimpleXMLObject> clonedObject(dynamic_cast<SimpleXMLObject*>(sxObject->clone()));
+ scoped_ptr<SimpleXMLObject> clonedObject(dynamic_cast<SimpleXMLObject*>(sxObject->clone()));
VectorOf(SimpleXMLObject) kids=clonedObject->getSimpleXMLObjects();
TSM_ASSERT_EQUALS("Number of child elements was not expected value", 3, kids.size());
diff --git a/xmltoolingtest/XMLObjectBaseTestCase.h b/xmltoolingtest/XMLObjectBaseTestCase.h
index 5031baf..2eae9d5 100644
--- a/xmltoolingtest/XMLObjectBaseTestCase.h
+++ b/xmltoolingtest/XMLObjectBaseTestCase.h
@@ -47,6 +47,8 @@ using namespace xmltooling;
using namespace xercesc;
using namespace std;
+using boost::scoped_ptr;
+
extern string data_path;
#if defined (_MSC_VER)
@@ -99,10 +101,8 @@ public:
XMLObject* clone() const {
auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
SimpleXMLObject* ret=dynamic_cast<SimpleXMLObject*>(domClone.get());
- if (ret) {
- domClone.release();
- return ret;
- }
+ if (ret)
+ return domClone.release();
return new SimpleXMLObject(*this);
}
diff --git a/xmltoolingtest/xmltoolingtest.h b/xmltoolingtest/xmltoolingtest.h
index e89ed2b..dcc86b0 100644
--- a/xmltoolingtest/xmltoolingtest.h
+++ b/xmltoolingtest/xmltoolingtest.h
@@ -90,10 +90,10 @@ public:
const XMLObjectBuilder* b=XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<XMLObject> xmlObject(b->buildFromDocument(doc)); // bind document
+ scoped_ptr<XMLObject> xmlObject(b->buildFromDocument(doc)); // bind document
TS_ASSERT(xmlObject.get()!=nullptr);
- auto_ptr<XMLObject> clonedObject(xmlObject->clone());
+ scoped_ptr<XMLObject> clonedObject(xmlObject->clone());
TS_ASSERT(clonedObject.get()!=nullptr);
DOMElement* rootElement=clonedObject->marshall();
@@ -119,7 +119,7 @@ public:
const XMLObjectBuilder* b=XMLObjectBuilder::getBuilder(doc->getDocumentElement());
TS_ASSERT(b!=nullptr);
- auto_ptr<XMLObject> xmlObject(b->buildFromDocument(doc)); // bind document
+ scoped_ptr<XMLObject> xmlObject(b->buildFromDocument(doc)); // bind document
TS_ASSERT(xmlObject.get()!=nullptr);
DOMDocument* newDoc=XMLToolingConfig::getConfig().getParser().newDocument();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list