Signed-off-by: Martin Koegler <mkoeg...@auto.tuwien.ac.at>
---
 common/rfb/CSecurityVeNCrypt.cxx |   19 +-------
 common/rfb/SSecurityVeNCrypt.cxx |   89 +------------------------------------
 common/rfb/SSecurityVeNCrypt.h   |    7 +---
 common/rfb/Security.cxx          |    8 +++-
 4 files changed, 13 insertions(+), 110 deletions(-)

diff --git a/common/rfb/CSecurityVeNCrypt.cxx b/common/rfb/CSecurityVeNCrypt.cxx
index 7b8c348..5871922 100644
--- a/common/rfb/CSecurityVeNCrypt.cxx
+++ b/common/rfb/CSecurityVeNCrypt.cxx
@@ -30,7 +30,6 @@
 #include <rfb/CSecurityVeNCrypt.h>
 #include <rfb/CSecurityVncAuth.h>
 #include <rfb/LogWriter.h>
-#include <rfb/SSecurityVeNCrypt.h>
 #include <list>
 
 using namespace rfb;
@@ -153,7 +152,7 @@ bool CSecurityVeNCrypt::processMsg(CConnection* cc)
       list<U32> preferredList;
 
       /* Try preferred choice */
-      SSecurityVeNCrypt::getSecTypes(&preferredList);
+      preferredList = security->GetEnabledExtSecTypes();
          
       for (j = preferredList.begin(); j != preferredList.end(); j++) {
        for (i = 0; i < nAvailableTypes; i++) {
@@ -169,21 +168,9 @@ bool CSecurityVeNCrypt::processMsg(CConnection* cc)
 
       vlog.debug("Choosing security type 
%s(%d)",secTypeName(chosenType),chosenType); 
       /* Set up the stack according to the chosen type: */
-      switch (chosenType) {
-       case secTypeTLSNone:
-       case secTypeTLSVnc:
-       case secTypeTLSPlain:
-       case secTypeX509None:
-       case secTypeX509Vnc:
-       case secTypeX509Plain:
-         csecurityStack = CSecurityVeNCrypt::getCSecurityStack(chosenType);
-         break;
-
-       case secTypeInvalid:
-       case secTypeVeNCrypt: /* would cause looping */
-       default:
+      if (chosenType == secTypeInvalid || chosenType == secTypeVeNCrypt)
          throw AuthFailureException("No valid VeNCrypt sub-type");
-      }
+      csecurityStack = CSecurityVeNCrypt::getCSecurityStack(chosenType);
       
       /* send chosen type to server */
       os->writeU32(chosenType);
diff --git a/common/rfb/SSecurityVeNCrypt.cxx b/common/rfb/SSecurityVeNCrypt.cxx
index 7f47493..2d14ae4 100644
--- a/common/rfb/SSecurityVeNCrypt.cxx
+++ b/common/rfb/SSecurityVeNCrypt.cxx
@@ -54,12 +54,6 @@ StringParameter SSecurityVeNCrypt::X509_KeyFile
  "specifies path to the key of the x509 certificate in PEM format",
  "", ConfServer);
 
-StringParameter SSecurityVeNCrypt::secTypesStr
-("VeNCryptTypes",
- "Specify which security scheme to use for VeNCrypt connections (TLSNone, "
- "TLSVnc, TLSPlain, X509None, X509Vnc, X509Plain)",
- "TLSVnc,TLSPlain,X509Vnc,X509Plain");
-
 SSecurityVeNCrypt::SSecurityVeNCrypt(Security* sec) : security(sec)
 {
   ssecurityStack = NULL;
@@ -141,7 +135,7 @@ bool SSecurityVeNCrypt::processMsg(SConnection* sc)
    */
   if (!haveSentTypes) {
     list<U32> listSubTypes;
-    SSecurityVeNCrypt::getSecTypes(&listSubTypes);
+    listSubTypes = security->GetEnabledExtSecTypes();
 
     numTypes = listSubTypes.size();
     subTypes = new U32[numTypes];
@@ -180,21 +174,9 @@ bool SSecurityVeNCrypt::processMsg(SConnection* sc)
 
     vlog.debug("Choosing security type 
%s(%d)",secTypeName(chosenType),chosenType);
     /* Set up the stack according to the chosen type */
-    switch(chosenType) {
-    case secTypeTLSNone:
-    case secTypeTLSVnc:
-    case secTypeTLSPlain:
-    case secTypeX509None:
-    case secTypeX509Vnc:
-    case secTypeX509Plain:
-      ssecurityStack = SSecurityVeNCrypt::getSSecurityStack(chosenType);
-       break;  
-    case secTypeInvalid:
-    case secTypeVeNCrypt: /* This would cause looping */
-    default:
+    if (chosenType == secTypeInvalid || chosenType == secTypeVeNCrypt)
       throw AuthFailureException("No valid VeNCrypt sub-type");
-    }
-
+    ssecurityStack = SSecurityVeNCrypt::getSSecurityStack(chosenType);
   }
 
   /* continue processing the messages */
@@ -220,68 +202,3 @@ SSecurityStack* SSecurityVeNCrypt::getSSecurityStack(int 
secType)
   }
 }
 
-void SSecurityVeNCrypt::getSecTypes(list<U32>* secTypes)
-{
-  CharArray types;
-
-  types.buf = SSecurityVeNCrypt::secTypesStr.getData();
-  list<U32> configured = SSecurityVeNCrypt::parseSecTypes(types.buf);
-  list<U32>::iterator i;
-  for (i = configured.begin(); i != configured.end(); i++)
-    secTypes->push_back(*i);
-}
-
-U32 SSecurityVeNCrypt::secTypeNum(const char *name)
-{
-  if (strcasecmp(name, "TLSNone") == 0)
-    return secTypeTLSNone;
-  if (strcasecmp(name, "TLSVnc") == 0)
-    return secTypeTLSVnc;
-  if (strcasecmp(name, "TLSPlain") == 0)
-    return secTypeTLSPlain;
-  if (strcasecmp(name, "X509None") == 0)
-    return secTypeX509None;
-  if (strcasecmp(name, "X509Vnc") == 0)
-    return secTypeX509Vnc;
-  if (strcasecmp(name, "X509Plain") == 0)
-    return secTypeX509Plain;
-
-  return secTypeInvalid;
-}
-
-char* SSecurityVeNCrypt::secTypeName(U32 num)
-{
-  switch (num) {
-  case secTypePlain:
-    return "Plain";
-  case secTypeTLSNone:
-    return "TLSNone";
-  case secTypeTLSVnc:
-    return "TLSVnc";
-  case secTypeTLSPlain:
-    return "TLSPlain";
-  case secTypeX509None:
-    return "X509None";
-  case secTypeX509Vnc:
-    return "X509Vnc";
-  case secTypeX509Plain:
-    return "X509Plain";
-  default:
-    return "[unknown secType]";
-  }
-}
-
-list<U32> SSecurityVeNCrypt::parseSecTypes(const char *secTypes)
-{
-  list<U32> result;
-  CharArray types(strDup(secTypes)), type;
-  while (types.buf) {
-    strSplit(types.buf, ',', &type.buf, &types.buf);
-    int typeNum = SSecurityVeNCrypt::secTypeNum(type.buf);
-    if (typeNum != secTypeInvalid)
-      result.push_back(typeNum);
-  }
-  return result;
-}
-
-
diff --git a/common/rfb/SSecurityVeNCrypt.h b/common/rfb/SSecurityVeNCrypt.h
index fb279d1..4d7b457 100644
--- a/common/rfb/SSecurityVeNCrypt.h
+++ b/common/rfb/SSecurityVeNCrypt.h
@@ -46,13 +46,8 @@ namespace rfb {
     virtual int getType() const { return secTypeVeNCrypt; }
     virtual const char* getUserName() const { return NULL; }
 
-    static StringParameter X509_CertFile, X509_KeyFile, secTypesStr;
+    static StringParameter X509_CertFile, X509_KeyFile;
 
-    /* XXX Derive Security class and merge those functions appropriately ? */
-    static void getSecTypes(std::list<rdr::U32>* secTypes);
-    static rdr::U32 secTypeNum(const char *name);
-    static char* secTypeName(rdr::U32 num);
-    static std::list<rdr::U32> parseSecTypes(const char *types);
   protected:
     static SSecurityStack* getSSecurityStack(int secType);
 
diff --git a/common/rfb/Security.cxx b/common/rfb/Security.cxx
index c5fb1b8..4aa8eda 100644
--- a/common/rfb/Security.cxx
+++ b/common/rfb/Security.cxx
@@ -50,13 +50,14 @@ UserPasswdGetter *CSecurity::upg = NULL;
 
 StringParameter Security::secTypes
 ("SecurityTypes",
- "Specify which security scheme to use (None, VncAuth)",
+ "Specify which security scheme to use (None, VncAuth, TLSNone, "
+ "TLSVnc, TLSPlain, X509None, X509Vnc, X509Plain)",
  "VncAuth");
 
 void Security::enableClientTypes()
 {
   /* override default value */
-  secTypes.setDefaultStr("None,VncAuth");
+  
secTypes.setDefaultStr("None,TLSNone,TLSPlain,VncAuth,TLSVnc,X509Vnc,TLSPlain,X509Plain");
 }
 
 Security::Security(void)
@@ -73,6 +74,7 @@ const std::list<rdr::U8> Security::GetEnabledSecTypes(void)
   std::list<rdr::U8> result;
   list<U32>::iterator i;
 
+  result.push_back(secTypeVeNCrypt);
   for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++)
     if (*i < 0x100)
       result.push_back(*i);
@@ -98,6 +100,8 @@ bool Security::IsSupported(U32 secType)
   for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++)
     if (*i == secType)
       return true;
+  if (secType == secTypeVeNCrypt)
+    return true;
 
   return false;
 }
-- 
1.6.4.2


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

Reply via email to