BinarySigningTimeAttribute.cpp
Go to the documentation of this file.00001
00009 #include "BinarySigningTimeAttribute.h"
00010
00011 #include "OID.h"
00012 #include "Buffer.h"
00013
00014 #include "BinarySigningTimeModule.h"
00015 #include "CryptographicMessageSyntax2004.h"
00016
00017 #include "ASN1Helper.h"
00018 #include "ToolkitUtils.h"
00019
00020 #include "PKIFMessageException.h"
00021
00022
00024 struct CPKIFBinarySigningTimeAttributeImpl
00025 {
00026 CPKIFBinarySigningTimeAttribute *m_parent;
00027
00028 const char* m_signingTime;
00029 void ParseAttributes (const unsigned char *buf, const unsigned int length);
00030 };
00038 void CPKIFBinarySigningTimeAttributeImpl::ParseAttributes (
00040 const unsigned char *buf,
00042 const unsigned int length)
00043 {
00044 CACASNWRAPPER_CREATE(CACCMSAttributeValues, attrsVals);
00045 CACCMSAttributeValues* attributesList = attrsVals.Decode(buf, length);
00046
00047
00048
00049 ASN1OpenType* ot = (ASN1OpenType*)((DListNode*)attributesList->head)->data;
00050
00051 CACASNWRAPPER_CREATE(BinarySigningTime, binaryTime);
00052
00053 BinarySigningTime *tmp = binaryTime.Decode(ot->data, ot->numocts);
00054
00055 m_signingTime = strdup(*tmp);
00056
00057 }
00058
00060
00061 char CPKIFBinarySigningTimeAttribute::extOID[] = "1.2.840.113549.1.9.16.2.46";
00070 CPKIFBinarySigningTimeAttribute::CPKIFBinarySigningTimeAttribute()
00071 :m_impl (new CPKIFBinarySigningTimeAttributeImpl)
00072 {
00073 m_impl->m_parent = this;
00074 m_impl->m_signingTime = NULL;
00075 LOG_STRING_DEBUG("CPKIFBinarySigningTimeAttribute::CPKIFBinarySigningTimeAttribute()", TOOLKIT_MESSAGE_ASN, 0, this);
00076 }
00084 CPKIFBinarySigningTimeAttribute::CPKIFBinarySigningTimeAttribute(
00086 const CPKIFBufferPtr& buf)
00087 :m_impl (new CPKIFBinarySigningTimeAttributeImpl)
00088 {
00089 LOG_STRING_DEBUG("CPKIFBinarySigningTimeAttribute::CPKIFBinarySigningTimeAttribute(const CACCMSAttribute& ext)", TOOLKIT_MESSAGE_ASN, 0, this);
00090
00091 m_impl->m_parent = this;
00092 m_impl->ParseAttributes (buf->GetBuffer(), buf->GetLength());
00093 }
00094
00095
00103 CPKIFBinarySigningTimeAttribute::~CPKIFBinarySigningTimeAttribute()
00104 {
00105 LOG_STRING_DEBUG("CPKIFBinarySigningTimeAttribute::~CPKIFBinarySigningTimeAttribute()", TOOLKIT_MESSAGE_ASN, 0, this);
00106
00107 if(m_impl->m_signingTime != NULL)
00108 delete m_impl->m_signingTime;
00109 delete m_impl;
00110 m_impl = NULL;
00111 }
00112
00113
00121 CPKIFOIDPtr CPKIFBinarySigningTimeAttribute::GetOID() const
00122 {
00123 return g_binarySigningTimeAttribute;
00124 }
00134 void CPKIFBinarySigningTimeAttribute::GetValues(
00136 CPKIFBufferList& values) const
00137 {
00138 LOG_STRING_DEBUG("CPKIFBinarySigningTimeAttribute::GetValues(CPKIFBufferList& values)", TOOLKIT_MESSAGE_ASN, 0, this);
00139
00140 values.clear();
00141
00142 CACASNWRAPPER_CREATE(BinarySigningTime, objPDU);
00143 BinarySigningTime tmpTime = m_impl->m_signingTime;
00144 ASN1OpenType* data1 = objPDU.Encode(&tmpTime);
00145
00146 CPKIFBufferPtr tmp(new CPKIFBuffer(data1->data, data1->numocts));
00147 values.push_back(tmp);
00148
00149 }
00150
00151
00161 void CPKIFBinarySigningTimeAttribute::SetSigningTime(
00163 const char* time)
00164 {
00165 LOG_STRING_DEBUG("CPKIFBinarySigningTimeAttribute::SetContentType(CPKIFOIDPtr& oid)", TOOLKIT_MESSAGE_ASN, 0, this);
00166
00167
00168 if(time == NULL)
00169 throw CPKIFMessageException(TOOLKIT_MESSAGE, COMMON_INVALID_INPUT);
00170
00171 m_impl->m_signingTime = time;
00172 }
00180 const char* CPKIFBinarySigningTimeAttribute::GetSigningTime()
00181 {
00182 return m_impl->m_signingTime;
00183 }