1 /* |
1 /* |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
15 * EAP method configuration QT interface |
15 * EAP method configuration QT interface |
16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 /* |
19 /* |
20 * %version: 41 % |
20 * %version: 49 % |
21 */ |
21 */ |
22 |
22 |
|
23 // System includes |
23 #include <QDir> |
24 #include <QDir> |
24 #include <QList> |
25 #include <QList> |
25 #include <QVariant> |
26 #include <QVariant> |
26 #include <QPluginLoader> |
27 #include <QPluginLoader> |
27 #include <HbTranslator> |
28 #include <HbTranslator> |
28 #include <QLocale> |
29 #include <QLocale> |
29 #include <QCoreApplication> |
30 #include <QCoreApplication> |
30 #include <QDebug> |
31 #include <QDebug> |
31 |
|
32 #include <cmmanager.h> |
32 #include <cmmanager.h> |
33 #include <cmpluginwlandef.h> |
33 #include <cmpluginwlandef.h> |
34 #include <EapGeneralSettings.h> |
34 #include <EapGeneralSettings.h> |
35 |
|
36 #include <eapqtplugininfo.h> |
35 #include <eapqtplugininfo.h> |
37 #include <eapqtcertificateinfo.h> |
36 #include <eapqtcertificateinfo.h> |
38 |
37 |
|
38 // User includes |
39 #include "cpeapplugininterface.h" |
39 #include "cpeapplugininterface.h" |
40 #include "eapqtconfiginterface_p.h" |
40 #include "eapqtconfiginterface_p.h" |
41 |
|
42 // validators |
|
43 #include "eapqtvalidatorpassword.h" |
41 #include "eapqtvalidatorpassword.h" |
44 #include "eapqtvalidatorusername.h" |
42 #include "eapqtvalidatorusername.h" |
45 #include "eapqtvalidatorrealm.h" |
43 #include "eapqtvalidatorrealm.h" |
46 |
44 #include "eapqtvalidatorpacstorepassword.h" |
47 static const QString eapPluginDir("\\resource\\qt\\plugins\\controlpanel\\eapsecurity"); |
45 #include "eapqtvalidatorpacstorepasswordconfirm.h" |
|
46 |
|
47 /*! |
|
48 * \class EapQtConfigInterfacePrivate |
|
49 * \brief Private implementation of EAP QT configuration interface |
|
50 */ |
|
51 |
|
52 // External function prototypes |
|
53 |
|
54 // Local constants |
48 static const QString eapTranslationFile("cpeapuiplugins"); |
55 static const QString eapTranslationFile("cpeapuiplugins"); |
|
56 |
|
57 // ======== LOCAL FUNCTIONS ======== |
|
58 |
|
59 // ======== MEMBER FUNCTIONS ======== |
49 |
60 |
50 EapQtConfigInterfacePrivate::EapQtConfigInterfacePrivate() : |
61 EapQtConfigInterfacePrivate::EapQtConfigInterfacePrivate() : |
51 mValidatorInstance(true), |
62 mValidatorInstance(true), |
52 mLastOuterHandle(EapQtPluginHandle::PluginUndefined), |
63 mLastOuterHandle(EapQtPluginHandle::PluginUndefined), |
53 mTranslator(NULL), |
64 mTranslator(NULL), |
57 mEapBearer(ELan), |
68 mEapBearer(ELan), |
58 mEapDbIndex(EapQtConfigInterface::IapIdUndefined), |
69 mEapDbIndex(EapQtConfigInterface::IapIdUndefined), |
59 mEapDbIndexValid(false) |
70 mEapDbIndexValid(false) |
60 { |
71 { |
61 qDebug("EapQtConfigInterfacePrivate() - created validator instance, this = 0x%08x", this); |
72 qDebug("EapQtConfigInterfacePrivate() - created validator instance, this = 0x%08x", this); |
62 |
73 } |
63 } |
74 |
64 |
75 EapQtConfigInterfacePrivate::EapQtConfigInterfacePrivate( |
65 EapQtConfigInterfacePrivate::EapQtConfigInterfacePrivate(/* EapQtConfigInterface *configIf, */ |
|
66 const EapQtConfigInterface::EapBearerType bearerType, const int iapId) : |
76 const EapQtConfigInterface::EapBearerType bearerType, const int iapId) : |
67 mValidatorInstance(false), |
77 mValidatorInstance(false), |
68 mLastOuterHandle(EapQtPluginHandle::PluginUndefined), |
78 mLastOuterHandle(EapQtPluginHandle::PluginUndefined), |
69 mTranslator(NULL), |
79 mTranslator(NULL), |
70 mEapGsIf(NULL), |
80 mEapGsIf(NULL), |
225 |
233 |
226 bool EapQtConfigInterfacePrivate::setEapWlanDbIndex(const int iapId) |
234 bool EapQtConfigInterfacePrivate::setEapWlanDbIndex(const int iapId) |
227 { |
235 { |
228 qDebug("EapQtConfigInterfacePrivate::setEapWlanDbIndex - requested id: %d, this = 0x%08x", iapId, this); |
236 qDebug("EapQtConfigInterfacePrivate::setEapWlanDbIndex - requested id: %d, this = 0x%08x", iapId, this); |
229 |
237 |
230 |
|
231 RCmManager cmm; |
238 RCmManager cmm; |
232 TRAPD(err, cmm.OpenL()); |
239 TRAPD(err, cmm.OpenL()); |
233 if (err != KErrNone) { |
240 if (err != KErrNone) { |
234 qDebug("ERROR: EapQtConfigInterfacePrivate::setEapWlanDbIndex - cmm.OpenL() failed", |
241 qDebug("ERROR: EapQtConfigInterfacePrivate::setEapWlanDbIndex - cmm.OpenL() failed", |
235 mEapBearer, iapId); |
242 mEapBearer, iapId); |
451 } |
459 } |
452 } |
460 } |
453 |
461 |
454 mLastOuterHandle = outer; |
462 mLastOuterHandle = outer; |
455 |
463 |
|
464 // sort the list |
|
465 qSort(mSupportedInnerTypes.begin(), mSupportedInnerTypes.end(), |
|
466 EapQtConfigInterfacePrivate::pluginLessThan); |
|
467 |
|
468 qDebug("EapQtConfigInterfacePrivate - supportedInnerTypes: supported EAP count: %d", |
|
469 mSupportedInnerTypes.count()); |
|
470 |
456 return mSupportedInnerTypes; |
471 return mSupportedInnerTypes; |
457 } |
472 } |
458 |
473 |
459 void EapQtConfigInterfacePrivate::copyCertificateInfo( |
474 void EapQtConfigInterfacePrivate::copyCertificateInfo( |
460 const RPointerArray<EapCertificateEntry>* const certEntries, |
475 const RPointerArray<EapCertificateEntry>* const certEntries, |
461 QList<EapQtCertificateInfo>* const certInfos) |
476 QList<EapQtCertificateInfo>* const certInfos) |
462 { |
477 { |
463 qDebug("EapQtConfigInterfacePrivate::copyCertificateInfo(), this = 0x%08x", this); |
478 qDebug("EapQtConfigInterfacePrivate::copyCertificateInfo(), this = 0x%08x", this); |
464 |
|
465 |
479 |
466 Q_ASSERT(certEntries); |
480 Q_ASSERT(certEntries); |
467 Q_ASSERT(certInfos); |
481 Q_ASSERT(certInfos); |
468 |
482 |
469 certInfos->clear(); |
483 certInfos->clear(); |
545 bool EapQtConfigInterfacePrivate::fetchCertificates(QList<EapQtCertificateInfo>* const caInfos, |
562 bool EapQtConfigInterfacePrivate::fetchCertificates(QList<EapQtCertificateInfo>* const caInfos, |
546 QList<EapQtCertificateInfo>* const clientInfos) |
563 QList<EapQtCertificateInfo>* const clientInfos) |
547 { |
564 { |
548 qDebug("EapQtConfigInterfacePrivate::fetchCertificates(), this = 0x%08x", this); |
565 qDebug("EapQtConfigInterfacePrivate::fetchCertificates(), this = 0x%08x", this); |
549 |
566 |
550 |
567 Q_ASSERT(caInfos != NULL || clientInfos != NULL); |
551 Q_ASSERT(caInfos != NULL || clientInfos != NULL || !mEapGsIf.isNull()); |
568 Q_ASSERT(!mEapGsIf.isNull()); |
552 |
569 |
553 TInt err(KErrNone); |
570 TInt err(KErrNone); |
554 RPointerArray<EapCertificateEntry> clientCerts; |
571 RPointerArray<EapCertificateEntry> clientCerts; |
555 RPointerArray<EapCertificateEntry> caCerts; |
572 RPointerArray<EapCertificateEntry> caCerts; |
556 |
573 |
557 // lists are always queried again as the user might have installed new certificates |
|
558 // during the life time of the object |
|
559 err = mEapGsIf->GetCertificateLists(clientCerts, caCerts); |
574 err = mEapGsIf->GetCertificateLists(clientCerts, caCerts); |
560 if (err != KErrNone) { |
575 if (err != KErrNone) { |
561 qDebug("EapQtConfigInterfacePrivate - fetchCertificates failed: %d", err); |
576 qDebug("EapQtConfigInterfacePrivate - fetchCertificates failed: %d", err); |
562 caCerts.ResetAndDestroy(); |
577 caCerts.ResetAndDestroy(); |
563 clientCerts.ResetAndDestroy(); |
578 clientCerts.ResetAndDestroy(); |
576 caCerts.ResetAndDestroy(); |
591 caCerts.ResetAndDestroy(); |
577 clientCerts.ResetAndDestroy(); |
592 clientCerts.ResetAndDestroy(); |
578 return true; |
593 return true; |
579 } |
594 } |
580 |
595 |
|
596 bool EapQtConfigInterfacePrivate::updateCertificates() { |
|
597 |
|
598 qDebug("EapQtConfigInterfacePrivate::updateCertificates(), this = 0x%08x", this); |
|
599 |
|
600 checkInstanceThrowing(); |
|
601 |
|
602 // empty current state |
|
603 mCaCertificates.clear(); |
|
604 mUserCertificates.clear(); |
|
605 |
|
606 return fetchCertificates(&mCaCertificates, &mUserCertificates); |
|
607 } |
|
608 |
581 QList<EapQtCertificateInfo> EapQtConfigInterfacePrivate::certificateAuthorityCertificates() |
609 QList<EapQtCertificateInfo> EapQtConfigInterfacePrivate::certificateAuthorityCertificates() |
582 { |
610 { |
583 qDebug("EapQtConfigInterfacePrivate::certificateAuthorityCertificates(), this = 0x%08x", this); |
611 qDebug("EapQtConfigInterfacePrivate::certificateAuthorityCertificates(), this = 0x%08x", this); |
584 |
612 |
585 |
|
586 checkInstanceThrowing(); |
613 checkInstanceThrowing(); |
587 |
614 |
588 QList<EapQtCertificateInfo> list; |
615 // update only if the list is empty |
589 if (!fetchCertificates(&list, 0)) { |
616 if(mCaCertificates.length() == 0) { |
590 // query failed |
617 qDebug() << "EapQtConfigInterfacePrivate::certificateAuthorityCertificates() - updates certificate lists"; |
591 list.clear(); |
618 updateCertificates(); |
592 } |
619 } |
593 return list; |
620 |
|
621 return mCaCertificates; |
594 } |
622 } |
595 |
623 |
596 QList<EapQtCertificateInfo> EapQtConfigInterfacePrivate::userCertificates() |
624 QList<EapQtCertificateInfo> EapQtConfigInterfacePrivate::userCertificates() |
597 { |
625 { |
598 qDebug("EapQtConfigInterfacePrivate::userCertificates(), this = 0x%08x", this); |
626 qDebug("EapQtConfigInterfacePrivate::userCertificates(), this = 0x%08x", this); |
599 |
627 |
600 |
628 // use the CA certificates method, it will update both the lists |
601 checkInstanceThrowing(); |
629 // if CA list is empty |
602 |
630 (void) certificateAuthorityCertificates(); |
603 QList<EapQtCertificateInfo> list; |
631 return mUserCertificates; |
604 if (!fetchCertificates(0, &list)) { |
632 } |
605 // query failed |
633 |
606 list.clear(); |
634 void EapQtConfigInterfacePrivate::getEapTypeIf(const EapQtPluginHandle &pluginHandle) |
607 } |
|
608 return list; |
|
609 } |
|
610 |
|
611 void EapQtConfigInterfacePrivate::getEapTypeIf(const EapQtPluginHandle& pluginHandle) |
|
612 { |
635 { |
613 qDebug("EapQtConfigInterfacePrivate::getEapTypeIf(), this = 0x%08x", this); |
636 qDebug("EapQtConfigInterfacePrivate::getEapTypeIf(), this = 0x%08x", this); |
614 |
|
615 |
637 |
616 // dig up the EAP type in TEapExpandedType format |
638 // dig up the EAP type in TEapExpandedType format |
617 TEapExpandedType eapServerType; |
639 TEapExpandedType eapServerType; |
618 QByteArray eapType = pluginHandle.type().eapExpandedData(); |
640 QByteArray eapType = pluginHandle.type().eapExpandedData(); |
619 TInt err(KErrNone); |
641 TInt err(KErrNone); |
657 // in config: |
679 // in config: |
658 // if OuterType is defined, the configuration for pluginHandle is set inside this OuterType |
680 // if OuterType is defined, the configuration for pluginHandle is set inside this OuterType |
659 // if OuterType is not defined, pluginHandle is for an outer type |
681 // if OuterType is not defined, pluginHandle is for an outer type |
660 // if InnerType is defined, the defined inner types in config are activated for pluginHandle |
682 // if InnerType is defined, the defined inner types in config are activated for pluginHandle |
661 // if InnerType is not defined, the pluginHandle does not activate any inner type (or they do not exist) |
683 // if InnerType is not defined, the pluginHandle does not activate any inner type (or they do not exist) |
662 bool EapQtConfigInterfacePrivate::saveConfiguration(const EapQtPluginHandle& pluginHandle, |
684 bool EapQtConfigInterfacePrivate::saveConfiguration(const EapQtPluginHandle &pluginHandle, |
663 EapQtConfig& config) |
685 const EapQtConfig &config) |
664 { |
686 { |
665 qDebug("EapQtConfigInterfacePrivate::saveConfiguration(), this = 0x%08x", this); |
687 qDebug("EapQtConfigInterfacePrivate::saveConfiguration(), this = 0x%08x", this); |
666 |
|
667 |
688 |
668 checkInstanceThrowing(); |
689 checkInstanceThrowing(); |
669 |
690 |
670 if (!mEapDbIndexValid) { |
691 if (!mEapDbIndexValid) { |
671 qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!"; |
692 qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!"; |
672 return false; |
693 return false; |
673 } |
694 } |
674 |
695 |
675 // only check if EAP ui is supported here, |
696 // set tunneling type & check if the requested EAP is supported |
676 // getEapTypeIf checks the EAP server support |
697 // if we are configuring outer type, OuterType == QVariant::Invalid or |
677 int dummy = 0; |
698 // EapQtPluginHandle::PluginUndefined |
678 if (!isUiSupported(pluginHandle.type().eapExpandedData(), dummy)) { |
699 |
679 qDebug( |
700 EapQtPluginHandle tmpOuterHandle; |
680 "ERROR: EapQtConfigInterfacePrivate::saveConfiguration() - UI not supported for the requested EAP"); |
701 QVariant varValue = config.value(EapQtConfig::OuterType); |
681 return false; |
702 if (varValue != QVariant::Invalid && !(varValue.value<EapQtPluginHandle> () == EapQtPluginHandle::PluginUndefined)) { |
|
703 tmpOuterHandle = varValue.value<EapQtPluginHandle> (); |
|
704 // check if supported |
|
705 if(!isSupportedInnerType(tmpOuterHandle, pluginHandle)) { |
|
706 qDebug("ERROR: EapQtConfigInterfacePrivate::saveConfiguration() - not supported outer/inner type combination"); |
|
707 return false; |
|
708 } |
|
709 } |
|
710 else { |
|
711 tmpOuterHandle = EapQtPluginHandle::PluginUndefined; |
|
712 // check if supported |
|
713 if(!isSupportedOuterType(pluginHandle)) { |
|
714 qDebug("ERROR: EapQtConfigInterfacePrivate::saveConfiguration() - not supported outer type"); |
|
715 return false; |
|
716 } |
682 } |
717 } |
683 |
718 |
684 getEapTypeIf(pluginHandle); |
719 getEapTypeIf(pluginHandle); |
685 if (mEapTypeIf.isNull()) { |
720 if (mEapTypeIf.isNull()) { |
686 qDebug("ERROR: EapQtConfigInterfacePrivate::saveConfiguration() - getEapTypeIf failed"); |
721 qDebug("ERROR: EapQtConfigInterfacePrivate::saveConfiguration() - getEapTypeIf failed"); |
687 return false; |
722 return false; |
688 } |
|
689 |
|
690 // set tunneling type |
|
691 // if we are configuring outer type, OuterType == Invalid or EapQtPluginHandle::PluginUndefined |
|
692 |
|
693 EapQtPluginHandle tmpOuterHandle; |
|
694 QVariant varValue = config.value(EapQtConfig::OuterType); |
|
695 if (varValue != QVariant::Invalid) { |
|
696 tmpOuterHandle = varValue.value<EapQtPluginHandle> (); |
|
697 } |
|
698 else { |
|
699 tmpOuterHandle = EapQtPluginHandle::PluginUndefined; |
|
700 } |
723 } |
701 |
724 |
702 TEapExpandedType tmpOuterEap; |
725 TEapExpandedType tmpOuterEap; |
703 tmpOuterEap.SetValue(tmpOuterHandle.type().eapExpandedData().data(), |
726 tmpOuterEap.SetValue(tmpOuterHandle.type().eapExpandedData().data(), |
704 tmpOuterHandle.type().eapExpandedData().length()); |
727 tmpOuterHandle.type().eapExpandedData().length()); |
746 if (!mEapDbIndexValid) { |
769 if (!mEapDbIndexValid) { |
747 qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!"; |
770 qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!"; |
748 return false; |
771 return false; |
749 } |
772 } |
750 |
773 |
751 // only check if UI is supported for pluginHandle here, |
774 // check EAP type support |
752 // getEapTypeIf checks the EAP server support |
775 if(!(outerHandle == EapQtPluginHandle::PluginUndefined)) { |
753 int dummy = 0; |
776 if(!isSupportedInnerType(outerHandle, pluginHandle)) { |
754 if (!isUiSupported(pluginHandle.type().eapExpandedData(), dummy)) { |
777 qDebug("ERROR: EapQtConfigInterfacePrivate::readConfiguration() - not supported outer/inner type combination"); |
755 qDebug( |
778 return false; |
756 "ERROR: EapQtConfigInterfacePrivate::readConfiguration - UI not supported for the requested EAP"); |
779 } |
757 return false; |
780 } else { |
|
781 if(!isSupportedOuterType(pluginHandle)) { |
|
782 qDebug("ERROR: EapQtConfigInterfacePrivate::readConfiguration() - not supported outer type"); |
|
783 return false; |
|
784 } |
758 } |
785 } |
759 |
786 |
760 getEapTypeIf(pluginHandle); |
787 getEapTypeIf(pluginHandle); |
761 if (mEapTypeIf.isNull()) { |
788 if (mEapTypeIf.isNull()) { |
762 qDebug("ERROR: EapQtConfigInterfacePrivate::readConfiguration - getEapTypeIf failed"); |
789 qDebug("ERROR: EapQtConfigInterfacePrivate::readConfiguration - getEapTypeIf failed"); |
806 TBool EapQtConfigInterfacePrivate::convertToTbool(bool value) |
833 TBool EapQtConfigInterfacePrivate::convertToTbool(bool value) |
807 { |
834 { |
808 return (value ? ETrue : EFalse); |
835 return (value ? ETrue : EFalse); |
809 } |
836 } |
810 |
837 |
811 void EapQtConfigInterfacePrivate::copyToEapSettings(EapQtConfig& config, EAPSettings& eapSettings) |
838 void EapQtConfigInterfacePrivate::copyToEapSettings(const EapQtConfig &config, EAPSettings &eapSettings) |
812 { |
839 { |
813 |
|
814 qDebug("EapQtConfigInterfacePrivate::copyToEapSettings(), this = 0x%08x", this); |
840 qDebug("EapQtConfigInterfacePrivate::copyToEapSettings(), this = 0x%08x", this); |
815 |
|
816 |
841 |
817 int ind = 0; |
842 int ind = 0; |
818 |
843 |
819 QVariant varValue = config.value(EapQtConfig::UsernameAutomatic); |
844 QVariant varValue = config.value(EapQtConfig::UsernameAutomatic); |
820 if (varValue.type() == QVariant::Bool) { |
845 if (varValue.type() == QVariant::Bool) { |
924 if (varValue.type() == QVariant::Bool) { |
949 if (varValue.type() == QVariant::Bool) { |
925 eapSettings.iPEAPVersionsPresent = ETrue; |
950 eapSettings.iPEAPVersionsPresent = ETrue; |
926 eapSettings.iPEAPv0Allowed = convertToTbool(varValue.toBool()); |
951 eapSettings.iPEAPv0Allowed = convertToTbool(varValue.toBool()); |
927 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion0Allowed: " |
952 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion0Allowed: " |
928 << varValue.toBool(); |
953 << varValue.toBool(); |
|
954 } else { |
|
955 // in any other case disable PEAP version; |
|
956 // no need to set eapSettings.iPEAPVersionsPresent, |
|
957 // it will be set if one of the other PEAP versions is enabled, |
|
958 // otherwise this setting is redundant and can be ignored |
|
959 eapSettings.iPEAPv0Allowed = EFalse; |
929 } |
960 } |
930 |
961 |
931 varValue = config.value(EapQtConfig::PeapVersion1Allowed); |
962 varValue = config.value(EapQtConfig::PeapVersion1Allowed); |
932 if (varValue.type() == QVariant::Bool) { |
963 if (varValue.type() == QVariant::Bool) { |
933 eapSettings.iPEAPVersionsPresent = ETrue; |
964 eapSettings.iPEAPVersionsPresent = ETrue; |
934 eapSettings.iPEAPv1Allowed = convertToTbool(varValue.toBool()); |
965 eapSettings.iPEAPv1Allowed = convertToTbool(varValue.toBool()); |
935 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion1Allowed: " |
966 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion1Allowed: " |
936 << varValue.toBool(); |
967 << varValue.toBool(); |
|
968 } else { |
|
969 // in any other case disable PEAP version; |
|
970 // no need to set eapSettings.iPEAPVersionsPresent, |
|
971 // it will be set if one of the other PEAP versions is enabled, |
|
972 // otherwise this setting is redundant and can be ignored |
|
973 eapSettings.iPEAPv1Allowed = EFalse; |
937 } |
974 } |
938 |
975 |
939 varValue = config.value(EapQtConfig::PeapVersion2Allowed); |
976 varValue = config.value(EapQtConfig::PeapVersion2Allowed); |
940 if (varValue.type() == QVariant::Bool) { |
977 if (varValue.type() == QVariant::Bool) { |
941 eapSettings.iPEAPVersionsPresent = ETrue; |
978 eapSettings.iPEAPVersionsPresent = ETrue; |
942 eapSettings.iPEAPv2Allowed = convertToTbool(varValue.toBool()); |
979 eapSettings.iPEAPv2Allowed = convertToTbool(varValue.toBool()); |
943 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion2Allowed: " |
980 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion2Allowed: " |
944 << varValue.toBool(); |
981 << varValue.toBool(); |
|
982 } else { |
|
983 // in any other case disable PEAP version; |
|
984 // no need to set eapSettings.iPEAPVersionsPresent, |
|
985 // it will be set if one of the other PEAP versions is enabled, |
|
986 // otherwise this setting is redundant and can be ignored |
|
987 eapSettings.iPEAPv2Allowed = EFalse; |
945 } |
988 } |
946 |
989 |
947 varValue = config.value(EapQtConfig::ProvisioningModeAuthenticated); |
990 varValue = config.value(EapQtConfig::ProvisioningModeAuthenticated); |
948 if (varValue.type() == QVariant::Bool) { |
991 if (varValue.type() == QVariant::Bool) { |
949 eapSettings.iAuthProvModeAllowedPresent = ETrue; |
992 eapSettings.iAuthProvModeAllowedPresent = ETrue; |
963 } |
1006 } |
964 |
1007 |
965 varValue = config.value(EapQtConfig::PACGroupReference); |
1008 varValue = config.value(EapQtConfig::PACGroupReference); |
966 // do not copy if too large string |
1009 // do not copy if too large string |
967 if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) { |
1010 if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) { |
968 // not supported |
1011 eapSettings.iPACGroupReference.Copy(varValue.toString().utf16()); |
|
1012 eapSettings.iPACGroupReferencePresent = ETrue; |
969 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PACGroupReference: " |
1013 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PACGroupReference: " |
970 << varValue.toString(); |
1014 << varValue.toString(); |
971 } |
1015 } |
972 |
1016 |
973 varValue = config.value(EapQtConfig::WarnADHPNoPAC); |
1017 varValue = config.value(EapQtConfig::WarnADHPNoPAC); |
1035 if (varValue.type() == QVariant::List) { |
1079 if (varValue.type() == QVariant::List) { |
1036 |
1080 |
1037 qDebug() << "EapQtConfigInterfacePrivate::copyToEapSettings() - CipherSuites present"; |
1081 qDebug() << "EapQtConfigInterfacePrivate::copyToEapSettings() - CipherSuites present"; |
1038 QList<QVariant> varCiphers = varValue.toList(); |
1082 QList<QVariant> varCiphers = varValue.toList(); |
1039 |
1083 |
|
1084 // clears the ciphersuite configuration if the provided list is empty |
|
1085 eapSettings.iCipherSuitesPresent = ETrue; |
|
1086 |
1040 for (ind = 0; ind < varCiphers.count(); ind++) { |
1087 for (ind = 0; ind < varCiphers.count(); ind++) { |
1041 // check that the item is of correct type (int also accepted to not be too strict) |
1088 // check that the item is of correct type (int also accepted to not be too strict) |
1042 if (varCiphers[ind].type() == QVariant::UInt || varCiphers[ind].type() == QVariant::Int) { |
1089 if (varCiphers[ind].type() == QVariant::UInt || varCiphers[ind].type() == QVariant::Int) { |
1043 // set to true only if at least item cipher is ok |
|
1044 eapSettings.iCipherSuitesPresent = ETrue; |
|
1045 eapSettings.iCipherSuites.Append(varCiphers[ind].toUInt()); |
1090 eapSettings.iCipherSuites.Append(varCiphers[ind].toUInt()); |
1046 qDebug( |
1091 qDebug( |
1047 "EapQtConfigInterfacePrivate::copyToEapSettings() - CipherSuites at %d: 0x%08x", |
1092 "EapQtConfigInterfacePrivate::copyToEapSettings() - CipherSuites at %d: 0x%08x", |
1048 ind, varCiphers[ind].toUInt()); |
1093 ind, varCiphers[ind].toUInt()); |
1049 } |
1094 } |
1050 } |
1095 } |
1051 } |
1096 } |
1052 |
1097 |
|
1098 // set always to true to support clearing previously configured CA/user certificates |
|
1099 // if the EAP method in question does not use certificates, |
|
1100 // EAP server will ignore the setting; |
|
1101 // CA/user certificates get cleared if EapQtConfig::Authority/UserCertificate is QVariant::Invalid or |
|
1102 // the provided lists are empty |
|
1103 eapSettings.iCertificatesPresent = ETrue; |
|
1104 |
1053 varValue = config.value(EapQtConfig::AuthorityCertificate); |
1105 varValue = config.value(EapQtConfig::AuthorityCertificate); |
1054 if (varValue.type() == QVariant::List) { |
1106 if (varValue.type() == QVariant::List) { |
1055 |
1107 |
1056 qDebug() |
1108 qDebug() |
1057 << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate present"; |
1109 << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate present"; |
1058 |
1110 |
1059 QList<QVariant> varCerts = varValue.toList(); |
1111 QList<QVariant> varCerts = varValue.toList(); |
1060 for (ind = 0; ind < varCerts.count(); ind++) { |
1112 for (ind = 0; ind < varCerts.count(); ind++) { |
1061 // check that the item is of correct type |
1113 // check that the item is of correct type |
1062 if (varCerts[ind].canConvert<EapQtCertificateInfo> ()) { |
1114 if (varCerts[ind].canConvert<EapQtCertificateInfo> ()) { |
1063 // set to true only if at least one item is ok |
|
1064 eapSettings.iCertificatesPresent = ETrue; |
|
1065 appendCertificateInfo(true, varCerts[ind].value<EapQtCertificateInfo> (), |
1115 appendCertificateInfo(true, varCerts[ind].value<EapQtCertificateInfo> (), |
1066 &(eapSettings.iCertificates)); |
1116 &(eapSettings.iCertificates)); |
1067 qDebug() |
1117 qDebug() |
1068 << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate appended"; |
1118 << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate appended"; |
1069 } |
1119 } |
1077 |
1127 |
1078 QList<QVariant> varCerts = varValue.toList(); |
1128 QList<QVariant> varCerts = varValue.toList(); |
1079 for (ind = 0; ind < varCerts.count(); ind++) { |
1129 for (ind = 0; ind < varCerts.count(); ind++) { |
1080 // check that the item is of correct type |
1130 // check that the item is of correct type |
1081 if (varCerts[ind].canConvert<EapQtCertificateInfo> ()) { |
1131 if (varCerts[ind].canConvert<EapQtCertificateInfo> ()) { |
1082 // set to true only if at least one item is ok |
|
1083 eapSettings.iCertificatesPresent = ETrue; |
|
1084 appendCertificateInfo(false, varCerts[ind].value<EapQtCertificateInfo> (), |
1132 appendCertificateInfo(false, varCerts[ind].value<EapQtCertificateInfo> (), |
1085 &(eapSettings.iCertificates)); |
1133 &(eapSettings.iCertificates)); |
1086 qDebug() |
1134 qDebug() |
1087 << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate appended"; |
1135 << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate appended"; |
1088 } |
1136 } |
1094 // caller takes care of deallocating resulting data in certList |
1142 // caller takes care of deallocating resulting data in certList |
1095 void EapQtConfigInterfacePrivate::appendCertificateInfo(bool isCaCertificate, |
1143 void EapQtConfigInterfacePrivate::appendCertificateInfo(bool isCaCertificate, |
1096 const EapQtCertificateInfo& certInfo, RPointerArray<EapCertificateEntry>* const certList) |
1144 const EapQtCertificateInfo& certInfo, RPointerArray<EapCertificateEntry>* const certList) |
1097 { |
1145 { |
1098 qDebug("EapQtConfigInterfacePrivate::appendCertificateInfo(), this = 0x%08x", this); |
1146 qDebug("EapQtConfigInterfacePrivate::appendCertificateInfo(), this = 0x%08x", this); |
1099 |
|
1100 |
1147 |
1101 Q_ASSERT(certList); |
1148 Q_ASSERT(certList); |
1102 |
1149 |
1103 // use scoped pointer to make sure memory is not leaked in failures |
1150 // use scoped pointer to make sure memory is not leaked in failures |
1104 QScopedPointer<EapCertificateEntry> certEntry(new EapCertificateEntry); |
1151 QScopedPointer<EapCertificateEntry> certEntry(new EapCertificateEntry); |
1481 |
1528 |
1482 QList<EapQtPluginHandle> EapQtConfigInterfacePrivate::selectedOuterTypes() |
1529 QList<EapQtPluginHandle> EapQtConfigInterfacePrivate::selectedOuterTypes() |
1483 { |
1530 { |
1484 qDebug("EapQtConfigInterfacePrivate::selectedOuterTypes(), this = 0x%08x", this); |
1531 qDebug("EapQtConfigInterfacePrivate::selectedOuterTypes(), this = 0x%08x", this); |
1485 |
1532 |
1486 |
|
1487 checkInstanceThrowing(); |
1533 checkInstanceThrowing(); |
1488 |
1534 |
1489 if (!mEapDbIndexValid) { |
1535 if (!mEapDbIndexValid) { |
1490 qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!"; |
1536 qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!"; |
1491 return QList<EapQtPluginHandle> (); |
1537 return QList<EapQtPluginHandle> (); |
1510 selectedOuterTypes.count()); |
1556 selectedOuterTypes.count()); |
1511 |
1557 |
1512 return selectedOuterTypes; |
1558 return selectedOuterTypes; |
1513 } |
1559 } |
1514 |
1560 |
1515 bool EapQtConfigInterfacePrivate::isSupportedOuterType(const EapQtPluginHandle& handle) |
1561 bool EapQtConfigInterfacePrivate::isSupportedOuterType(const EapQtPluginHandle &handle) |
1516 { |
1562 { |
1517 qDebug("EapQtConfigInterfacePrivate::isSupportedOuterType(), this = 0x%08x", this); |
1563 qDebug("EapQtConfigInterfacePrivate::isSupportedOuterType(), this = 0x%08x", this); |
1518 |
|
1519 |
1564 |
1520 checkInstanceThrowing(); |
1565 checkInstanceThrowing(); |
1521 |
1566 |
1522 // check if mSupportedOuterTypes is up-to-date |
1567 // check if mSupportedOuterTypes is up-to-date |
1523 if (mSupportedOuterTypes.count() <= 0) { |
1568 if (mSupportedOuterTypes.count() <= 0) { |
1635 { |
1677 { |
1636 qDebug("EapQtConfigInterfacePrivate::loadPlugins(), this = 0x%08x", this); |
1678 qDebug("EapQtConfigInterfacePrivate::loadPlugins(), this = 0x%08x", this); |
1637 |
1679 |
1638 checkInstanceThrowing(); |
1680 checkInstanceThrowing(); |
1639 |
1681 |
1640 QDir pluginsDir(eapPluginDir); |
1682 // plugin directory defined in cpeapplugininterface.h |
|
1683 QDir pluginsDir(CpEapPluginInterfacePluginDirectory); |
1641 foreach( QString fileName, pluginsDir.entryList(QDir::Files) ) |
1684 foreach( QString fileName, pluginsDir.entryList(QDir::Files) ) |
1642 { |
1685 { |
1643 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName)); |
1686 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName)); |
1644 QObject *tmp = loader.instance(); |
1687 QObject *tmp = loader.instance(); |
1645 if (tmp) { |
1688 if (tmp) { |
1653 // collect UI plugin infos |
1696 // collect UI plugin infos |
1654 QList<CpEapPluginInterface*>::iterator iter; |
1697 QList<CpEapPluginInterface*>::iterator iter; |
1655 for (iter = mPlugins.begin(); iter != mPlugins.end(); ++iter) { |
1698 for (iter = mPlugins.begin(); iter != mPlugins.end(); ++iter) { |
1656 mPluginInfos.append((*iter)->pluginInfo()); |
1699 mPluginInfos.append((*iter)->pluginInfo()); |
1657 } |
1700 } |
1658 } |
1701 |
1659 |
1702 // sort the UI plugins according to their order number |
1660 CpBaseSettingView *EapQtConfigInterfacePrivate::uiInstance(const EapQtPluginHandle& outerHandle, |
1703 qSort(mPluginInfos.begin(), mPluginInfos.end(), EapQtConfigInterfacePrivate::pluginLessThan); |
1661 const EapQtPluginHandle& pluginHandle) |
1704 |
|
1705 qDebug("EapQtConfigInterfacePrivate - loadPlugins: supported EAP plugin count: %d", |
|
1706 mPluginInfos.count()); |
|
1707 } |
|
1708 |
|
1709 bool EapQtConfigInterfacePrivate::pluginLessThan( |
|
1710 const EapQtPluginInfo &plugin1, |
|
1711 const EapQtPluginInfo &plugin2) |
|
1712 { |
|
1713 return plugin1.orderNumber() < plugin2.orderNumber(); |
|
1714 } |
|
1715 |
|
1716 CpBaseSettingView *EapQtConfigInterfacePrivate::uiInstance(const EapQtPluginHandle &outerHandle, |
|
1717 const EapQtPluginHandle &pluginHandle) |
1662 { |
1718 { |
1663 qDebug("EapQtConfigInterfacePrivate::uiInstance(), this = 0x%08x", this); |
1719 qDebug("EapQtConfigInterfacePrivate::uiInstance(), this = 0x%08x", this); |
1664 |
|
1665 |
1720 |
1666 checkInstanceThrowing(); |
1721 checkInstanceThrowing(); |
1667 |
1722 |
1668 // if outer type UI is requested, outerHandle must be undefined and pluginHandle |
1723 // if outer type UI is requested, outerHandle must be undefined and pluginHandle |
1669 // must be supported as outer type |
1724 // must be supported as outer type |