00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #include <xsec/framework/XSECDefs.hpp>
00059
00060
00061
00062 #include <xercesc/dom/DOM.hpp>
00063 #include <xercesc/dom/DOMNamedNodeMap.hpp>
00064
00065
00066 #include <xsec/utils/XSECSafeBufferFormatter.hpp>
00067 #include <xsec/dsig/DSIGTransform.hpp>
00068 #include <xsec/dsig/DSIGReferenceList.hpp>
00069 #include <xsec/dsig/DSIGConstants.hpp>
00070
00071 class DSIGTransformList;
00072 class DSIGTransformBase64;
00073 class DSIGTransformC14n;
00074 class DSIGTransformEnvelope;
00075 class DSIGTransformXPath;
00076 class DSIGTransformXSL;
00077 class DSIGSignature;
00078
00079 class TXFMBase;
00080 class XSECBinTXFMInputStream;
00081 class XSECURIResolver;
00082
00096 class DSIG_EXPORT DSIGReference {
00097
00098 public:
00099
00102
00119 DSIGReference(DSIGSignature * sig, DOMNode *dom);
00120
00135 DSIGReference(DSIGSignature * sig);
00136
00146 ~DSIGReference();
00147
00149
00152
00161 void load();
00162
00181 DOMElement * createBlankReference(char * URI, hashMethod hm, char * type);
00182
00193 DSIGTransformEnvelope * appendEnvelopedSignatureTransform();
00194
00201 DSIGTransformBase64 * appendBase64Transform();
00202
00214 DSIGTransformXPath * appendXPathTransform(char * expr);
00215
00226 DSIGTransformXSL * appendXSLTransform(DOMNode *stylesheet);
00227
00235 DSIGTransformC14n * appendCanonicalizationTransform(canonicalizationMethod cm);
00236
00250 void setPreHashTXFM(TXFMBase * t);
00251
00252
00254
00257
00270 XSECBinTXFMInputStream * makeBinInputStream(void) const;
00271
00279 const safeBuffer &getURISB();
00280
00287 bool isManifest();
00288
00296 DSIGReferenceList * getManifestReferenceList();
00297
00298
00300
00303
00316 unsigned int calculateHash(XMLByte * toFill,
00317 unsigned int maxToFill);
00318
00331 unsigned int readHash(XMLByte *toFill,
00332 unsigned int maxToFill);
00333
00344 bool checkHash();
00345
00354 void setHash();
00355
00357
00360
00380 static TXFMBase * DSIGReference::createTXFMChainFromList(TXFMBase * input,
00381 DSIGTransformList * lst);
00382
00395 static DSIGTransformList * loadTransforms(
00396 DOMNode *transformsNode,
00397 XSECSafeBufferFormatter * formatter,
00398 DSIGSignature * sig);
00399
00413 static TXFMBase * getURIBaseTXFM(DOMDocument * doc,
00414 safeBuffer URI,
00415 XSECURIResolver * resolver);
00416
00430 static DSIGReferenceList *loadReferenceListFromXML(DSIGSignature * sig,
00431 DOMNode *firstReference);
00432
00444 static bool verifyReferenceList(DSIGReferenceList * lst, safeBuffer &errorStr);
00445
00461 static void hashReferenceList(DSIGReferenceList * list, bool interlocking = true);
00462
00464
00465 private:
00466
00467
00468 void createTransformList(void);
00469 void addTransform(DSIGTransform * txfm, DOMElement * txfmElt);
00470
00471
00472 XSECSafeBufferFormatter * mp_formatter;
00473 bool formatterLocal;
00474 DOMNode * mp_referenceNode;
00475 TXFMBase * mp_preHash;
00476 DSIGReferenceList * mp_manifestList;
00477 safeBuffer m_URI;
00478 bool m_URISet;
00479 bool m_isManifest;
00480 DOMNode * mp_transformsNode;
00481 hashMethod me_hashMethod;
00482 DOMNode * mp_hashValueNode;
00483 DSIGSignature * mp_parentSignature;
00484 DSIGTransformList * mp_transformList;
00485
00486 DSIGReference();
00487
00488
00489 };
00490
00491
00492
00493