Added support for multiple --login url username password entries to osgviewer

This commit is contained in:
Robert Osfield 2017-10-05 15:37:03 +01:00
parent d75564c7e3
commit ddf8c68d26
2 changed files with 11 additions and 8 deletions

View File

@ -74,14 +74,10 @@ int main(int argc, char** argv)
std::string url, username, password;
while(arguments.read("--login",url, username, password))
{
if (!osgDB::Registry::instance()->getAuthenticationMap())
{
osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
url,
new osgDB::AuthenticationDetails(username, password)
);
}
osgDB::Registry::instance()->getOrCreateAuthenticationMap()->addAuthenticationDetails(
url,
new osgDB::AuthenticationDetails(username, password)
);
}
std::string device;

View File

@ -366,6 +366,13 @@ class OSGDB_EXPORT Registry : public osg::Referenced
/** Set the password map to be used by plugins when access files from secure locations.*/
void setAuthenticationMap(AuthenticationMap* authenticationMap) { _authenticationMap = authenticationMap; }
/** Get the password map to be used by plugins when access files from secure locations. Create a AuthenticationMap if one isn't already assigned.*/
AuthenticationMap* getOrCreateAuthenticationMap()
{
if (!_authenticationMap) _authenticationMap = new AuthenticationMap;
return _authenticationMap.get();
}
/** Get the password map to be used by plugins when access files from secure locations.*/
AuthenticationMap* getAuthenticationMap() { return _authenticationMap.get(); }