#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");
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) {
}
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);
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