blautenb 2003/02/21 03:53:09
Modified: c/src/dsig DSIGKeyInfoList.cpp DSIGReference.cpp
DSIGReference.hpp DSIGSignature.cpp
DSIGSignature.hpp DSIGTransform.hpp
DSIGTransformBase64.cpp DSIGTransformBase64.hpp
DSIGTransformC14n.cpp DSIGTransformC14n.hpp
DSIGTransformEnvelope.cpp DSIGTransformEnvelope.hpp
DSIGTransformXPath.cpp DSIGTransformXPath.hpp
DSIGTransformXSL.cpp DSIGTransformXSL.hpp
c/src/framework XSECW32Config.hpp
c/src/tools/templatesign templatesign.cpp
c/src/tools/txfmout txfmout.cpp
c/src/transformers TXFMBase.cpp TXFMBase.hpp TXFMC14n.cpp
TXFMEnvelope.cpp TXFMOutputFile.cpp TXFMParser.cpp
TXFMParser.hpp TXFMSHA1.cpp TXFMXPath.cpp
TXFMXSL.cpp
c/src/utils XSECBinTXFMInputStream.cpp
XSECBinTXFMInputStream.hpp XSECDOMUtils.cpp
XSECTXFMInputSource.cpp XSECTXFMInputSource.hpp
Added: c/src/transformers TXFMChain.cpp TXFMChain.hpp
Log:
TXFMChain to prevent memory leaks
Revision Changes Path
1.3 +24 -6 xml-security/c/src/dsig/DSIGKeyInfoList.cpp
Index: DSIGKeyInfoList.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGKeyInfoList.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGKeyInfoList.cpp 9 Feb 2003 11:13:47 -0000 1.2
+++ DSIGKeyInfoList.cpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -159,7 +157,13 @@
// Have a certificate!
XSECnew(k, DSIGKeyInfoX509(mp_parentSignature, ki));
- k->load();
+ try {
+ k->load();
+ }
+ catch (...) {
+ delete k;
+ throw;
+ }
// Add to the KeyInfo list
this->addKeyInfo(k);
@@ -173,7 +177,14 @@
DSIGKeyInfoName * k;
XSECnew(k, DSIGKeyInfoName(mp_parentSignature, ki));
- k->load();
+
+ try {
+ k->load();
+ }
+ catch (...) {
+ delete k;
+ throw;
+ }
this->addKeyInfo(k);
@@ -185,7 +196,14 @@
DSIGKeyInfoValue * k;
XSECnew(k, DSIGKeyInfoValue(mp_parentSignature, ki));
- k->load();
+
+ try {
+ k->load();
+ }
+ catch (...) {
+ delete k;
+ throw;
+ }
// Add
this->addKeyInfo(k);
1.6 +84 -99 xml-security/c/src/dsig/DSIGReference.cpp
Index: DSIGReference.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGReference.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DSIGReference.cpp 17 Feb 2003 11:23:38 -0000 1.5
+++ DSIGReference.cpp 21 Feb 2003 11:53:06 -0000 1.6
@@ -64,20 +64,14 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
-// Xerces
-
-#include <xercesc/util/XMLNetAccessor.hpp>
-#include <xercesc/util/XMLUniDefs.hpp>
-
// XSEC includes
#include <xsec/dsig/DSIGReference.hpp>
+#include <xsec/transformers/TXFMChain.hpp>
#include <xsec/transformers/TXFMURL.hpp>
#include <xsec/transformers/TXFMDocObject.hpp>
#include <xsec/transformers/TXFMOutputFile.hpp>
@@ -102,6 +96,14 @@
#include <xsec/utils/XSECDOMUtils.hpp>
#include <xsec/utils/XSECBinTXFMInputStream.hpp>
+// Xerces
+
+#include <xercesc/util/XMLNetAccessor.hpp>
+#include <xercesc/util/XMLUniDefs.hpp>
+#include <xercesc/util/Janitor.hpp>
+
+XSEC_USING_XERCES(Janitor);
+
#include <iostream.h>
//
--------------------------------------------------------------------------------
@@ -452,6 +454,7 @@
// Have a fragment URI from the local document
TXFMDocObject * to;
XSECnew(to, TXFMDocObject(doc));
+ Janitor<TXFMDocObject> j_to(to);
// Find out what sort of object pointer this is.
@@ -516,7 +519,9 @@
}
+ j_to.release();
return to;
+
}
//
--------------------------------------------------------------------------------
@@ -750,6 +755,7 @@
DSIGReference * r;
XSECnew(refList, DSIGReferenceList());
+ Janitor<DSIGReferenceList> j_refList(refList);
while (tmpRef != 0) {
@@ -777,7 +783,8 @@
tmpRef = tmpRef->getNextSibling();
}
-
+
+ j_refList.release();
return refList;
}
@@ -789,6 +796,7 @@
// First set up for input
+ TXFMChain * txfmChain;
TXFMBase * currentTxfm;
if (mp_URI == NULL) {
@@ -802,35 +810,29 @@
currentTxfm = getURIBaseTXFM(mp_referenceNode->getOwnerDocument(),
mp_URI,
mp_parentSignature->getURIResolver());
- // Now check for Transforms
-
- if (mp_transformList != NULL) {
+ // Set up the transform chain
- // Process the transforms using the static function.
-
- currentTxfm = createTXFMChainFromList(currentTxfm,
mp_transformList);
-
-
- }
+ txfmChain = createTXFMChainFromList(currentTxfm, mp_transformList);
+ Janitor<TXFMChain> j_txfmChain(txfmChain);
DOMDocument *d = mp_referenceNode->getOwnerDocument();
// All transforms done. If necessary, change the type from nodes to
bytes
- if (currentTxfm->getOutputType() == TXFMBase::DOM_NODES) {
+ if (txfmChain->getLastTxfm()->getOutputType() == TXFMBase::DOM_NODES) {
TXFMC14n * c14n;
XSECnew(c14n, TXFMC14n(d));
- c14n->setInput(currentTxfm);
-
- currentTxfm= c14n;
+ txfmChain->appendTxfm(c14n);
}
// Now create the InputStream
XSECBinTXFMInputStream * ret;
- XSECnew(ret, XSECBinTXFMInputStream(currentTxfm));
+ XSECnew(ret, XSECBinTXFMInputStream(txfmChain));
+ j_txfmChain.release(); // Now owned by "ret"
+
return ret;
}
@@ -847,6 +849,7 @@
DSIGReference * r;
int i = lst->getSize();
safeBuffer errStr;
+ errStr.sbXMLChIn(DSIGConstants::s_unicodeStrEmpty);
// Run a VERY naieve process at the moment that assumes the list will
"settle"
// after N iterations through the list. This will settle any
inter-locking references
@@ -939,41 +942,35 @@
// processTransforms
//
--------------------------------------------------------------------------------
-TXFMBase * DSIGReference::createTXFMChainFromList(TXFMBase * input,
+TXFMChain * DSIGReference::createTXFMChainFromList(TXFMBase * input,
DSIGTransformList *
lst) {
+ TXFMChain * ret;
+ XSECnew(ret, TXFMChain(input));
+
if (lst == NULL)
- return input;
+ return ret;
+
+ Janitor<TXFMChain> j_ret(ret);
DSIGTransformList::TransformListVectorType::size_type size, i;
size = lst->getSize();
- if (size == 0)
- return input;
+ if (size > 0) {
- TXFMBase * txfm; // The transform we are working on;
- TXFMBase * nextTxfm; // The transform we are creating
-
- txfm = input;
+ // Iterate through the list
- // Iterate through the list
+ for (i = 0; i < size; ++i) {
+
+ lst->item(i)->appendTransformer(ret);
- for (i = 0; i < size; ++i) {
-
- try {
- nextTxfm = lst->item(i)->createTransformer(txfm);
- // nextTxfm->setInput(txfm);
- txfm = nextTxfm;
- }
- catch (...) {
- deleteTXFMChain(txfm);
- throw;
}
}
- return txfm;
+ j_ret.release();
+ return ret;
}
@@ -1001,6 +998,7 @@
// Create the list
DSIGTransformList * lst;
XSECnew(lst, DSIGTransformList());
+ Janitor<DSIGTransformList> j_lst(lst);
// Find First transform
@@ -1047,33 +1045,33 @@
if (algorithm.sbStrcmp(URI_ID_BASE64) == 0) {
DSIGTransformBase64 * b;
- b = new DSIGTransformBase64(sig, transforms);
- b->load();
+ XSECnew(b, DSIGTransformBase64(sig, transforms));
lst->addTransform(b);
+ b->load();
}
else if (algorithm.sbStrcmp(URI_ID_XPATH) == 0) {
DSIGTransformXPath * x;
- x = new DSIGTransformXPath(sig, transforms);
- x->load();
+ XSECnew(x, DSIGTransformXPath(sig, transforms));
lst->addTransform(x);
+ x->load();
}
else if (algorithm.sbStrcmp(URI_ID_ENVELOPE) == 0) {
DSIGTransformEnvelope * e;
- e = new DSIGTransformEnvelope(sig, transforms);
- e->load();
+ XSECnew(e, DSIGTransformEnvelope(sig, transforms));
lst->addTransform(e);
+ e->load();
}
else if (algorithm.sbStrcmp(URI_ID_XSLT) == 0) {
DSIGTransformXSL * x;
- x = new DSIGTransformXSL(sig, transforms);
- x->load();
+ XSECnew(x, DSIGTransformXSL(sig, transforms));
lst->addTransform(x);
+ x->load();
}
@@ -1084,9 +1082,9 @@
algorithm.sbStrcmp(URI_ID_EXC_C14N_NOC) == 0) {
DSIGTransformC14n * c;
- c = new DSIGTransformC14n(sig, transforms);
- c->load();
+ XSECnew(c, DSIGTransformC14n(sig, transforms));
lst->addTransform(c);
+ c->load();
}
@@ -1110,7 +1108,7 @@
} /* while (transforms != NULL) */
-
+ j_lst.release();
return lst;
}
@@ -1131,7 +1129,7 @@
// Calculate the base64 value
XSECCryptoBase64 * b64 =
XSECPlatformUtils::g_cryptoProvider->base64();
-
+
if (!b64) {
throw XSECException(XSECException::CryptoProviderError,
@@ -1139,6 +1137,8 @@
}
+ Janitor<XSECCryptoBase64> j_b64(b64);
+
b64->encodeInit();
base64HashLen = b64->encode(calculatedHashVal,
calculatedHashLen,
@@ -1146,7 +1146,6 @@
CRYPTO_MAX_HASH_SIZE * 2);
base64HashLen += b64->encodeFinish(&base64Hash[base64HashLen],
(CRYPTO_MAX_HASH_SIZE * 2) - base64HashLen);
- delete b64;
// Ensure the string is terminated
if (base64Hash[base64HashLen-1] == '\n')
@@ -1195,7 +1194,9 @@
// First set up for input
- TXFMBase * currentTxfm, * nextInput;
+ TXFMBase * currentTxfm;
+ TXFMChain * chain;
+
unsigned int size;
if (mp_URI == NULL) {
@@ -1209,28 +1210,22 @@
currentTxfm = getURIBaseTXFM(mp_referenceNode->getOwnerDocument(),
mp_URI,
mp_parentSignature->getURIResolver());
- // Now check for Transforms
-
- if (mp_transformList != NULL) {
-
- // Process the transforms using the static function.
+ // Now build the transforms list
+ // Note this passes ownership of currentTxfm to the function, so it is
the
+ // responsibility of createTXFMChain to ensure it gets deleted if this
throws.
- currentTxfm = createTXFMChainFromList(currentTxfm,
mp_transformList);
+ chain = createTXFMChainFromList(currentTxfm, mp_transformList);
+ Janitor<TXFMChain> j_chain(chain);
-
- }
-
DOMDocument *d = mp_referenceNode->getOwnerDocument();
// All transforms done. If necessary, change the type from nodes to
bytes
- if (currentTxfm->getOutputType() == TXFMBase::DOM_NODES) {
+ if (chain->getLastTxfm()->getOutputType() == TXFMBase::DOM_NODES) {
TXFMC14n * c14n;
XSECnew(c14n, TXFMC14n(d));
- c14n->setInput(currentTxfm);
-
- currentTxfm= c14n;
+ chain->appendTxfm(c14n);
}
@@ -1238,8 +1233,8 @@
if (mp_preHash != NULL) {
- mp_preHash->setInput(currentTxfm);
- currentTxfm= mp_preHash;
+ chain->appendTxfm(mp_preHash);
+ mp_preHash = NULL; // Can't be re-used
}
@@ -1247,11 +1242,9 @@
TXFMOutputFile * of = new TXFMOutputFile(d);
of->setFile("Output");
- of->setInput(currentTxfm);
- currentTxfm =of;
+ chain->(of);
#endif
- nextInput = currentTxfm;
// Determine what the digest method actually is
@@ -1270,16 +1263,12 @@
}
// Now we have the hashing transform, run it.
-
- currentTxfm->setInput(nextInput);
- // Now get the value
-
- size = currentTxfm->readBytes(toFill, maxToFill);
+ chain->appendTxfm(currentTxfm);
+ size = chain->getLastTxfm()->readBytes(toFill, maxToFill);
// Clean out document if necessary
- currentTxfm->deleteExpandedNameSpaces();
- deleteTXFMChain(currentTxfm);
+ chain->getLastTxfm()->deleteExpandedNameSpaces();
return size;
@@ -1299,7 +1288,7 @@
DOMNode *tmpElt;
//const XMLCh * stringHash;
- TXFMBase * nextInput, *currentTransform;
+ TXFMBase * nextInput;
DOMDocument *d = mp_referenceNode->getOwnerDocument();
@@ -1330,31 +1319,27 @@
// Now have the value of the string - create a transform around it
- nextInput = (TXFMBase *) new TXFMSB(d);
-
- if (nextInput == NULL)
- throw XSECException(XSECException::MemoryAllocationFail);
-
+ XSECnew(nextInput, TXFMSB(d));
((TXFMSB *) nextInput)->setInput(b64HashVal);
- // Now create the base64 transform
+ // Create a transform chain (really as a janitor for the entire list)
+ TXFMChain * chain;
+ XSECnew(chain, TXFMChain(nextInput));
+ Janitor<TXFMChain> j_chain(chain);
- currentTransform = new TXFMBase64(d);
+ // Now create the base64 transform
- if (currentTransform == NULL)
- throw XSECException(XSECException::MemoryAllocationFail);
+ XSECnew(nextInput, TXFMBase64(d));
+ chain->appendTxfm(nextInput);
- currentTransform->setInput(nextInput);
-
// Now get the value
- size = currentTransform->readBytes(toFill, maxToFill);
+ size = chain->getLastTxfm()->readBytes(toFill, maxToFill);
- // Delete the transforms
-
- currentTransform->deleteExpandedNameSpaces();
- deleteTXFMChain(currentTransform);
+ // Clear any documentat modifications
+ chain->getLastTxfm()->deleteExpandedNameSpaces();
+
return size;
}
1.3 +2 -1 xml-security/c/src/dsig/DSIGReference.hpp
Index: DSIGReference.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGReference.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGReference.hpp 9 Feb 2003 11:13:47 -0000 1.2
+++ DSIGReference.hpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -93,6 +93,7 @@
class DSIGSignature;
class TXFMBase;
+class TXFMChain;
class XSECBinTXFMInputStream;
class XSECURIResolver;
@@ -393,7 +394,7 @@
* transforms.
*/
- static TXFMBase * DSIGReference::createTXFMChainFromList(TXFMBase *
input,
+ static TXFMChain * DSIGReference::createTXFMChainFromList(TXFMBase *
input,
DSIGTransformList *
lst);
/**
1.5 +46 -39 xml-security/c/src/dsig/DSIGSignature.cpp
Index: DSIGSignature.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGSignature.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DSIGSignature.cpp 18 Feb 2003 11:28:12 -0000 1.4
+++ DSIGSignature.cpp 21 Feb 2003 11:53:06 -0000 1.5
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -81,6 +79,7 @@
#include <xsec/transformers/TXFMSHA1.hpp>
#include <xsec/transformers/TXFMBase64.hpp>
#include <xsec/transformers/TXFMC14n.hpp>
+#include <xsec/transformers/TXFMChain.hpp>
#include <xsec/framework/XSECError.hpp>
#include <xsec/enc/XSECCryptoKeyDSA.hpp>
#include <xsec/enc/XSECCryptoKeyRSA.hpp>
@@ -245,12 +244,17 @@
XSECBinTXFMInputStream * DSIGSignature::makeBinInputStream(void) const {
- TXFMBase * input, * can;
+ TXFMBase * txfm;
// Create the starting point for the transform list
- XSECnew(input, TXFMDocObject(mp_doc));
- ((TXFMDocObject *) input)->setInput(mp_doc,
mp_signedInfo->getDOMNode());
+ XSECnew(txfm, TXFMDocObject(mp_doc));
+
+ TXFMChain * chain;
+ XSECnew(chain, TXFMChain(txfm));
+ Janitor<TXFMChain> j_chain(chain);
+
+ ((TXFMDocObject *) txfm)->setInput(mp_doc, mp_signedInfo->getDOMNode());
// canonicalise the SignedInfo content
@@ -258,15 +262,17 @@
case CANON_C14N_NOC :
- XSECnew(can, TXFMC14n(mp_doc));
- can->stripComments();
+ XSECnew(txfm, TXFMC14n(mp_doc));
+ chain->appendTxfm(txfm);
+ txfm->stripComments();
break;
case CANON_C14N_COM :
- XSECnew(can, TXFMC14n(mp_doc));
- can->activateComments();
+ XSECnew(txfm, TXFMC14n(mp_doc));
+ chain->appendTxfm(txfm);
+ txfm->activateComments();
break;
@@ -277,13 +283,12 @@
}
- can->setInput(input);
-
// Now create the InputStream
XSECBinTXFMInputStream * ret;
- XSECnew(ret, XSECBinTXFMInputStream(can));
+ XSECnew(ret, XSECBinTXFMInputStream(chain));
+ j_chain.release();
return ret;
@@ -770,6 +775,9 @@
// Find base transform using the base URI
currentTxfm =
DSIGReference::getURIBaseTXFM(mp_doc, URI, mp_URIResolver);
+ TXFMChain * chain;
+ XSECnew(chain, TXFMChain(currentTxfm));
+ Janitor<TXFMChain> j_chain(chain);
// Now check for transforms
tmpKI = tmpKI->getFirstChild();
@@ -801,10 +809,9 @@
size = l->getSize();
for (i = 0; i < size; ++ i) {
try {
- currentTxfm =
l->item(i)->createTransformer(currentTxfm);
+
l->item(i)->appendTransformer(chain);
}
catch (...) {
-
deleteTXFMChain(currentTxfm);
delete l;
throw;
}
@@ -816,7 +823,7 @@
// Find out the type of the final transform and
process accordingly
- TXFMBase::nodeType type =
currentTxfm->getNodeType();
+ TXFMBase::nodeType type =
chain->getLastTxfm()->getNodeType();
XSECXPathNodeList lst;
const DOMNode * element;
@@ -833,7 +840,7 @@
case TXFMBase::DOM_NODE_XPATH_NODESET :
- lst = currentTxfm->getXPathNodeList();
+ lst =
chain->getLastTxfm()->getXPathNodeList();
element = lst.getFirstNode();
while (element != NULL) {
@@ -855,11 +862,9 @@
}
// Delete the transform chain
- if (currentTxfm != NULL) {
- currentTxfm->deleteExpandedNameSpaces();
- deleteTXFMChain(currentTxfm);
+
chain->getLastTxfm()->deleteExpandedNameSpaces();
- }
+ // Janitor will clean up chain
} /* if getNodeName == Retrieval Method */
@@ -888,11 +893,15 @@
// Calculate the hash and store in the hashBuf
- TXFMBase * hashVal, * tmpTfm;
+ TXFMBase * txfm;
+ TXFMChain * chain;
// First we calculate the hash. Start off by creating a starting point
- XSECnew(hashVal, TXFMDocObject(mp_doc));
- ((TXFMDocObject *) hashVal)->setInput(mp_doc,
mp_signedInfo->getDOMNode());
+ XSECnew(txfm, TXFMDocObject(mp_doc));
+ XSECnew(chain, TXFMChain(txfm));
+ Janitor<TXFMChain> j_chain(chain);
+
+ ((TXFMDocObject *) txfm)->setInput(mp_doc, mp_signedInfo->getDOMNode());
// canonicalise the SignedInfo content
@@ -900,15 +909,17 @@
case CANON_C14N_NOC :
- XSECnew(tmpTfm, TXFMC14n(mp_doc));
- tmpTfm->stripComments();
+ XSECnew(txfm, TXFMC14n(mp_doc));
+ chain->appendTxfm(txfm);
+ txfm->stripComments();
break;
case CANON_C14N_COM :
- XSECnew(tmpTfm, TXFMC14n(mp_doc));
- tmpTfm->activateComments();
+ XSECnew(txfm, TXFMC14n(mp_doc));
+ chain->appendTxfm(txfm);
+ txfm->activateComments();
break;
@@ -919,9 +930,6 @@
}
- tmpTfm->setInput(hashVal);
- hashVal = tmpTfm;
-
// Setup Hash
switch (mp_signedInfo->getHashMethod()) {
@@ -929,10 +937,10 @@
case HASH_SHA1 :
if (mp_signedInfo->getSignatureMethod() == SIGNATURE_HMAC){
- XSECnew(tmpTfm, TXFMSHA1(mp_doc, mp_signingKey));
+ XSECnew(txfm, TXFMSHA1(mp_doc, mp_signingKey));
}
else {
- XSECnew(tmpTfm, TXFMSHA1(mp_doc));
+ XSECnew(txfm, TXFMSHA1(mp_doc));
}
break;
@@ -952,16 +960,12 @@
hashVal=of;
#endif
- tmpTfm->setInput(hashVal);
- hashVal = tmpTfm;
+ chain->appendTxfm(txfm);
// Write hash to the buffer
int hashLen;
- hashLen = hashVal->readBytes((XMLByte *) hashBuf, hashBufLen);
-
- // Clean up transforms
- deleteTXFMChain(hashVal);
+ hashLen = chain->getLastTxfm()->readBytes((XMLByte *) hashBuf,
hashBufLen);
return hashLen;
@@ -1146,6 +1150,9 @@
}
+
+ // Reset error string in case we have any reference problems.
+ m_errStr.sbXMLChIn(DSIGConstants::s_unicodeStrEmpty);
// Set up the reference list hashes - including any manifests
mp_signedInfo->hash();
1.3 +1 -3 xml-security/c/src/dsig/DSIGSignature.hpp
Index: DSIGSignature.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGSignature.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGSignature.hpp 9 Feb 2003 11:13:47 -0000 1.2
+++ DSIGSignature.hpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
1.3 +5 -7 xml-security/c/src/dsig/DSIGTransform.hpp
Index: DSIGTransform.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransform.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGTransform.hpp 9 Feb 2003 11:13:47 -0000 1.2
+++ DSIGTransform.hpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -83,7 +81,7 @@
#include <stdio.h>
class DSIGSignature;
-class TXFMBase;
+class TXFMChain;
/**
* @ingroup pubsig
@@ -172,13 +170,13 @@
virtual transformType getTransformType() = 0;
/**
- * \brief Create the transformer element.
+ * \brief Create the transformer element and append to an existing
Chain.
*
* Implemented by each Transform class and used by the DSIGSignature
- * to construct a complete Transform list.
+ * to construct a complete Transform chain (TXFMChain).
*/
- virtual TXFMBase * createTransformer(TXFMBase * input) = 0;
+ virtual void appendTransformer(TXFMChain * input) = 0;
/**
* \brief Construct a new transform.
1.3 +9 -21 xml-security/c/src/dsig/DSIGTransformBase64.cpp
Index: DSIGTransformBase64.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformBase64.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGTransformBase64.cpp 9 Feb 2003 11:13:48 -0000 1.2
+++ DSIGTransformBase64.cpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -76,6 +74,7 @@
#include <xsec/dsig/DSIGSignature.hpp>
#include <xsec/transformers/TXFMBase64.hpp>
#include <xsec/transformers/TXFMC14n.hpp>
+#include <xsec/transformers/TXFMChain.hpp>
#include <xsec/transformers/TXFMXPath.hpp>
#include <xsec/framework/XSECException.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
@@ -107,13 +106,11 @@
}
-TXFMBase * DSIGTransformBase64::createTransformer(TXFMBase * input) {
-
- TXFMBase *newInput;
+void DSIGTransformBase64::appendTransformer(TXFMChain * input) {
// If the input is a Nodeset then we need to find the text from the
input
- if (input->getOutputType() == TXFMBase::DOM_NODES) {
+ if (input->getLastTxfm()->getOutputType() == TXFMBase::DOM_NODES) {
#ifdef XSEC_NO_XPATH
@@ -128,7 +125,7 @@
TXFMXPath *x;
XSECnew(x, TXFMXPath(mp_txfmNode->getOwnerDocument()));
- x->setInput(input);
+ input->appendTxfm(x);
((TXFMXPath *) x)->evaluateExpr(mp_txfmNode, "self::text()");
TXFMC14n *c;
@@ -136,25 +133,16 @@
// Now use c14n to translate to BYTES
XSECnew(c, TXFMC14n(mp_txfmNode->getOwnerDocument()));
- c->setInput(x);
-
- newInput = c;
+ input->appendTxfm(c);
#endif
}
- else {
-
- newInput = input;
-
- }
-
// Now the actual Base64
- TXFMBase64 *b = new TXFMBase64(mp_txfmNode->getOwnerDocument());
- b->setInput(newInput);
-
- return b;
+ TXFMBase64 *b;
+ XSECnew(b, TXFMBase64(mp_txfmNode->getOwnerDocument()));
+ input->appendTxfm(b);
}
1.3 +2 -4 xml-security/c/src/dsig/DSIGTransformBase64.hpp
Index: DSIGTransformBase64.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformBase64.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGTransformBase64.hpp 9 Feb 2003 11:13:48 -0000 1.2
+++ DSIGTransformBase64.hpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -159,7 +157,7 @@
* to construct a complete Transform list.
*/
- virtual TXFMBase * createTransformer(TXFMBase * input);
+ virtual void appendTransformer(TXFMChain * input);
/**
* \brief Construct blank Base64 Transform element.
1.4 +3 -7 xml-security/c/src/dsig/DSIGTransformC14n.cpp
Index: DSIGTransformC14n.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformC14n.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DSIGTransformC14n.cpp 17 Feb 2003 11:23:38 -0000 1.3
+++ DSIGTransformC14n.cpp 21 Feb 2003 11:53:06 -0000 1.4
@@ -73,6 +73,7 @@
#include <xsec/dsig/DSIGTransformC14n.hpp>
#include <xsec/framework/XSECException.hpp>
#include <xsec/transformers/TXFMC14n.hpp>
+#include <xsec/transformers/TXFMChain.hpp>
#include <xsec/framework/XSECError.hpp>
#include <xsec/dsig/DSIGSignature.hpp>
@@ -115,14 +116,12 @@
}
-TXFMBase * DSIGTransformC14n::createTransformer(TXFMBase * input) {
+void DSIGTransformC14n::appendTransformer(TXFMChain * input) {
TXFMC14n * c;
XSECnew(c, TXFMC14n(mp_txfmNode->getOwnerDocument()));
- Janitor<TXFMC14n> j_c(c);
-
- c->setInput(input);
+ input->appendTxfm(c);
switch (m_cMethod) {
@@ -155,9 +154,6 @@
}
}
-
- j_c.release();
- return c;
}
1.3 +2 -4 xml-security/c/src/dsig/DSIGTransformC14n.hpp
Index: DSIGTransformC14n.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformC14n.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGTransformC14n.hpp 9 Feb 2003 11:13:48 -0000 1.2
+++ DSIGTransformC14n.hpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -154,7 +152,7 @@
* when consructing a TXFM List that includes canonicalisation (nearly
always)
*/
- virtual TXFMBase * createTransformer(TXFMBase * input);
+ virtual void appendTransformer(TXFMChain * input);
/**
* \brief Construct blank Canonicalisation Transform element.
1.3 +5 -8 xml-security/c/src/dsig/DSIGTransformEnvelope.cpp
Index: DSIGTransformEnvelope.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformEnvelope.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGTransformEnvelope.cpp 9 Feb 2003 11:13:48 -0000 1.2
+++ DSIGTransformEnvelope.cpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -76,6 +74,7 @@
#include <xsec/dsig/DSIGSignature.hpp>
#include <xsec/transformers/TXFMEnvelope.hpp>
#include <xsec/transformers/TXFMC14n.hpp>
+#include <xsec/transformers/TXFMChain.hpp>
#include <xsec/transformers/TXFMXPath.hpp>
#include <xsec/framework/XSECException.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
@@ -107,7 +106,7 @@
}
-TXFMBase * DSIGTransformEnvelope::createTransformer(TXFMBase * input) {
+void DSIGTransformEnvelope::appendTransformer(TXFMChain * input) {
#ifdef XSEC_USE_XPATH_ENVELOPE
@@ -115,7 +114,7 @@
// Special XPath transform
XSECnew(x, TXFMXPath(mp_txfmNode->getOwnerDocument()));
- x->setInput(input);
+ input->appendTxfm(x);
// Execute the envelope expression
x->evaluateEnvelope(mp_txfmNode);
@@ -126,14 +125,12 @@
// Use the Envelope transform
XSECnew(x, TXFMEnvelope(mp_txfmNode->getOwnerDocument()));
- x->setInput(input);
+ input->appendTxfm(x);
// Execute envelope
x->evaluateEnvelope(mp_txfmNode);
#endif
-
- return x;
}
1.3 +2 -4 xml-security/c/src/dsig/DSIGTransformEnvelope.hpp
Index: DSIGTransformEnvelope.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformEnvelope.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGTransformEnvelope.hpp 9 Feb 2003 11:13:48 -0000 1.2
+++ DSIGTransformEnvelope.hpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -154,7 +152,7 @@
* to construct a complete Transform list.
*/
- virtual TXFMBase * createTransformer(TXFMBase * input);
+ virtual void appendTransformer(TXFMChain * input);
/**
* \brief Construct blank Envelope Transform element.
1.5 +4 -7 xml-security/c/src/dsig/DSIGTransformXPath.cpp
Index: DSIGTransformXPath.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformXPath.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DSIGTransformXPath.cpp 18 Feb 2003 11:28:12 -0000 1.4
+++ DSIGTransformXPath.cpp 21 Feb 2003 11:53:06 -0000 1.5
@@ -73,6 +73,7 @@
#include <xsec/transformers/TXFMXPath.hpp>
#include <xsec/framework/XSECException.hpp>
#include <xsec/transformers/TXFMC14n.hpp>
+#include <xsec/transformers/TXFMChain.hpp>
#include <xsec/framework/XSECError.hpp>
#include <xsec/dsig/DSIGSignature.hpp>
@@ -116,7 +117,7 @@
}
-TXFMBase * DSIGTransformXPath::createTransformer(TXFMBase * input) {
+void DSIGTransformXPath::appendTransformer(TXFMChain * input) {
#ifdef XSEC_NO_XPATH
@@ -128,13 +129,9 @@
TXFMXPath *x;
// XPath transform
XSECnew(x, TXFMXPath(mp_txfmNode->getOwnerDocument()));
- Janitor<TXFMXPath> j_x(x);
- x->setInput(input);
+ input->appendTxfm(x);
x->setNameSpace(mp_NSMap);
x->evaluateExpr(mp_txfmNode, m_expr);
-
- j_x.release();
- return x;
#endif /* NO_XPATH */
1.3 +2 -4 xml-security/c/src/dsig/DSIGTransformXPath.hpp
Index: DSIGTransformXPath.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformXPath.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGTransformXPath.hpp 9 Feb 2003 11:13:48 -0000 1.2
+++ DSIGTransformXPath.hpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -163,7 +161,7 @@
* @returns The TXFMXPath transformer associated with this Transform
*/
- virtual TXFMBase * createTransformer(TXFMBase * input);
+ virtual void appendTransformer(TXFMChain * input);
/**
* \brief Construct blank XPath Transform element.
1.3 +6 -13 xml-security/c/src/dsig/DSIGTransformXSL.cpp
Index: DSIGTransformXSL.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformXSL.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGTransformXSL.cpp 9 Feb 2003 11:13:48 -0000 1.2
+++ DSIGTransformXSL.cpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -76,6 +74,7 @@
#include <xsec/dsig/DSIGSignature.hpp>
#include <xsec/transformers/TXFMXSL.hpp>
#include <xsec/transformers/TXFMC14n.hpp>
+#include <xsec/transformers/TXFMChain.hpp>
#include <xsec/framework/XSECException.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
#include <xsec/framework/XSECError.hpp>
@@ -108,7 +107,7 @@
}
-TXFMBase * DSIGTransformXSL::createTransformer(TXFMBase * input) {
+void DSIGTransformXSL::appendTransformer(TXFMChain * input) {
#ifdef XSEC_NO_XSLT
@@ -125,23 +124,19 @@
// XSLT Transform - requires a byte stream input
- if (input->getOutputType() == TXFMBase::DOM_NODES) {
+ if (input->getLastTxfm()->getOutputType() == TXFMBase::DOM_NODES) {
// Use c14n to translate to BYTES
XSECnew(nextInput, TXFMC14n(mp_txfmNode->getOwnerDocument()));
- nextInput->setInput(input);
- }
- else {
- nextInput = input;
-
+ input->appendTxfm(nextInput);
}
TXFMXSL * x;
// Create the XSLT transform
XSECnew(x, TXFMXSL(mp_txfmNode->getOwnerDocument()));
- x->setInput(nextInput);
+ input->appendTxfm(x);
// Again use C14n (convenient) to translate to a SafeBuffer
@@ -161,8 +156,6 @@
sbStyleSheet[size] = '\0'; // Terminate as though a string
x->evaluateStyleSheet(sbStyleSheet);
-
- return x;
#endif /* NO_XSLT */
1.3 +2 -4 xml-security/c/src/dsig/DSIGTransformXSL.hpp
Index: DSIGTransformXSL.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformXSL.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DSIGTransformXSL.hpp 9 Feb 2003 11:13:48 -0000 1.2
+++ DSIGTransformXSL.hpp 21 Feb 2003 11:53:06 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -155,7 +153,7 @@
*
*/
- virtual TXFMBase * createTransformer(TXFMBase * input);
+ virtual void appendTransformer(TXFMChain * input);
/**
* \brief Construct blank XSLT Transform element.
1.3 +12 -3 xml-security/c/src/framework/XSECW32Config.hpp
Index: XSECW32Config.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/framework/XSECW32Config.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSECW32Config.hpp 9 Feb 2003 11:13:50 -0000 1.2
+++ XSECW32Config.hpp 21 Feb 2003 11:53:08 -0000 1.3
@@ -66,9 +66,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -80,3 +78,14 @@
*/
/* #define XSEC_NO_XALAN */
+
+/*
+ * Macros used to determine what header files exist on this
+ * system
+ */
+
+/* Posix unistd.h */
+/* #define HAVE_UNISTD_H */
+
+/* Windows direct.h */
+#define HAVE_DIRECT_H 1
\ No newline at end of file
1.3 +4 -4 xml-security/c/src/tools/templatesign/templatesign.cpp
Index: templatesign.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/tools/templatesign/templatesign.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- templatesign.cpp 9 Feb 2003 11:13:51 -0000 1.2
+++ templatesign.cpp 21 Feb 2003 11:53:08 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -876,8 +874,10 @@
}
catch (XSECException &e) {
+ char * m = XMLString::transcode(e.getMsg());
cerr << "An error occured during signature verification\n
Message: "
- << e.getMsg() << endl;
+ << m << endl;
+ delete m;
errorsOccured = true;
exit (1);
}
1.5 +4 -7 xml-security/c/src/tools/txfmout/txfmout.cpp
Index: txfmout.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/tools/txfmout/txfmout.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- txfmout.cpp 20 Feb 2003 10:34:24 -0000 1.4
+++ txfmout.cpp 21 Feb 2003 11:53:08 -0000 1.5
@@ -67,14 +67,6 @@
*
* $Id$
*
- * $Log$
- * Revision 1.4 2003/02/20 10:34:24 blautenb
- * Check for unistd.h
- *
- * Revision 1.3 2003/02/17 11:22:39 blautenb
- * Now handle relative file URIs in references
- *
- *
*/
// XSEC
@@ -617,8 +609,10 @@
}
catch (XSECException &e) {
+ char * m = XMLString::transcode(e.getMsg());
cerr << "An error occured during signature processing\n
Message: "
- << e.getMsg() << endl;
+ << m << endl;
+ delete[] m;
errorsOccured = true;
exit (2);
}
1.4 +2 -19 xml-security/c/src/transformers/TXFMBase.cpp
Index: TXFMBase.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/transformers/TXFMBase.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TXFMBase.cpp 18 Feb 2003 11:28:12 -0000 1.3
+++ TXFMBase.cpp 21 Feb 2003 11:53:08 -0000 1.4
@@ -129,24 +129,7 @@
if (input != NULL)
input->deleteExpandedNameSpaces();
-}
-
-
-
-// -----------------------------------------------------------------------
-// deleteTransformChain = easy way to delete an entire chain of transforms
-// -----------------------------------------------------------------------
-
-
-void deleteTXFMChain(TXFMBase * toDelete) {
-
- if (toDelete != NULL) {
- deleteTXFMChain(toDelete->input);
- delete toDelete;
- }
-
-}
-
+}
void TXFMBase::activateComments(void) {
1.3 +6 -7 xml-security/c/src/transformers/TXFMBase.hpp
Index: TXFMBase.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/transformers/TXFMBase.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TXFMBase.hpp 9 Feb 2003 11:13:51 -0000 1.2
+++ TXFMBase.hpp 21 Feb 2003 11:53:08 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -82,9 +80,9 @@
#include <xercesc/util/BinInputStream.hpp>
-
#include <stdlib.h>
+class TXFMChain;
class DSIG_EXPORT TXFMBase {
@@ -123,6 +121,9 @@
// Methods to set the inputs
+ // NOTE: If this throws an exception, the implementation class
+ // MUST have added the newInput to it's chain to ensure that
+ // Deletion of the chain will include everything.
virtual void setInput(TXFMBase *newInput) = 0;
@@ -155,14 +156,12 @@
// Friends and Statics
- friend void deleteTXFMChain(TXFMBase * toDelete);
+ friend TXFMChain;
private:
TXFMBase();
};
-
-void deleteTXFMChain(TXFMBase * toDelete);
#endif /* #define TXFMBASE_INCLUDE */
1.4 +2 -3 xml-security/c/src/transformers/TXFMC14n.cpp
Index: TXFMC14n.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/transformers/TXFMC14n.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TXFMC14n.cpp 17 Feb 2003 11:23:38 -0000 1.3
+++ TXFMC14n.cpp 21 Feb 2003 11:53:08 -0000 1.4
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -103,6 +101,7 @@
}
catch (...) {
delete parser;
+ input = newInput; // Ensure chain will be
deleted.
throw;
}
1.3 +4 -6 xml-security/c/src/transformers/TXFMEnvelope.cpp
Index: TXFMEnvelope.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/transformers/TXFMEnvelope.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TXFMEnvelope.cpp 9 Feb 2003 11:13:51 -0000 1.2
+++ TXFMEnvelope.cpp 21 Feb 2003 11:53:08 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -89,13 +87,13 @@
void TXFMEnvelope::setInput(TXFMBase *newInput) {
- if (newInput->getOutputType() != TXFMBase::DOM_NODES) {
+ input = newInput;
+
+ if (newInput->getOutputType() != TXFMBase::DOM_NODES) {
throw XSECException(XSECException::TransformInputOutputFail,
"XPath requires DOM_NODES input type");
}
-
- input = newInput;
// Expand if necessary
this->expandNameSpaces();
1.3 +3 -5 xml-security/c/src/transformers/TXFMOutputFile.cpp
Index: TXFMOutputFile.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/transformers/TXFMOutputFile.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TXFMOutputFile.cpp 9 Feb 2003 11:13:51 -0000 1.2
+++ TXFMOutputFile.cpp 21 Feb 2003 11:53:08 -0000 1.3
@@ -65,9 +65,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -86,13 +84,13 @@
void TXFMOutputFile::setInput(TXFMBase *newInput) {
+ input = newInput;
+
if (newInput->getOutputType() != TXFMBase::BYTE_STREAM) {
throw XSECException(XSECException::TransformInputOutputFail,
"OutputFile transform requires BYTE_STREAM input");
}
-
- input = newInput;
keepComments = input->getCommentsStatus();
1.2 +9 -4 xml-security/c/src/transformers/TXFMParser.cpp
Index: TXFMParser.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/transformers/TXFMParser.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TXFMParser.cpp 17 Feb 2003 11:20:03 -0000 1.1
+++ TXFMParser.cpp 21 Feb 2003 11:53:08 -0000 1.2
@@ -66,23 +66,21 @@
*
* $Id$
*
- * $Log$
- * Revision 1.1 2003/02/17 11:20:03 blautenb
- * Parser Transformer to convert a BYTE_STREAM to DOM_NODES
- *
- *
*/
#include <xsec/transformers/TXFMParser.hpp>
+#include <xsec/transformers/TXFMChain.hpp>
#include <xsec/utils/XSECPlatformUtils.hpp>
#include <xsec/framework/XSECError.hpp>
#include <xsec/utils/XSECTXFMInputSource.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/framework/MemBufInputSource.hpp>
+#include <xercesc/util/Janitor.hpp>
XSEC_USING_XERCES(XercesDOMParser);
XSEC_USING_XERCES(MemBufInputSource);
+XSEC_USING_XERCES(Janitor);
@@ -150,7 +148,11 @@
input = newInput;
// Create a InputStream
- XSECTXFMInputSource is(newInput, false);
+ TXFMChain * chain;
+ XSECnew(chain, TXFMChain(newInput, false));
+ Janitor<TXFMChain> j_chain(chain);
+
+ XSECTXFMInputSource is(chain, false);
// Create a XercesParser and parse!
XercesDOMParser parser;
1.2 +1 -3 xml-security/c/src/transformers/TXFMParser.hpp
Index: TXFMParser.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/transformers/TXFMParser.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TXFMParser.hpp 17 Feb 2003 11:20:03 -0000 1.1
+++ TXFMParser.hpp 21 Feb 2003 11:53:08 -0000 1.2
@@ -66,11 +66,6 @@
*
* $Id$
*
- * $Log$
- * Revision 1.1 2003/02/17 11:20:03 blautenb
- * Parser Transformer to convert a BYTE_STREAM to DOM_NODES
- *
- *
*/
#ifndef TXFMPARSER_INCLUDE
1.3 +1 -3 xml-security/c/src/transformers/TXFMSHA1.cpp
Index: TXFMSHA1.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/transformers/TXFMSHA1.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TXFMSHA1.cpp 9 Feb 2003 11:13:51 -0000 1.2
+++ TXFMSHA1.cpp 21 Feb 2003 11:53:08 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
1.5 +2 -1 xml-security/c/src/transformers/TXFMXPath.cpp
Index: TXFMXPath.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/transformers/TXFMXPath.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TXFMXPath.cpp 18 Feb 2003 11:28:12 -0000 1.4
+++ TXFMXPath.cpp 21 Feb 2003 11:53:08 -0000 1.5
@@ -252,6 +252,7 @@
}
catch (...) {
delete parser;
+ input = newInput;
throw;
}
1.3 +3 -5 xml-security/c/src/transformers/TXFMXSL.cpp
Index: TXFMXSL.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/transformers/TXFMXSL.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TXFMXSL.cpp 9 Feb 2003 11:13:52 -0000 1.2
+++ TXFMXSL.cpp 21 Feb 2003 11:53:08 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -170,6 +168,8 @@
void TXFMXSL::setInput(TXFMBase *newInput) {
+ input = newInput;
+
if (newInput->getOutputType() != TXFMBase::BYTE_STREAM) {
throw XSECException(XSECException::TransformInputOutputFail,
"XSL requires DOM_NODES input type");
@@ -178,8 +178,6 @@
// Should have a method to check if the input is a straight URL - if it
is, just read the
// URL name and create an XSLTInputSource with this as the input ID.
-
- input = newInput;
int size = 0;
int count = 0;
1.1 xml-security/c/src/transformers/TXFMChain.cpp
Index: TXFMChain.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "<WebSig>" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, Institute for
* Data Communications Systems, <http://www.nue.et-inf.uni-siegen.de/>.
* The development of this software was partly funded by the European
* Commission in the <WebSig> project in the ISIS Programme.
* For more information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* XSEC
*
* TXFMChain := List class that holds and manipulates a chain of TXFM
* objects.
*
* Author(s): Berin Lautenbach
*
* $Id: TXFMChain.cpp,v 1.1 2003/02/21 11:53:08 blautenb Exp $
*
*/
#include <xsec/transformers/TXFMBase.hpp>
#include <xsec/transformers/TXFMChain.hpp>
// -----------------------------------------------------------------------
// deleteTransformChain = easy way to delete an entire chain of transforms
// -----------------------------------------------------------------------
void TXFMChain::deleteTXFMChain(TXFMBase * toDelete) {
if (toDelete != NULL) {
deleteTXFMChain(toDelete->input);
delete toDelete;
}
}
//
--------------------------------------------------------------------------------
// Constructors/Destructors
//
--------------------------------------------------------------------------------
TXFMChain::TXFMChain(TXFMBase * baseTxfm, bool deleteChainWhenDone) :
mp_currentTxfm(baseTxfm),
m_deleteChainWhenDone(deleteChainWhenDone) {
}
TXFMChain::~TXFMChain() {
if (m_deleteChainWhenDone)
deleteTXFMChain(mp_currentTxfm);
}
//
--------------------------------------------------------------------------------
// Read hash
//
--------------------------------------------------------------------------------
void TXFMChain::appendTxfm(TXFMBase * txfm) {
TXFMBase * oldTxfm = mp_currentTxfm;
mp_currentTxfm = txfm;
// This may throw an exception, but if it does each TXFM type
// Guarantees that it will have made the input part of the
// chain before such an exception. So the caller can clear out
// the entire chain - including the new txfm - by deleting
// *this.
txfm->setInput(oldTxfm);
}
1.1 xml-security/c/src/transformers/TXFMChain.hpp
Index: TXFMChain.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "<WebSig>" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, Institute for
* Data Communications Systems, <http://www.nue.et-inf.uni-siegen.de/>.
* The development of this software was partly funded by the European
* Commission in the <WebSig> project in the ISIS Programme.
* For more information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* XSEC
*
* TXFMChain := List class that holds and manipulates a chain of TXFM
* objects.
*
* Author(s): Berin Lautenbach
*
* $Id: TXFMChain.hpp,v 1.1 2003/02/21 11:53:08 blautenb Exp $
*
*/
#ifndef TXFMCHAIN_INCLUDE
#define TXFMCHAIN_INCLUDE
#include <xsec/framework/XSECDefs.hpp>
class TXFMBase;
class DSIG_EXPORT TXFMChain {
public:
// Constructors/destructors
TXFMChain(TXFMBase * baseTxfm, bool deleteChainWhenDone = true);
~TXFMChain();
// Manipulate
void appendTxfm(TXFMBase * txfm);
TXFMBase * getLastTxfm(void);
private:
TXFMChain();
TXFMChain(TXFMChain &toCopy);
TXFMBase * mp_currentTxfm;
bool m_deleteChainWhenDone;
void deleteTXFMChain(TXFMBase * toDelete);
};
inline
TXFMBase * TXFMChain::getLastTxfm(void) {return mp_currentTxfm;}
#endif /* TXFMCHAIN_INCLUDE */
1.3 +8 -5 xml-security/c/src/utils/XSECBinTXFMInputStream.cpp
Index: XSECBinTXFMInputStream.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/XSECBinTXFMInputStream.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSECBinTXFMInputStream.cpp 9 Feb 2003 11:13:52 -0000 1.2
+++ XSECBinTXFMInputStream.cpp 21 Feb 2003 11:53:09 -0000 1.3
@@ -73,6 +73,7 @@
#include <xsec/utils/XSECBinTXFMInputStream.hpp>
#include <xsec/transformers/TXFMBase.hpp>
+#include <xsec/transformers/TXFMChain.hpp>
#include <xsec/framework/XSECError.hpp>
//
---------------------------------------------------------------------------
@@ -80,8 +81,9 @@
//
---------------------------------------------------------------------------
-XSECBinTXFMInputStream::XSECBinTXFMInputStream(TXFMBase * lst, bool
deleteWhenDone) :
-mp_txfm(lst),
+XSECBinTXFMInputStream::XSECBinTXFMInputStream(TXFMChain * lst, bool
deleteWhenDone) :
+mp_txfm(lst->getLastTxfm()),
+mp_chain(lst),
m_deleteWhenDone(deleteWhenDone),
m_deleted(false),
m_done(false),
@@ -100,8 +102,8 @@
if (m_deleteWhenDone == true && m_deleted == false) {
- deleteTXFMChain(mp_txfm);
- m_deleted = false;
+ delete mp_chain;
+ m_deleted = true;
}
@@ -133,8 +135,9 @@
if (m_deleteWhenDone) {
- deleteTXFMChain(mp_txfm);
+ delete mp_chain;
mp_txfm = 0;
+ mp_chain = 0;
m_deleted = true;
}
1.3 +6 -4 xml-security/c/src/utils/XSECBinTXFMInputStream.hpp
Index: XSECBinTXFMInputStream.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/XSECBinTXFMInputStream.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSECBinTXFMInputStream.hpp 9 Feb 2003 11:13:52 -0000 1.2
+++ XSECBinTXFMInputStream.hpp 21 Feb 2003 11:53:09 -0000 1.3
@@ -77,6 +77,7 @@
#include <xsec/framework/XSECDefs.hpp>
#include <xercesc/util/BinInputStream.hpp>
+class TXFMChain;
class TXFMBase;
/**
@@ -88,9 +89,9 @@
*/
/**
- * @brief BinInputSource wrapper for a TXFMList.
+ * @brief BinInputSource wrapper for a TXFMChain.
*
- * This class provides a wrapper for a TXFMList. It can be used to either
provide
+ * This class provides a wrapper for a TXFMChain. It can be used to either
provide
* a nice interface to applications wishing to read the BYTESTREAM output of
a
* TXFM chain, or, as it is derived from BinInputStream, provide an input to
the
* Xerces Parser.
@@ -109,12 +110,12 @@
/**
* \brief Construct around an existing transform list
*
- * @param lst The final TXFM element in the input chain.
+ * @param lst The input TXFM chain.
* @param deleteWhenDone Flag to instruct the class to delete the chain
when
* done. By default set to true.
*/
- XSECBinTXFMInputStream(TXFMBase * lst, bool deleteWhenDone = true);
+ XSECBinTXFMInputStream(TXFMChain * lst, bool deleteWhenDone = true);
/**
* \brief Destructor
@@ -173,6 +174,7 @@
private :
TXFMBase * mp_txfm;
// End point of list
+ TXFMChain * mp_chain;
// The actual chain
bool m_deleteWhenDone;
// Do we delete?
bool m_deleted;
// Have we deleted?
bool m_done;
// Are we done?
1.3 +1 -1 xml-security/c/src/utils/XSECDOMUtils.cpp
Index: XSECDOMUtils.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/XSECDOMUtils.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSECDOMUtils.cpp 9 Feb 2003 11:13:52 -0000 1.2
+++ XSECDOMUtils.cpp 21 Feb 2003 11:53:09 -0000 1.3
@@ -159,7 +159,7 @@
}
safeBuffer &makeQName(safeBuffer & qname, const XMLCh *prefix, char *
localName) {
- if (prefix[0] == 0) {
+ if (prefix == NULL || prefix[0] == 0) {
qname.sbTranscodeIn(localName);
}
else {
1.2 +8 -5 xml-security/c/src/utils/XSECTXFMInputSource.cpp
Index: XSECTXFMInputSource.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/XSECTXFMInputSource.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSECTXFMInputSource.cpp 17 Feb 2003 11:19:12 -0000 1.1
+++ XSECTXFMInputSource.cpp 21 Feb 2003 11:53:09 -0000 1.2
@@ -67,6 +67,9 @@
* $Id$
*
* $Log$
+ * Revision 1.2 2003/02/21 11:53:09 blautenb
+ * TXFMChain to prevent memory leaks
+ *
* Revision 1.1 2003/02/17 11:19:12 blautenb
* Class to use a transform as an InputSource to Xerces
*
@@ -88,9 +91,9 @@
// Construct/Destruct
//
--------------------------------------------------------------------------------
-XSECTXFMInputSource::XSECTXFMInputSource(TXFMBase * lst, bool
deleteWhenDone) :
+XSECTXFMInputSource::XSECTXFMInputSource(TXFMChain * chain, bool
deleteWhenDone) :
-mp_txfm(lst),
+mp_chain(chain),
m_deleteWhenDone(deleteWhenDone) {
}
@@ -107,7 +110,7 @@
XSECBinTXFMInputStream * ret;
- XSECnew(ret, XSECBinTXFMInputStream(mp_txfm, m_deleteWhenDone));
+ XSECnew(ret, XSECBinTXFMInputStream(mp_chain, m_deleteWhenDone));
return ret;
1.2 +8 -5 xml-security/c/src/utils/XSECTXFMInputSource.hpp
Index: XSECTXFMInputSource.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/XSECTXFMInputSource.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSECTXFMInputSource.hpp 17 Feb 2003 11:19:12 -0000 1.1
+++ XSECTXFMInputSource.hpp 21 Feb 2003 11:53:09 -0000 1.2
@@ -67,6 +67,9 @@
* $Id$
*
* $Log$
+ * Revision 1.2 2003/02/21 11:53:09 blautenb
+ * TXFMChain to prevent memory leaks
+ *
* Revision 1.1 2003/02/17 11:19:12 blautenb
* Class to use a transform as an InputSource to Xerces
*
@@ -80,7 +83,7 @@
#include <xsec/framework/XSECDefs.hpp>
#include <xercesc/sax/InputSource.hpp>
-class TXFMBase;
+class TXFMChain;
XSEC_DECLARE_XERCES_CLASS(BinInputStream);
@@ -118,7 +121,7 @@
* done. By default set to true.
*/
- XSECTXFMInputSource(TXFMBase * lst, bool deleteWhenDone = true);
+ XSECTXFMInputSource(TXFMChain * lst, bool deleteWhenDone = true);
/**
* \brief Destructor
@@ -146,7 +149,7 @@
private :
- mutable TXFMBase * mp_txfm;
// End point of list
+ mutable TXFMChain * mp_chain;
// End point of list
bool m_deleteWhenDone;
// Do we delete?
};