You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

483 lines
24 KiB

#include "security802_1xtab.h"
#include "ui_security802_1xtab.h"
#include <QDebug>
Security802_1xTab::Security802_1xTab(QWidget *parent) :
QDialog(parent),
ui(new Ui::Security802_1xTab)
{
ui->setupUi(this);
connect(ui->enable802_1xCheckBox, &QCheckBox::stateChanged, this, &Security802_1xTab::onEnable802_1xCheckBoxToggled);
onEnable802_1xCheckBoxToggled(Qt::Unchecked);
QStringList passwordStoreItems;
passwordStoreItems.append(tr("Store password for all users (not encrypted)"));
passwordStoreItems.append(tr("Store password for this user (encrypted)"));
passwordStoreItems.append(tr("Ask for this password every time"));
ui->md5PasswordStoreComboBox->addItems(passwordStoreItems);
ui->tlsPasswordStoreComboBox->addItems(passwordStoreItems);
ui->pwdPasswordStoreComboBox->addItems(passwordStoreItems);
ui->fastPasswordStoreComboBox->addItems(passwordStoreItems);
ui->ttlsPasswordStoreComboBox->addItems(passwordStoreItems);
ui->peapPasswordStoreComboBox->addItems(passwordStoreItems);
ui->fastAutoPacProvisionComboBox->addItems(QStringList() << tr("Anonymous") << tr("Authenticated") << tr("Both"));
ui->fastInnerAuthenticationComboBox->addItems(QStringList() << tr("GTC") << tr("MSCHAPv2"));
ui->ttlsInnerAuthenticationComboBox->addItems(QStringList() << tr("PAP") << tr("CHAP") << tr("MSCHAP") << tr("MSCHAPv2"));
ui->peapVersionComboBox->addItems(QStringList() << tr("Automatic") << tr ("Zero") << tr("One"));
ui->peapInnerAuthenticationComboBox->addItems(QStringList() << tr("MSCHAPv2") << tr("MD5") << tr("GTC"));
connect(ui->md5ShowPasswordCheckBox, &QCheckBox::stateChanged, this, &Security802_1xTab::onMd5ShowPasswordCheckBoxToggled);
connect(ui->tlsShowPasswordCheckBox, &QCheckBox::stateChanged, this, &Security802_1xTab::onTlsShowPasswordCheckBoxToggled);
connect(ui->pwdShowPasswordCheckBox, &QCheckBox::stateChanged, this, &Security802_1xTab::onPwdShowPasswordCheckBoxToggled);
connect(ui->fastShowPasswordCheckBox, &QCheckBox::stateChanged, this, &Security802_1xTab::onFastShowPasswordCheckBoxToggled);
connect(ui->ttlsShowPasswordCheckBox, &QCheckBox::stateChanged, this, &Security802_1xTab::onTtlsShowPasswordCheckBoxToggled);
connect(ui->peapShowPasswordCheckBox, &QCheckBox::stateChanged, this, &Security802_1xTab::onPeapShowPasswordCheckBoxToggled);
}
Security802_1xTab::~Security802_1xTab()
{
delete ui;
}
QVariantMap Security802_1xTab::readSettings()
{
QVariantMap output;
if (ui->enable802_1xCheckBox->isChecked()) {
output.insert("802.1xEnabled", true);
switch (ui->authenticationModeTabs->currentIndex()) {
case 0: // MD5
output.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthMd5);
output.insert("802.1xMd5Username", ui->md5UsernameLineEdit->text());
output.insert("802.1xMd5Password", ui->md5PasswordLineEdit->text());
switch (ui->md5PasswordStoreComboBox->currentIndex()) {
case 0: // all users
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers);
break;
case 1: // one user
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser);
break;
case 2: // ask every time
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved);
break;
}
break;
case 1: // TLS
output.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthTls);
output.insert("802.1xTlsIdentity", ui->tlsIdentityLineEdit->text());
output.insert("802.1xTlsDomain", ui->tlsDomainLineEdit->text());
output.insert("802.1xTlsCaCertificate", ui->tlsCaCertificateLineEdit->text());
output.insert("802.1xTlsUserCertificate",ui->tlsUserCertificateLineEdit->text());
output.insert("802.1xTlsUserPrivateKey", ui->tlsUserPrivateKeyLineEdit->text());
output.insert("802.1xTlsUserKeyPassword", ui->tlsUserKeyPasswordLineEdit->text());
switch (ui->tlsPasswordStoreComboBox->currentIndex()) {
case 0: // all users
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers);
break;
case 1: // one user
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser);
break;
case 2: // ask every time
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved);
break;
}
break;
case 2: // PWD
output.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthPwd);
output.insert("802.1xPwdUsername", ui->pwdUsernameLineEdit->text());
output.insert("802.1xPwdPassword", ui->pwdPasswordLineEdit->text());
switch (ui->pwdPasswordStoreComboBox->currentIndex()) {
case 0: // all users
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers);
break;
case 1: // one user
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser);
break;
case 2: // ask every time
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved);
break;
}
break;
case 3: // FAST
output.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthFast);
output.insert("802.1xFastAnonymousIdentity", ui->fastAnonymousIdentityLineEdit->text());
if (ui->fastAutoPacProvisionCheckBox->isChecked()) {
switch (ui->fastAutoPacProvisionComboBox->currentIndex()) {
case 0: // Anonymous
output.insert("802.1xFastProvisioningMode", ConnectionSettingsEngine::Security802_1xFastProvisioningAnonymous);
break;
case 1: // Authenticated
output.insert("802.1xFastProvisioningMode", ConnectionSettingsEngine::Security802_1xFastProvisioningAuthenticated);
break;
case 2: // Both
output.insert("802.1xFastProvisioningMode", ConnectionSettingsEngine::Security802_1xFastProvisioningBoth);
break;
}
} else {
output.insert("802.1xFastProvisioningMode", ConnectionSettingsEngine::Security802_1xFastProvisioningOff);
}
output.insert("802.1xFastPacFile", ui->fastPacFileLineEdit->text());
switch (ui->fastInnerAuthenticationComboBox->currentIndex()) {
case 0: // GTC
output.insert("802.1xFastAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodGtc);
break;
case 1: // MSCHAPv2
output.insert("802.1xFastAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2);
break;
}
output.insert("802.1xFastUsername", ui->fastUsernameLineEdit->text());
output.insert("802.1xFastPassword", ui->fastPasswordLineEdit->text());
switch (ui->fastPasswordStoreComboBox->currentIndex()) {
case 0: // all users
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers);
break;
case 1: // one user
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser);
break;
case 2: // ask every time
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved);
break;
}
break;
case 4: // Tunneled TLS
output.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthTtls);
output.insert("802.1xTtlsAnonymousIdentity", ui->ttlsAnonymousIdentityLineEdit->text());
output.insert("802.1xTtlsDomain", ui->ttlsDomainLineEdit->text());
output.insert("802.1xTtlsCaCertificate", ui->ttlsCaCertificateLineEdit->text());
switch (ui->ttlsInnerAuthenticationComboBox->currentIndex()) {
case 0: // PAP
output.insert("802.1xTtlsAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodPap);
break;
case 1: // CHAP
output.insert("802.1xTtlsAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodChap);
break;
case 2: // MSCHAP
output.insert("802.1xTtlsAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodMschap);
break;
case 3: // MSCHAPv2
output.insert("802.1xTtlsAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2);
break;
}
output.insert("802.1xTtlsUsername", ui->ttlsUsernameLineEdit->text());
output.insert("802.1xTtlsPassword", ui->ttlsPasswordLineEdit->text());
switch (ui->ttlsPasswordStoreComboBox->currentIndex()) {
case 0: // all users
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers);
break;
case 1: // one user
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser);
break;
case 2: // ask every time
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved);
break;
}
break;
case 5: // Protected EAP
output.insert("802.1xAuthMode", ConnectionSettingsEngine::Security802_1xAuthPeap);
output.insert("802.1xPeapAnonymousIdentity", ui->peapAnonymousIdentityLineEdit->text());
output.insert("802.1xPeapDomain", ui->peapDomainLineEdit->text());
output.insert("802.1xPeapCaCertificate", ui->peapCaCertificateLineEdit->text());
switch (ui->peapVersionComboBox->currentIndex()) {
case 0: // Automatic
output.insert("802.1xPeapVersion", ConnectionSettingsEngine::Security802_1xPeapVersionUnknown);
break;
case 1: // Zero
output.insert("802.1xPeapVersion", ConnectionSettingsEngine::Security802_1xPeapVersionZero);
break;
case 2: // One
output.insert("802.1xPeapVersion", ConnectionSettingsEngine::Security802_1xPeapVersionOne);
break;
}
switch (ui->peapInnerAuthenticationComboBox->currentIndex()) {
case 0: // MSCHAPv2
output.insert("802.1xPeapAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2);
break;
case 1: // MD5
output.insert("802.1xPeapAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodMd5);
break;
case 2: // GTC
output.insert("802.1xPeapAuthMethod", ConnectionSettingsEngine::Security802_1xAuthMethodGtc);
break;
}
output.insert("802.1xPeapUsername", ui->peapUsernameLineEdit->text());
output.insert("802.1xPeapPassword", ui->peapPasswordLineEdit->text());
switch (ui->peapPasswordStoreComboBox->currentIndex()) {
case 0: // all users
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers);
break;
case 1: // one user
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser);
break;
case 2: // ask every time
output.insert("802.1xPasswordStore", ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved);
break;
}
break;
}
} else {
output.insert("802.1xEnabled", false);
}
return output;
}
void Security802_1xTab::loadSettings(QVariantMap settings)
{
if (settings["802.1xEnabled"].isValid() && settings["802.1xEnabled"].toBool()) {
ui->enable802_1xCheckBox->setChecked(true);
switch (settings["802.1xAuthMode"].toInt()) {
case ConnectionSettingsEngine::Security802_1xAuthMd5:
ui->authenticationModeTabs->setCurrentIndex(0);
ui->md5UsernameLineEdit->setText(settings["802.1xMd5Username"].toString());
ui->md5PasswordLineEdit->setText(settings["802.1xMd5Password"].toString());
switch (settings["802.1xPasswordStore"].toInt()) {
case ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers:
ui->md5PasswordStoreComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser:
ui->md5PasswordStoreComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved:
ui->md5PasswordStoreComboBox->setCurrentIndex(2);
break;
}
break;
case ConnectionSettingsEngine::Security802_1xAuthTls:
ui->authenticationModeTabs->setCurrentIndex(1);
ui->tlsIdentityLineEdit->setText(settings["802.1xTlsIdentity"].toString());
ui->tlsDomainLineEdit->setText(settings["802.1xTlsDomain"].toString());
ui->tlsCaCertificateLineEdit->setText(settings["802.1xTlsCaCertificate"].toString());
ui->tlsUserCertificateLineEdit->setText(settings["802.1xTlsUserCertificate"].toString());
ui->tlsUserPrivateKeyLineEdit->setText(settings["802.1xTlsUserPrivateKey"].toString());
ui->tlsUserKeyPasswordLineEdit->setText(settings["802.1xTlsUserKeyPassword"].toString());
switch (settings["802.1xPasswordStore"].toInt()) {
case ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers:
ui->tlsPasswordStoreComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser:
ui->tlsPasswordStoreComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved:
ui->tlsPasswordStoreComboBox->setCurrentIndex(2);
break;
}
break;
case ConnectionSettingsEngine::Security802_1xAuthPwd:
ui->authenticationModeTabs->setCurrentIndex(2);
ui->pwdUsernameLineEdit->setText(settings["802.1xPwdUsername"].toString());
ui->pwdPasswordLineEdit->setText(settings["802.1xPwdPassword"].toString());
switch (settings["802.1xPasswordStore"].toInt()) {
case ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers:
ui->pwdPasswordStoreComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser:
ui->pwdPasswordStoreComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved:
ui->pwdPasswordStoreComboBox->setCurrentIndex(2);
break;
}
break;
case ConnectionSettingsEngine::Security802_1xAuthFast:
ui->authenticationModeTabs->setCurrentIndex(3);
ui->fastAnonymousIdentityLineEdit->setText(settings["802.1xFastAnonymousIdentity"].toString());
switch (settings["802.1xFastProvisioningMode"].toInt()) {
case ConnectionSettingsEngine::Security802_1xFastProvisioningAnonymous:
ui->fastAutoPacProvisionCheckBox->setChecked(true);
ui->fastAutoPacProvisionComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Security802_1xFastProvisioningAuthenticated:
ui->fastAutoPacProvisionCheckBox->setChecked(true);
ui->fastAutoPacProvisionComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Security802_1xFastProvisioningBoth:
ui->fastAutoPacProvisionCheckBox->setChecked(true);
ui->fastAutoPacProvisionComboBox->setCurrentIndex(2);
break;
case ConnectionSettingsEngine::Security802_1xFastProvisioningOff:
ui->fastAutoPacProvisionCheckBox->setChecked(false);
break;
}
ui->fastPacFileLineEdit->setText(settings["802.1xFastPacFile"].toString());
switch (settings["802.1xFastAuthMethod"].toInt()) {
case ConnectionSettingsEngine::Security802_1xAuthMethodGtc:
ui->fastInnerAuthenticationComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2:
ui->fastInnerAuthenticationComboBox->setCurrentIndex(1);
break;
}
ui->fastUsernameLineEdit->setText(settings["802.1xFastUsername"].toString());
ui->fastPasswordLineEdit->setText(settings["802.1xFastPassword"].toString());
switch (settings["802.1xPasswordStore"].toInt()) {
case ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers:
ui->fastPasswordStoreComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser:
ui->fastPasswordStoreComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved:
ui->fastPasswordStoreComboBox->setCurrentIndex(2);
break;
}
break;
case ConnectionSettingsEngine::Security802_1xAuthTtls:
ui->authenticationModeTabs->setCurrentIndex(4);
ui->ttlsAnonymousIdentityLineEdit->setText(settings["802.1xTtlsAnonymousIdentity"].toString());
ui->ttlsDomainLineEdit->setText(settings["802.1xTtlsDomain"].toString());
ui->ttlsCaCertificateLineEdit->setText(settings["802.1xTtlsCaCertificate"].toString());
switch (settings["802.1xTtlsAuthMethod"].toInt()) {
case ConnectionSettingsEngine::Security802_1xAuthMethodPap:
ui->ttlsInnerAuthenticationComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Security802_1xAuthMethodChap:
ui->ttlsInnerAuthenticationComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Security802_1xAuthMethodMschap:
ui->ttlsInnerAuthenticationComboBox->setCurrentIndex(2);
break;
case ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2:
ui->ttlsInnerAuthenticationComboBox->setCurrentIndex(3);
break;
}
ui->ttlsUsernameLineEdit->setText(settings["802.1xTtlsUsername"].toString());
ui->ttlsPasswordLineEdit->setText(settings["802.1xTtlsPassword"].toString());
switch (settings["802.1xPasswordStore"].toInt()) {
case ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers:
ui->ttlsPasswordStoreComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser:
ui->ttlsPasswordStoreComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved:
ui->ttlsPasswordStoreComboBox->setCurrentIndex(2);
break;
}
break;
case ConnectionSettingsEngine::Security802_1xAuthPeap:
ui->authenticationModeTabs->setCurrentIndex(5);
ui->peapAnonymousIdentityLineEdit->setText(settings["802.1xPeapAnonymousIdentity"].toString());
ui->peapDomainLineEdit->setText(settings["802.1xPeapDomain"].toString());
ui->peapCaCertificateLineEdit->setText(settings["802.1xPeapCaCertificate"].toString());
switch (settings["802.1xPeapVersion"].toInt()) {
case ConnectionSettingsEngine::Security802_1xPeapVersionUnknown:
ui->peapVersionComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Security802_1xPeapVersionZero:
ui->peapVersionComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Security802_1xPeapVersionOne:
ui->peapVersionComboBox->setCurrentIndex(2);
break;
}
switch (settings["802.1xPeapAuthMethod"].toInt()) {
case ConnectionSettingsEngine::Security802_1xAuthMethodMschapv2:
ui->peapInnerAuthenticationComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Security802_1xAuthMethodMd5:
ui->peapInnerAuthenticationComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Security802_1xAuthMethodGtc:
ui->peapInnerAuthenticationComboBox->setCurrentIndex(2);
break;
}
ui->peapUsernameLineEdit->setText(settings["802.1xPeapUsername"].toString());
ui->peapPasswordLineEdit->setText(settings["802.1xPeapPassword"].toString());
switch (settings["802.1xPasswordStore"].toInt()) {
case ConnectionSettingsEngine::Security802_1xPasswordStoreForAllUsers:
ui->peapPasswordStoreComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreForOneUser:
ui->peapPasswordStoreComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Security802_1xPasswordStoreNotSaved:
ui->peapPasswordStoreComboBox->setCurrentIndex(2);
break;
}
break;
}
} else {
ui->enable802_1xCheckBox->setChecked(false);
}
}
void Security802_1xTab::onEnable802_1xCheckBoxToggled(int state)
{
switch (state) {
case Qt::Checked:
ui->authenticationModeTabs->setEnabled(true);
break;
case Qt::Unchecked:
ui->authenticationModeTabs->setEnabled(false);
break;
}
}
void Security802_1xTab::onMd5ShowPasswordCheckBoxToggled(int state)
{
switch (state) {
case Qt::Checked:
ui->md5PasswordLineEdit->setEchoMode(QLineEdit::Normal);
break;
case Qt::Unchecked:
ui->md5PasswordLineEdit->setEchoMode(QLineEdit::Password);
break;
}
}
void Security802_1xTab::onTlsShowPasswordCheckBoxToggled(int state)
{
switch (state) {
case Qt::Checked:
ui->tlsUserKeyPasswordLineEdit->setEchoMode(QLineEdit::Normal);
break;
case Qt::Unchecked:
ui->tlsUserKeyPasswordLineEdit->setEchoMode(QLineEdit::Password);
break;
}
}
void Security802_1xTab::onPwdShowPasswordCheckBoxToggled(int state)
{
switch (state) {
case Qt::Checked:
ui->pwdPasswordLineEdit->setEchoMode(QLineEdit::Normal);
break;
case Qt::Unchecked:
ui->pwdPasswordLineEdit->setEchoMode(QLineEdit::Password);
break;
}
}
void Security802_1xTab::onFastShowPasswordCheckBoxToggled(int state)
{
switch (state) {
case Qt::Checked:
ui->fastPasswordLineEdit->setEchoMode(QLineEdit::Normal);
break;
case Qt::Unchecked:
ui->fastPasswordLineEdit->setEchoMode(QLineEdit::Password);
break;
}
}
void Security802_1xTab::onTtlsShowPasswordCheckBoxToggled(int state)
{
switch (state) {
case Qt::Checked:
ui->ttlsPasswordLineEdit->setEchoMode(QLineEdit::Normal);
break;
case Qt::Unchecked:
ui->ttlsPasswordLineEdit->setEchoMode(QLineEdit::Password);
break;
}
}
void Security802_1xTab::onPeapShowPasswordCheckBoxToggled(int state)
{
switch (state) {
case Qt::Checked:
ui->peapPasswordLineEdit->setEchoMode(QLineEdit::Normal);
break;
case Qt::Unchecked:
ui->peapPasswordLineEdit->setEchoMode(QLineEdit::Password);
break;
}
}