]> source.dussan.org Git - tigervnc.git/commitdiff
[Development] Add "Security" options dialog for Windows viewer.
authorAdam Tkac <atkac@redhat.com>
Wed, 8 Dec 2010 13:45:40 +0000 (13:45 +0000)
committerAdam Tkac <atkac@redhat.com>
Wed, 8 Dec 2010 13:45:40 +0000 (13:45 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4215 3789f03b-4d11-0410-bbf8-ca57d06f2519

common/rfb/CConnection.h
win/vncviewer/OptionsDialog.cxx
win/vncviewer/resource.h
win/vncviewer/vncviewer.rc

index eb8c1c3f34dadf2cdc3fa05d547f2a6623229438..db236bc985edb09b544c9ade53fca3134e94d906 100644 (file)
@@ -131,10 +131,10 @@ namespace rfb {
 
     stateEnum state() { return state_; }
 
-    CSecurity *csecurity; /* Windows viewer needs it exported. */
+    CSecurity *csecurity;
+    SecurityClient *security;
   protected:
     void setState(stateEnum s) { state_ = s; }
-    SecurityClient *security;
 
   private:
     void processVersionMsg();
index c2c2fc90926906d00599639a6fe5271efc40c7c3..b3d72f2eb7257c87a1ebf3a0d4d744e39eacd077 100644 (file)
 #include <rfb/CConnection.h>
 #include <commdlg.h>
 #include <rfb/LogWriter.h>
+#include <rfb/Security.h>
 
+#include <list>
+
+using namespace rdr;
 using namespace rfb;
 using namespace rfb::win32;
+using namespace std;
 
 static LogWriter vlog("Options");
 
@@ -349,6 +354,138 @@ protected:
   OptionsInfo* dlg;
 };
 
+class SecurityPage : public PropSheetPage {
+public:
+  SecurityPage(OptionsInfo* dlg_, Security *security_)
+    : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_SECURITY)),
+      dlg(dlg_), security(security_) {
+  }
+  virtual void initDialog() {
+    enableVeNCryptFeatures(false);
+
+    /* Process non-VeNCrypt sectypes */
+    list<U8> secTypes = security->GetEnabledSecTypes();
+    list<U8>::iterator i;
+
+    for (i = secTypes.begin(); i != secTypes.end(); i++) {
+      switch (*i) {
+        case secTypeVeNCrypt:
+          enableVeNCryptFeatures(true);
+         setItemChecked(IDC_VENCRYPT, true);
+          break;
+        case secTypeNone:
+          setItemChecked(IDC_ENC_NONE, true);
+          setItemChecked(IDC_AUTH_NONE, true);
+          break;
+        case secTypeVncAuth:
+          setItemChecked(IDC_ENC_NONE, true);
+          setItemChecked(IDC_AUTH_VNC, true);
+          break;
+      }
+    }
+
+    /* Process VeNCrypt subtypes */
+    if (isItemChecked(IDC_VENCRYPT)) {
+      list<U32> secTypesExt = security->GetEnabledExtSecTypes();
+      list<U32>::iterator iext;
+      for (iext = secTypesExt.begin(); iext != secTypesExt.end(); iext++) {
+        switch (*iext) {
+        case secTypePlain:
+          setItemChecked(IDC_ENC_NONE, true);
+          setItemChecked(IDC_AUTH_PLAIN, true);
+          break;
+        case secTypeTLSNone:
+          setItemChecked(IDC_ENC_TLS, true);
+          setItemChecked(IDC_AUTH_NONE, true);
+          break;
+        case secTypeTLSVnc:
+          setItemChecked(IDC_ENC_TLS, true);
+          setItemChecked(IDC_AUTH_VNC, true);
+          break;
+        case secTypeTLSPlain:
+          setItemChecked(IDC_ENC_TLS, true);
+          setItemChecked(IDC_AUTH_PLAIN, true);
+          break;
+        case secTypeX509None:
+          setItemChecked(IDC_ENC_X509, true);
+          setItemChecked(IDC_AUTH_NONE, true);
+          enableItem(IDC_LOAD_CACERT, true);
+          enableItem(IDC_LOAD_CRLCERT, true);
+          break;
+        case secTypeX509Vnc:
+          setItemChecked(IDC_ENC_X509, true);
+          setItemChecked(IDC_AUTH_VNC, true);
+          enableItem(IDC_LOAD_CACERT, true);
+          enableItem(IDC_LOAD_CRLCERT, true);
+          break;
+        case secTypeX509Plain:
+          setItemChecked(IDC_ENC_X509, true);
+          setItemChecked(IDC_AUTH_PLAIN, true);
+          enableItem(IDC_LOAD_CACERT, true);
+          enableItem(IDC_LOAD_CRLCERT, true);
+          break;
+        }
+      }
+    }
+  }
+  virtual bool onCommand(int id, int cmd) {
+    switch (id) {
+    case IDC_VENCRYPT:
+      enableVeNCryptFeatures(isItemChecked(IDC_VENCRYPT));
+      break;
+    case IDC_ENC_NONE:
+      break;
+    case IDC_ENC_TLS:
+      break;
+    case IDC_ENC_X509:
+      if (isItemChecked(IDC_ENC_X509)) {
+        enableItem(IDC_LOAD_CACERT, true);
+        enableItem(IDC_LOAD_CRLCERT, true);
+      } else {
+        enableItem(IDC_LOAD_CACERT, false);
+        enableItem(IDC_LOAD_CRLCERT, false);
+      }
+      break;
+    case IDC_LOAD_CACERT:
+      break;
+    case IDC_LOAD_CRLCERT:
+      break;
+    case IDC_AUTH_NONE:
+      break;
+    case IDC_AUTH_VNC:
+      break;
+    case IDC_AUTH_PLAIN:
+      break;
+    default:
+      throw rdr::Exception("Unhandled action in SecurityPage");
+    }
+    return true;
+  }
+protected:
+  OptionsInfo* dlg;
+private:
+  Security *security;
+
+  void 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);
+      enableItem(IDC_LOAD_CACERT, false);
+      enableItem(IDC_LOAD_CRLCERT, false);
+    }
+  }
+
+  void disableFeature(int id) {
+    enableItem(id, false);
+    setItemChecked(id, false);
+  }
+};
+
 
 OptionsDialog::OptionsDialog() : visible(false) {
 }
