EnvelopedData.h
Go to the documentation of this file.00001
00009 #ifndef __ENVELOPEDDATA_H__
00010 #define __ENVELOPEDDATA_H__
00011
00012 #include "PKIFCMSDLL.h"
00013 #include "PKIFMediators.h"
00014 #include "IPKIFHasAttributes.h"
00015 #include "PKIFCMSUtils.h"
00016 #include "components.h"
00017 #include "OID.h"
00018 #include "ContentType.h"
00019
00020 FD_LIST_PTR(CPKIFCertificate);
00021 FD_LIST_PTR(CPKIFCRL);
00022 FD_LIST_PTR(CPKIFRecipientInfo);
00023 FD_SMART_PTR(CPKIFCertificatePath);
00024 FD_SMART_PTR(CPKIFKEKRecipInfoDetails);
00025 FD_SMART_PTR(CPKIFPathValidationResults);
00026 FD_SMART_PTR(CPKIFEncryptedContentInfo);
00027 FD_SMART_PTR(CPKIFPathSettings);
00028 FD_SMART_PTR(CPKIFCredential);
00029 FD_SMART_PTR(CPKIFKARIDetails);
00030 template<class T> class CPKIFASNWrapper;
00031
00056 class PKIFCMS_API CPKIFEnvelopedData : public IPKIFHasAttributes, public CPKIFContentType
00057 {
00058 friend struct CPKIFEnvelopedDataImpl;
00059 public:
00060
00061
00062 typedef enum {
00063 CMSv0 = 0,
00064 CMSv1 = 1,
00065 CMSv2 = 2,
00066 CMSv3 = 3,
00067 CMSv4 = 4
00068 } CMSVersion;
00069
00070
00071
00072
00073 CPKIFEnvelopedData();
00074 virtual ~CPKIFEnvelopedData();
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 CMSVersion GetVersion() const;
00114
00115
00116 void AddOriginatorCertificate(CPKIFCertificatePtr& cert);
00117 void AddOriginatorCRL(CPKIFCRLPtr& crl);
00118
00119 void SetOriginatorCredential(CPKIFCredentialPtr & cred);
00120
00121 void GetOriginatorCertificates(CPKIFCertificateList& certs);
00122 void GetOriginatorCRLs(CPKIFCRLList& crls);
00123
00124 void GetRecipientInfos(CPKIFRecipientInfoList& recipInfos) const;
00125
00126
00127 void AddRecipient(CPKIFCertificatePtr& cert, CMSPathValidationStatus minStatus = PVS_REV_STATUS_VERIFIED);
00128 void AddRecipient(CPKIFCertificatePtr& cert, CPKIFCertificatePathPtr& path, CPKIFPathValidationResultsPtr& valResults, CMSPathValidationStatus minStatus = PVS_REV_STATUS_VERIFIED);
00129 void AddRecipient(CPKIFKEKRecipInfoDetailsPtr& kek);
00130
00131
00132
00133 void SetDataToEncrypt(CPKIFEncryptedContentInfoPtr& buf);
00134 CPKIFEncryptedContentInfoPtr GetEncryptedData() const;
00135
00136
00137 void AddUnprotectedAttribute(CPKIFAttributePtr& attr);
00138
00139 void GetUnprotectedAttributes(CPKIFAttributeList& ual);
00140
00141
00142 void GetEncodedUnprotectedAttributes (CPKIFBufferPtr& buf);
00143
00144
00145
00146
00147 void _GetUnprotectedAttributes(std::vector<CPKIFAttributePtr> attrVector);
00148
00149 template <class T> boost::shared_ptr<T> GetUnprotectedAttribute();
00150
00151 void ClearContent();
00152
00153 void SetAlgorithmAndMode(PKIFCRYPTO::SYMKEY_ALG alg, PKIFCRYPTO::SYMKEY_MODE mode);
00154 PKIFCRYPTO::SYMKEY_ALG GetAlgorithm() const;
00155 PKIFCRYPTO::SYMKEY_MODE GetMode() const;
00156
00157
00158
00159
00160 CPKIFBufferPtr Encode();
00161 void Decode(CPKIFBufferPtr& buf);
00162
00163
00164
00165
00166 void SetPathSettings(CPKIFPathSettingsPtr& settings);
00167 CPKIFBufferPtr Decrypt(CPKIFCredentialPtr& cred);
00168 CPKIFBufferPtr Decrypt(CPKIFKEKRecipInfoDetailsPtr& kek);
00169 void GetAddedUnprotectedAttributes(std::vector<CPKIFAttributePtr>& attr);
00170
00171 void SetMediator(IPKIFMediatorPtr& m);
00172 IPKIFMediatorPtr GetMediator();
00173 private:
00175 CPKIFEnvelopedData(const CPKIFEnvelopedData& copy);
00177 CPKIFEnvelopedData& operator=(const CPKIFEnvelopedData& rhs);
00178
00179 enum {thisComponent=TOOLKIT_MESSAGE_ENVELOPED_DATA};
00180
00181 struct CPKIFEnvelopedDataImpl *m_impl;
00182
00183
00184 };
00185 DECLARE_SMART_POINTERS(CPKIFEnvelopedData)
00186
00187
00196 template <class T> boost::shared_ptr<T> CPKIFEnvelopedData::GetUnprotectedAttribute()
00197
00198 {
00199
00200
00201 std::vector<CPKIFAttributePtr> attrVector;
00202
00203
00204
00205 _GetUnprotectedAttributes(attrVector);
00206
00207
00208
00209 CPKIFStringPtr oidStr(new std::string(T::extOID));
00210 CPKIFOID oid(oidStr);
00211
00212 CPKIFAttribute* p = NULL;
00213 CPKIFAttributeList::iterator pos;
00214 CPKIFAttributeList::iterator end = attrVector.end();
00215 for(pos = attrVector.begin(); pos != end; ++pos)
00216 {
00217 p = &(*(*pos));
00218 if(oid == (*pos)->GetOID() && NULL != dynamic_cast<T*>(p))
00219 {
00220 return *((boost::shared_ptr<T>*)&(*pos));
00221 }
00222 }
00223
00224 boost::shared_ptr<T> nullExt;
00225 return nullExt;
00226 }
00227
00228 #endif