PrivateKeyUsage.cpp
Go to the documentation of this file.00001
00009 #include "PrivateKeyUsage.h"
00010 #include "OID.h"
00011 #include "Buffer.h"
00012
00013 #include "ASN1Helper.h"
00014 #include "PKIX1Implicit88.h"
00015 #include "PKIX1Explicit88.h"
00016
00018
00019 struct CPKIFPrivateKeyUsageImpl
00020 {
00021 CPKIFStringPtr m_notAfter;
00022 CPKIFStringPtr m_notBefore;
00023 CPKIFBufferPtr m_value;
00024 bool m_extModified;
00025 };
00026
00028
00029 char CPKIFPrivateKeyUsage::extOID[] = "2.5.29.16";
00030
00038 CPKIFPrivateKeyUsage::CPKIFPrivateKeyUsage()
00039 :m_impl (new CPKIFPrivateKeyUsageImpl)
00040 {
00041 }
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00085 CPKIFPrivateKeyUsage::CPKIFPrivateKeyUsage(
00086 const bool& criticality,
00087 const CPKIFBufferPtr& ext)
00088 : CPKIFX509Extension (criticality, ext), m_impl (new CPKIFPrivateKeyUsageImpl)
00089 {
00090
00091 CACASNWRAPPER_CREATE(CACX509V3PrivateKeyUsagePeriod, objPDU);
00092 objPDU.Decode(ext->GetBuffer(), ext->GetLength());
00093
00094 CACX509V3PrivateKeyUsagePeriod* pku = objPDU.data();
00095 if(pku->m.notAfterPresent)
00096 {
00097 CPKIFStringPtr t(new std::string(pku->notAfter));
00098 m_impl->m_notAfter = t;
00099 }
00100 if(pku->m.notBeforePresent)
00101 {
00102 CPKIFStringPtr t(new std::string(pku->notBefore));
00103 m_impl->m_notBefore = t;
00104 }
00105
00106 m_impl->m_value = ext;
00107 m_impl->m_extModified = false;
00108 }
00109
00117 CPKIFPrivateKeyUsage::~CPKIFPrivateKeyUsage()
00118 {
00119 if(m_impl)
00120 {
00121 delete m_impl;
00122 m_impl = 0;
00123 }
00124 }
00132 const char* CPKIFPrivateKeyUsage::NotAfter() const
00133 {
00134 if(m_impl->m_notAfter == (std::string*)NULL)
00135 return NULL;
00136 else
00137 return m_impl->m_notAfter->c_str();
00138 }
00146 const char* CPKIFPrivateKeyUsage::NotBefore() const
00147 {
00148 if(m_impl->m_notBefore == (std::string*)NULL)
00149 return NULL;
00150 else
00151 return m_impl->m_notBefore->c_str();
00152 }
00153
00162 const CPKIFOIDPtr CPKIFPrivateKeyUsage::oid() const
00163 {
00164
00165 static CPKIFOID staticOID(extOID);
00166
00167 static CPKIFOIDPtr tmp(new CPKIFOID(staticOID));
00168 return tmp;
00169 }
00177 CPKIFBufferPtr CPKIFPrivateKeyUsage::value() const
00178 {
00179 CPKIFBufferPtr rv = m_impl->m_value;
00180 if(m_impl->m_value == (CPKIFBuffer*)NULL || m_impl->m_extModified)
00181 {
00182
00183 }
00184
00185 return rv;
00186 }