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 
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();     // Return list of references for a manifest object
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     // Internal functions
00508     void createTransformList(void);
00509     void addTransform(DSIGTransform * txfm, DOMElement * txfmElt);
00510 
00511 
00512     XSECSafeBufferFormatter     * mp_formatter;
00513     bool formatterLocal;
00514     DOMNode                     * mp_referenceNode;     // Points to start of document where reference node is
00515     TXFMBase                    * mp_preHash;           // To be used pre-hash
00516     DSIGReferenceList           * mp_manifestList;      // The list of references in a manifest
00517     const XMLCh                 * mp_URI;               // The URI String
00518     bool                        m_isManifest;           // Does this reference a manifest?
00519     DOMNode                     * mp_transformsNode;
00520     hashMethod                  me_hashMethod;          // What form of digest?
00521     DOMNode                     * mp_hashValueNode;     // Node where the Hash value is stored
00522     DSIGSignature               * mp_parentSignature;   // Owner signature
00523     DSIGTransformList           * mp_transformList;     // List of transforms
00524 
00525     DSIGReference();
00526 
00527     /*\@}*/
00528 };
00529 
00530 
00531 
00532 

Generated on Wed May 7 21:43:50 2003 for XML-Security-C by doxygen1.2.18