[Development] Create VeNCrypt security types in Security class.
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4103 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/CSecurityVeNCrypt.cxx b/common/rfb/CSecurityVeNCrypt.cxx
index 39a95f4..2d91190 100644
--- a/common/rfb/CSecurityVeNCrypt.cxx
+++ b/common/rfb/CSecurityVeNCrypt.cxx
@@ -26,9 +26,7 @@
#include <rdr/InStream.h>
#include <rdr/OutStream.h>
#include <rfb/CConnection.h>
-#include <rfb/CSecurityTLS.h>
#include <rfb/CSecurityVeNCrypt.h>
-#include <rfb/CSecurityVncAuth.h>
#include <rfb/LogWriter.h>
#include <list>
@@ -173,7 +171,7 @@
if (chosenType == secTypeInvalid || chosenType == secTypeVeNCrypt)
throw AuthFailureException("No valid VeNCrypt sub-type");
- csecurity = CSecurityVeNCrypt::getCSecurityStack(chosenType);
+ csecurity = security->GetCSecurity(chosenType);
/* send chosen type to server */
os->writeU32(chosenType);
@@ -193,25 +191,3 @@
return csecurity->processMsg(cc);
}
-CSecurityStack* CSecurityVeNCrypt::getCSecurityStack(int secType)
-{
- switch (secType) {
- case secTypeTLSNone:
- return new CSecurityStack(secTypeTLSNone, "TLS with no password",
- new CSecurityTLS());
- case secTypeTLSVnc:
- return new CSecurityStack(secTypeTLSVnc, "TLS with VNCAuth",
- new CSecurityTLS(), new CSecurityVncAuth());
-#if 0
- /* Following subtypes are not implemented, yet */
- case secTypeTLSPlain:
- case secTypeX509None:
- case secTypeX509Vnc:
- case secTypeX509Plain:
-#endif
- default:
- throw Exception("Unsupported VeNCrypt subtype");
- }
-
- return NULL; /* not reached */
-}
diff --git a/common/rfb/CSecurityVeNCrypt.h b/common/rfb/CSecurityVeNCrypt.h
index 3ad6eb2..1385f58 100644
--- a/common/rfb/CSecurityVeNCrypt.h
+++ b/common/rfb/CSecurityVeNCrypt.h
@@ -26,7 +26,6 @@
#define __CSECURITYVENCRYPT_H__
#include <rfb/CSecurity.h>
-#include <rfb/CSecurityStack.h>
#include <rfb/Security.h>
#include <rdr/types.h>
@@ -43,8 +42,6 @@
static StringParameter secTypesStr;
protected:
- static CSecurityStack* getCSecurityStack(int secType);
-
CSecurity *csecurity;
Security *security;
bool haveRecvdMajorVersion;
diff --git a/common/rfb/Makefile.am b/common/rfb/Makefile.am
index c683fe0..7df6b6b 100644
--- a/common/rfb/Makefile.am
+++ b/common/rfb/Makefile.am
@@ -1,17 +1,16 @@
noinst_LTLIBRARIES = librfb.la
-VENCRYPT_HDRS = CSecurityStack.h CSecurityTLS.h CSecurityTLSBase.h \
- CSecurityVeNCrypt.h SSecurityPlain.h SSecurityStack.h SSecurityTLS.h \
- SSecurityTLSBase.h SSecurityVeNCrypt.h
+VENCRYPT_HDRS = CSecurityTLS.h CSecurityTLSBase.h \
+ SSecurityTLS.h SSecurityTLSBase.h
-VENCRYPT_SRCS = CSecurityStack.cxx CSecurityTLS.cxx CSecurityTLSBase.cxx \
- CSecurityVeNCrypt.cxx SSecurityPlain.cxx SSecurityStack.cxx \
- SSecurityTLS.cxx SSecurityTLSBase.cxx SSecurityVeNCrypt.cxx
+VENCRYPT_SRCS = CSecurityTLS.cxx CSecurityTLSBase.cxx \
+ SSecurityTLS.cxx SSecurityTLSBase.cxx
HDRS = Blacklist.h CapsContainer.h CapsList.h CConnection.h \
CMsgHandler.h CMsgReader.h CMsgReaderV3.h CMsgWriter.h \
CMsgWriterV3.h ColourCube.h ColourMap.h ComparingUpdateTracker.h \
Configuration.h ConnParams.h CSecurity.h CSecurityNone.h \
+ CSecurityStack.h CSecurityVeNCrypt.h \
CSecurityVncAuth.h Cursor.h Decoder.h d3des.h Encoder.h \
encodings.h Exception.h hextileConstants.h hextileDecode.h \
HextileDecoder.h hextileEncodeBetter.h hextileEncode.h \
@@ -23,6 +22,7 @@
ScaledPixelBuffer.h ScaleFilters.h SConnection.h ScreenSet.h \
screenTypes.h SDesktop.h ServerCore.h SMsgHandler.h SMsgReader.h \
SMsgReaderV3.h SMsgWriter.h SMsgWriterV3.h SSecurity.h SSecurityNone.h \
+ SSecurityPlain.h SSecurityStack.h SSecurityVeNCrypt.h \
SSecurityVncAuth.h Threading.h tightDecode.h \
TightDecoder.h tightEncode.h TightEncoder.h TightPalette.h Timer.h \
TransImageGetter.h transInitTempl.h transTempl.h TrueColourMap.h \
@@ -32,6 +32,7 @@
librfb_la_SOURCES = $(HDRS) Blacklist.cxx CConnection.cxx CMsgHandler.cxx \
CMsgReader.cxx CMsgReaderV3.cxx CMsgWriter.cxx CMsgWriterV3.cxx \
+ CSecurityStack.cxx CSecurityVeNCrypt.cxx \
CSecurityVncAuth.cxx CapsContainer.cxx CapsList.cxx \
ComparingUpdateTracker.cxx Configuration.cxx ConnParams.cxx \
Cursor.cxx Decoder.cxx d3des.c Encoder.cxx \
@@ -41,7 +42,8 @@
RREEncoder.cxx RREDecoder.cxx RawDecoder.cxx RawEncoder.cxx \
Region.cxx SConnection.cxx SMsgHandler.cxx \
SMsgReader.cxx SMsgReaderV3.cxx SMsgWriter.cxx SMsgWriterV3.cxx \
- ServerCore.cxx Security.cxx SSecurityVncAuth.cxx \
+ ServerCore.cxx Security.cxx SSecurityPlain.cxx SSecurityStack.cxx \
+ SSecurityVncAuth.cxx SSecurityVeNCrypt.cxx \
ScaledPixelBuffer.cxx ScaleFilters.cxx Timer.cxx TightDecoder.cxx \
TightEncoder.cxx TightPalette.cxx TransImageGetter.cxx \
UpdateTracker.cxx VNCSConnectionST.cxx \
diff --git a/common/rfb/SSecurityPlain.cxx b/common/rfb/SSecurityPlain.cxx
index 6b7bd9e..04eabe0 100644
--- a/common/rfb/SSecurityPlain.cxx
+++ b/common/rfb/SSecurityPlain.cxx
@@ -21,10 +21,6 @@
#include <config.h>
#endif
-#ifndef HAVE_GNUTLS
-#error "This source should not be compiled without HAVE_GNUTLS defined"
-#endif
-
#include <rfb/SSecurityPlain.h>
#include <rfb/SConnection.h>
#include <rfb/Exception.h>
diff --git a/common/rfb/SSecurityPlain.h b/common/rfb/SSecurityPlain.h
index ecdd618..f7a9c3d 100644
--- a/common/rfb/SSecurityPlain.h
+++ b/common/rfb/SSecurityPlain.h
@@ -24,10 +24,6 @@
#include <config.h>
#endif
-#ifndef HAVE_GNUTLS
-#error "This header should not be included without HAVE_GNUTLS defined"
-#endif
-
#include <rfb/SConnection.h>
#include <rfb/SSecurity.h>
#include <rfb/SSecurityVeNCrypt.h>
diff --git a/common/rfb/SSecurityVeNCrypt.cxx b/common/rfb/SSecurityVeNCrypt.cxx
index 2dd331e..c704d1e 100644
--- a/common/rfb/SSecurityVeNCrypt.cxx
+++ b/common/rfb/SSecurityVeNCrypt.cxx
@@ -26,17 +26,11 @@
#include <config.h>
#endif
-#ifndef HAVE_GNUTLS
-#error "This source should not be compiled without HAVE_GNUTLS defined"
-#endif
-
#include <rfb/SSecurityVeNCrypt.h>
#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
#include <rdr/InStream.h>
#include <rdr/OutStream.h>
-#include <rfb/SSecurityVncAuth.h>
-#include <rfb/SSecurityTLS.h>
using namespace rfb;
using namespace rdr;
@@ -180,29 +174,10 @@
if (chosenType == secTypeInvalid || chosenType == secTypeVeNCrypt)
throw AuthFailureException("No valid VeNCrypt sub-type");
- ssecurity = SSecurityVeNCrypt::getSSecurityStack(chosenType);
+ ssecurity = security->GetSSecurity(chosenType);
}
/* continue processing the messages */
return ssecurity->processMsg(sc);
}
-SSecurityStack* SSecurityVeNCrypt::getSSecurityStack(int secType)
-{
- switch (secType) {
- case secTypeTLSNone:
- return new SSecurityStack(secTypeTLSNone, new SSecurityTLS());
- case secTypeTLSVnc:
- return new SSecurityStack(secTypeTLSVnc, new SSecurityTLS(), new SSecurityVncAuth());
-#if 0
- /* Following types are not implemented, yet */
- case secTypeTLSPlain:
- case secTypeX509None:
- case secTypeX509Vnc:
- case secTypeX509Plain:
-#endif
- default:
- throw Exception("Bug in the SSecurityVeNCrypt::getSSecurityStack");
- }
-}
-
diff --git a/common/rfb/SSecurityVeNCrypt.h b/common/rfb/SSecurityVeNCrypt.h
index 3d5949e..6201a7b 100644
--- a/common/rfb/SSecurityVeNCrypt.h
+++ b/common/rfb/SSecurityVeNCrypt.h
@@ -29,10 +29,6 @@
#include <config.h>
#endif
-#ifndef HAVE_GNUTLS
-#error "This header should not be included without HAVE_GNUTLS defined"
-#endif
-
#include <rfb/SSecurityStack.h>
#include <rfb/SConnection.h>
@@ -49,8 +45,6 @@
static StringParameter X509_CertFile, X509_KeyFile;
protected:
- static SSecurityStack* getSSecurityStack(int secType);
-
SSecurity *ssecurity;
Security *security;
bool haveSentVersion, haveRecvdMajorVersion, haveRecvdMinorVersion;
diff --git a/common/rfb/Security.cxx b/common/rfb/Security.cxx
index 4dea41e..e6a51bc 100644
--- a/common/rfb/Security.cxx
+++ b/common/rfb/Security.cxx
@@ -28,15 +28,19 @@
#define strcasecmp _stricmp
#endif
#include <rfb/CSecurityNone.h>
+#include <rfb/CSecurityStack.h>
#include <rfb/CSecurityVeNCrypt.h>
#include <rfb/CSecurityVncAuth.h>
#include <rdr/Exception.h>
#include <rfb/LogWriter.h>
#include <rfb/Security.h>
#include <rfb/SSecurityNone.h>
+#include <rfb/SSecurityStack.h>
#include <rfb/SSecurityVncAuth.h>
-#ifdef HAVE_GNUTLS
#include <rfb/SSecurityVeNCrypt.h>
+#ifdef HAVE_GNUTLS
+#include <rfb/CSecurityTLS.h>
+#include <rfb/SSecurityTLS.h>
#endif
#include <rfb/util.h>
@@ -116,8 +120,12 @@
switch (secType) {
case secTypeNone: return new SSecurityNone();
case secTypeVncAuth: return new SSecurityVncAuth();
-#ifdef HAVE_GNUTLS
case secTypeVeNCrypt: return new SSecurityVeNCrypt(this);
+#ifdef HAVE_GNUTLS
+ case secTypeTLSNone:
+ return new SSecurityStack(secTypeTLSNone, new SSecurityTLS());
+ case secTypeTLSVnc:
+ return new SSecurityStack(secTypeTLSVnc, new SSecurityTLS(), new SSecurityVncAuth());
#endif
}
@@ -135,8 +143,14 @@
switch (secType) {
case secTypeNone: return new CSecurityNone();
case secTypeVncAuth: return new CSecurityVncAuth();
-#ifdef HAVE_GNUTLS
case secTypeVeNCrypt: return new CSecurityVeNCrypt(this);
+#ifdef HAVE_GNUTLS
+ case secTypeTLSNone:
+ return new CSecurityStack(secTypeTLSNone, "TLS with no password",
+ new CSecurityTLS());
+ case secTypeTLSVnc:
+ return new CSecurityStack(secTypeTLSVnc, "TLS with VNCAuth",
+ new CSecurityTLS(), new CSecurityVncAuth());
#endif
}