[Development] Replace SSecurityFactoryStandard class by simplier Security class.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4039 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/Makefile.am b/common/rfb/Makefile.am
index a3b134f..138fec8 100644
--- a/common/rfb/Makefile.am
+++ b/common/rfb/Makefile.am
@@ -15,7 +15,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 \
- Security.h SSecurityFactoryStandard.h SSecurityNone.h \
+ Security.h SSecurity.h SSecurityNone.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 \
@@ -34,7 +34,7 @@
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 SSecurityFactoryStandard.cxx SSecurityVncAuth.cxx \
+ ServerCore.cxx Security.cxx SSecurityVncAuth.cxx \
ScaledPixelBuffer.cxx ScaleFilters.cxx Timer.cxx TightDecoder.cxx \
TightEncoder.cxx TightPalette.cxx TransImageGetter.cxx \
UpdateTracker.cxx VNCSConnectionST.cxx \
diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx
index 83e1599..0e6ded5 100644
--- a/common/rfb/SConnection.cxx
+++ b/common/rfb/SConnection.cxx
@@ -42,10 +42,10 @@
const SConnection::AccessRights SConnection::AccessFull = 0xffff;
-SConnection::SConnection(SSecurityFactory* secFact, bool reverseConnection_)
+SConnection::SConnection(bool reverseConnection_)
: readyForSetColourMapEntries(false),
is(0), os(0), reader_(0), writer_(0),
- security(0), securityFactory(secFact), state_(RFBSTATE_UNINITIALISED),
+ security(0), ssecurity(0), state_(RFBSTATE_UNINITIALISED),
reverseConnection(reverseConnection_)
{
defaultMajorVersion = 3;
@@ -54,11 +54,13 @@
defaultMinorVersion = 3;
cp.setVersion(defaultMajorVersion, defaultMinorVersion);
+
+ security = new Security();
}
SConnection::~SConnection()
{
- if (security) security->destroy();
+ if (ssecurity) ssecurity->destroy();
deleteReaderAndWriter();
}
@@ -141,7 +143,7 @@
std::list<rdr::U8> secTypes;
std::list<rdr::U8>::iterator i;
- securityFactory->getSecTypes(&secTypes, reverseConnection);
+ secTypes = security->GetEnabledSecTypes();
if (cp.isVersion(3,3)) {
@@ -160,7 +162,7 @@
os->writeU32(*i);
if (*i == secTypeNone) os->flush();
state_ = RFBSTATE_SECURITY;
- security = securityFactory->getSSecurity(*i, reverseConnection);
+ ssecurity = security->GetSSecurity(*i);
processSecurityMsg();
return;
}
@@ -237,7 +239,7 @@
// NOTE: In addition to standard security types, we might want to offer
// TightVNC-specific authentication types. But currently we support
// only the standard security types: secTypeNone and secTypeVncAuth.
- securityFactory->getSecTypes(&secTypes, reverseConnection);
+ secTypes = security->GetEnabledSecTypes();
CapsList caps;
for (i = secTypes.begin(); i != secTypes.end(); i++) {
@@ -292,7 +294,8 @@
// Verify that the requested security type should be offered
std::list<rdr::U8> secTypes;
std::list<rdr::U8>::iterator i;
- securityFactory->getSecTypes(&secTypes, reverseConnection);
+
+ secTypes = security->GetEnabledSecTypes();
for (i=secTypes.begin(); i!=secTypes.end(); i++)
if (*i == secType) break;
if (i == secTypes.end())
@@ -303,7 +306,7 @@
try {
state_ = RFBSTATE_SECURITY;
- security = securityFactory->getSSecurity(secType, reverseConnection);
+ ssecurity = security->GetSSecurity(secType);
} catch (rdr::Exception& e) {
throwConnFailedException(e.str());
}
@@ -315,10 +318,10 @@
{
vlog.debug("processing security message");
try {
- bool done = security->processMsg(this);
+ bool done = ssecurity->processMsg(this);
if (done) {
state_ = RFBSTATE_QUERYING;
- queryConnection(security->getUserName());
+ queryConnection(ssecurity->getUserName());
}
} catch (AuthFailureException& e) {
vlog.error("AuthFailureException: %s", e.str());
@@ -383,7 +386,7 @@
if (!reason) reason = "Authentication failure";
- if (!cp.beforeVersion(3,8) || security->getType() != secTypeNone) {
+ if (!cp.beforeVersion(3,8) || ssecurity->getType() != secTypeNone) {
if (accept) {
os->writeU32(secResultOK);
} else {
diff --git a/common/rfb/SConnection.h b/common/rfb/SConnection.h
index e41ef5f..e139f15 100644
--- a/common/rfb/SConnection.h
+++ b/common/rfb/SConnection.h
@@ -26,6 +26,7 @@
#include <rdr/InStream.h>
#include <rdr/OutStream.h>
#include <rfb/SMsgHandler.h>
+#include <rfb/Security.h>
#include <rfb/SSecurity.h>
namespace rfb {
@@ -37,7 +38,7 @@
class SConnection : public SMsgHandler {
public:
- SConnection(SSecurityFactory* sf, bool reverseConnection_);
+ SConnection(bool reverseConnection_);
virtual ~SConnection();
// Methods to initialise the connection
@@ -167,10 +168,6 @@
stateEnum state() { return state_; }
- // ssecurity() returns a pointer to this connection's SSecurity object, if
- // any
- const SSecurity* ssecurity() const { return security; }
-
protected:
void setState(stateEnum s) { state_ = s; }
@@ -194,8 +191,8 @@
rdr::OutStream* os;
SMsgReader* reader_;
SMsgWriter* writer_;
- SSecurity* security;
- SSecurityFactory* securityFactory;
+ Security *security;
+ SSecurity* ssecurity;
stateEnum state_;
bool reverseConnection;
};
diff --git a/common/rfb/SSecurity.h b/common/rfb/SSecurity.h
index 108985b..afc744e 100644
--- a/common/rfb/SSecurity.h
+++ b/common/rfb/SSecurity.h
@@ -65,20 +65,5 @@
virtual const char* getUserName() const = 0;
};
- // SSecurityFactory creates new SSecurity instances for
- // particular security types.
- // The instances must be destroyed by calling destroy()
- // on them when done.
- // getSecTypes returns a list of the security types that are both configured
- // and actually supported. Which configuration is considered depends on the
- // reverseConnection parameter.
- class SSecurityFactory {
- public:
- virtual ~SSecurityFactory() {}
- virtual SSecurity* getSSecurity(rdr::U8 secType, bool noAuth=false)=0;
- virtual void getSecTypes(std::list<rdr::U8>* secTypes,
- bool reverseConnection) = 0;
- };
-
}
#endif
diff --git a/common/rfb/Security.cxx b/common/rfb/Security.cxx
index a38029a..adc21c9 100644
--- a/common/rfb/Security.cxx
+++ b/common/rfb/Security.cxx
@@ -25,7 +25,6 @@
#include <rfb/LogWriter.h>
#include <rfb/Security.h>
#include <rfb/SSecurityNone.h>
-#include <rfb/SSecurityFactoryStandard.h>
#include <rfb/SSecurityVncAuth.h>
#include <rfb/util.h>
@@ -35,9 +34,14 @@
static LogWriter vlog("Security");
+StringParameter Security::secTypes
+("SecurityTypes",
+ "Specify which security scheme to use (None, VncAuth)",
+ "VncAuth");
+
Security::Security(void)
{
- char *secTypesStr = SSecurityFactoryStandard::sec_types.getData();
+ char *secTypesStr = secTypes.getData();
enabledSecTypes = parseSecTypes(secTypesStr);
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 29ce5e5..efbc008 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -34,7 +34,7 @@
VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
bool reverse)
- : SConnection(server_->securityFactory, reverse), sock(s), server(server_),
+ : SConnection(reverse), sock(s), server(server_),
updates(false), image_getter(server->useEconomicTranslate),
drawRenderedCursor(false), removeRenderedCursor(false),
pointerEventTime(0), accessRights(AccessDefault),
diff --git a/common/rfb/VNCServer.h b/common/rfb/VNCServer.h
index 850dbd3..7fa44c1 100644
--- a/common/rfb/VNCServer.h
+++ b/common/rfb/VNCServer.h
@@ -85,10 +85,6 @@
// setCursorPos() tells the server the current position of the cursor.
virtual void setCursorPos(const Point& p) = 0;
- // setSSecurityFactory() tells the server which factory to use when
- // attempting to authenticate connections.
- virtual void setSSecurityFactory(SSecurityFactory* f) = 0;
-
// setName() tells the server what desktop title to supply to clients
virtual void setName(const char* name) = 0;
};
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx
index a21526a..1685b33 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -53,7 +53,7 @@
#include <rfb/VNCServerST.h>
#include <rfb/VNCSConnectionST.h>
#include <rfb/ComparingUpdateTracker.h>
-#include <rfb/SSecurityFactoryStandard.h>
+#include <rfb/Security.h>
#include <rfb/KeyRemapper.h>
#include <rfb/util.h>
@@ -63,7 +63,6 @@
static LogWriter slog("VNCServerST");
LogWriter VNCServerST::connectionsLog("Connections");
-static SSecurityFactoryStandard defaultSecurityFactory;
//
// -=- VNCServerST Implementation
@@ -71,12 +70,10 @@
// -=- Constructors/Destructor
-VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_,
- SSecurityFactory* sf)
+VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_)
: blHosts(&blacklist), desktop(desktop_), desktopStarted(false), pb(0),
name(strDup(name_)), pointerClient(0), comparer(0),
renderedCursorInvalid(false),
- securityFactory(sf ? sf : &defaultSecurityFactory),
queryConnectionHandler(0), keyRemapper(&KeyRemapper::defInstance),
useEconomicTranslate(false),
lastConnectionTime(0), disableclients(false)
diff --git a/common/rfb/VNCServerST.h b/common/rfb/VNCServerST.h
index 320db2f..aa9ade0 100644
--- a/common/rfb/VNCServerST.h
+++ b/common/rfb/VNCServerST.h
@@ -47,8 +47,7 @@
// -=- Constructors
// Create a server exporting the supplied desktop.
- VNCServerST(const char* name_, SDesktop* desktop_,
- SSecurityFactory* securityFactory_=0);
+ VNCServerST(const char* name_, SDesktop* desktop_);
virtual ~VNCServerST();
@@ -91,7 +90,6 @@
virtual void setCursor(int width, int height, const Point& hotspot,
void* cursorData, void* mask);
virtual void setCursorPos(const Point& p);
- virtual void setSSecurityFactory(SSecurityFactory* f) {securityFactory=f;}
virtual void bell();
@@ -229,7 +227,6 @@
void notifyScreenLayoutChange(VNCSConnectionST *requester);
- SSecurityFactory* securityFactory;
QueryConnectionHandler* queryConnectionHandler;
KeyRemapper* keyRemapper;
bool useEconomicTranslate;
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx
index d050a00..64fbe68 100644
--- a/unix/x0vncserver/x0vncserver.cxx
+++ b/unix/x0vncserver/x0vncserver.cxx
@@ -29,7 +29,6 @@
#include <rfb/LogWriter.h>
#include <rfb/VNCServerST.h>
#include <rfb/Configuration.h>
-#include <rfb/SSecurityFactoryStandard.h>
#include <rfb/Timer.h>
#include <network/TcpSocket.h>
#include <tx/TXWindow.h>
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
index e7cb2a7..a014831 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -47,7 +47,6 @@
#include <rfb/LogWriter.h>
#include <rfb/util.h>
#include <rfb/ServerCore.h>
-#include <rfb/SSecurityFactoryStandard.h>
#include <rdr/HexOutStream.h>
#include <rfb/LogWriter.h>
#undef max
diff --git a/win/vncconfig/Authentication.h b/win/vncconfig/Authentication.h
index a59990b..cae9719 100644
--- a/win/vncconfig/Authentication.h
+++ b/win/vncconfig/Authentication.h
@@ -40,7 +40,7 @@
AuthenticationPage(const RegKey& rk)
: PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_AUTHENTICATION)), regKey(rk) {}
void initDialog() {
- CharArray sec_types_str(SSecurityFactoryStandard::sec_types.getData());
+ CharArray sec_types_str(Security::secTypes.getData());
std::list<rdr::U8> sec_types = parseSecTypes(sec_types_str.buf);
useNone = useVNC = false;
@@ -114,7 +114,7 @@
static bool haveVncPassword() {
- PlainPasswd password(SSecurityFactoryStandard::vncAuthPasswd.getVncAuthPasswd());
+ PlainPasswd password(SSecurityVncAuth::vncAuthPasswd.getVncAuthPasswd());
return password.buf && strlen(password.buf) != 0;
}
diff --git a/win/vncconfig/vncconfig.cxx b/win/vncconfig/vncconfig.cxx
index f5b1631..afbe365 100644
--- a/win/vncconfig/vncconfig.cxx
+++ b/win/vncconfig/vncconfig.cxx
@@ -26,7 +26,6 @@
#include "resource.h"
#include <rfb/Logger_stdio.h>
#include <rfb/LogWriter.h>
-#include <rfb/SSecurityFactoryStandard.h>
#include <rfb_win32/Dialog.h>
#include <rfb_win32/RegConfig.h>
#include <rfb_win32/CurrentUser.h>
diff --git a/win/winvnc/VNCServerWin32.cxx b/win/winvnc/VNCServerWin32.cxx
index cd0978b..cd37eef 100644
--- a/win/winvnc/VNCServerWin32.cxx
+++ b/win/winvnc/VNCServerWin32.cxx
@@ -24,7 +24,6 @@
#include <rfb_win32/ComputerName.h>
#include <rfb_win32/CurrentUser.h>
#include <rfb_win32/Service.h>
-#include <rfb/SSecurityFactoryStandard.h>
#include <rfb/Hostname.h>
#include <rfb/LogWriter.h>
diff --git a/win/winvnc/VNCServerWin32.h b/win/winvnc/VNCServerWin32.h
index f05f2c7..5b40a5a 100644
--- a/win/winvnc/VNCServerWin32.h
+++ b/win/winvnc/VNCServerWin32.h
@@ -118,8 +118,6 @@
ManagedListener httpSock;
STrayIconThread* trayIcon;
- //rfb::SSecurityFactoryStandard securityFactory;
-
QueryConnectDialog* queryConnectDialog;
};