Browse Source

[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
tags/v1.0.90
Adam Tkac 14 years ago
parent
commit
a6578bfc98

+ 2
- 2
common/rfb/Makefile.am View File

@@ -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 \

+ 14
- 11
common/rfb/SConnection.cxx View File

@@ -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 {

+ 4
- 7
common/rfb/SConnection.h View File

@@ -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;
};

+ 0
- 15
common/rfb/SSecurity.h View File

@@ -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

+ 6
- 2
common/rfb/Security.cxx View File

@@ -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);


+ 1
- 1
common/rfb/VNCSConnectionST.cxx View File

@@ -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),

+ 0
- 4
common/rfb/VNCServer.h View File

@@ -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;
};

+ 2
- 5
common/rfb/VNCServerST.cxx View File

@@ -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)

+ 1
- 4
common/rfb/VNCServerST.h View File

@@ -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;

+ 0
- 1
unix/x0vncserver/x0vncserver.cxx View File

@@ -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>

+ 0
- 1
unix/xserver/hw/vnc/vncExtInit.cc View File

@@ -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

+ 2
- 2
win/vncconfig/Authentication.h View File

@@ -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;
}


+ 0
- 1
win/vncconfig/vncconfig.cxx View File

@@ -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>

+ 0
- 1
win/winvnc/VNCServerWin32.cxx View File

@@ -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>


+ 0
- 2
win/winvnc/VNCServerWin32.h View File

@@ -118,8 +118,6 @@ namespace winvnc {
ManagedListener httpSock;
STrayIconThread* trayIcon;

//rfb::SSecurityFactoryStandard securityFactory;

QueryConnectDialog* queryConnectDialog;
};


Loading…
Cancel
Save