Index: /OpenSceneGraph/trunk/src/osgPlugins/vnc/ReaderWriterVNC.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgPlugins/vnc/ReaderWriterVNC.cpp (revision 12850)
+++ /OpenSceneGraph/trunk/src/osgPlugins/vnc/ReaderWriterVNC.cpp (revision 12851)
@@ -50,4 +50,9 @@
         static void updateImage(rfbClient* client,int x,int y,int w,int h);
         
+        static void passwordCheck(rfbClient* client,const char* encryptedPassWord,int len);
+        static char* getPassword(rfbClient* client);
+
+        std::string                 _username;
+        std::string                 _password;
         double                      _timeOfLastUpdate;
         double                      _timeOfLastRender;
@@ -138,5 +143,4 @@
 
     _inactiveBlock = new osg::RefBlock;
-
 }
 
@@ -198,4 +202,16 @@
 }
 
+void LibVncImage::passwordCheck(rfbClient* client,const char* encryptedPassWord,int len)
+{
+    OSG_NOTICE<<"LibVncImage::passwordCheck"<<std::endl;
+}
+
+char* LibVncImage::getPassword(rfbClient* client)
+{
+    LibVncImage* image = (LibVncImage*)(rfbClientGetClientData(client, 0));
+    OSG_NOTICE<<"LibVncImage::getPassword "<<image->_password<<std::endl;
+    return strdup(image->_password.c_str());
+}
+
 
 bool LibVncImage::connect(const std::string& hostname)
@@ -212,4 +228,7 @@
     _client->HandleTextChat = 0;
 
+    // provide the password if we have one assigned
+    if (!_password.empty())  _client->GetPassword = getPassword;
+
     rfbClientSetClientData(_client, 0, this);
     
@@ -268,5 +287,11 @@
     PrintPixelFormat(&(client->format));
 
+#ifdef __APPLE__
+    // feedback is that Mac's have an endian swap even though the PixelFormat results see under OSX are identical.
+    bool swap = true;
+#else
     bool swap = client->format.redShift!=0;
+#endif
+
     GLenum gl_pixelFormat = swap ? GL_BGRA : GL_RGBA;
 
@@ -349,7 +374,23 @@
 
             osg::ref_ptr<LibVncImage> image = new LibVncImage;
-            image->setDataVariance(osg::Object::DYNAMIC);
-            
+            image->setDataVariance(osg::Object::DYNAMIC);           
             image->setOrigin(osg::Image::TOP_LEFT);
+
+            const osgDB::AuthenticationMap* authenticationMap = (options && options->getAuthenticationMap()) ?
+                    options->getAuthenticationMap() :
+                    osgDB::Registry::instance()->getAuthenticationMap();
+
+            const osgDB::AuthenticationDetails* details = authenticationMap ?
+                authenticationMap->getAuthenticationDetails(hostname) :
+                0;
+
+            // configure authentication if required.
+            if (details)
+            {
+                OSG_NOTICE<<"Passing in password = "<<details->password<<std::endl;
+
+                image->_username = details->username;
+                image->_password = details->password;
+            }
 
             if (!image->connect(hostname))
Index: /OpenSceneGraph/trunk/examples/osgvnc/osgvnc.cpp
===================================================================
--- /OpenSceneGraph/trunk/examples/osgvnc/osgvnc.cpp (revision 12292)
+++ /OpenSceneGraph/trunk/examples/osgvnc/osgvnc.cpp (revision 12851)
@@ -1,4 +1,5 @@
 #include <osgWidget/VncClient>
 
+#include <osgDB/Registry>
 #include <osgViewer/Viewer>
 #include <osgViewer/ViewerEventHandlers>
@@ -47,8 +48,21 @@
     osg::ref_ptr<osg::Group> group = new osg::Group;
 
+    std::string password;
+    while(arguments.read("--password",password))
+    {
+    }
+
     for(int i=1; i<arguments.argc(); ++i)
     {
         if (!arguments.isOption(i))
         {
+            std::string hostname = arguments[i];
+
+            if (!password.empty())
+            {
+                if (!osgDB::Registry::instance()->getAuthenticationMap()) osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
+                osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(hostname, new osgDB::AuthenticationDetails("", password));
+            }
+
             osg::ref_ptr<osgWidget::VncClient> vncClient = new osgWidget::VncClient;
             if (vncClient->connect(arguments[i], hints))
