From 292b892478b05f42a67250f9c91b71b3062ecc52 Mon Sep 17 00:00:00 2001 From: Laurens Voerman Date: Thu, 21 Sep 2017 16:33:14 +0200 Subject: [PATCH] VNC: try to find password for host if no password for host:port is found --- src/osgPlugins/vnc/ReaderWriterVNC.cpp | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/osgPlugins/vnc/ReaderWriterVNC.cpp b/src/osgPlugins/vnc/ReaderWriterVNC.cpp index 6da3ccbc3..926ab930e 100644 --- a/src/osgPlugins/vnc/ReaderWriterVNC.cpp +++ b/src/osgPlugins/vnc/ReaderWriterVNC.cpp @@ -397,20 +397,23 @@ class ReaderWriterVNC : public osgDB::ReaderWriter const osgDB::AuthenticationMap* authenticationMap = (options && options->getAuthenticationMap()) ? options->getAuthenticationMap() : osgDB::Registry::instance()->getAuthenticationMap(); + if (authenticationMap != NULL) { + const osgDB::AuthenticationDetails* details = authenticationMap->getAuthenticationDetails(hostname); + if (details == NULL) { + size_t pos = hostname.find(":"); + if (pos != std::string::npos) { + details = authenticationMap->getAuthenticationDetails(hostname.substr(0, pos)); + } + } + // configure authentication if required. + if (details != NULL) + { + OSG_NOTICE << "Passing in password = " << details->password << std::endl; - const osgDB::AuthenticationDetails* details = authenticationMap ? - authenticationMap->getAuthenticationDetails(hostname) : - 0; - - // configure authentication if required. - if (details) - { - OSG_NOTICE<<"Passing in password = "<password<_username = details->username; - image->_password = details->password; + image->_username = details->username; + image->_password = details->password; + } } - if (options && !options->getOptionString().empty()) { image->_optionString = options->getOptionString();