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
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 #include <xsec/framework/XSECDefs.hpp>
00075
00076
00077
00078 #include <xercesc/dom/DOM.hpp>
00079 #include <xercesc/dom/DOMNamedNodeMap.hpp>
00080
00081
00082 #include <xsec/utils/XSECSafeBufferFormatter.hpp>
00083 #include <xsec/dsig/DSIGTransform.hpp>
00084 #include <xsec/dsig/DSIGReferenceList.hpp>
00085 #include <xsec/dsig/DSIGConstants.hpp>
00086
00087 class DSIGTransformList;
00088 class DSIGTransformBase64;
00089 class DSIGTransformC14n;
00090 class DSIGTransformEnvelope;
00091 class DSIGTransformXPath;
00092 class DSIGTransformXPathFilter;
00093 class DSIGTransformXSL;
00094 class DSIGSignature;
00095
00096 class TXFMBase;
00097 class TXFMChain;
00098 class XSECBinTXFMInputStream;
00099 class XSECURIResolver;
00100
00114 class DSIG_EXPORT DSIGReference {
00115
00116 public:
00117
00120
00137 DSIGReference(DSIGSignature * sig, DOMNode *dom);
00138
00153 DSIGReference(DSIGSignature * sig);
00154
00164 ~DSIGReference();
00165
00167
00170
00179 void load();
00180
00200 DOMElement * createBlankReference(const XMLCh * URI, hashMethod hm, char * type);
00201
00212 DSIGTransformEnvelope * appendEnvelopedSignatureTransform();
00213
00220 DSIGTransformBase64 * appendBase64Transform();
00221
00233 DSIGTransformXPath * appendXPathTransform(const char * expr);
00234
00245 DSIGTransformXPathFilter * appendXPathFilterTransform(void);
00246
00257 DSIGTransformXSL * appendXSLTransform(DOMNode *stylesheet);
00258
00266 DSIGTransformC14n * appendCanonicalizationTransform(canonicalizationMethod cm);
00267
00281 void setPreHashTXFM(TXFMBase * t);
00282
00283
00285
00288
00301 XSECBinTXFMInputStream * makeBinInputStream(void) const;
00302
00310 const XMLCh * getURI();
00311
00320 hashMethod getHashMethod(void) {
00321 return me_hashMethod;
00322 }
00323
00331 DSIGTransformList * getTransforms(void) {
00332 return mp_transformList;
00333 }
00334
00341 bool isManifest();
00342
00350 DSIGReferenceList * getManifestReferenceList();
00351
00352
00354
00357
00370 unsigned int calculateHash(XMLByte * toFill,
00371 unsigned int maxToFill);
00372
00385 unsigned int readHash(XMLByte *toFill,
00386 unsigned int maxToFill);
00387
00398 bool checkHash();
00399
00408 void setHash();
00409
00411
00414
00434 static TXFMChain * DSIGReference::createTXFMChainFromList(TXFMBase * input,
00435 DSIGTransformList * lst);
00436
00449 static DSIGTransformList * loadTransforms(
00450 DOMNode *transformsNode,
00451 XSECSafeBufferFormatter * formatter,
00452 DSIGSignature * sig);
00453
00467 static TXFMBase * getURIBaseTXFM(DOMDocument * doc,
00468 const XMLCh * URI,
00469 XSECURIResolver * resolver);
00470
00484 static DSIGReferenceList *loadReferenceListFromXML(DSIGSignature * sig,
00485 DOMNode *firstReference);
00486
00498 static bool verifyReferenceList(DSIGReferenceList * lst, safeBuffer &errorStr);
00499
00515 static void hashReferenceList(DSIGReferenceList * list, bool interlocking = true);
00516
00518
00519 private:
00520
00521
00522 void createTransformList(void);
00523 void addTransform(DSIGTransform * txfm, DOMElement * txfmElt);
00524
00525
00526 XSECSafeBufferFormatter * mp_formatter;
00527 bool formatterLocal;
00528 DOMNode * mp_referenceNode;
00529 TXFMBase * mp_preHash;
00530 DSIGReferenceList * mp_manifestList;
00531 const XMLCh * mp_URI;
00532 bool m_isManifest;
00533 DOMNode * mp_transformsNode;
00534 hashMethod me_hashMethod;
00535 DOMNode * mp_hashValueNode;
00536 DSIGSignature * mp_parentSignature;
00537 DSIGTransformList * mp_transformList;
00538
00539 bool m_loaded;
00540
00541 DSIGReference();
00542
00543
00544 };
00545
00546
00547
00548