]> source.dussan.org Git - tigervnc.git/commitdiff
[Development] Use SecurityType also as configuration for VeNCrypt.
authorAdam Tkac <atkac@redhat.com>
Tue, 20 Jul 2010 15:14:50 +0000 (15:14 +0000)
committerAdam Tkac <atkac@redhat.com>
Tue, 20 Jul 2010 15:14:50 +0000 (15:14 +0000)
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4102 3789f03b-4d11-0410-bbf8-ca57d06f2519

common/rfb/CSecurityVeNCrypt.cxx
common/rfb/SSecurityVeNCrypt.cxx
common/rfb/SSecurityVeNCrypt.h

index 94af48d558e34f351887508dbaeaaadefb366a70..39a95f443dfd7391bf46e82fbde2542fad63bef1 100644 (file)
@@ -30,7 +30,6 @@
 #include <rfb/CSecurityVeNCrypt.h>\r
 #include <rfb/CSecurityVncAuth.h>\r
 #include <rfb/LogWriter.h>\r
-#include <rfb/SSecurityVeNCrypt.h>\r
 #include <list>\r
 \r
 using namespace rfb;\r
@@ -147,14 +146,14 @@ bool CSecurityVeNCrypt::processMsg(CConnection* cc)
 \r
     /* make a choice and send it to the server, meanwhile set up the stack */\r
     if (!haveChosenType) {\r
-      chosenType = 0;\r
+      chosenType = secTypeInvalid;\r
       U8 i;\r
       list<U32>::iterator j;\r
       list<U32> preferredList;\r
 \r
       /* Try preferred choice */\r
-      SSecurityVeNCrypt::getSecTypes(&preferredList);\r
-         \r
+      preferredList = security->GetEnabledExtSecTypes();\r
+\r
       for (j = preferredList.begin(); j != preferredList.end(); j++) {\r
        for (i = 0; i < nAvailableTypes; i++) {\r
          if (*j == availableTypes[i]) {\r
@@ -163,29 +162,19 @@ bool CSecurityVeNCrypt::processMsg(CConnection* cc)
          }\r
        }\r
 \r
-       if (chosenType)\r
+       if (chosenType != secTypeInvalid)\r
          break;\r
       }\r
 \r
       vlog.debug("Choosing security type %s (%d)", secTypeName(chosenType),\r
                 chosenType);\r
+\r
       /* Set up the stack according to the chosen type: */\r
-      switch (chosenType) {\r
-       case secTypeTLSNone:\r
-       case secTypeTLSVnc:\r
-       case secTypeTLSPlain:\r
-       case secTypeX509None:\r
-       case secTypeX509Vnc:\r
-       case secTypeX509Plain:\r
-         csecurity = CSecurityVeNCrypt::getCSecurityStack(chosenType);\r
-         break;\r
+      if (chosenType == secTypeInvalid || chosenType == secTypeVeNCrypt)\r
+       throw AuthFailureException("No valid VeNCrypt sub-type");\r
+\r
+      csecurity = CSecurityVeNCrypt::getCSecurityStack(chosenType);\r
 \r
-       case secTypeInvalid:\r
-       case secTypeVeNCrypt: /* would cause looping */\r
-       default:\r
-         throw AuthFailureException("No valid VeNCrypt sub-type");\r
-      }\r
-      \r
       /* send chosen type to server */\r
       os->writeU32(chosenType);\r
       os->flush();\r
index 894118db284bfd5f0a0be07fa418fbea34cb8620..2dd331e926d2803eea69600cd46407081e5e3810 100644 (file)
@@ -54,12 +54,6 @@ StringParameter SSecurityVeNCrypt::X509_KeyFile
  "specifies path to the key of the x509 certificate in PEM format",\r
  "", ConfServer);\r
 \r
