Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

DSIGReference.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2002-2004 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * imitations under the License.
00015  */
00016 
00017 /*
00018  * XSEC
00019  *
00020  * DSIG_Reference := Class for checking and setting up reference nodes in a DSIG signature
00021  *
00022  * $Id: DSIGReference.hpp,v 1.14 2004/02/29 06:39:44 blautenb Exp $
00023  *                   
00024  */
00025 
00026 // High level include
00027 #include <xsec/framework/XSECDefs.hpp>
00028 
00029 // Xerces INcludes
00030 
00031 #include <xercesc/dom/DOM.hpp>
00032 #include <xercesc/dom/DOMNamedNodeMap.hpp>
00033 
00034 // XSEC Includes
00035 #include <xsec/utils/XSECSafeBufferFormatter.hpp>
00036 #include <xsec/dsig/DSIGTransform.hpp>
00037 #include <xsec/dsig/DSIGReferenceList.hpp>
00038 #include <xsec/dsig/DSIGConstants.hpp>
00039 
00040 class DSIGTransformList;
00041 class DSIGTransformBase64;
00042 class DSIGTransformC14n;
00043 class DSIGTransformEnvelope;
00044 class DSIGTransformXPath;
00045 class DSIGTransformXPathFilter;
00046 class DSIGTransformXSL;
00047 class DSIGSignature;
00048 
00049 class TXFMBase;
00050 class TXFMChain;
00051 class XSECBinTXFMInputStream;
00052 class XSECURIResolver;
00053 class XSECEnv;
00054 
00068 class DSIG_EXPORT DSIGReference {
00069 
00070 public:
00071 
00074     
00091     DSIGReference(const XSECEnv * env, XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *dom);
00092 
00107     DSIGReference(const XSECEnv * env);
00108 
00118     ~DSIGReference();
00119 
00121 
00124 
00133     void load();
00134 
00154     XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * 
00155         createBlankReference(const XMLCh * URI, hashMethod hm, char * type);
00156 
00167     DSIGTransformEnvelope *  appendEnvelopedSignatureTransform();
00168     
00175     DSIGTransformBase64 * appendBase64Transform();
00176     
00188     DSIGTransformXPath * appendXPathTransform(const char * expr);
00189     
00200     DSIGTransformXPathFilter * appendXPathFilterTransform(void);
00201 
00212     DSIGTransformXSL * appendXSLTransform(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *stylesheet);
00213     
00221     DSIGTransformC14n * appendCanonicalizationTransform(canonicalizationMethod cm);
00222 
00236     void setPreHashTXFM(TXFMBase * t);
00237 
00238 
00240 
00243 
00256     XSECBinTXFMInputStream * makeBinInputStream(void) const;
00257 
00265     const XMLCh * getURI();
00266 
00275     hashMethod getHashMethod(void) {
00276         return me_hashMethod;
00277     }
00278 
00286     DSIGTransformList * getTransforms(void) {
00287         return mp_transformList;
00288     }
00289 
00296     bool isManifest();
00297 
00305     DSIGReferenceList * getManifestReferenceList();     // Return list of references for a manifest object
00306 
00307 
00309     
00312 
00325     unsigned int calculateHash(XMLByte * toFill, 
00326                             unsigned int maxToFill);
00327 
00340     unsigned int readHash(XMLByte *toFill,          
00341                             unsigned int maxToFill);
00342 
00353     bool checkHash();
00354 
00363     void setHash();
00364 
00366 
00369 
00389     static TXFMChain * DSIGReference::createTXFMChainFromList(TXFMBase * input, 
00390                             DSIGTransformList * lst);
00391 
00404     static DSIGTransformList * loadTransforms(
00405                             XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *transformsNode,
00406                             XSECSafeBufferFormatter * formatter,
00407                             const XSECEnv * env);
00408 
00421     static TXFMBase * getURIBaseTXFM(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc, 
00422                                     const XMLCh * URI, 
00423                                     const XSECEnv * env);
00424 
00438     static DSIGReferenceList *loadReferenceListFromXML(const XSECEnv * env, 
00439                                                        XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *firstReference);
00440 
00452     static bool verifyReferenceList(DSIGReferenceList * lst, safeBuffer &errorStr);
00453     
00469     static void hashReferenceList(DSIGReferenceList * list, bool interlocking = true);
00470 
00472 
00473 private:
00474 
00475     // Internal functions
00476     void createTransformList(void);
00477     void addTransform(
00478         DSIGTransform * txfm, 
00479         XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * txfmElt
00480     );
00481 
00482 
00483     XSECSafeBufferFormatter     * mp_formatter;
00484     bool formatterLocal;
00485     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode                      
00486                                 * mp_referenceNode;     // Points to start of document where reference node is
00487     TXFMBase                    * mp_preHash;           // To be used pre-hash
00488     DSIGReferenceList           * mp_manifestList;      // The list of references in a manifest
00489     const XMLCh                 * mp_URI;               // The URI String
00490     bool                        m_isManifest;           // Does this reference a manifest?
00491     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode                      
00492                                 * mp_transformsNode;
00493     hashMethod                  me_hashMethod;          // What form of digest?
00494     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode                      
00495                                 * mp_hashValueNode;     // Node where the Hash value is stored
00496     const XSECEnv               * mp_env;
00497     DSIGTransformList           * mp_transformList;     // List of transforms
00498     
00499     bool                        m_loaded;
00500 
00501     DSIGReference();
00502 
00503     /*\@}*/
00504 };
00505 
00506 
00507 
00508 

Generated on Sun Mar 14 20:20:34 2004 for XML-Security-C by doxygen 1.3.2