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) 1999 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 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 
00304     bool isManifest();
00305 
00313     DSIGReferenceList * getManifestReferenceList();     // Return list of references for a manifest object
00314 
00315 
00317     
00320 
00333     unsigned int calculateHash(XMLByte * toFill, 
00334                             unsigned int maxToFill);
00335 
00348     unsigned int readHash(XMLByte *toFill,          
00349                             unsigned int maxToFill);
00350 
00361     bool checkHash();
00362 
00371     void setHash();
00372 
00374 
00377 
00397     static TXFMChain * DSIGReference::createTXFMChainFromList(TXFMBase * input, 
00398                             DSIGTransformList * lst);
00399 
00412     static DSIGTransformList * loadTransforms(
00413                             DOMNode *transformsNode,
00414                             XSECSafeBufferFormatter * formatter,
00415                             DSIGSignature * sig);
00416 
00430     static TXFMBase * getURIBaseTXFM(DOMDocument * doc, 
00431                                     const XMLCh * URI, 
00432                                     XSECURIResolver * resolver);
00433 
00447     static DSIGReferenceList *loadReferenceListFromXML(DSIGSignature * sig, 
00448                                                        DOMNode *firstReference);
00449 
00461     static bool verifyReferenceList(DSIGReferenceList * lst, safeBuffer &errorStr);
00462     
00478     static void hashReferenceList(DSIGReferenceList * list, bool interlocking = true);
00479 
00481 
00482 private:
00483 
00484     // Internal functions
00485     void createTransformList(void);
00486     void addTransform(DSIGTransform * txfm, DOMElement * txfmElt);
00487 
00488 
00489     XSECSafeBufferFormatter     * mp_formatter;
00490     bool formatterLocal;
00491     DOMNode                     * mp_referenceNode;     // Points to start of document where reference node is
00492     TXFMBase                    * mp_preHash;           // To be used pre-hash
00493     DSIGReferenceList           * mp_manifestList;      // The list of references in a manifest
00494     const XMLCh                 * mp_URI;               // The URI String
00495     bool                        m_isManifest;           // Does this reference a manifest?
00496     DOMNode                     * mp_transformsNode;
00497     hashMethod                  me_hashMethod;          // What form of digest?
00498     DOMNode                     * mp_hashValueNode;     // Node where the Hash value is stored
00499     DSIGSignature               * mp_parentSignature;   // Owner signature
00500     DSIGTransformList           * mp_transformList;     // List of transforms
00501 
00502     DSIGReference();
00503 
00504     /*\@}*/
00505 };
00506 
00507 
00508 
00509 

Generated on Wed Mar 26 20:11:50 2003 for XML-Security-C by doxygen1.2.15