summaryrefslogtreecommitdiffstats
path: root/win/rfb_win32
diff options
context:
space:
mode:
authorAdam Tkac <atkac@redhat.com>2011-02-01 14:35:39 +0000
committerAdam Tkac <atkac@redhat.com>2011-02-01 14:35:39 +0000
commitcf4e7511b2fe7be125ba087389f4003dd51513a4 (patch)
treeb53d2f7153a4b948ae47b91afdadfd4f7955a177 /win/rfb_win32
parenta9a7b4b34a6b586312f7f253ba07f2b8f0531399 (diff)
downloadtigervnc-cf4e7511b2fe7be125ba087389f4003dd51513a4.tar.gz
tigervnc-cf4e7511b2fe7be125ba087389f4003dd51513a4.zip
[Development] Add new rfb_win32::SecurityPage class
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4246 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'win/rfb_win32')
-rw-r--r--win/rfb_win32/CMakeLists.txt1
-rw-r--r--win/rfb_win32/Makefile.am3
-rw-r--r--win/rfb_win32/SecurityPage.cxx237
-rw-r--r--win/rfb_win32/SecurityPage.h62
-rw-r--r--win/rfb_win32/resource.h38
5 files changed, 341 insertions, 0 deletions
diff --git a/win/rfb_win32/CMakeLists.txt b/win/rfb_win32/CMakeLists.txt
index 60af6db5..83d7f1c6 100644
--- a/win/rfb_win32/CMakeLists.txt
+++ b/win/rfb_win32/CMakeLists.txt
@@ -20,6 +20,7 @@ set(RFB_WIN32_SOURCES
RegConfig.cxx
Registry.cxx
ScaledDIBSectionBuffer.cxx
+ SecurityPage.cxx
SDisplayCorePolling.cxx
SDisplayCoreWMHooks.cxx
SDisplay.cxx
diff --git a/win/rfb_win32/Makefile.am b/win/rfb_win32/Makefile.am
index 80d9286f..c6ae74e4 100644
--- a/win/rfb_win32/Makefile.am
+++ b/win/rfb_win32/Makefile.am
@@ -32,7 +32,9 @@ HDRS = \
ProgressControl.h \
RegConfig.h \
Registry.h \
+ resource.h \
ScaledDIBSectionBuffer.h \
+ SecurityPage.h \
SDisplayCoreDriver.h \
SDisplayCorePolling.h \
SDisplayCoreWMHooks.h \
@@ -76,6 +78,7 @@ librfb_win32_la_SOURCES = $(HDRS) \
RegConfig.cxx \
Registry.cxx \
ScaledDIBSectionBuffer.cxx \
+ SecurityPage.cxx \
SDisplayCorePolling.cxx \
SDisplayCoreWMHooks.cxx \
SDisplay.cxx \
diff --git a/win/rfb_win32/SecurityPage.cxx b/win/rfb_win32/SecurityPage.cxx
new file mode 100644
index 00000000..15157270
--- /dev/null
+++ b/win/rfb_win32/SecurityPage.cxx
@@ -0,0 +1,237 @@
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright (C) 2011 TigerVNC Team
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <rdr/Exception.h>
+
+#include <rfb/LogWriter.h>
+#include <rfb/Security.h>
+
+#include <rfb_win32/resource.h>
+#include <rfb_win32/SecurityPage.h>
+
+#include <list>
+
+using namespace rdr;
+using namespace rfb;
+using namespace rfb::win32;
+using namespace std;
+
+static LogWriter vlog("AuthDialog");
+
+/* XXX: This class contains bunch of similar code to unix/vncviewer/CConn.cxx */
+SecurityPage::SecurityPage(Security *security_)
+ : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_SECURITY)),
+ security(security_) {
+}
+
+void
+SecurityPage::initDialog()
+{
+ list<U8> secTypes;
+ list<U8>::iterator i;
+
+ enableVeNCryptFeatures(false);
+
+ secTypes = security->GetEnabledSecTypes();
+
+ /* Process non-VeNCrypt sectypes */
+ for (i = secTypes.begin(); i != secTypes.end(); i++) {
+ switch (*i) {
+ case secTypeVeNCrypt:
+ enableVeNCryptFeatures(true);
+ setItemChecked(IDC_VENCRYPT, true);
+ break;
+ case secTypeNone:
+ enableAuthMethod(IDC_ENC_NONE, IDC_AUTH_NONE);
+ break;
+ case secTypeVncAuth:
+ enableAuthMethod(IDC_ENC_NONE, IDC_AUTH_VNC);
+ break;
+ }
+ }
+
+ list<U32> secTypesExt;
+ list<U32>::iterator iext;
+
+ secTypesExt = security->GetEnabledExtSecTypes();
+
+ /* Process VeNCrypt subtypes */
+ if (isItemChecked(IDC_VENCRYPT)) {
+ for (iext = secTypesExt.begin(); iext != secTypesExt.end(); iext++) {
+ switch (*iext) {
+ case secTypePlain:
+ enableAuthMethod(IDC_ENC_NONE, IDC_AUTH_PLAIN);
+ break;
+ case secTypeTLSNone:
+ enableAuthMethod(IDC_ENC_TLS, IDC_AUTH_NONE);
+ break;
+ case secTypeTLSVnc:
+ enableAuthMethod(IDC_ENC_TLS, IDC_AUTH_VNC);
+ break;
+ case secTypeTLSPlain:
+ enableAuthMethod(IDC_ENC_TLS, IDC_AUTH_PLAIN);
+ break;
+ case secTypeX509None:
+ enableAuthMethod(IDC_ENC_X509, IDC_AUTH_NONE);
+ enableX509Dialogs();
+ break;
+ case secTypeX509Vnc:
+ enableAuthMethod(IDC_ENC_X509, IDC_AUTH_VNC);
+ enableX509Dialogs();
+ break;
+ case secTypeX509Plain:
+ enableAuthMethod(IDC_ENC_X509, IDC_AUTH_PLAIN);
+ enableX509Dialogs();
+ break;
+ }
+ }
+ }
+}
+
+bool
+SecurityPage::onCommand(int id, int cmd)
+{
+ if (id == IDC_VENCRYPT) {
+ enableVeNCryptFeatures(isItemChecked(IDC_VENCRYPT));
+ } else if (id == IDC_ENC_X509) {
+ if (isItemChecked(IDC_ENC_X509))
+ enableX509Dialogs();
+ else
+ disableX509Dialogs();
+ }
+
+ return true;
+}
+
+bool
+SecurityPage::onOk() {
+ bool x509_loaded = false;
+ bool vnc_loaded = false;
+ list<U32> secTypes;
+
+ /* Keep same priorities as in common/rfb/SecurityClient::secTypes */
+ if (isItemChecked(IDC_VENCRYPT)) {
+ secTypes.push_back(secTypeVeNCrypt);
+
+#ifdef HAVE_GNUTLS
+ /* X509Plain */
+ if (authMethodEnabled(IDC_ENC_X509, IDC_AUTH_PLAIN)) {
+ loadX509Certs(x509_loaded);
+ secTypes.push_back(secTypeX509Plain);
+ }
+
+ /* TLSPlain */
+ if (authMethodEnabled(IDC_ENC_TLS, IDC_AUTH_PLAIN))
+ secTypes.push_back(secTypeTLSPlain);
+
+ /* X509Vnc */
+ if (authMethodEnabled(IDC_ENC_X509, IDC_AUTH_VNC)) {
+ loadX509Certs(x509_loaded);
+ loadVncPasswd(vnc_loaded);
+ secTypes.push_back(secTypeX509Vnc);
+ }
+
+ /* TLSVnc */
+ if (authMethodEnabled(IDC_ENC_TLS, IDC_AUTH_VNC)) {
+ loadVncPasswd(vnc_loaded);
+ secTypes.push_back(secTypeTLSVnc);
+ }
+
+ /* X509None */
+ if (authMethodEnabled(IDC_ENC_X509, IDC_AUTH_NONE)) {
+ loadX509Certs(x509_loaded);
+ secTypes.push_back(secTypeX509None);
+ }
+
+ /* TLSNone */
+ if (authMethodEnabled(IDC_ENC_TLS, IDC_AUTH_NONE))
+ secTypes.push_back(secTypeTLSNone);
+#endif
+ }
+
+ /* VncAuth */
+ if (authMethodEnabled(IDC_ENC_NONE, IDC_AUTH_VNC)) {
+ loadVncPasswd(vnc_loaded);
+ secTypes.push_back(secTypeVncAuth);
+ }
+
+ /* None */
+ if (authMethodEnabled(IDC_ENC_NONE, IDC_AUTH_NONE))
+ secTypes.push_back(secTypeNone);
+
+ security->SetSecTypes(secTypes);
+
+ return true;
+}
+
+inline void
+SecurityPage::enableVeNCryptFeatures(bool enable)
+{
+ if (enable) {
+ enableItem(IDC_ENC_TLS, true);
+ enableItem(IDC_ENC_X509, true);
+ enableItem(IDC_AUTH_PLAIN, true);
+ } else {
+ disableFeature(IDC_ENC_TLS);
+ disableFeature(IDC_ENC_X509);
+ disableFeature(IDC_AUTH_PLAIN);
+ disableX509Dialogs();
+ }
+}
+
+inline void
+SecurityPage::disableFeature(int id)
+{
+ enableItem(id, false);
+ setItemChecked(id, false);
+}
+
+inline void
+SecurityPage::enableAuthMethod(int encid, int authid)
+{
+ setItemChecked(encid, true);
+ setItemChecked(authid, true);
+}
+
+inline bool
+SecurityPage::authMethodEnabled(int encid, int authid)
+{
+ return isItemChecked(encid) && isItemChecked(authid);
+}
+
+inline void
+SecurityPage::loadX509Certs(bool &loaded)
+{
+ if (!loaded)
+ loadX509Certs();
+ loaded = true;
+}
+
+inline void
+SecurityPage::loadVncPasswd(bool &loaded)
+{
+ if (!loaded)
+ loadVncPasswd();
+ loaded = true;
+}
+
diff --git a/win/rfb_win32/SecurityPage.h b/win/rfb_win32/SecurityPage.h
new file mode 100644
index 00000000..b43c2a36
--- /dev/null
+++ b/win/rfb_win32/SecurityPage.h
@@ -0,0 +1,62 @@
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright (C) 2011 TigerVNC Team
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+#ifndef __RFB_WIN32_SECURITYPAGE_H__
+#define __RFB_WIN32_SECURITYPAGE_H__
+
+#include <rdr/types.h>
+
+#include <rfb/Security.h>
+#include <rfb_win32/Dialog.h>
+
+#include <list>
+
+namespace rfb {
+namespace win32 {
+
+class SecurityPage: public PropSheetPage
+{
+public:
+ SecurityPage(Security *security_);
+
+ virtual void loadX509Certs(void) = 0;
+ virtual void enableX509Dialogs(void) = 0;
+ virtual void disableX509Dialogs(void) = 0;
+ virtual void loadVncPasswd(void) = 0;
+
+ virtual void initDialog();
+ virtual bool onCommand(int id, int cmd);
+ virtual bool onOk();
+
+protected:
+ Security *security;
+
+private:
+ inline void enableVeNCryptFeatures(bool enable);
+ inline void disableFeature(int id);
+ inline void enableAuthMethod(int encid, int authid);
+ inline bool authMethodEnabled(int encid, int authid);
+ inline void loadX509Certs(bool &loaded);
+ inline void loadVncPasswd(bool &loaded);
+};
+
+};
+};
+
+#endif
diff --git a/win/rfb_win32/resource.h b/win/rfb_win32/resource.h
new file mode 100644
index 00000000..aedfbda0
--- /dev/null
+++ b/win/rfb_win32/resource.h
@@ -0,0 +1,38 @@
+/* Copyright (C) 2011 TigerVNC Team
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+/*
+ * This file contains resource IDs shared between various Windows binaries.
+ * If you are adding new resource ID ensure it doesn't conflict with per-binary
+ * resource IDs.
+ */
+
+#ifndef __RFB_WIN32_RESOURCE_H__
+#define __RFB_WIN32_RESOURCE_H__
+
+#define IDD_SECURITY 117
+
+#define IDC_VENCRYPT 1200
+#define IDC_ENC_NONE 1201
+#define IDC_ENC_TLS 1202
+#define IDC_ENC_X509 1203
+#define IDC_AUTH_NONE 1206
+#define IDC_AUTH_VNC 1207
+#define IDC_AUTH_PLAIN 1208
+
+#endif