Merge pull request #2767 from jdhoek/feature/choose-connection-method

Add dialog to connection wizard for client-side TLS certificates
This commit is contained in:
Daniel Molkentin 2015-02-02 23:22:19 +01:00
commit d2670b8473
6 changed files with 176 additions and 11 deletions

View file

@ -27,6 +27,7 @@ set(client_UI
owncloudsetuppage.ui
addcertificatedialog.ui
wizard/owncloudadvancedsetuppage.ui
wizard/owncloudconnectionmethoddialog.ui
wizard/owncloudhttpcredspage.ui
wizard/owncloudsetupnocredspage.ui
wizard/owncloudwizardresultpage.ui
@ -64,6 +65,7 @@ set(client_SRCS
addcertificatedialog.cpp
wizard/abstractcredswizardpage.cpp
wizard/owncloudadvancedsetuppage.cpp
wizard/owncloudconnectionmethoddialog.cpp
wizard/owncloudhttpcredspage.cpp
wizard/owncloudsetuppage.cpp
wizard/owncloudshibbolethcredspage.cpp

View file

@ -0,0 +1,32 @@
#include "wizard/owncloudconnectionmethoddialog.h"
OwncloudConnectionMethodDialog::OwncloudConnectionMethodDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::OwncloudConnectionMethodDialog)
{
ui->setupUi(this);
connect(ui->btnNoTLS, SIGNAL(clicked(bool)), this, SLOT(returnNoTLS()));
connect(ui->btnClientSideTLS, SIGNAL(clicked(bool)), this, SLOT(returnClientSideTLS()));
connect(ui->btnBack, SIGNAL(clicked(bool)), this, SLOT(returnBack()));
}
void OwncloudConnectionMethodDialog::returnNoTLS()
{
done(No_TLS);
}
void OwncloudConnectionMethodDialog::returnClientSideTLS()
{
done(Client_Side_TLS);
}
void OwncloudConnectionMethodDialog::returnBack()
{
done(Back);
}
OwncloudConnectionMethodDialog::~OwncloudConnectionMethodDialog()
{
delete ui;
}

View file

@ -0,0 +1,34 @@
#ifndef OWNCLOUDCONNECTIONMETHODDIALOG_H
#define OWNCLOUDCONNECTIONMETHODDIALOG_H
#include <QDialog>
#include "ui_owncloudconnectionmethoddialog.h"
namespace Ui {
class OwncloudConnectionMethodDialog;
}
class OwncloudConnectionMethodDialog : public QDialog
{
Q_OBJECT
public:
explicit OwncloudConnectionMethodDialog(QWidget *parent = 0);
~OwncloudConnectionMethodDialog();
enum {
No_TLS,
Client_Side_TLS,
Back
};
public slots:
void returnNoTLS();
void returnClientSideTLS();
void returnBack();
private:
Ui::OwncloudConnectionMethodDialog *ui;
};
#endif // OWNCLOUDCONNECTIONMETHODDIALOG_H

View file

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OwncloudConnectionMethodDialog</class>
<widget class="QDialog" name="OwncloudConnectionMethodDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>401</width>
<height>205</height>
</rect>
</property>
<property name="windowTitle">
<string>Connection failed</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Failed to connect to the secure server address specified. How do you wish to proceed?&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="btnNoTLS">
<property name="text">
<string>Try without TLS (not very secure)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClientSideTLS">
<property name="text">
<string>Configure client-side TLS certificate</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnBack">
<property name="text">
<string>Use a different URL</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -26,6 +26,7 @@
#include "wizard/owncloudwizardcommon.h"
#include "wizard/owncloudsetuppage.h"
#include "wizard/owncloudconnectionmethoddialog.h"
#include "../3rdparty/certificates/p12topem.h"
#include "theme.h"
#include "account.h"
@ -236,17 +237,31 @@ void OwncloudSetupPage::setErrorString( const QString& err, bool retryHTTPonly )
_ui.errorLabel->setVisible(false);
} else {
if (retryHTTPonly) {
if (err.contains("SSL handshake failed", Qt::CaseInsensitive)) {
slotAskSSLClientCertificate();
} else {
QString msg = tr("<p>Could not connect securely:</p><p>%1</p><p>Do you want to connect unencrypted instead (not recommended)?</p>").arg(err);
QString title = tr("Connection failed");
if (QMessageBox::question(this, title, msg, QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
QUrl url(_ui.leUrl->text());
url.setScheme("http");
_ui.leUrl->setText(url.toString());
// skip ahead to next page, since the user would expect us to retry automatically
wizard()->next();
QUrl url(_ui.leUrl->text());
if (url.scheme() == "https") {
// Ask the user how to proceed when connecting to a https:// URL fails.
// It is possible that the server is secured with client-side TLS certificates,
// but that it has no way of informing the owncloud client that this is the case.
OwncloudConnectionMethodDialog dialog;
int retVal = dialog.exec();
switch (retVal) {
case OwncloudConnectionMethodDialog::No_TLS:
{
url.setScheme("http");
_ui.leUrl->setText(url.toString());
// skip ahead to next page, since the user would expect us to retry automatically
wizard()->next();
}
break;
case OwncloudConnectionMethodDialog::Client_Side_TLS:
slotAskSSLClientCertificate();
break;
case OwncloudConnectionMethodDialog::Back:
default:
// No-op.
break;
}
}
}

View file

@ -22,6 +22,7 @@
#include "wizard/owncloudwizard.h"
#include "../addcertificatedialog.h"
#include "wizard/owncloudconnectionmethoddialog.h"
#include "ui_owncloudsetupnocredspage.h"