securitysettings/qtconfigutils/eapqtconfiginterface/src/eapqtconfiginterface_p.cpp
changeset 27 9660a5eb236f
parent 26 9abfd4f00d37
child 34 ad1f037f1ac2
equal deleted inserted replaced
26:9abfd4f00d37 27:9660a5eb236f
    15  *   EAP method configuration QT interface
    15  *   EAP method configuration QT interface
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 /*
    19 /*
    20  * %version: 39 %
    20  * %version: 41 %
    21  */
    21  */
    22 
    22 
    23 #include <QDir>
    23 #include <QDir>
    24 #include <QList>
    24 #include <QList>
    25 #include <QVariant>
    25 #include <QVariant>
   473     const TDes* text = 0;
   473     const TDes* text = 0;
   474     int ind = 0;
   474     int ind = 0;
   475 
   475 
   476     for (ind = 0; ind < certEntries->Count(); ind++) {
   476     for (ind = 0; ind < certEntries->Count(); ind++) {
   477 
   477 
       
   478         EapCertificateEntry* certPtr = (*certEntries)[ind];
       
   479 
   478         qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo *** certificate starts *** ";
   480         qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo *** certificate starts *** ";
   479 
   481 
   480         if ((*certEntries)[ind]->GetSubjectNamePresent() != EFalse) {
   482         if (certPtr->GetSubjectNamePresent() != EFalse) {
   481 
   483 
   482             text = (*certEntries)[ind]->GetSubjectName();
   484             text = certPtr->GetSubjectName();
   483             cert.setValue(EapQtCertificateInfo::SubjectName, QString::fromUtf16(text->Ptr(),
   485             cert.setValue(EapQtCertificateInfo::SubjectName, QString::fromUtf16(text->Ptr(),
   484                 text->Length()));
   486                 text->Length()));
   485 
   487 
   486             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SubjectName: "
   488             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SubjectName: "
   487                 << QString::fromUtf16(text->Ptr(), text->Length());
   489                 << QString::fromUtf16(text->Ptr(), text->Length());
   488         }
   490         }
   489         if ((*certEntries)[ind]->GetIssuerNamePresent() != EFalse) {
   491         if (certPtr->GetIssuerNamePresent() != EFalse) {
   490 
   492 
   491             text = (*certEntries)[ind]->GetIssuerName();
   493             text = certPtr->GetIssuerName();
   492             cert.setValue(EapQtCertificateInfo::IssuerName, QString::fromUtf16(text->Ptr(),
   494             cert.setValue(EapQtCertificateInfo::IssuerName, QString::fromUtf16(text->Ptr(),
   493                 text->Length()));
   495                 text->Length()));
   494 
   496 
   495             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo IssuerName: "
   497             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo IssuerName: "
   496                 << QString::fromUtf16(text->Ptr(), text->Length());
   498                 << QString::fromUtf16(text->Ptr(), text->Length());
   497         }
   499         }
   498         if ((*certEntries)[ind]->GetSerialNumberPresent() != EFalse) {
   500         if (certPtr->GetSerialNumberPresent() != EFalse) {
   499 
   501 
   500             text = (*certEntries)[ind]->GetSerialNumber();
   502             text = certPtr->GetSerialNumber();
   501             cert.setValue(EapQtCertificateInfo::SerialNumber, QString::fromUtf16(text->Ptr(),
   503             cert.setValue(EapQtCertificateInfo::SerialNumber, QString::fromUtf16(text->Ptr(),
   502                 text->Length()));
   504                 text->Length()));
   503 
   505 
   504             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SerialNumber: "
   506             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SerialNumber: "
   505                 << QString::fromUtf16(text->Ptr(), text->Length());
   507                 << QString::fromUtf16(text->Ptr(), text->Length());
   506         }
   508         }
   507         if ((*certEntries)[ind]->GetSubjectKeyIdPresent() != EFalse) {
   509         if (certPtr->GetSubjectKeyIdPresent() != EFalse) {
   508 
   510 
   509             subjectKeyId = (*certEntries)[ind]->GetSubjectKeyId();
   511             subjectKeyId = certPtr->GetSubjectKeyId();
   510             cert.setValue(EapQtCertificateInfo::SubjectKeyId, QByteArray(
   512             cert.setValue(EapQtCertificateInfo::SubjectKeyId, QByteArray(
   511                 reinterpret_cast<const char*> (subjectKeyId.Ptr()), subjectKeyId.Length()));
   513                 reinterpret_cast<const char*> (subjectKeyId.Ptr()), subjectKeyId.Length()));
   512 
   514 
   513             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SubjectKeyId: "
   515             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SubjectKeyId: "
   514                 << (QByteArray(reinterpret_cast<const char*> (subjectKeyId.Ptr()),
   516                 << (QByteArray(reinterpret_cast<const char*> (subjectKeyId.Ptr()),
   515                     subjectKeyId.Length())).toHex();
   517                     subjectKeyId.Length())).toHex();
   516         }
   518         }
   517         if ((*certEntries)[ind]->GetThumbprintPresent() != EFalse) {
   519         if (certPtr->GetThumbprintPresent() != EFalse) {
   518 
   520 
   519             text = (*certEntries)[ind]->GetThumbprint();
   521             text = certPtr->GetThumbprint();
   520             cert.setValue(EapQtCertificateInfo::ThumbPrint, QString::fromUtf16(text->Ptr(),
   522             cert.setValue(EapQtCertificateInfo::ThumbPrint, QString::fromUtf16(text->Ptr(),
   521                 text->Length()));
   523                 text->Length()));
   522 
   524 
   523             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo ThumbPrint: "
   525             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo ThumbPrint: "
   524                 << QString::fromUtf16(text->Ptr(), text->Length());
   526                 << QString::fromUtf16(text->Ptr(), text->Length());
   525         }
   527         }
   526         if ((*certEntries)[ind]->GetLabelPresent() != EFalse) {
   528         if (certPtr->GetLabelPresent() != EFalse) {
   527 
   529 
   528             text = (*certEntries)[ind]->GetLabel();
   530             text = certPtr->GetLabel();
   529             cert.setValue(EapQtCertificateInfo::CertificateLabel, QString::fromUtf16(text->Ptr(),
   531             cert.setValue(EapQtCertificateInfo::CertificateLabel, QString::fromUtf16(text->Ptr(),
   530                 text->Length()));
   532                 text->Length()));
   531 
   533 
   532             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo CertificateLabel: "
   534             qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo CertificateLabel: "
   533                 << QString::fromUtf16(text->Ptr(), text->Length());
   535                 << QString::fromUtf16(text->Ptr(), text->Length());
   734 bool EapQtConfigInterfacePrivate::readConfiguration(const EapQtPluginHandle& outerHandle,
   736 bool EapQtConfigInterfacePrivate::readConfiguration(const EapQtPluginHandle& outerHandle,
   735     const EapQtPluginHandle& pluginHandle, EapQtConfig& config)
   737     const EapQtPluginHandle& pluginHandle, EapQtConfig& config)
   736 {
   738 {
   737     qDebug("EapQtConfigInterfacePrivate::readConfiguration(), this = 0x%08x", this);
   739     qDebug("EapQtConfigInterfacePrivate::readConfiguration(), this = 0x%08x", this);
   738 
   740 
   739 
       
   740     // clear input
   741     // clear input
   741     config.clear();
   742     config.clear();
   742 
   743 
   743     checkInstanceThrowing();
   744     checkInstanceThrowing();
   744 
   745 
   807     return (value ? ETrue : EFalse);
   808     return (value ? ETrue : EFalse);
   808 }
   809 }
   809 
   810 
   810 void EapQtConfigInterfacePrivate::copyToEapSettings(EapQtConfig& config, EAPSettings& eapSettings)
   811 void EapQtConfigInterfacePrivate::copyToEapSettings(EapQtConfig& config, EAPSettings& eapSettings)
   811 {
   812 {
   812     // TODO:
       
   813     // - fix & add validation
       
   814     // - check if there are something missing still defined in EapSettings.h
       
   815     // - pac store parameters from eapqtconfig.h
       
   816 
   813 
   817     qDebug("EapQtConfigInterfacePrivate::copyToEapSettings(), this = 0x%08x", this);
   814     qDebug("EapQtConfigInterfacePrivate::copyToEapSettings(), this = 0x%08x", this);
   818 
   815 
   819 
   816 
   820     int ind = 0;
   817     int ind = 0;
   966     }
   963     }
   967 
   964 
   968     varValue = config.value(EapQtConfig::PACGroupReference);
   965     varValue = config.value(EapQtConfig::PACGroupReference);
   969     // do not copy if too large string
   966     // do not copy if too large string
   970     if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) {
   967     if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) {
   971         // TODO: what is the format (ascii/unicode?) of iPACGroupReference?
   968         // not supported
   972         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PACGroupReference: "
   969         qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PACGroupReference: "
   973             << varValue.toString();
   970             << varValue.toString();
   974     }
   971     }
   975 
   972 
   976     varValue = config.value(EapQtConfig::WarnADHPNoPAC);
   973     varValue = config.value(EapQtConfig::WarnADHPNoPAC);
  1203     (void) certEntry.take();
  1200     (void) certEntry.take();
  1204 }
  1201 }
  1205 
  1202 
  1206 void EapQtConfigInterfacePrivate::copyFromEapSettings(EAPSettings& eapSettings, EapQtConfig& config)
  1203 void EapQtConfigInterfacePrivate::copyFromEapSettings(EAPSettings& eapSettings, EapQtConfig& config)
  1207 {
  1204 {
  1208     // TODO:
       
  1209     // - add validation?
       
  1210     // - check if there are something missing still defined in EaPSettings.h
       
  1211     // - pac store parameters from eapqtconfig.h
       
  1212     qDebug("EapQtConfigInterfacePrivate::copyFromEapSettings(), this = 0x%08x", this);
  1205     qDebug("EapQtConfigInterfacePrivate::copyFromEapSettings(), this = 0x%08x", this);
  1213 
       
  1214 
  1206 
  1215     int ind = 0;
  1207     int ind = 0;
  1216 
  1208 
  1217     // automatic username
  1209     // automatic username
  1218     if (eapSettings.iUseAutomaticUsernamePresent) {
  1210     if (eapSettings.iUseAutomaticUsernamePresent) {