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 //CPKIFCRLReason::CPKIFCRLReason(
00094 //  //! [in] Reference to a CACX509V3CRLReason object containing information used to 
00095 //  //! populate a new instance of CPKIFCRLReason
00096 //  CACX509V3CRLReason& r)
00097 //  :m_impl (new CPKIFCRLReasonImpl)
00098 //{
00099 //  switch(r)
00100 //  {
00101 //  case CACX509V3unspecified:
00102 //      m_impl->m_bits.set(UNSPEC);
00103 //      break;
00104 //  case CACX509V3keyCompromise:
00105 //      m_impl->m_bits.set(KEYCOMP);
00106 //      break;
00107 //  case CACX509V3cACompromise:
00108 //      m_impl->m_bits.set(CACOMP);
00109 //      break;
00110 //  case CACX509V3affiliationChanged:
00111 //      m_impl->m_bits.set(AFFILCHANGE);
00112 //      break;
00113 //  case CACX509V3superseded:
00114 //      m_impl->m_bits.set(SUPERSEDED);
00115 //      break;
00116 //  case CACX509V3cessationOfOperation:
00117 //      m_impl->m_bits.set(CESSOFOPER);
00118 //      break;
00119 //  case CACX509V3certificateHold:
00120 //      m_impl->m_bits.set(CERTHOLD);
00121 //      break;
00122 //  case CACX509V3removeFromCRL:
00123 //      m_impl->m_bits.set(REMOVE);
00124 //      break;
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 //CPKIFCRLReason::CPKIFCRLReason(
00202 //  //! [in] Reference to an internal structure representation of the extension containing 
00203 //  //! information used to construct the object
00204 //                             const CACX509V3Extension& ext) 
00205 //  : CPKIFX509Extension(ext), m_impl (new CPKIFCRLReasonImpl)
00206 //{
00207 //  CACASNWRAPPER_CREATE(CACX509V3CRLReason, objPDU);
00208 //  objPDU.Decode(ext.extnValue.data, ext.extnValue.numocts);
00209 //  
00210 //  CACX509V3CRLReason * reason = objPDU.data();
00211 //  switch(*reason)
00212 //  {
00213 //  case CACX509V3unspecified:
00214 //      m_impl->m_bits.set(UNSPEC);
00215 //      break;
00216 //  case CACX509V3keyCompromise:
00217 //      m_impl->m_bits.set(KEYCOMP);
00218 //      break;
00219 //  case CACX509V3cACompromise:
00220 //      m_impl->m_bits.set(CACOMP);
00221 //      break;
00222 //  case CACX509V3affiliationChanged:
00223 //      m_impl->m_bits.set(AFFILCHANGE);
00224 //      break;
00225 //  case CACX509V3superseded:
00226 //      m_impl->m_bits.set(SUPERSEDED);
00227 //      break;
00228 //  case CACX509V3cessationOfOperation:
00229 //      m_impl->m_bits.set(CESSOFOPER);
00230 //      break;
00231 //  case CACX509V3certificateHold:
00232 //      m_impl->m_bits.set(CERTHOLD);
00233 //      break;
00234 //  case CACX509V3removeFromCRL:
00235 //      m_impl->m_bits.set(REMOVE);
00236 //      break;
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     //added static variable for copying instead of string creation each call
00317     static CPKIFOID staticOID(extOID);
00318     //CPKIFOIDPtr tmp(new CPKIFOID(new std::string(extOID)));
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         //XXX ENCODE HERE and set rv if necessary 
00335     }
00336 
00337     return rv;
00338 }

Generated on Mon Nov 15 11:15:50 2010 for PublicKeyInfrastructureFramework(PKIF) by  doxygen 1.5.6