SignatureRequest.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 //  $Header: //DWF/Development/Components/Internal/DWF Toolkit/v7.6/develop/global/src/dwf/package/SignatureRequest.h#1 $
00019 //  $DateTime: 2008/02/20 08:38:28 $
00020 //  $Author: appacsviewers $
00021 //  $Change: 84992 $
00022 //  $Revision: #1 $
00023 //
00024 
00025 #ifndef _DWFTK_SIGNATURE_REQUEST_H
00026 #define _DWFTK_SIGNATURE_REQUEST_H
00027 
00032 
00033 #include "dwfcore/STL.h"
00034 #include "dwfcore/DWFXMLSerializer.h"
00035 #include "dwfcore/Vector.h"
00036 #include "dwfcore/SkipList.h"
00037 #include "dwfcore/DigestOutputStream.h"
00038 using namespace DWFCore;
00039 
00040 #include "dwf/Toolkit.h"
00041 #include "dwf/package/Signature.h"
00042 
00043 
00044 namespace DWFToolkit
00045 {
00046 
00047 // forward decl
00048 class DWFResource;
00049 class DWFSection;
00050 
00051 
00061 class DWFSignatureRequest
00062             : public DWFSignature
00063 #ifndef DWFTK_READ_ONLY
00064             , public DWFXMLSerializable
00065 #endif
00066             _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00067 {
00068     //
00069     // During writing, PackageWriter needs access to this class.
00070     //
00071     friend class DWFPackageWriter;
00072     friend class DWF6PackageWriter;
00073 
00074 public:
00078     typedef DWFOrderedVector<DWFSignatureRequest*>             tList;
00082     typedef DWFStringKeySkipList<DWFSignatureRequest*>         tMap;
00087     typedef DWFCachingIterator<DWFSignatureRequest*>           tCachingIterator;
00091     typedef DWFIterator<DWFSignatureRequest*>                  tIterator;
00092 
00093 public:
00094 
00102     class Reference : public DWFSignature::Reference
00103     {
00104         friend class DWFSignatureRequest;
00105 
00106     public:
00112         _DWFTK_API
00113         Reference()
00114             throw()
00115             : _pDigestOutputStream(NULL)
00116         {
00117             ;
00118         }
00119 
00125         _DWFTK_API
00126         virtual ~Reference()
00127             throw()
00128         {
00129             ;
00130         }
00131 
00134         //          for calculation of its digest.
00139         DWFDigestOutputStream* digestOutputStream()
00140             throw()
00141         {
00142             return _pDigestOutputStream;
00143         }
00144 
00147         //          for calculation of its digest.
00152         void setDigestOutputStream(DWFDigestOutputStream* pDigestOutputStream)
00153             throw( DWFException )
00154         {
00155             if(_pDigestOutputStream != NULL )
00156             {
00157                 _DWFCORE_THROW( DWFInvalidArgumentException, /*NOXLATE*/ L"Can't reassign digest streams." );
00158             }
00159 
00160             _pDigestOutputStream = pDigestOutputStream;
00161         }
00162 
00163 
00169         DWFSignatureRequest* signatureRequest()
00170         {
00171             return dynamic_cast<DWFSignatureRequest*>(DWFSignature::Reference::signature());
00172         }
00173 
00174 
00175     protected:
00182         void setSignatureRequest(DWFSignatureRequest* pSignatureRequest)
00183             throw( DWFException )
00184         {
00185             if(signatureRequest() != NULL )
00186             {
00187                 _DWFCORE_THROW( DWFInvalidArgumentException, /*NOXLATE*/ L"Can't re-use References." );
00188             }
00189 
00190             DWFSignature::Reference::setSignature(pSignatureRequest);
00191         }
00192 
00193     private:
00194 
00195         // The digest stream which will be used to compute our digest
00196         DWFDigestOutputStream*  _pDigestOutputStream;
00197     };
00198 
00206     class ConcreteReference : public Reference
00207     {
00208     public:
00214         _DWFTK_API
00215         ConcreteReference()
00216             throw();
00217 
00223         _DWFTK_API
00224         virtual ~ConcreteReference()
00225             throw();
00226 
00233         virtual const DWFResource* resource() const
00234             throw();
00235 
00242         virtual void setResource(const DWFResource* pResource)
00243             throw();
00244 
00248         virtual const DWFString& URI() const
00249             throw( DWFException );
00250 
00251     private:
00252         const DWFResource* _pResource;
00253     };
00254 
00262     class ForwardReference : public Reference
00263     {
00264     };
00265 
00273     class ManifestReference : public ForwardReference
00274     {
00275     public:
00281         _DWFTK_API
00282         ManifestReference()
00283             throw()
00284         {
00285             setURI(L"manifest.xml");
00286         }
00287 
00293         _DWFTK_API
00294         virtual ~ManifestReference()
00295             throw()
00296         {
00297             ;
00298         }
00299 
00300     };
00301 
00309     class SectionDescriptorReference : public ForwardReference
00310     {
00311     public:
00317         _DWFTK_API
00318         SectionDescriptorReference()
00319             throw()
00320             : _pSection(NULL)
00321         {
00322         }
00323 
00329         _DWFTK_API
00330         virtual ~SectionDescriptorReference()
00331             throw()
00332         {
00333         }
00334 
00341         virtual const DWFSection* section() const
00342             throw()
00343         {
00344             return _pSection;
00345         }
00346 
00353         virtual void setSection(const DWFSection* pSection)
00354             throw()
00355         {
00356             _pSection = pSection;
00357         }
00358 
00359     private:
00360         const DWFSection*    _pSection;
00361     };
00362 
00370     class SignatureRequestReference : public ForwardReference
00371     {
00372     public:
00378         _DWFTK_API
00379         SignatureRequestReference(const DWFSignatureRequest* pSignatureRequest=NULL)
00380             throw()
00381             : _pSignatureRequest(pSignatureRequest)
00382         {
00383         }
00384 
00390         _DWFTK_API
00391         virtual ~SignatureRequestReference()
00392             throw()
00393         {
00394         }
00395 
00402         virtual const DWFSignatureRequest* signatureRequest() const
00403             throw()
00404         {
00405             return _pSignatureRequest;
00406         }
00407 
00414         virtual void setSignatureRequest(const DWFSignatureRequest* pSignatureRequest)
00415             throw()
00416         {
00417             _pSignatureRequest = pSignatureRequest;
00418         }
00419 
00420     private:
00421         const DWFSignatureRequest*    _pSignatureRequest;
00422     };
00423 
00431     class ContentReference : public ForwardReference
00432     {
00433     public:
00439         _DWFTK_API
00440         ContentReference(const DWFContent* pContent=NULL)
00441             throw()
00442             : _pContent(pContent)
00443         {
00444         }
00445 
00451         _DWFTK_API
00452         virtual ~ContentReference()
00453             throw()
00454         {
00455         }
00456 
00463         virtual const DWFContent* content() const
00464             throw()
00465         {
00466             return _pContent;
00467         }
00468 
00475         virtual void setContent(const DWFContent* pContent)
00476             throw()
00477         {
00478             _pContent = pContent;
00479         }
00480 
00481     private:
00482         const DWFContent*    _pContent;
00483     };
00484 
00485 
00486 
00487 public:
00488 
00494     _DWFTK_API
00495     DWFSignatureRequest()
00496         throw();
00497 
00503     _DWFTK_API
00504     virtual ~DWFSignatureRequest()
00505         throw();
00506 
00513     _DWFTK_API
00514     void setPrivateKey(DWFCryptoKey* pPrivateKey)
00515         throw();
00516 
00517 
00518 #ifndef DWFTK_READ_ONLY
00519 
00523     _DWFTK_API
00524     virtual void serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00525         throw( DWFException );
00526 
00527 #endif
00528 
00529 
00530 private:
00531 
00538     _DWFTK_API
00539     DWFCryptoKey* privateKey() const
00540         throw()
00541     {
00542         return _pPrivateKey;
00543     }
00544 
00545 
00546     //
00547     // Returns the resource that will be associated with this request.
00548     //
00549     // The resource will be created the first time this method is called.
00550     //
00551     DWFResource* resource()
00552         throw();
00553 
00554 
00555 private:
00556     float                   _nVersion;
00557     DWFResource*            _pResource;
00558     DWFCryptoKey*           _pPrivateKey;
00559 
00560 
00561 private:
00562 
00563     DWFSignatureRequest( const DWFSignatureRequest& );
00564     DWFSignatureRequest& operator=( const DWFSignatureRequest& );
00565 };
00566 
00567 }
00568 
00569 #endif
00570 

Generated on Tue Jan 6 22:40:05 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5