summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Tkac <atkac@redhat.com>2010-04-23 14:07:41 +0000
committerAdam Tkac <atkac@redhat.com>2010-04-23 14:07:41 +0000
commita6578bfc986695bf9e5d4272b6d2e57516aa4cbf (patch)
treeff36c03b224765b677ca1c13d670c41d5b47e2c4
parent1d15e2d60a171a43c83e51a1343727701ac34f4b (diff)
downloadtigervnc-a6578bfc986695bf9e5d4272b6d2e57516aa4cbf.tar.gz
tigervnc-a6578bfc986695bf9e5d4272b6d2e57516aa4cbf.zip
[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
-rw-r--r--common/rfb/Makefile.am4
-rw-r--r--common/rfb/SConnection.cxx25
-rw-r--r--common/rfb/SConnection.h11
-rw-r--r--common/rfb/SSecurity.h15
-rw-r--r--common/rfb/Security.cxx8
-rw-r--r--common/rfb/VNCSConnectionST.cxx2
-rw-r--r--common/rfb/VNCServer.h4
-rw-r--r--common/rfb/VNCServerST.cxx7
-rw-r--r--common/rfb/VNCServerST.h5
-rw-r--r--unix/x0vncserver/x0vncserver.cxx1
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.cc1
-rw-r--r--win/vncconfig/Authentication.h4
-rw-r--r--win/vncconfig/vncconfig.cxx1
-rw-r--r--win/winvnc/VNCServerWin32.cxx1
-rw-r--r--win/winvnc/VNCServerWin32.h2
15 files changed, 32 insertions, 59 deletions
diff --git a/common/rfb/Makefile.am b/common/rfb/Makefile.am
index a3b134fc..138fec80 100644
--- a/common/rfb/Makefile.am
+++ b/common/rfb/Makefile.am
@@ -15,7 +15,7 @@ HDRS = Blacklist.h CapsContainer.h CapsList.h CConnection.h \
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 @@ librfb_la_SOURCES = $(HDRS) Blacklist.cxx CConnection.cxx CMsgHandler.cxx \
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 83e1599c..0e6ded52 100644
--- a/common/rfb/SConnection.cxx
+++ b/common/rfb/SConnection.cxx
@@ -42,10 +42,10 @@ const SConnection::AccessRights SConnection::AccessNoQuery = 0x0400;
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 @@ SConnection::SConnection(SSecurityFactory* secFact, bool reverseConnection_)
defaultMinorVersion = 3;
cp.setVersion(defaultMajorVersion, defaultMinorVersion);
+
+ security = new Security();
}
SConnection::~SConnection()
{
- if (security) security->destroy();
+ if (ssecurity) ssecurity->destroy();
deleteReaderAndWriter();
}
@@ -141,7 +143,7 @@ void SConnection::processVersionMsg()
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 @@ void SConnection::processVersionMsg()
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 @@ void SConnection::offerAuthentication()
// 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 @@ void SConnection::processSecurityType(int secType)
// 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 @@ void SConnection::processSecurityType(int secType)
try {
state_ = RFBSTATE_SECURITY;
- security = securityFactory->getSSecurity(secType, reverseConnection);
+ ssecurity = security->GetSSecurity(secType);
} catch (rdr::Exception& e) {
throwConnFailedException(e.str());
}
@@ -315,10 +318,10 @@ void SConnection::processSecurityMsg()
{
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 @@ void SConnection::approveConnection(bool accept, const char* reason)
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 e41ef5fb..e139f15f 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 @@ namespace rfb {
class SConnection : public SMsgHandler {
public:
- SConnection(SSecurityFactory* sf, bool reverseConnection_);
+ SConnection(bool reverseConnection_);
virtual ~SConnection();
// Methods to initialise the connection
@@ -167,10 +168,6 @@ namespace rfb {
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 @@ namespace rfb {
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 108985b3..afc744e4 100644
--- a/common/rfb/SSecurity.h
+++ b/common/rfb/SSecurity.h
@@ -65,20 +65,5 @@ namespace rfb {
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 a38029a5..adc21c99 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 @@ using namespace std;
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 29ce5e59..efbc0081 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -34,7 +34,7 @@ static LogWriter vlog("VNCSConnST");
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 850dbd3c..7fa44c18 100644
--- a/common/rfb/VNCServer.h
+++ b/common/rfb/VNCServer.h
@@ -85,10 +85,6 @@ namespace rfb {
// 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 a21526ad..1685b33c 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 @@ using namespace rfb;
static LogWriter slog("VNCServerST");
LogWriter VNCServerST::connectionsLog("Connections");
-static SSecurityFactoryStandard defaultSecurityFactory;
//
// -=- VNCServerST Implementation
@@ -71,12 +70,10 @@ static SSecurityFactoryStandard defaultSecurityFactory;
// -=- 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 320db2f4..aa9ade0f 100644
--- a/common/rfb/VNCServerST.h
+++ b/common/rfb/VNCServerST.h
@@ -47,8 +47,7 @@ namespace rfb {
// -=- 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 @@ namespace rfb {
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 @@ namespace rfb {
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 d050a001..64fbe683 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 e7cb2a7a..a0148316 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -47,7 +47,6 @@ extern "C" {
#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 a59990b9..cae97190 100644
--- a/win/vncconfig/Authentication.h
+++ b/win/vncconfig/Authentication.h
@@ -40,7 +40,7 @@ namespace rfb {
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 @@ namespace rfb {
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 f5b1631f..afbe365c 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 cd0978b6..cd37eef3 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 f05f2c70..5b40a5ab 100644
--- a/win/winvnc/VNCServerWin32.h
+++ b/win/winvnc/VNCServerWin32.h
@@ -118,8 +118,6 @@ namespace winvnc {
ManagedListener httpSock;
STrayIconThread* trayIcon;
- //rfb::SSecurityFactoryStandard securityFactory;
-
QueryConnectDialog* queryConnectDialog;
};