Add const to AlgorithmMapper lookup.
git-svn-id: https://svn.apache.org/repos/asf/santuario/xml-security-cpp/trunk@1826034 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/xsec/dsig/DSIGReference.cpp b/xsec/dsig/DSIGReference.cpp
index 80c2e6e..8432b4a 100644
--- a/xsec/dsig/DSIGReference.cpp
+++ b/xsec/dsig/DSIGReference.cpp
@@ -1286,22 +1286,17 @@
// Get the mapping for the hash transform
- XSECAlgorithmHandler * handler =
+ const XSECAlgorithmHandler* handler =
XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(mp_algorithmURI);
if (handler == NULL) {
-
-
throw XSECException(XSECException::SigVfyError,
"Hash method unknown in DSIGReference::calculateHash()");
-
}
if (!handler->appendHashTxfm(chain, mp_algorithmURI)) {
-
throw XSECException(XSECException::SigVfyError,
"Unexpected error in handler whilst appending Hash transform");
-
}
// Now we have the hashing transform, run it.
diff --git a/xsec/dsig/DSIGSignature.cpp b/xsec/dsig/DSIGSignature.cpp
index 9523a7e..5ee911c 100644
--- a/xsec/dsig/DSIGSignature.cpp
+++ b/xsec/dsig/DSIGSignature.cpp
@@ -730,7 +730,7 @@
// Setup Hash
// First find the appropriate handler for the URI
- XSECAlgorithmHandler* handler =
+ const XSECAlgorithmHandler* handler =
XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(
mp_signedInfo->getAlgorithmURI());
@@ -814,15 +814,13 @@
// Now set up to verify
// First find the appropriate handler for the URI
- XSECAlgorithmHandler* handler =
+ const XSECAlgorithmHandler* handler =
XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(
mp_signedInfo->getAlgorithmURI());
if (handler == NULL) {
-
throw XSECException(XSECException::SigVfyError,
"Hash method unknown in DSIGSignature::verifySignatureOnlyInternal()");
-
}
bool sigVfyRet = handler->verifyBase64Signature(chain,
@@ -911,16 +909,13 @@
safeBuffer b64Buf;
- XSECAlgorithmHandler* handler =
+ const XSECAlgorithmHandler* handler =
XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(
mp_signedInfo->getAlgorithmURI());
if (handler == NULL) {
-
-
throw XSECException(XSECException::SigVfyError,
"Hash method unknown in DSIGSignature::sign()");
-
}
if (!handler->signToSafeBuffer(chain, mp_signedInfo->getAlgorithmURI(),
diff --git a/xsec/framework/XSECAlgorithmMapper.cpp b/xsec/framework/XSECAlgorithmMapper.cpp
index 3671f52..9d4b72a 100644
--- a/xsec/framework/XSECAlgorithmMapper.cpp
+++ b/xsec/framework/XSECAlgorithmMapper.cpp
@@ -67,7 +67,7 @@
-XSECAlgorithmMapper::XSECAlgorithmMapper(void) {
+XSECAlgorithmMapper::XSECAlgorithmMapper() {
}
@@ -83,7 +83,6 @@
delete (*it);
it++;
-
}
m_mapping.clear();
@@ -102,7 +101,7 @@
m_blacklist.clear();
}
-XSECAlgorithmMapper::MapperEntry * XSECAlgorithmMapper::findEntry(const XMLCh * URI) const {
+XSECAlgorithmMapper::MapperEntry* XSECAlgorithmMapper::findEntry(const XMLCh* URI) const {
MapperEntryVectorType::const_iterator it = m_mapping.begin();
@@ -121,7 +120,7 @@
}
-XSECAlgorithmHandler * XSECAlgorithmMapper::mapURIToHandler(const XMLCh * URI) const {
+const XSECAlgorithmHandler* XSECAlgorithmMapper::mapURIToHandler(const XMLCh* URI) const {
bool allowed = true;
if (!m_whitelist.empty()) {
@@ -162,21 +161,18 @@
return entry->mp_handler;
}
-void XSECAlgorithmMapper::registerHandler(const XMLCh * URI, const XSECAlgorithmHandler & handler) {
+void XSECAlgorithmMapper::registerHandler(const XMLCh* URI, const XSECAlgorithmHandler& handler) {
MapperEntry * entry = findEntry(URI);
if (entry != NULL) {
-
delete entry->mp_handler;
-
}
else {
XSECnew(entry, MapperEntry);
entry->mp_uri = XMLString::replicate(URI);
m_mapping.push_back(entry);
-
}
entry->mp_handler = handler.clone();
diff --git a/xsec/framework/XSECAlgorithmMapper.hpp b/xsec/framework/XSECAlgorithmMapper.hpp
index e9926ba..0ec0814 100644
--- a/xsec/framework/XSECAlgorithmMapper.hpp
+++ b/xsec/framework/XSECAlgorithmMapper.hpp
@@ -73,7 +73,7 @@
* \brief Map a URI to a handler
*/
- XSECAlgorithmHandler * mapURIToHandler(const XMLCh * URI) const;
+ const XSECAlgorithmHandler* mapURIToHandler(const XMLCh* URI) const;
//@}
@@ -84,7 +84,7 @@
* \brief Register a new handler
*/
- void registerHandler(const XMLCh * URI, const XSECAlgorithmHandler & handler);
+ void registerHandler(const XMLCh* URI, const XSECAlgorithmHandler& handler);
/**
* \brief Indicate an algorithm is approved for use, implying others are not.
@@ -104,18 +104,18 @@
struct MapperEntry {
- XMLCh * mp_uri;
- XSECAlgorithmHandler * mp_handler;
+ XMLCh* mp_uri;
+ XSECAlgorithmHandler* mp_handler;
};
- MapperEntry * findEntry(const XMLCh * URI) const;
+ MapperEntry* findEntry(const XMLCh* URI) const;
#if defined(XSEC_NO_NAMESPACES)
- typedef vector<MapperEntry *> MapperEntryVectorType;
+ typedef vector<MapperEntry*> MapperEntryVectorType;
typedef vector<XMLCh*> WhitelistVectorType;
#else
- typedef std::vector<MapperEntry *> MapperEntryVectorType;
+ typedef std::vector<MapperEntry*> MapperEntryVectorType;
typedef std::vector<XMLCh*> WhitelistVectorType;
#endif
diff --git a/xsec/xenc/impl/XENCCipherImpl.cpp b/xsec/xenc/impl/XENCCipherImpl.cpp
index 22f481e..0fe16bd 100644
--- a/xsec/xenc/impl/XENCCipherImpl.cpp
+++ b/xsec/xenc/impl/XENCCipherImpl.cpp
@@ -352,7 +352,7 @@
XSECCryptoKey * XENCCipherImpl::decryptKeyFromKeyInfoList(DSIGKeyInfoList * kil) {
XSECCryptoKey * ret = NULL;
- XSECAlgorithmHandler *handler;
+ const XSECAlgorithmHandler *handler;
int kLen = (int) kil->getSize();
@@ -445,7 +445,7 @@
DOMNode * XENCCipherImpl::decryptElementDetached() {
- XSECAlgorithmHandler *handler;
+ const XSECAlgorithmHandler *handler;
if (mp_encryptedData == NULL) {
@@ -567,11 +567,11 @@
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element
) {
- XSECAlgorithmHandler *handler;
+ const XSECAlgorithmHandler *handler;
// First of all load the element
if (mp_encryptedData != NULL)
- delete mp_encryptedData;
+ delete mp_encryptedData;
XSECnew(mp_encryptedData,
XENCEncryptedDataImpl(mp_env, element));
@@ -690,7 +690,7 @@
// Get the Algorithm handler for the algorithm
XENCEncryptionMethod * encryptionMethod = encryptedKey->getEncryptionMethod();
- XSECAlgorithmHandler *handler;
+ const XSECAlgorithmHandler *handler;
if (encryptionMethod != NULL) {
@@ -795,7 +795,7 @@
mp_encryptedData->createBlankEncryptedData(XENCCipherData::VALUE_TYPE, algorithmURI, s_noData);
// Perform the encryption
- XSECAlgorithmHandler *handler = XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(algorithmURI);
+ const XSECAlgorithmHandler *handler = XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(algorithmURI);
if (!handler) {
// Very strange if we get here - any problems should throw an
// exception in the AlgorithmMapper.
@@ -881,7 +881,7 @@
tsb->setInput(rawKey, keyLen);
// Perform the encryption
- XSECAlgorithmHandler *handler = XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(algorithmURI);
+ const XSECAlgorithmHandler *handler = XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(algorithmURI);
if (!handler) {
// Very strange if we get here - any problems should throw an
// exception in the AlgorithmMapper.