TimestampAttribute.cpp
Go to the documentation of this file.00001
00009 #include "TimestampAttribute.h"
00010
00011 #include "ContentInfo.h"
00012 #include "Buffer.h"
00013
00014 #include "ASN1Helper.h"
00015 #include "ToolkitUtils.h"
00016 #include "PKIFMessageException.h"
00017
00018 #include "CryptographicMessageSyntax2004.h"
00019
00021 struct CPKIFTimestampAttributeImpl
00022 {
00023 CPKIFContentInfoPtr m_timestamp;
00024
00025 void ParseAttributes (const unsigned char *buf, const unsigned int length);
00026 };
00034 void CPKIFTimestampAttributeImpl::ParseAttributes (
00036 const unsigned char *buf,
00038 const unsigned int length)
00039 {
00040 CACASNWRAPPER_CREATE(CACCMSAttributeValues, attrsVals);
00041 CACCMSAttributeValues* attributesList = attrsVals.Decode(buf, length);
00042
00043 if(0 == attributesList->count)
00044 return;
00045
00046 DListNode* node = attributesList->head;
00047 ASN1OpenType* tmpOT = (ASN1OpenType*)node->data;
00048
00049 CPKIFContentInfoPtr tmpCI(new CPKIFContentInfo());
00050 tmpCI->Decode(tmpOT->data, tmpOT->numocts);
00051 m_timestamp = tmpCI;
00052
00053
00054
00055 }
00056
00057
00059
00060 char CPKIFTimestampAttribute::extOID[] = "1.2.840.113549.1.9.16.2.14";
00068 CPKIFTimestampAttribute::CPKIFTimestampAttribute()
00069 :m_impl (new CPKIFTimestampAttributeImpl)
00070 {
00071 LOG_STRING_DEBUG("CPKIFTimestampAttribute::CPKIFTimestampAttribute()", TOOLKIT_MESSAGE_ASN, 0, this);
00072 }
00073
00081
00083
00084
00085
00086
00087
00088
00089
00090
00091
00099 CPKIFTimestampAttribute::CPKIFTimestampAttribute(
00101 const CPKIFBufferPtr& buf)
00102 :m_impl (new CPKIFTimestampAttributeImpl)
00103 {
00104 LOG_STRING_DEBUG("CPKIFTimestampAttribute::CPKIFTimestampAttribute(const CACCMSAttribute& ext)", TOOLKIT_MESSAGE_ASN, 0, this);
00105
00106 m_impl->ParseAttributes (buf->GetBuffer(), buf->GetLength());
00107 }
00108
00116 CPKIFTimestampAttribute::~CPKIFTimestampAttribute()
00117 {
00118 LOG_STRING_DEBUG("CPKIFTimestampAttribute::~CPKIFTimestampAttribute()", TOOLKIT_MESSAGE_ASN, 0, this);
00119
00120 delete m_impl;
00121 m_impl = NULL;
00122 }
00123
00124
00134 CPKIFOIDPtr CPKIFTimestampAttribute::GetOID() const
00135 {
00136 return g_timestampAttribute;
00137 }
00145 void CPKIFTimestampAttribute::GetValues(
00147 CPKIFBufferList& values) const
00148 {
00149 LOG_STRING_DEBUG("CPKIFTimestampAttribute::GetValues(CPKIFBufferList& values)", TOOLKIT_MESSAGE_ASN, 0, this);
00150
00151
00152 values.clear();
00153
00154
00155 CPKIFBufferPtr buf = m_impl->m_timestamp->Encode();
00156
00157
00158 values.push_back(buf);
00159 }
00160
00161
00171 void CPKIFTimestampAttribute::SetTimestamp(
00173 CPKIFContentInfoPtr& ts)
00174 {
00175 LOG_STRING_DEBUG("CPKIFTimestampAttribute::SetTimestamp(CPKIFContentInfoPtr& ts)", TOOLKIT_MESSAGE_ASN, 0, this);
00176
00177
00178 if(ts == (CPKIFContentInfo*)NULL)
00179 throw CPKIFMessageException(TOOLKIT_MESSAGE, COMMON_INVALID_INPUT);
00180
00181 m_impl->m_timestamp = ts;
00182 }
00190 CPKIFContentInfoPtr CPKIFTimestampAttribute::GetTimestamp() const
00191 {
00192 return m_impl->m_timestamp;
00193 }