Signed-off-by: Martin Koegler <mkoeg...@auto.tuwien.ac.at>
---
 common/rfb/CSecurityPlain.cxx |   46 +++++++++++++++++++++++++++++++++++++++++
 common/rfb/CSecurityPlain.h   |   36 ++++++++++++++++++++++++++++++++
 common/rfb/Makefile.am        |    4 +-
 common/rfb/Security.cxx       |   10 ++++++++-
 4 files changed, 93 insertions(+), 3 deletions(-)
 create mode 100644 common/rfb/CSecurityPlain.cxx
 create mode 100644 common/rfb/CSecurityPlain.h

diff --git a/common/rfb/CSecurityPlain.cxx b/common/rfb/CSecurityPlain.cxx
new file mode 100644
index 0000000..f5f7c1a
--- /dev/null
+++ b/common/rfb/CSecurityPlain.cxx
@@ -0,0 +1,46 @@
+/* Copyright (C) 2005 Martin Kögler
+ * 
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+#include <rfb/CConnection.h>
+#include <rfb/CSecurityPlain.h>
+#include <rfb/UserPasswdGetter.h>
+#include <rfb/util.h>
+
+using namespace rfb;
+
+CSecurityPlain::CSecurityPlain()
+{
+}
+
+bool CSecurityPlain::processMsg(CConnection* cc)
+{
+   rdr::OutStream* os = cc->getOutStream();
+
+  CharArray username;
+  CharArray password;
+
+  (CSecurity::upg)->getUserPasswd(&username.buf, &password.buf);
+
+  // Return the response to the server
+  os->writeU32(strlen(username.buf));
+  os->writeU32(strlen(password.buf));
+  os->writeBytes(username.buf,strlen(username.buf));
+  os->writeBytes(password.buf,strlen(password.buf));
+  os->flush();
+  return true;
+}
diff --git a/common/rfb/CSecurityPlain.h b/common/rfb/CSecurityPlain.h
new file mode 100644
index 0000000..30d4850
--- /dev/null
+++ b/common/rfb/CSecurityPlain.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 2005 Martin Kögler
+ * 
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+#ifndef __RFB_CSECURITYPLAIN_H__
+#define __RFB_CSECURITYPLAIN_H__
+
+#include <rfb/CSecurity.h>
+#include <rfb/Security.h>
+
+namespace rfb {
+
+  class UserPasswdGetter;
+
+  class CSecurityPlain : public CSecurity {
+  public:
+    CSecurityPlain();
+    virtual bool processMsg(CConnection* cc);
+    virtual int getType() const {return secTypePlain;};
+    virtual const char* description() const {return "ask for username and 
password";}
+  };
+}
+#endif
diff --git a/common/rfb/Makefile.am b/common/rfb/Makefile.am
index 78c959f..4e5bbd7 100644
--- a/common/rfb/Makefile.am
+++ b/common/rfb/Makefile.am
@@ -8,7 +8,7 @@ HDRS = Blacklist.h CapsContainer.h CapsList.h CConnection.h \
        CMsgHandler.h CMsgReader.h CMsgReaderV3.h CMsgWriter.h \
        CMsgWriterV3.h ColourCube.h ColourMap.h ComparingUpdateTracker.h \
        Configuration.h ConnParams.h CSecurity.h CSecurityNone.h \
-       CSecurityStack.h CSecurityVeNCrypt.h \
+       CSecurityPlain.h CSecurityStack.h CSecurityVeNCrypt.h \
        CSecurityVncAuth.h Cursor.h Decoder.h d3des.h Encoder.h \
        encodings.h Exception.h hextileConstants.h hextileDecode.h \
        HextileDecoder.h hextileEncodeBetter.h hextileEncode.h \
@@ -30,7 +30,7 @@ HDRS = Blacklist.h CapsContainer.h CapsList.h CConnection.h \
 
 librfb_la_SOURCES = $(HDRS) Blacklist.cxx CConnection.cxx CMsgHandler.cxx \
        CMsgReader.cxx CMsgReaderV3.cxx CMsgWriter.cxx CMsgWriterV3.cxx \
-       CSecurityStack.cxx CSecurityVeNCrypt.cxx \
+       CSecurityPlain.cxx CSecurityStack.cxx CSecurityVeNCrypt.cxx \
        CSecurityVncAuth.cxx CapsContainer.cxx CapsList.cxx \
        ComparingUpdateTracker.cxx Configuration.cxx ConnParams.cxx \
        Cursor.cxx Decoder.cxx d3des.c Encoder.cxx \
diff --git a/common/rfb/Security.cxx b/common/rfb/Security.cxx
index 71e45de..708c10a 100644
--- a/common/rfb/Security.cxx
+++ b/common/rfb/Security.cxx
@@ -31,6 +31,7 @@
 #include <rfb/CSecurityStack.h>
 #include <rfb/CSecurityVeNCrypt.h>
 #include <rfb/CSecurityVncAuth.h>
+#include <rfb/CSecurityPlain.h>
 #include <rdr/Exception.h>
 #include <rfb/LogWriter.h>
 #include <rfb/Security.h>
@@ -56,7 +57,7 @@ StringParameter Security::secTypesViewer
 ("SecurityTypes",
  "Specify which security scheme to use (None, VncAuth)",
 #ifdef HAVE_GNUTLS
- "VeNCrypt,X509Vnc,TLSVnc,X509None,TLSNone,VncAuth,None",
+ 
"VeNCrypt,X509Plain,TLSPlain,X509Vnc,TLSVnc,X509None,TLSNone,Plain,VncAuth,None",
 #else
  "VncAuth,None",
 #endif
@@ -172,6 +173,7 @@ CSecurity* Security::GetCSecurity(U32 secType)
   case secTypeNone: return new CSecurityNone();
   case secTypeVncAuth: return new CSecurityVncAuth();
   case secTypeVeNCrypt: return new CSecurityVeNCrypt(this);
+  case secTypePlain: return new CSecurityPlain();
 #ifdef HAVE_GNUTLS
   case secTypeTLSNone:
     return new CSecurityStack(secTypeTLSNone, "TLS with no password",
@@ -179,12 +181,18 @@ CSecurity* Security::GetCSecurity(U32 secType)
   case secTypeTLSVnc:
     return new CSecurityStack(secTypeTLSVnc, "TLS with VNCAuth",
                              new CSecurityTLS(true), new CSecurityVncAuth());
+  case secTypeTLSPlain:
+    return new CSecurityStack(secTypeTLSPlain, "TLS with Username/Password",
+                             new CSecurityTLS(true), new CSecurityPlain());
   case secTypeX509None:
     return new CSecurityStack(secTypeX509None, "X509 with no password",
                              new CSecurityTLS(false));
   case secTypeX509Vnc:
     return new CSecurityStack(secTypeX509None, "X509 with VNCAuth",
                              new CSecurityTLS(false), new CSecurityVncAuth());
+  case secTypeX509Plain:
+    return new CSecurityStack(secTypeX509Plain, "X509 with Username/Password",
+                             new CSecurityTLS(false), new CSecurityPlain());
 #endif
   }
 
-- 
1.5.6.5


------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

Reply via email to