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 DSIGTransformXSL;
00093 class DSIGSignature;
00094
00095 class TXFMBase;
00096 class TXFMChain;
00097 class XSECBinTXFMInputStream;
00098 class XSECURIResolver;
00099
00113 class DSIG_EXPORT DSIGReference {
00114
00115 public:
00116
00119
00136 DSIGReference(DSIGSignature * sig, DOMNode *dom);
00137
00152 DSIGReference(DSIGSignature * sig);
00153
00163 ~DSIGReference();
00164
00166
00169
00178 void load();
00179
00198 DOMElement * createBlankReference(const XMLCh * URI, hashMethod hm, char * type);
00199
00210 DSIGTransformEnvelope * appendEnvelopedSignatureTransform();
00211
00218 DSIGTransformBase64 * appendBase64Transform();
00219
00231 DSIGTransformXPath * appendXPathTransform(char * expr);
00232
00243 DSIGTransformXSL * appendXSLTransform(DOMNode *stylesheet);
00244
00252 DSIGTransformC14n * appendCanonicalizationTransform(canonicalizationMethod cm);
00253
00267 void setPreHashTXFM(TXFMBase * t);
00268
00269
00271
00274
00287 XSECBinTXFMInputStream * makeBinInputStream(void) const;
00288
00296 const XMLCh * getURI();
00297
00306 hashMethod getHashMethod(void) {
00307 return me_hashMethod;
00308 }
00309
00317 DSIGTransformList * getTransforms(void) {
00318 return mp_transformList;
00319 }
00320
00327 bool isManifest();
00328
00336 DSIGReferenceList * getManifestReferenceList();
00337
00338
00340
00343
00356 unsigned int calculateHash(XMLByte * toFill,
00357 unsigned int maxToFill);
00358
00371 unsigned int readHash(XMLByte *toFill,
00372 unsigned int maxToFill);
00373
00384 bool checkHash();
00385
00394 void setHash();
00395
00397
00400
00420 static TXFMChain * DSIGReference::createTXFMChainFromList(TXFMBase * input,
00421 DSIGTransformList * lst);
00422
00435 static DSIGTransformList * loadTransforms(
00436 DOMNode *transformsNode,
00437 XSECSafeBufferFormatter * formatter,
00438 DSIGSignature * sig);
00439
00453 static TXFMBase * getURIBaseTXFM(DOMDocument * doc,
00454 const XMLCh * URI,
00455 XSECURIResolver * resolver);
00456
00470 static DSIGReferenceList *loadReferenceListFromXML(DSIGSignature * sig,
00471 DOMNode *firstReference);
00472
00484 static bool verifyReferenceList(DSIGReferenceList * lst, safeBuffer &errorStr);
00485
00501 static void hashReferenceList(DSIGReferenceList * list, bool interlocking = true);
00502
00504
00505 private:
00506
00507
00508 void createTransformList(void);
00509 void addTransform(DSIGTransform * txfm, DOMElement * txfmElt);
00510
00511
00512 XSECSafeBufferFormatter * mp_formatter;
00513 bool formatterLocal;
00514 DOMNode * mp_referenceNode;
00515 TXFMBase * mp_preHash;
00516 DSIGReferenceList * mp_manifestList;
00517 const XMLCh * mp_URI;
00518 bool m_isManifest;
00519 DOMNode * mp_transformsNode;
00520 hashMethod me_hashMethod;
00521 DOMNode * mp_hashValueNode;
00522 DSIGSignature * mp_parentSignature;
00523 DSIGTransformList * mp_transformList;
00524
00525 DSIGReference();
00526
00527
00528 };
00529
00530
00531
00532