00001
00010 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && defined(PKIFRESOURCES_ALLOW_GCC_PRAGMA)
00011 #pragma implementation "GeneralCRLDetailsPanel.cpp"
00012 #endif
00013
00014
00015 #include "PKIFdll.h"
00016
00017 #include "wx/wxprec.h"
00018
00019 #ifdef __BORLANDC__
00020 #pragma hdrstop
00021 #endif
00022
00023 #include "GeneralCRLDetailsPanel.h"
00024 #include "pkif.h"
00025 #include "ResourceUtils.h"
00026 #include "PRStringUtils.h"
00027 #include "wx/wxhtml.h"
00028
00029 #include <boost/algorithm/string.hpp>
00030
00031 #include <iostream>
00032 #include <fstream>
00033 #include <sstream>
00034 using namespace std;
00035 using namespace boost;
00036
00037
00038
00039
00040
00041
00042
00043 string DecodeIP(CPKIFBufferPtr& encodedIP);
00044 string GetOIDString(const CPKIFOIDPtr &oid);
00045 const wxString& GetBufAsAscii(const CPKIFBufferPtr& in, wxString& out);
00046
00047 BEGIN_EVENT_TABLE(CPKIFGeneralCRLDetailsPanel,wxPanel)
00048 EVT_BUTTON( PKIFR_ID_COPY_TO_FILECRL, CPKIFGeneralCRLDetailsPanel::OnSaveCRL )
00049 EVT_LIST_ITEM_SELECTED( PKIFR_ID_CRL_DETAILS_LIST, CPKIFGeneralCRLDetailsPanel::OnSelectItem )
00050 END_EVENT_TABLE()
00058 CPKIFGeneralCRLDetailsPanel::CPKIFGeneralCRLDetailsPanel( wxWindow *parent, wxWindowID id,
00059 const wxPoint &position, const wxSize& size, long style ) :
00060 wxPanel( parent, id, position, size, style )
00061 {
00062
00063 m_sizer = GeneralCRLDetailsPanel( this, TRUE );
00064
00065 wxListItem itemCol;
00066 itemCol.SetText(_T("Field"));
00067 itemCol.SetAlign(wxLIST_FORMAT_LEFT);
00068 itemCol.SetWidth(190);
00069 GetListboxGeneralInfo()->InsertColumn(0, itemCol);
00070
00071 itemCol.SetText(_T("Value"));
00072 itemCol.SetAlign(wxLIST_FORMAT_LEFT);
00073 itemCol.SetWidth(190);
00074 GetListboxGeneralInfo()->InsertColumn(1, itemCol);
00075 }
00083 void CPKIFGeneralCRLDetailsPanel::OnInitDialog(wxInitDialogEvent& event)
00084 {
00085 PopulateList();
00086 PopulateListExtensions();
00087 }
00095 void CPKIFGeneralCRLDetailsPanel::PopulateList()
00096 {
00097 m_fieldCount = 1;
00098 long tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Version"));
00099 char numbuf[10];
00100 sprintf (numbuf, "%i", m_crl->Version());
00101 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(numbuf));
00102 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(numbuf));
00103 m_fieldCount++;
00104
00105 tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Issuer"));
00106 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(m_crl->Issuer()->ToString()));
00107 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(m_crl->Issuer()->ToString()));
00108 m_fieldCount++;
00109
00110 ostringstream os5;
00111 tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Effective Date"));
00112 os5<< m_crl->ThisUpdate()->month()<<"/";
00113 os5<< m_crl->ThisUpdate()->dayOfMonth() <<"/" ;
00114 os5<< m_crl->ThisUpdate()->year() << " ";
00115 os5<< m_crl->ThisUpdate()->hours()<<":";
00116 os5<< m_crl->ThisUpdate()->minutes() <<":" ;
00117 os5<< m_crl->ThisUpdate()->seconds();
00118 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(os5.str().c_str()));
00119 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(os5.str().c_str()));
00120 m_fieldCount++;
00121
00122 ostringstream os6;
00123 tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Next Update"));
00124 os6<< m_crl->NextUpdate()->month()<<"/";
00125 os6<< m_crl->NextUpdate()->dayOfMonth() <<"/" ;
00126 os6<< m_crl->NextUpdate()->year() << " ";
00127 os6<< m_crl->NextUpdate()->hours()<<":";
00128 os6<< m_crl->NextUpdate()->minutes() <<":" ;
00129 os6<< m_crl->NextUpdate()->seconds();
00130 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(os6.str().c_str()));
00131 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(os6.str().c_str()));
00132 m_fieldCount++;
00133
00134
00135 tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Signature algorithm"));
00136 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(GetOIDString(m_crl->SignatureAlgorithm()->oid()).c_str()));
00137 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(GetOIDString(m_crl->SignatureAlgorithm()->oid()).c_str()));
00138 m_fieldCount++;
00139 }
00147 void CPKIFGeneralCRLDetailsPanel::SetCRL(CPKIFCRLPtr& crl)
00148 {
00149 m_crl = crl;
00150 }
00158 void CPKIFGeneralCRLDetailsPanel::OnSelectItem(wxListEvent& event)
00159 {
00160 wxListItem info;
00161 info.m_itemId = event.m_itemIndex;
00162 info.m_col = 1;
00163 info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_DATA;
00164 if ( GetListboxGeneralInfo()->GetItem(info) )
00165 {
00166
00167 GetFieldInfo()->SetValue(_T((char*)info.GetData()));
00168 }
00169
00170 }
00178 void CPKIFGeneralCRLDetailsPanel::OnSaveCRL(wxCommandEvent& event)
00179 {
00180 if(m_crl) {
00181 wxString prompt;
00182 prompt.Printf(wxT("Save CRL issued by %s As:"),WXCASTCHARS(m_crl->Issuer()->ToString()));
00183 static wxString filter = wxT("CRL files (*.crl)|*.crl|All files (*.*)|*.*");
00184
00185 wxString tafile = wxFileSelector(prompt, NULL, NULL, NULL, filter);
00186 if(tafile != wxT("")) {
00187 CPKIFBufferPtr certbuf = m_crl->Encoded();
00188 WriteBufferToFile(string(tafile.mb_str()),certbuf);
00189 }
00190 }
00191 }
00199 void CPKIFGeneralCRLDetailsPanel::PopulateListExtensions()
00200 {
00201 CPKIFX509ExtensionMediator2 * mediator = CPKIFX509ExtensionMediator2::GetInstance();
00202 std::vector<CPKIFX509ExtensionPtr> exts;
00203 m_crl->IPKIFHasExtensions::GetExtensions (mediator, exts);
00204
00205 std::vector<CPKIFX509ExtensionPtr>::iterator pos;
00206 std::vector<CPKIFX509ExtensionPtr>::iterator end = exts.end();
00207 for(pos = exts.begin(); pos != end; ++pos)
00208 {
00209
00210
00211 {
00212 CPKIFAuthorityKeyIdentifier* ext = dynamic_cast<CPKIFAuthorityKeyIdentifier*>((*pos).get());
00213
00214 if(ext != (CPKIFAuthorityKeyIdentifier*)NULL)
00215 {
00216 ostringstream os;
00217 int tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Authority Key Identifier"));
00218
00219 bool issDNAndSerPresent = ext->IssDNAndSerialNumberPresent();
00220 bool keyIDPresent = ext->KeyIDPresent();
00221 CPKIFGeneralNames issuerNames;
00222 ext->Issuer(issuerNames);
00223 const char* serialNumber = ext->SerialNumber();
00224 CPKIFBufferPtr kid = ext->KeyIdentifier();
00225
00226
00227
00228 if(issDNAndSerPresent)
00229 {
00230 if(issuerNames.empty() || NULL == serialNumber)
00231 {
00232 }
00233 }
00234 if(keyIDPresent)
00235 {
00236 wxString out;
00237 os << "KeyID=" << GetBufAsAscii(kid, out) << endl;
00238 }
00239
00240 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(os.str().c_str()));
00241 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(os.str().c_str()));
00242 wxListItem info;
00243 info.m_itemId = tmp;
00244 GetListboxGeneralInfo()->GetItem(info);
00245 m_fieldCount++;
00246 if(ext->isCritical())
00247 {
00248 info.SetTextColour(*wxRED);
00249 GetListboxGeneralInfo()->SetItem(info);
00250 GetListboxGeneralInfo()->RefreshItem(info.m_itemId);
00251 }
00252 continue;
00253 }
00254 }
00255
00256
00257 {
00258 CPKIFCRLNumber* ext = dynamic_cast<CPKIFCRLNumber*>((*pos).get());
00259
00260 if(ext != (CPKIFCRLNumber*)NULL)
00261 {
00262 ostringstream os;
00263 int tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("CRL Number"));
00264
00265
00266 const char* crlNumber = ext->CRLNumber();
00267 os << "CRL Number=" << crlNumber << endl;
00268
00269 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(os.str().c_str()));
00270 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(os.str().c_str()));
00271 wxListItem info;
00272 info.m_itemId = tmp;
00273 GetListboxGeneralInfo()->GetItem(info);
00274 m_fieldCount++;
00275 if(ext->isCritical())
00276 {
00277 info.SetTextColour(*wxRED);
00278 GetListboxGeneralInfo()->SetItem(info);
00279 GetListboxGeneralInfo()->RefreshItem(info.m_itemId);
00280 }
00281 continue;
00282 }
00283 }
00284
00285
00286 {
00287 CPKIFCRLReason* ext = dynamic_cast<CPKIFCRLReason*>((*pos).get());
00288
00289 if(ext != (CPKIFCRLReason*)NULL)
00290 {
00291 ostringstream os;
00292 int tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("CRL Reason Code"));
00293
00294
00295 bool bAffilChanged = ext->AffiliationChanged();
00296 bool bCACompromise = ext->CACompromise();
00297 bool bCertificateHold = ext->CertificateHold();
00298 bool bCessationOfOperation = ext->CessationOfOperation();
00299 bool bKeyCompromise = ext->KeyCompromise();
00300 bool bRemoveFromCRL = ext->RemoveFromCRL();
00301 bool bSuperseded = ext->Superseded();
00302 bool bUnspecified = ext->Unspecified();
00303
00304 if(bAffilChanged)
00305 {
00306 os << "Affiliation Changed";
00307 }
00308 else if(bCACompromise)
00309 {
00310 os << "CA Compromise";
00311 }
00312 else if(bCertificateHold)
00313 {
00314 os << "Certificate Hold";
00315 }
00316 else if(bCessationOfOperation)
00317 {
00318 os << "Cessation Of Operation";
00319 }
00320 else if(bKeyCompromise)
00321 {
00322 os << "Key Compromise";
00323 }
00324 else if(bRemoveFromCRL)
00325 {
00326 os << "Remove From CRL";
00327 }
00328 else if(bSuperseded)
00329 {
00330 os << "Superseded";
00331 }
00332 else if(bUnspecified)
00333 {
00334 os << "Unspecified";
00335 }
00336
00337 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(os.str().c_str()));
00338 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(os.str().c_str()));
00339 wxListItem info;
00340 info.m_itemId = tmp;
00341 GetListboxGeneralInfo()->GetItem(info);
00342 m_fieldCount++;
00343 if(ext->isCritical())
00344 {
00345 info.SetTextColour(*wxRED);
00346 GetListboxGeneralInfo()->SetItem(info);
00347 GetListboxGeneralInfo()->RefreshItem(info.m_itemId);
00348 }
00349 continue;
00350 }
00351 }
00352
00353
00354 {
00355 CPKIFDeltaCRLIndicator* ext = dynamic_cast<CPKIFDeltaCRLIndicator*>((*pos).get());
00356
00357 if(ext != (CPKIFDeltaCRLIndicator*)NULL)
00358 {
00359 ostringstream os;
00360 int tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Delta CRL Indicator"));
00361
00362
00363 const char* baseCRLNumber = ext->BaseCRLNumber();
00364 os << "Minimum Base CRL Number=" << baseCRLNumber;
00365
00366 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(os.str().c_str()));
00367 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(os.str().c_str()));
00368 wxListItem info;
00369 info.m_itemId = tmp;
00370 GetListboxGeneralInfo()->GetItem(info);
00371 m_fieldCount++;
00372 if(ext->isCritical())
00373 {
00374 info.SetTextColour(*wxRED);
00375 GetListboxGeneralInfo()->SetItem(info);
00376 GetListboxGeneralInfo()->RefreshItem(info.m_itemId);
00377 }
00378 continue;
00379 }
00380 }
00381
00382
00383 {
00384 CPKIFFreshestCRL* ext = dynamic_cast<CPKIFFreshestCRL*>((*pos).get());
00385
00386 if(ext != (CPKIFFreshestCRL*)NULL)
00387 {
00388 ostringstream os;
00389 int tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Freshest CRL"));
00390
00391 CPKIFCRLDistributionPointListPtr dps = ext->DPs();
00392 CPKIFCRLDistributionPointList::iterator pos;
00393 CPKIFCRLDistributionPointList::iterator end = dps->end();;
00394 for(pos = dps->begin(); pos != end; ++pos)
00395 {
00396 CPKIFDistributionPointNamePtr dp = (*pos)->DistributionPoint();
00397
00398 {
00399 CPKIFGeneralNameList gns;
00400 dp->FullName(gns);
00401
00402 CPKIFGeneralNames::iterator gnPos;
00403 CPKIFGeneralNames::iterator gnEnd = gns.end();
00404 int count = 1;
00405 for(gnPos = gns.begin(); gnPos != gnEnd; ++gnPos)
00406 {
00407 os << "[" << count <<"]" << "Freshest CRL"<<endl;
00408 CPKIFGeneralName::GENNAMETYPE gnt = (*gnPos)->GetType();
00409 if(CPKIFGeneralName::DIRECTORYNAME == gnt)
00410 {
00411 os << " Directory Address:" << endl;
00412 os << " " <<(*gnPos)->directoryName()->ToString() << endl;
00413 }
00414 else if(CPKIFGeneralName::DNSNAME == gnt)
00415 {
00416 os << " DNS Name=" << (*gnPos)->dnsName() << endl;
00417 }
00418 else if(CPKIFGeneralName::IPADDRESS == gnt)
00419 {
00420
00421 CPKIFBufferPtr ip = (*gnPos)->ipAddress();
00422 string ipStr = DecodeIP(ip);
00423 vector<std::string> parts1;
00424 string separator = "/";
00425 StringSplit(ipStr, separator, parts1);
00426 if(parts1.size() == 2)
00427 {
00428 os << " IP Address=" << parts1[0] << endl;
00429 os << " Mask=" << parts1[1] << endl;
00430 }
00431 }
00432 else if(CPKIFGeneralName::OID == gnt)
00433 {
00434 os << " OID Name=" << (*gnPos)->oid()->ToString() << endl;
00435 }
00436 else if(CPKIFGeneralName::OTHERNAME == gnt)
00437 {
00438
00439 CPKIFBufferPtr on = (*gnPos)->otherName();
00440 int buffLen = on->GetLength();
00441 unsigned char* asciiVal = new unsigned char[buffLen*2+1];
00442 btoa((char*)on->GetBuffer(), (char*)asciiVal, on->GetLength());
00443
00444 os << " Other Name:" << endl;
00445 os << " " << asciiVal << endl;
00446
00447 if(asciiVal)
00448 delete[] asciiVal;
00449 }
00450 else if(CPKIFGeneralName::RFC822 == gnt)
00451 {
00452 os << " RFC822 Name=" << (*gnPos)->rfc822Name() << endl;
00453 }
00454 else if(CPKIFGeneralName::URI == gnt)
00455 {
00456 os << " URI=" << (*gnPos)->uri() << endl;
00457 }
00458
00459 count++;
00460 }
00461
00462 }
00463 {
00464 CPKIFGeneralNames gns;
00465 (*pos)->CRLIssuer(gns);
00466
00467 CPKIFGeneralNames::iterator gnPos;
00468 CPKIFGeneralNames::iterator gnEnd = gns.end();
00469 int count = 1;
00470 for(gnPos = gns.begin(); gnPos != gnEnd; ++gnPos)
00471 {
00472 os << "[" << count <<"]" << "CRL Issuer"<<endl;
00473 CPKIFGeneralName::GENNAMETYPE gnt = (*gnPos)->GetType();
00474 if(CPKIFGeneralName::DIRECTORYNAME == gnt)
00475 {
00476 os << " Directory Address:" << endl;
00477 os << " " << (*gnPos)->directoryName()->ToString() << endl;
00478 }
00479 else if(CPKIFGeneralName::DNSNAME == gnt)
00480 {
00481 os << " DNS Name=" << (*gnPos)->dnsName() << endl;
00482 }
00483
00484 else if(CPKIFGeneralName::OID == gnt)
00485 {
00486 os << " OID=" << (*gnPos)->oid()->ToString() << endl;
00487 }
00488
00489 else if(CPKIFGeneralName::RFC822 == gnt)
00490 {
00491 os << " RFC822 Name=" << (*gnPos)->rfc822Name() << endl;
00492 }
00493 else if(CPKIFGeneralName::URI == gnt)
00494 {
00495 os << " URI=" << (*gnPos)->uri() << endl;
00496 }
00497 }
00498 }
00499 }
00500
00501 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(os.str().c_str()));
00502 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(os.str().c_str()));
00503 wxListItem info;
00504 info.m_itemId = tmp;
00505 GetListboxGeneralInfo()->GetItem(info);
00506 m_fieldCount++;
00507 if(ext->isCritical())
00508 {
00509 info.SetTextColour(*wxRED);
00510 GetListboxGeneralInfo()->SetItem(info);
00511 GetListboxGeneralInfo()->RefreshItem(info.m_itemId);
00512 }
00513 continue;
00514 }
00515 }
00516
00517
00518 {
00519 CPKIFHoldInstructionCode* ext = dynamic_cast<CPKIFHoldInstructionCode*>((*pos).get());
00520
00521 if(ext != (CPKIFHoldInstructionCode*)NULL)
00522 {
00523 ostringstream os;
00524 int tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Hold Instruction Code"));
00525
00526 CPKIFOIDPtr holdCode = ext->HoldInstruction();
00527 os << "Hold Instruction Code=" <<holdCode->ToString() << endl;
00528
00529 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(os.str().c_str()));
00530 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(os.str().c_str()));
00531 wxListItem info;
00532 info.m_itemId = tmp;
00533 GetListboxGeneralInfo()->GetItem(info);
00534 m_fieldCount++;
00535 if(ext->isCritical())
00536 {
00537 info.SetTextColour(*wxRED);
00538 GetListboxGeneralInfo()->SetItem(info);
00539 GetListboxGeneralInfo()->RefreshItem(info.m_itemId);
00540 }
00541 continue;
00542 }
00543 }
00544
00545
00546 {
00547 CPKIFIssuingDistributionPoint* ext = dynamic_cast<CPKIFIssuingDistributionPoint*>((*pos).get());
00548
00549 if(ext != (CPKIFIssuingDistributionPoint*)NULL)
00550 {
00551
00552 ostringstream os;
00553 int tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Issuing Distribution Point"));
00554
00555 CPKIFDistributionPointNamePtr dp = ext->DistributionPoint();
00556 if(dp != (CPKIFDistributionPointName*)NULL)
00557 {
00558 os << "Distribution Point Name:" << endl;
00559 CPKIFGeneralNames gns;
00560 dp->FullName(gns);
00561
00562 os << " Full Name:" << endl;
00563 CPKIFGeneralNames::iterator gnPos;
00564 CPKIFGeneralNames::iterator gnEnd = gns.end();
00565 for(gnPos = gns.begin(); gnPos != gnEnd; ++gnPos)
00566 {
00567 CPKIFGeneralName::GENNAMETYPE gnt = (*gnPos)->GetType();
00568 if(CPKIFGeneralName::DIRECTORYNAME == gnt)
00569 {
00570 os << " Directory Address:" << endl;
00571 os << " " << (*gnPos)->directoryName()->ToString() << endl;
00572 }
00573 else if(CPKIFGeneralName::DNSNAME == gnt)
00574 {
00575 os << " DNS Name:" << endl;
00576 os << " " << (*gnPos)->dnsName() << endl;
00577 }
00578
00579 else if(CPKIFGeneralName::OID == gnt)
00580 {
00581 os << " OID:" << endl;
00582 os << " " << (*gnPos)->oid()->ToString() << endl;
00583 }
00584
00585 else if(CPKIFGeneralName::RFC822 == gnt)
00586 {
00587 os << " RFC822 Name:" << endl;
00588 os << " " << (*gnPos)->rfc822Name() << endl;
00589 }
00590 else if(CPKIFGeneralName::URI == gnt)
00591 {
00592 os << " URI:" << endl;
00593 os << " " << (*gnPos)->uri() << endl;
00594 }
00595 }
00596 }
00597
00598 if(ext->OnlyContainsUserCerts())
00599 {
00600 os << "Only Contains User Certs=Yes "<<endl;
00601 }
00602 else
00603 {
00604 os << "Only Contains User Certs=No "<<endl;
00605 }
00606
00607 if(ext->OnlyContainsAuthorityCerts())
00608 {
00609 os << "Only Contains CA Certs=Yes "<<endl;
00610 }
00611 else
00612 {
00613 os << "Only Contains CA Certs=No "<<endl;
00614 }
00615
00616 if(ext->IndirectCRL())
00617 {
00618 os << "Indirect CRL=Yes "<<endl;
00619 }
00620 else
00621 {
00622 os << "Indirect CRL=No "<<endl;
00623 }
00624 if(ext->OnlySomeReasons())
00625 {
00626 os << "Only Some Reasons=Yes "<<endl;
00627 }
00628 else
00629 {
00630 os << "Only Some Reasons=No "<<endl;
00631 }
00632
00633 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(os.str().c_str()));
00634 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(os.str().c_str()));
00635 wxListItem info;
00636 info.m_itemId = tmp;
00637 GetListboxGeneralInfo()->GetItem(info);
00638 m_fieldCount++;
00639 if(ext->isCritical())
00640 {
00641 info.SetTextColour(*wxRED);
00642 GetListboxGeneralInfo()->SetItem(info);
00643 GetListboxGeneralInfo()->RefreshItem(info.m_itemId);
00644 }
00645 continue;
00646 }
00647 }
00648
00649
00650 {
00651 CPKIFAuthorityInfoAccess* ext = dynamic_cast<CPKIFAuthorityInfoAccess*>((*pos).get());
00652
00653 if(ext != (CPKIFAuthorityInfoAccess*)NULL)
00654 {
00655 ostringstream os;
00656 int tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Authority Information Access"));
00657
00658
00659 CPKIFAccessDescriptionListPtr adl = ext->GetAccessDescriptions();
00660 if(adl != (CPKIFAccessDescriptionList*)NULL)
00661 {
00662 CPKIFAccessDescription ad;
00663 CPKIFAccessDescriptionList::iterator pos;
00664 CPKIFAccessDescriptionList::iterator end = adl->end();
00665 int count = 1;
00666 for(pos = adl->begin(); pos != end; ++pos)
00667 {
00668 os << "[" << count <<"]" << "Authority Info Access"<<endl;
00669 CPKIFOIDPtr accessMethod = (*pos)->AccessMethod();
00670 string accessMethodStr = "";
00671
00672 if(0 == strcmp(accessMethod->ToString(), "1.3.6.1.5.5.7.48.2"))
00673 {
00674 accessMethodStr = "Certification Authority Issuer (1.3.6.1.5.5.7.48.2)";
00675 }
00676 else if(0 == strcmp(accessMethod->ToString(), "1.3.6.1.5.5.7.48.5"))
00677 {
00678 accessMethodStr = "Certification Repository (1.3.6.1.5.5.7.48.5)";
00679 }
00680 else if(0 == strcmp(accessMethod->ToString(), "1.3.6.1.5.5.7.48.1"))
00681 {
00682 accessMethodStr = "On-line Certificate Status Protocol (1.3.6.1.5.5.7.48.1)";
00683 }
00684
00685 os << " Access Method=" << accessMethodStr << endl;
00686
00687 CPKIFGeneralNamePtr gn = (*pos)->AccessLocation();
00688 if(gn != (CPKIFGeneralName*)NULL)
00689 {
00690 os << " Alternative Name:"<<endl;
00691 CPKIFGeneralName::GENNAMETYPE gnt = gn->GetType();
00692 if(CPKIFGeneralName::DIRECTORYNAME == gnt)
00693 {
00694 os << " Directory Name:" << endl;
00695 os << " " << gn->directoryName()->ToString() << endl;
00696 }
00697 else if(CPKIFGeneralName::DNSNAME == gnt)
00698 {
00699 os << " DNS Name=" << gn->dnsName() << endl;
00700 }
00701 else if(CPKIFGeneralName::IPADDRESS == gnt)
00702 {
00703
00704 CPKIFBufferPtr ip = gn->ipAddress();
00705 string ipStr = DecodeIP(ip);
00706 vector<std::string> parts1;
00707 string separator = "/";
00708 StringSplit(ipStr, separator, parts1);
00709 if(parts1.size() == 2)
00710 {
00711 os << " IP Address=" << parts1[0] << endl;
00712 os << " Mask=" << parts1[1] << endl;
00713 }
00714 }
00715 else if(CPKIFGeneralName::OID == gnt)
00716 {
00717 os << " OID=" << gn->oid()->ToString() << endl;
00718 }
00719 else if(CPKIFGeneralName::OTHERNAME == gnt)
00720 {
00721
00722 CPKIFBufferPtr on = gn->otherName();
00723 int buffLen = on->GetLength();
00724 unsigned char* asciiVal = new unsigned char[buffLen*2+1];
00725 btoa((char*)on->GetBuffer(), (char*)asciiVal, on->GetLength());
00726
00727 os << " Other Name:" << endl;
00728 os << " " << asciiVal << endl;
00729
00730 if(asciiVal)
00731 delete[] asciiVal;
00732 }
00733 else if(CPKIFGeneralName::RFC822 == gnt)
00734 {
00735 os << " RFC822 Name=" << gn->rfc822Name() << endl;
00736 }
00737 else if(CPKIFGeneralName::URI == gnt)
00738 {
00739 os << " URI=" << gn->uri() << endl;
00740 }
00741
00742 }
00743
00744 count++;
00745 }
00746 }
00747
00748 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(os.str().c_str()));
00749 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(os.str().c_str()));
00750 wxListItem info;
00751 info.m_itemId = tmp;
00752 GetListboxGeneralInfo()->GetItem(info);
00753 m_fieldCount++;
00754 if(ext->isCritical())
00755 {
00756 info.SetTextColour(*wxRED);
00757 GetListboxGeneralInfo()->SetItem(info);
00758 GetListboxGeneralInfo()->RefreshItem(info.m_itemId);
00759 }
00760 continue;
00761 }
00762 }
00763
00764
00765 {
00766 CPKIFIssuerAltName* ext = dynamic_cast<CPKIFIssuerAltName*>((*pos).get());
00767
00768 if(ext != (CPKIFIssuerAltName*)NULL)
00769 {
00770 ostringstream os;
00771 int tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T("Issuer Alternative Name"));
00772
00773 CPKIFGeneralNames gns;
00774 ext->GeneralNames(gns);
00775 CPKIFGeneralNames::iterator gnPos;
00776 CPKIFGeneralNames::iterator gnEnd = gns.end();
00777 for(gnPos = gns.begin(); gnPos != gnEnd; ++gnPos)
00778 {
00779 CPKIFGeneralName::GENNAMETYPE gnt = (*gnPos)->GetType();
00780 if(CPKIFGeneralName::DIRECTORYNAME == gnt)
00781 {
00782 os << "Directory Address:" << endl;
00783 os << " " << (*gnPos)->directoryName()->ToString() << endl;
00784 }
00785 else if(CPKIFGeneralName::DNSNAME == gnt)
00786 {
00787 os << "DNS Name=" << (*gnPos)->dnsName() << endl;
00788 }
00789 else if(CPKIFGeneralName::IPADDRESS == gnt)
00790 {
00791
00792 CPKIFBufferPtr ip = (*gnPos)->ipAddress();
00793 string ipStr = DecodeIP(ip);
00794 vector<std::string> parts1;
00795 string separator = "/";
00796 StringSplit(ipStr, separator, parts1);
00797 if(parts1.size() == 2)
00798 {
00799 os << " IP Address=" << parts1[0] << endl;
00800 os << " Mask=" << parts1[1] << endl;
00801 }
00802 }
00803 else if(CPKIFGeneralName::OID == gnt)
00804 {
00805 os << "OID=" << (*gnPos)->oid()->ToString() << endl;
00806 }
00807 else if(CPKIFGeneralName::OTHERNAME == gnt)
00808 {
00809
00810 CPKIFBufferPtr on = (*gnPos)->otherName();
00811 int buffLen = on->GetLength();
00812 unsigned char* asciiVal = new unsigned char[buffLen*2+1];
00813 btoa((char*)on->GetBuffer(), (char*)asciiVal, on->GetLength());
00814
00815 os << "Other Name:" << endl;
00816 os << " " << asciiVal << endl;
00817
00818 if(asciiVal)
00819 delete[] asciiVal;
00820 }
00821 else if(CPKIFGeneralName::RFC822 == gnt)
00822 {
00823 os << "RFC822 Name=" << (*gnPos)->rfc822Name() << endl;
00824 }
00825 else if(CPKIFGeneralName::URI == gnt)
00826 {
00827 os << "URI=" << (*gnPos)->uri() << endl;
00828 }
00829
00830 }
00831
00832 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(os.str().c_str()));
00833 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(os.str().c_str()));
00834 wxListItem info;
00835 info.m_itemId = tmp;
00836 GetListboxGeneralInfo()->GetItem(info);
00837 m_fieldCount++;
00838 if(ext->isCritical())
00839 {
00840 info.SetTextColour(*wxRED);
00841 GetListboxGeneralInfo()->SetItem(info);
00842 GetListboxGeneralInfo()->RefreshItem(info.m_itemId);
00843 }
00844 continue;
00845 }
00846 }
00847
00848
00849 {
00850 CPKIFOIDPtr extOID = (*pos)->oid();
00851
00852 int tmp = GetListboxGeneralInfo()->InsertItem(m_fieldCount, _T(extOID->ToString()));
00853
00854 int buffLen = (*pos)->value()->GetLength();
00855 char* asciiVal = new char[buffLen*2+1];
00856 btoa((char*)(*pos)->value()->GetBuffer(), (char*)asciiVal, (*pos)->value()->GetLength());
00857
00858
00859
00860 GetListboxGeneralInfo()->SetItem(tmp, 1, _T(asciiVal));
00861 wxListItem info;
00862 info.m_itemId = tmp;
00863 GetListboxGeneralInfo()->GetItem(info);
00864 m_fieldCount++;
00865 ostringstream os;
00866 os << "05 00";
00867 GetListboxGeneralInfo()->SetItemPtrData(tmp, (wxUIntPtr)strdup(asciiVal));
00868 if((*pos)->isCritical())
00869 {
00870 info.SetTextColour(*wxRED);
00871 GetListboxGeneralInfo()->SetItem(info);
00872 GetListboxGeneralInfo()->RefreshItem(info.m_itemId);
00873 }
00874
00875 if(*asciiVal)
00876 delete[] asciiVal;
00877
00878 continue;
00879 }
00880 }
00881 }