From 283aad6d4e6291bb79567bac2d4e373cece4c6ad Mon Sep 17 00:00:00 2001 From: cantor Date: Fri, 20 Apr 2007 19:50:09 +0000 Subject: [PATCH] Some header cleanup. Clean up dangerous info from resolved KeyInfo when cloning. git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/trunk@283 de75baf8-a10c-0410-a50a-987c0e22f00f --- xmltooling/ElementProxy.h | 1 - xmltooling/security/impl/BasicX509Credential.cpp | 6 ++--- xmltooling/security/impl/InlineKeyResolver.cpp | 32 ++++++++++++++++-------- xmltooling/util/XMLObjectChildrenList.h | 3 +++ xmltooling/xmltooling.vcproj | 4 +++ 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/xmltooling/ElementProxy.h b/xmltooling/ElementProxy.h index e5a5d77..8c814b3 100644 --- a/xmltooling/ElementProxy.h +++ b/xmltooling/ElementProxy.h @@ -25,7 +25,6 @@ #include #include -#include namespace xmltooling { diff --git a/xmltooling/security/impl/BasicX509Credential.cpp b/xmltooling/security/impl/BasicX509Credential.cpp index 0550baa..df3d1aa 100644 --- a/xmltooling/security/impl/BasicX509Credential.cpp +++ b/xmltooling/security/impl/BasicX509Credential.cpp @@ -129,8 +129,7 @@ const char* BasicX509Credential::getAlgorithm() const return "HMAC"; case XSECCryptoKey::KEY_SYMMETRIC: { - XSECCryptoSymmetricKey* skey = static_cast(m_key); - switch (skey->getSymmetricKeyType()) { + switch (static_cast(m_key)->getSymmetricKeyType()) { case XSECCryptoSymmetricKey::KEY_3DES_192: return "DESede"; case XSECCryptoSymmetricKey::KEY_AES_128: @@ -158,8 +157,7 @@ unsigned int BasicX509Credential::getKeySize() const } case XSECCryptoKey::KEY_SYMMETRIC: { - XSECCryptoSymmetricKey* skey = static_cast(m_key); - switch (skey->getSymmetricKeyType()) { + switch (static_cast(m_key)->getSymmetricKeyType()) { case XSECCryptoSymmetricKey::KEY_3DES_192: return 192; case XSECCryptoSymmetricKey::KEY_AES_128: diff --git a/xmltooling/security/impl/InlineKeyResolver.cpp b/xmltooling/security/impl/InlineKeyResolver.cpp index c198b93..acc6953 100644 --- a/xmltooling/security/impl/InlineKeyResolver.cpp +++ b/xmltooling/security/impl/InlineKeyResolver.cpp @@ -67,18 +67,30 @@ namespace xmltooling { KeyInfo* getKeyInfo(bool compact=false) const { KeyInfo* ret = m_credctx->getKeyInfo() ? m_credctx->getKeyInfo()->cloneKeyInfo() : NULL; - if (ret && compact) { - ret->getKeyValues().clear(); - ret->getSPKIDatas().clear(); - ret->getPGPDatas().clear(); - ret->getUnknownXMLObjects().clear(); - const vector x509Datas=const_cast(ret)->getX509Datas(); - for (vector::const_iterator x=x509Datas.begin(); x!=x509Datas.end(); ++x) { - (*x)->getX509Certificates().clear(); - (*x)->getX509CRLs().clear(); - (*x)->getUnknownXMLObjects().clear(); + if (ret) { + ret->setId(NULL); + ret->getRetrievalMethods().clear(); + if (compact) { + ret->getKeyValues().clear(); + ret->getSPKIDatas().clear(); + ret->getPGPDatas().clear(); + ret->getUnknownXMLObjects().clear(); + VectorOf(X509Data) x509Datas=ret->getX509Datas(); + for (VectorOf(X509Data)::size_type pos = 0; pos < x509Datas.size();) { + x509Datas[pos]->getX509Certificates().clear(); + x509Datas[pos]->getX509CRLs().clear(); + x509Datas[pos]->getUnknownXMLObjects().clear(); + if (x509Datas[pos]->hasChildren()) + ++pos; + else + x509Datas.erase(x509Datas.begin() + pos); + } } } + if (!ret->hasChildren()) { + delete ret; + ret = NULL; + } return ret; } diff --git a/xmltooling/util/XMLObjectChildrenList.h b/xmltooling/util/XMLObjectChildrenList.h index be3244e..8a21e60 100644 --- a/xmltooling/util/XMLObjectChildrenList.h +++ b/xmltooling/util/XMLObjectChildrenList.h @@ -24,6 +24,9 @@ #define __xmltooling_list_h__ #include +#include + +#include /** * Shorthand for an XMLObjectChildrenList wrapped around a vector diff --git a/xmltooling/xmltooling.vcproj b/xmltooling/xmltooling.vcproj index a81e37c..bcc3c75 100644 --- a/xmltooling/xmltooling.vcproj +++ b/xmltooling/xmltooling.vcproj @@ -486,6 +486,10 @@ > + + -- 2.1.4