TimeStampRequest.h

Go to the documentation of this file.
00001 
00009 #ifndef __TIMESTAMPREQUEST_H__
00010 #define __TIMESTAMPREQUEST_H__
00011 
00012 #include "PKIFTSPDLL.h"
00013 #include "IPKIFHasExtensions.h"
00014 
00015 // forward declarations
00016 struct CPKIFTimeStampRequestImpl;
00017 FD_SMART_PTR(CPKIFMessageImprint);
00018 
00037 class PKIFTSP_API CPKIFTimeStampRequest: public IPKIFHasExtensions
00038 {
00039 public:
00040     CPKIFTimeStampRequest();
00041     virtual ~CPKIFTimeStampRequest(void);
00042 
00043     //version is always 1 when encoding - hence no Set function
00044     int GetVersion() const;
00045 
00046     //required field
00047     void SetMessageImprint(CPKIFMessageImprintPtr& messageImprint);
00048     CPKIFMessageImprintPtr GetMessageImprint() const;
00049 
00050     //optional field
00051     void SetPolicy(CPKIFOIDPtr& policy);
00052     CPKIFOIDPtr GetPolicy() const;
00053 
00054     //optional field
00055     void SetNonce(CPKIFStringPtr& nonce); //nonce format must be ASCII Hex preceded by 0x
00056     const char* GetNonce() const;
00057 
00058     //convenience function to trigger automatic generation and inclusion
00059     //of a random nonce.  the mediator param allows caller to control what
00060     //random number generator will be used.  if m is NULL (or does not contain
00061     //the IPKIFCryptoMisc interface) then an instance of CPKIFCAPIRaw will be 
00062     //used to produce the nonce.  The value passed as m MUST NOT be destroyed
00063     //prior to calling encode.
00064     void SetGenerateNonce(bool generateNonce, IPKIFMediator* m = NULL);
00065     bool GetGenerateNonce() const;
00066 
00067     //required field - default false
00068     void SetReqCert(bool reqCert);
00069     bool GetReqCert() const;
00070 
00071     //optional field - this version of PKIF does not support encoding extensions in TSP structures
00072     //void AddExtension(CPKIFX509ExtensionPtr& ext);
00073 
00074     //convenience function to allow quick failure in the TSA (the prototype TSA built using PKIF
00075     //does not and will not support TSP extensions)
00076     bool ExtensionsPresent() const;
00077 
00078 
00079     template <class T> boost::shared_ptr<T> GetExtension();
00080 
00081     CPKIFBufferPtr Encode() const;
00082     void Decode(CPKIFBufferPtr& msg);
00083 
00084     void GetExtensionByOID(const CPKIFOID& oid, CPKIFX509ExtensionPtr& ref);
00085     void GetEncodedExtensions (CPKIFBufferPtr& buf);
00086 private:
00088     CPKIFTimeStampRequest(const CPKIFTimeStampRequest& copy);
00090     CPKIFTimeStampRequest& operator=(const CPKIFTimeStampRequest& rhs); //added 4/6/2004
00091 
00092     struct CPKIFTimeStampRequestImpl *m_impl;
00093 };
00094 DECLARE_SMART_POINTERS(CPKIFTimeStampRequest);
00096 //@b Interface: External
00097 //
00098 //This function is used to get an extension contained by a TimeStampRequest object.
00099 //
00100 //@return A smart pointer to an appropriate extension
00101 //*/
00102 //template <typename T>
00103 //shared_ptr<T> CPKIFTimeStampRequest::GetExtension()
00104 //{
00105 //    CPKIFX509ExtensionPtr ext;
00106 //    CPKIFStringPtr oidStr(new std::string(T::extOID));
00107 //    CPKIFOID oid(oidStr);
00108 //    GetExtensionByOID(oid,ext);
00109 //
00110 //    if(ext && 0 != dynamic_cast<T*>(ext.get())){
00111 //  return *((shared_ptr<T>*)&(ext));
00112 //    }
00113 //
00114 //    shared_ptr<T> nullExt;
00115 //    return nullExt;
00116 //}
00117 
00118 
00119 /*template <class T> shared_ptr<T> CPKIFTimeStampRequest::GetExtension()
00120 
00121 {
00122     if(m_exts.empty() && 0 != m_signedCert->toBeSigned.extensions.count)
00123         populateExtensionsVector();
00124 
00125     CPKIFStringPtr oidStr(new std::string(T::extOID));
00126     CPKIFOID oid(oidStr);
00127 
00128     CPKIFX509Extension* p = NULL;
00129     vector<CPKIFX509ExtensionPtr>::iterator pos;
00130     vector<CPKIFX509ExtensionPtr>::iterator end = m_exts.end();
00131     for(pos = m_exts.begin(); pos != end; ++pos)
00132     {
00133         p = &(*(*pos));
00134         if(oid == (*pos)->oid() && NULL != dynamic_cast<T*>(p))
00135         {
00136             return *((shared_ptr<T>*)&(*pos));
00137         }
00138     }       
00139 
00140 
00141     shared_ptr<T> nullExt;
00142 
00143     return nullExt;
00144 }
00145 */
00146 #endif //__TIMESTAMPREQUEST_H__

Generated on Mon Nov 15 11:15:56 2010 for PublicKeyInfrastructureFramework(PKIF) by  doxygen 1.5.6