CRLReason.cpp
Go to the documentation of this file.00001
00009 #include "CRLReason.h"
00010 #include "OID.h"
00011 #include "Buffer.h"
00012
00013 #include "ASN1Helper.h"
00014 #include "PKIX1Implicit88.h"
00015 #include "PKIX1Explicit88.h"
00016
00017 #include <bitset>
00018 using namespace std;
00019
00021
00022 struct CPKIFCRLReasonImpl
00023 {
00024 std::bitset<10> m_bits;
00025 CPKIFBufferPtr m_value;
00026 bool m_extModified;
00027 };
00028
00030
00031 char CPKIFCRLReason::extOID[] = "2.5.29.21";
00032
00040 CPKIFCRLReason::CPKIFCRLReason()
00041 :m_impl (new CPKIFCRLReasonImpl)
00042 {
00043 }
00052 CPKIFCRLReason::CPKIFCRLReason(
00054 const int reason)
00055 :m_impl (new CPKIFCRLReasonImpl)
00056 {
00057 switch(reason)
00058 {
00059 case CACX509V3unspecified:
00060 m_impl->m_bits.set(UNSPEC);
00061 break;
00062 case CACX509V3keyCompromise:
00063 m_impl->m_bits.set(KEYCOMP);
00064 break;
00065 case CACX509V3cACompromise:
00066 m_impl->m_bits.set(CACOMP);
00067 break;
00068 case CACX509V3affiliationChanged:
00069 m_impl->m_bits.set(AFFILCHANGE);
00070 break;
00071 case CACX509V3superseded:
00072 m_impl->m_bits.set(SUPERSEDED);
00073 break;
00074 case CACX509V3cessationOfOperation:
00075 m_impl->m_bits.set(CESSOFOPER);
00076 break;
00077 case CACX509V3certificateHold:
00078 m_impl->m_bits.set(CERTHOLD);
00079 break;
00080 case CACX509V3removeFromCRL:
00081 m_impl->m_bits.set(REMOVE);
00082 break;
00083 }
00084 }
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00134 bool CPKIFCRLReason::Unspecified() const {return m_impl->m_bits[UNSPEC];}
00142 bool CPKIFCRLReason::KeyCompromise() const {return m_impl->m_bits[KEYCOMP];}
00150 bool CPKIFCRLReason::CACompromise() const {return m_impl->m_bits[CACOMP];}
00158 bool CPKIFCRLReason::AffiliationChanged() const {return m_impl->m_bits[AFFILCHANGE];}
00166 bool CPKIFCRLReason::Superseded() const {return m_impl->m_bits[SUPERSEDED];}
00174 bool CPKIFCRLReason::CessationOfOperation() const {return m_impl->m_bits[CESSOFOPER];}
00182 bool CPKIFCRLReason::CertificateHold() const {return m_impl->m_bits[CERTHOLD];}
00190 bool CPKIFCRLReason::RemoveFromCRL() const {return m_impl->m_bits[REMOVE];}
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00250 CPKIFCRLReason::CPKIFCRLReason(
00251 const bool& criticality,
00252 const CPKIFBufferPtr& ext)
00253 : CPKIFX509Extension (criticality, ext), m_impl (new CPKIFCRLReasonImpl)
00254 {
00255 CACASNWRAPPER_CREATE(CACX509V3CRLReason, objPDU);
00256 objPDU.Decode(ext->GetBuffer(), ext->GetLength());
00257
00258 CACX509V3CRLReason * reason = objPDU.data();
00259 switch(*reason)
00260 {
00261 case CACX509V3unspecified:
00262 m_impl->m_bits.set(UNSPEC);
00263 break;
00264 case CACX509V3keyCompromise:
00265 m_impl->m_bits.set(KEYCOMP);
00266 break;
00267 case CACX509V3cACompromise:
00268 m_impl->m_bits.set(CACOMP);
00269 break;
00270 case CACX509V3affiliationChanged:
00271 m_impl->m_bits.set(AFFILCHANGE);
00272 break;
00273 case CACX509V3superseded:
00274 m_impl->m_bits.set(SUPERSEDED);
00275 break;
00276 case CACX509V3cessationOfOperation:
00277 m_impl->m_bits.set(CESSOFOPER);
00278 break;
00279 case CACX509V3certificateHold:
00280 m_impl->m_bits.set(CERTHOLD);
00281 break;
00282 case CACX509V3removeFromCRL:
00283 m_impl->m_bits.set(REMOVE);
00284 break;
00285 }
00286
00287 m_impl->m_value = ext;
00288 m_impl->m_extModified = false;
00289 }
00290
00298 CPKIFCRLReason::~CPKIFCRLReason()
00299 {
00300 if(m_impl)
00301 {
00302 delete m_impl;
00303 m_impl = 0;
00304 }
00305 }
00314 const CPKIFOIDPtr CPKIFCRLReason::oid() const
00315 {
00316
00317 static CPKIFOID staticOID(extOID);
00318
00319 static CPKIFOIDPtr tmp(new CPKIFOID(staticOID));
00320 return tmp;
00321 }
00329 CPKIFBufferPtr CPKIFCRLReason::value() const
00330 {
00331 CPKIFBufferPtr rv = m_impl->m_value;
00332 if(m_impl->m_value == (CPKIFBuffer*)NULL || m_impl->m_extModified)
00333 {
00334
00335 }
00336
00337 return rv;
00338 }