-StringParameter SSecurityVeNCrypt::secTypesStr\r
-("VeNCryptTypes",\r
- "Specify which security scheme to use for VeNCrypt connections (TLSNone, "\r
- "TLSVnc, TLSPlain, X509None, X509Vnc, X509Plain)",\r
- "TLSVnc,TLSPlain,X509Vnc,X509Plain");\r
-\r
 SSecurityVeNCrypt::SSecurityVeNCrypt(Security *sec) : security(sec)\r
 {\r
   ssecurity = NULL;\r
@@ -141,7 +135,8 @@ bool SSecurityVeNCrypt::processMsg(SConnection* sc)
    */\r
   if (!haveSentTypes) {\r
     list<U32> listSubTypes;\r
-    SSecurityVeNCrypt::getSecTypes(&listSubTypes);\r
+\r
+    listSubTypes = security->GetEnabledExtSecTypes();\r
 \r
     numTypes = listSubTypes.size();\r
     subTypes = new U32[numTypes];\r
@@ -180,22 +175,12 @@ bool SSecurityVeNCrypt::processMsg(SConnection* sc)
 \r
     vlog.debug("Choosing security type %s (%d)", secTypeName(chosenType),\r
               chosenType);\r
+\r
     /* Set up the stack according to the chosen type */\r
-    switch(chosenType) {\r
-    case secTypeTLSNone:\r
-    case secTypeTLSVnc:\r
-    case secTypeTLSPlain:\r
-    case secTypeX509None:\r
-    case secTypeX509Vnc:\r
-    case secTypeX509Plain:\r
-      ssecurity = SSecurityVeNCrypt::getSSecurityStack(chosenType);\r
-       break;  \r
-    case secTypeInvalid:\r
-    case secTypeVeNCrypt: /* This would cause looping */\r
-    default:\r
+    if (chosenType == secTypeInvalid || chosenType == secTypeVeNCrypt)\r
       throw AuthFailureException("No valid VeNCrypt sub-type");\r
-    }\r
 \r
+    ssecurity = SSecurityVeNCrypt::getSSecurityStack(chosenType);\r
   }\r
 \r
   /* continue processing the messages */\r
@@ -221,68 +206,3 @@ SSecurityStack* SSecurityVeNCrypt::getSSecurityStack(int secType)
   }\r
 }\r
 \r
-void SSecurityVeNCrypt::getSecTypes(list<U32>* secTypes)\r
-{\r
-  CharArray types;\r
-\r
-  types.buf = SSecurityVeNCrypt::secTypesStr.getData();\r
-  list<U32> configured = SSecurityVeNCrypt::parseSecTypes(types.buf);\r
-  list<U32>::iterator i;\r
-  for (i = configured.begin(); i != configured.end(); i++)\r
-    secTypes->push_back(*i);\r
-}\r
-\r
-U32 SSecurityVeNCrypt::secTypeNum(const char *name)\r
-{\r
-  if (strcasecmp(name, "TLSNone") == 0)\r
-    return secTypeTLSNone;\r
-  if (strcasecmp(name, "TLSVnc") == 0)\r
-    return secTypeTLSVnc;\r
-  if (strcasecmp(name, "TLSPlain") == 0)\r
-    return secTypeTLSPlain;\r
-  if (strcasecmp(name, "X509None") == 0)\r
-    return secTypeX509None;\r
-  if (strcasecmp(name, "X509Vnc") == 0)\r
-    return secTypeX509Vnc;\r
-  if (strcasecmp(name, "X509Plain") == 0)\r
-    return secTypeX509Plain;\r
-\r
-  return secTypeInvalid;\r
-}\r
-\r
-char* SSecurityVeNCrypt::secTypeName(U32 num)\r
-{\r
-  switch (num) {\r
-  case secTypePlain:\r
-    return "Plain";\r
-  case secTypeTLSNone:\r
-    return "TLSNone";\r
-  case secTypeTLSVnc:\r
-    return "TLSVnc";\r
-  case secTypeTLSPlain:\r
-    return "TLSPlain";\r
-  case secTypeX509None:\r
-    return "X509None";\r
-  case secTypeX509Vnc:\r
-    return "X509Vnc";\r
-  case secTypeX509Plain:\r
-    return "X509Plain";\r
-  default:\r
-    return "[unknown secType]";\r
-  }\r
-}\r
-\r
-list<U32> SSecurityVeNCrypt::parseSecTypes(const char *secTypes)\r
-{\r
-  list<U32> result;\r
-  CharArray types(strDup(secTypes)), type;\r
-  while (types.buf) {\r
-    strSplit(types.buf, ',', &type.buf, &types.buf);\r
-    int typeNum = SSecurityVeNCrypt::secTypeNum(type.buf);\r
-    if (typeNum != secTypeInvalid)\r
-      result.push_back(typeNum);\r
-  }\r
-  return result;\r
-}\r
-\r
-\r
index 1fd6b4a0fa844a0a017c97de4fec86bebf60b8fa..3d5949ef267076fac76ea4f90e73ee919832917b 100644 (file)
@@ -46,13 +46,8 @@ namespace rfb {
     virtual int getType() const { return secTypeVeNCrypt; }\r
     virtual const char* getUserName() const { return NULL; }\r
 \r
-    static StringParameter X509_CertFile, X509_KeyFile, secTypesStr;\r
+    static StringParameter X509_CertFile, X509_KeyFile;\r
 \r
-    /* XXX Derive Security class and merge those functions appropriately ? */\r
-    static void getSecTypes(std::list<rdr::U32>* secTypes);\r
-    static rdr::U32 secTypeNum(const char *name);\r
-    static char* secTypeName(rdr::U32 num);\r
-    static std::list<rdr::U32> parseSecTypes(const char *types);\r
   protected:\r
     static SSecurityStack* getSSecurityStack(int secType);\r
 \r