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  * The Apache Software License, Version 1.1
00003  *
00004  *
00005  * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights 
00006  * reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer. 
00014  *
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in
00017  *    the documentation and/or other materials provided with the
00018  *    distribution.
00019  *
00020  * 3. The end-user documentation included with the redistribution,
00021  *    if any, must include the following acknowledgment:  
00022  *       "This product includes software developed by the
00023  *        Apache Software Foundation (http://www.apache.org/)."
00024  *    Alternately, this acknowledgment may appear in the software itself,
00025  *    if and wherever such third-party acknowledgments normally appear.
00026  *
00027  * 4. The names "<WebSig>" and "Apache Software Foundation" must
00028  *    not be used to endorse or promote products derived from this
00029  *    software without prior written permission. For written 
00030  *    permission, please contact apache@apache.org.
00031  *
00032  * 5. Products derived from this software may not be called "Apache",
00033  *    nor may "Apache" appear in their name, without prior written
00034  *    permission of the Apache Software Foundation.
00035  *
00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00039  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00040  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00041  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00042  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00043  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00044  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00045  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00046  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00047  * SUCH DAMAGE.
00048  * ====================================================================
00049  *
00050  * This software consists of voluntary contributions made by many
00051  * individuals on behalf of the Apache Software Foundation and was
00052  * originally based on software copyright (c) 2001, Institute for
00053  * Data Communications Systems, <http://www.nue.et-inf.uni-siegen.de/>.
00054  * The development of this software was partly funded by the European 
00055  * Commission in the <WebSig> project in the ISIS Programme. 
00056  * For more information on the Apache Software Foundation, please see
00057  * <http://www.apache.org/>.
00058  */
00059 
00060 /*
00061  * XSEC
00062  *
00063  * DSIG_Reference := Class for checking and setting up reference nodes in a DSIG signature
00064  *
00065  * Author(s): Berin Lautenbach
00066  *
00067  * $ID$
00068  *
00069  * $LOG$
00070  *                   
00071  */
00072 
00073 // High level include
00074 #include <xsec/framework/XSECDefs.hpp>
00075 
00076 // Xerces INcludes
00077 
00078 #include <xercesc/dom/DOM.hpp>
00079 #include <xercesc/dom/DOMNamedNodeMap.hpp>
00080 
00081 // XSEC Includes
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();     // Return list of references for a manifest object
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     // Internal functions
00522     void createTransformList(void);
00523     void addTransform(DSIGTransform * txfm, DOMElement * txfmElt);
00524 
00525 
00526     XSECSafeBufferFormatter     * mp_formatter;
00527     bool formatterLocal;
00528     DOMNode                     * mp_referenceNode;     // Points to start of document where reference node is
00529     TXFMBase                    * mp_preHash;           // To be used pre-hash
00530     DSIGReferenceList           * mp_manifestList;      // The list of references in a manifest
00531     const XMLCh                 * mp_URI;               // The URI String
00532     bool                        m_isManifest;           // Does this reference a manifest?
00533     DOMNode                     * mp_transformsNode;
00534     hashMethod                  me_hashMethod;          // What form of digest?
00535     DOMNode                     * mp_hashValueNode;     // Node where the Hash value is stored
00536     DSIGSignature               * mp_parentSignature;   // Owner signature
00537     DSIGTransformList           * mp_transformList;     // List of transforms
00538     
00539     bool                        m_loaded;
00540 
00541     DSIGReference();
00542 
00543     /*\@}*/
00544 };
00545 
00546 
00547 
00548 

Generated on Sat Aug 9 18:36:25 2003 for XML-Security-C by doxygen 1.3.2