@@ -369,6 +506,7 @@ bool OptionsDialog::showDialog(CConn* view, bool capture) {
   InputsPage inputsPage(&info); pages.push_back(&inputsPage);
   MiscPage miscPage(&info); pages.push_back(&miscPage);
   DefaultsPage defPage(&info); if (view) pages.push_back(&defPage);
+  SecurityPage secPage(&info, view->security); pages.push_back(&secPage);
 
   // Show the property sheet
   ViewerOptions dialog(info, pages);
index a9a2b969dd078088cd2ddb156c74a8f58703d353..0487c5e8e9b4f4dab01b15ff198741a4ff2166d6 100644 (file)
@@ -16,6 +16,7 @@
 #define IDR_TRAY                        112
 #define IDD_CONNECTION_INFO             113
 #define IDD_DEFAULTS                    116
+#define IDD_SECURITY                    117
 #define IDB_BITMAP                      120
 #define IDB_TOOLBAR                     122
 #define IDC_PASSWORD                    1000
 #define IDC_STATIC_SCALE                1097
 #define IDC_COMBO_SCALE                 1098
 #define IDC_STATIC_PERCENT              1099
+#define IDC_VENCRYPT                    1200
+#define IDC_ENC_NONE                    1201
+#define IDC_ENC_TLS                     1202
+#define IDC_ENC_X509                    1203
+#define IDC_LOAD_CACERT                 1204
+#define IDC_LOAD_CRLCERT                1205
+#define IDC_AUTH_NONE                   1206
+#define IDC_AUTH_VNC                    1207
+#define IDC_AUTH_PLAIN                  1208
 #define ID_TOOLBAR                      4002
 #define ID_CLOSE                        4003
 #define ID_OPTIONS                      4004
index 60aa6363afae371206a768a4cf90e5e5604982de..ed89a4ea8e45d038462c977d906ff12fc881b5ac 100644 (file)
@@ -316,6 +316,33 @@ BEGIN
 END
 
 
+IDD_SECURITY DIALOG DISCARDABLE  0, 0, 200, 200
+STYLE DS_MODALFRAME | DS_CONTROL | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Security"
+FONT 8, "MS Sans Serif"
+BEGIN
+    CONTROL         "Extended encryption and authentication methods (VeNCrypt)",
+                    IDC_VENCRYPT, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+                    7,10,200,15
+    GROUPBOX        "Session encryption", IDC_STATIC, 7,25,120,60
+    CONTROL         "None", IDC_ENC_NONE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+                    10,35,50,15
+    CONTROL         "Anonymous TLS", IDC_ENC_TLS, "Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP, 10,50,80,15
+    CONTROL         "TLS with X.509 certificates", IDC_ENC_X509, "Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP, 10,65,110,15
+    GROUPBOX        "X.509 certificates", IDC_STATIC, 7,90,170,30
+    PUSHBUTTON      "Load CA certificate", IDC_LOAD_CACERT, 10,100,80,15
+    PUSHBUTTON      "Load CRL certificate", IDC_LOAD_CRLCERT, 90,100,80,15
+    GROUPBOX        "Authentication", IDC_STATIC, 7,125,100,60
+    CONTROL         "None", IDC_AUTH_NONE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+                    10,135,50,15
+    CONTROL         "Standard VNC", IDC_AUTH_VNC, "Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP, 10,150,80,15
+    CONTROL         "Plaintext", IDC_AUTH_PLAIN, "Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP, 10,165,70,15
+END
+
 /////////////////////////////////////////////////////////////////////////////
 //
 // DESIGNINFO