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

DSIGReference.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2002-2005 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  * limitations 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 394035 2006-04-14 06:53:07Z blautenb $
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 
00067 class DSIG_EXPORT DSIGReference {
00068 
00069 public:
00070 
00073     
00090     DSIGReference(const XSECEnv * env, XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *dom);
00091 
00106     DSIGReference(const XSECEnv * env);
00107 
00117     ~DSIGReference();
00118 
00120 
00123 
00132     void load();
00133 
00154     XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * 
00155         createBlankReference(const XMLCh * URI, hashMethod hm, char * type);
00156 
00176     XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * 
00177         createBlankReference(const XMLCh * URI, 
00178             const XMLCh * hashAlgorithmURI, 
00179             const XMLCh * type);
00180 
00191     DSIGTransformEnvelope *  appendEnvelopedSignatureTransform();
00192     
00199     DSIGTransformBase64 * appendBase64Transform();
00200     
00212     DSIGTransformXPath * appendXPathTransform(const char * expr);
00213     
00224     DSIGTransformXPathFilter * appendXPathFilterTransform(void);
00225 
00236     DSIGTransformXSL * appendXSLTransform(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *stylesheet);
00237     
00245     DSIGTransformC14n * appendCanonicalizationTransform(
00246         const XMLCh * canonicalizationAlgorithmURI
00247     );
00248 
00257     DSIGTransformC14n * appendCanonicalizationTransform(canonicalizationMethod cm);
00258 
00272     void setPreHashTXFM(TXFMBase * t);
00273 
00274 
00276 
00279 
00292     XSECBinTXFMInputStream * makeBinInputStream(void) const;
00293 
00301     const XMLCh * getURI();
00302 
00311     hashMethod getHashMethod(void) {
00312         return me_hashMethod;
00313     }
00314 
00322     DSIGTransformList * getTransforms(void) {
00323         return mp_transformList;
00324     }
00325 
00332     bool isManifest();
00333 
00341     DSIGReferenceList * getManifestReferenceList();     // Return list of references for a manifest object
00342 
00343 
00345     
00348 
00361     unsigned int calculateHash(XMLByte * toFill, 
00362                             unsigned int maxToFill);
00363 
00376     unsigned int readHash(XMLByte *toFill,          
00377                             unsigned int maxToFill);
00378 
00389     bool checkHash();
00390 
00399     void setHash();
00400 
00402 
00405 
00425     static TXFMChain * createTXFMChainFromList(TXFMBase * input, 
00426                             DSIGTransformList * lst);
00427 
00440     static DSIGTransformList * loadTransforms(
00441                             XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *transformsNode,
00442                             XSECSafeBufferFormatter * formatter,
00443                             const XSECEnv * env);
00444 
00457     static TXFMBase * getURIBaseTXFM(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc, 
00458                                     const XMLCh * URI, 
00459                                     const XSECEnv * env);
00460 
00474     static DSIGReferenceList *loadReferenceListFromXML(const XSECEnv * env, 
00475                                                        XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *firstReference);
00476 
00488     static bool verifyReferenceList(DSIGReferenceList * lst, safeBuffer &errorStr);
00489     
00505     static void hashReferenceList(DSIGReferenceList * list, bool interlocking = true);
00506 
00508 
00509 private:
00510 
00511     // Internal functions
00512     void createTransformList(void);
00513     void addTransform(
00514         DSIGTransform * txfm, 
00515         XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * txfmElt
00516     );
00517 
00518 
00519     XSECSafeBufferFormatter     * mp_formatter;
00520     bool formatterLocal;
00521     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode                      
00522                                 * mp_referenceNode;     // Points to start of document where reference node is
00523     TXFMBase                    * mp_preHash;           // To be used pre-hash
00524     DSIGReferenceList           * mp_manifestList;      // The list of references in a manifest
00525     const XMLCh                 * mp_URI;               // The URI String
00526     bool                        m_isManifest;           // Does this reference a manifest?
00527     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode                      
00528                                 * mp_transformsNode;
00529     hashMethod                  me_hashMethod;          // What form of digest?
00530     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode                      
00531                                 * mp_hashValueNode;     // Node where the Hash value is stored
00532     const XSECEnv               * mp_env;
00533     DSIGTransformList           * mp_transformList;     // List of transforms
00534     const XMLCh                 * mp_algorithmURI;      // Hash algorithm for this reference
00535     
00536     bool                        m_loaded;
00537 
00538     DSIGReference();
00539 
00540     /*\@}*/
00541 };
00542 
00543 
00544 
00545 

Generated on Sun Jan 28 19:37:22 2007 for XML-Security-C by  doxygen 1.4.2