#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
\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
}\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
"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
*/\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
\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
}\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
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