initial support for ClientRedirect and VeNCrypt sub-type Ident in java viewer
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4489 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tigervnc/rfb/CConnection.java b/java/src/com/tigervnc/rfb/CConnection.java
index 5acae52..2a7ecfc 100644
--- a/java/src/com/tigervnc/rfb/CConnection.java
+++ b/java/src/com/tigervnc/rfb/CConnection.java
@@ -256,17 +256,6 @@
nSecTypes = 0;
}
- // addSecType() should be called once for each security type which the
- // client supports. The order in which they're added is such that the
- // first one is most preferred.
-/*
- public void addSecType(int secType) {
- if (nSecTypes == maxSecTypes)
- throw new Exception("too many security types");
- secTypes.set(nSecTypes++,secType);
- }
-*/
-
// setShared sets the value of the shared flag which will be sent to the
// server upon initialisation.
public void setShared(boolean s) { shared = s; }
diff --git a/java/src/com/tigervnc/rfb/CMsgHandler.java b/java/src/com/tigervnc/rfb/CMsgHandler.java
index 11d2681..81fd2a1 100644
--- a/java/src/com/tigervnc/rfb/CMsgHandler.java
+++ b/java/src/com/tigervnc/rfb/CMsgHandler.java
@@ -61,6 +61,9 @@
cp.setName(name);
}
+ public void clientRedirect(int port, String host,
+ String x509subject) {}
+
public void setCursor(int width, int height, Point hotspot,
int[] data, byte[] mask) {}
public void serverInit() {}
diff --git a/java/src/com/tigervnc/rfb/CMsgReaderV3.java b/java/src/com/tigervnc/rfb/CMsgReaderV3.java
index 308d60d..6d9e254 100644
--- a/java/src/com/tigervnc/rfb/CMsgReaderV3.java
+++ b/java/src/com/tigervnc/rfb/CMsgReaderV3.java
@@ -80,6 +80,9 @@
case Encodings.pseudoEncodingLastRect:
nUpdateRectsLeft = 1; // this rectangle is the last one
break;
+ case Encodings.pseudoEncodingClientRedirect:
+ readClientRedirect(x, y, w, h);
+ break;
default:
readRect(new Rect(x, y, x+w, y+h), encoding);
break;
@@ -133,6 +136,19 @@
handler.setExtendedDesktopSize(x, y, w, h, layout);
}
+ void readClientRedirect(int x, int y, int w, int h)
+ {
+ int port = is.readU16();
+ String host = is.readString();
+ String x509subject = is.readString();
+
+ if (x != 0 || y != 0 || w != 0 || h != 0) {
+ vlog.error("Ignoring ClientRedirect rect with non-zero position/size");
+ } else {
+ handler.clientRedirect(port, host, x509subject);
+ }
+ }
+
int nUpdateRectsLeft;
static LogWriter vlog = new LogWriter("CMsgReaderV3");
diff --git a/java/src/com/tigervnc/rfb/CMsgWriter.java b/java/src/com/tigervnc/rfb/CMsgWriter.java
index 7abbc09..7cafddd 100644
--- a/java/src/com/tigervnc/rfb/CMsgWriter.java
+++ b/java/src/com/tigervnc/rfb/CMsgWriter.java
@@ -57,6 +57,8 @@
encodings[nEncodings++] = Encodings.pseudoEncodingExtendedDesktopSize;
if (cp.supportsDesktopRename)
encodings[nEncodings++] = Encodings.pseudoEncodingDesktopName;
+ if (cp.supportsClientRedirect)
+ encodings[nEncodings++] = Encodings.pseudoEncodingClientRedirect;
if (Decoder.supported(preferredEncoding)) {
encodings[nEncodings++] = preferredEncoding;
}
diff --git a/java/src/com/tigervnc/rfb/CSecurityIdent.java b/java/src/com/tigervnc/rfb/CSecurityIdent.java
new file mode 100644
index 0000000..6523e41
--- /dev/null
+++ b/java/src/com/tigervnc/rfb/CSecurityIdent.java
@@ -0,0 +1,58 @@
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
+ * 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.
+ */
+
+package com.tigervnc.rfb;
+
+import java.io.IOException;
+
+import com.tigervnc.rdr.*;
+import com.tigervnc.vncviewer.*;
+
+public class CSecurityIdent extends CSecurity {
+
+ public CSecurityIdent() { }
+
+ public boolean processMsg(CConnection cc) {
+ InStream is = cc.getInStream();
+ OutStream os = cc.getOutStream();
+
+ StringBuffer username = new StringBuffer();
+
+ CConn.upg.getUserPasswd(username, null);
+
+ // Return the response to the server
+ os.writeU32(username.length());
+ try {
+ byte[] utf8str = username.toString().getBytes("UTF8");
+ os.writeBytes(utf8str, 0, username.length());
+ } catch(java.io.UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ os.flush();
+ return true;
+ }
+
+ public int getType() { return Security.secTypeIdent; }
+
+ java.net.Socket sock;
+ UserPasswdGetter upg;
+
+ static LogWriter vlog = new LogWriter("Ident");
+ public String description() { return "No Encryption"; }
+
+}
diff --git a/java/src/com/tigervnc/rfb/ConnParams.java b/java/src/com/tigervnc/rfb/ConnParams.java
index 16c6ff4..c5e50d5 100644
--- a/java/src/com/tigervnc/rfb/ConnParams.java
+++ b/java/src/com/tigervnc/rfb/ConnParams.java
@@ -29,7 +29,7 @@
supportsLocalCursor = false; supportsLocalXCursor = false;
supportsDesktopResize = false; supportsExtendedDesktopSize = false;
supportsDesktopRename = false; supportsLastRect = false;
- supportsSetDesktopSize = false;
+ supportsSetDesktopSize = false; supportsClientRedirect = false;
customCompressLevel = false; compressLevel = 6;
noJpeg = false; qualityLevel = -1;
name_ = null; nEncodings_ = 0; encodings_ = null;
@@ -134,6 +134,8 @@
supportsLocalCursor = true;
else if (encodings[i] == Encodings.pseudoEncodingDesktopSize)
supportsDesktopResize = true;
+ else if (encodings[i] == Encodings.pseudoEncodingClientRedirect)
+ supportsClientRedirect = true;
else if (encodings[i] >= Encodings.pseudoEncodingCompressLevel0 &&
encodings[i] <= Encodings.pseudoEncodingCompressLevel9) {
customCompressLevel = true;
@@ -154,6 +156,7 @@
public boolean supportsDesktopResize;
public boolean supportsExtendedDesktopSize;
public boolean supportsDesktopRename;
+ public boolean supportsClientRedirect;
public boolean supportsLastRect;
public boolean supportsSetDesktopSize;
diff --git a/java/src/com/tigervnc/rfb/Encodings.java b/java/src/com/tigervnc/rfb/Encodings.java
index 215178d..493d548 100644
--- a/java/src/com/tigervnc/rfb/Encodings.java
+++ b/java/src/com/tigervnc/rfb/Encodings.java
@@ -35,6 +35,7 @@
public static final int pseudoEncodingDesktopSize = -223;
public static final int pseudoEncodingExtendedDesktopSize = -308;
public static final int pseudoEncodingDesktopName = -307;
+ public static final int pseudoEncodingClientRedirect = -311;
// TightVNC-specific
public static final int pseudoEncodingLastRect = -224;
diff --git a/java/src/com/tigervnc/rfb/Security.java b/java/src/com/tigervnc/rfb/Security.java
index 95a66c3..379851d 100644
--- a/java/src/com/tigervnc/rfb/Security.java
+++ b/java/src/com/tigervnc/rfb/Security.java
@@ -39,7 +39,6 @@
public static final int secTypeUltra = 17;
public static final int secTypeTLS = 18;
public static final int secTypeVeNCrypt = 19;
- public static final int secTypeManaged = 20;
/* VeNCrypt subtypes */
public static final int secTypePlain = 256;
@@ -49,6 +48,9 @@
public static final int secTypeX509None = 260;
public static final int secTypeX509Vnc = 261;
public static final int secTypeX509Plain = 262;
+ public static final int secTypeIdent = 265;
+ public static final int secTypeTLSIdent = 266;
+ public static final int secTypeX509Ident = 267;
// result types
@@ -131,16 +133,18 @@
//if (name.equalsIgnoreCase("ultra")) return secTypeUltra;
//if (name.equalsIgnoreCase("TLS")) return secTypeTLS;
if (name.equalsIgnoreCase("VeNCrypt")) return secTypeVeNCrypt;
- if (name.equalsIgnoreCase("Managed")) return secTypeManaged;
/* VeNCrypt subtypes */
if (name.equalsIgnoreCase("Plain")) return secTypePlain;
+ if (name.equalsIgnoreCase("Ident")) return secTypeIdent;
if (name.equalsIgnoreCase("TLSNone")) return secTypeTLSNone;
if (name.equalsIgnoreCase("TLSVnc")) return secTypeTLSVnc;
if (name.equalsIgnoreCase("TLSPlain")) return secTypeTLSPlain;
+ if (name.equalsIgnoreCase("TLSIdent")) return secTypeTLSIdent;
if (name.equalsIgnoreCase("X509None")) return secTypeX509None;
if (name.equalsIgnoreCase("X509Vnc")) return secTypeX509Vnc;
if (name.equalsIgnoreCase("X509Plain")) return secTypeX509Plain;
+ if (name.equalsIgnoreCase("X509Ident")) return secTypeX509Ident;
return secTypeInvalid;
}
@@ -157,16 +161,18 @@
//case secTypeUltra: return "Ultra";
//case secTypeTLS: return "TLS";
case secTypeVeNCrypt: return "VeNCrypt";
- case secTypeManaged: return "Managed";
/* VeNCrypt subtypes */
case secTypePlain: return "Plain";
+ case secTypeIdent: return "Ident";
case secTypeTLSNone: return "TLSNone";
case secTypeTLSVnc: return "TLSVnc";
case secTypeTLSPlain: return "TLSPlain";
+ case secTypeTLSIdent: return "TLSIdent";
case secTypeX509None: return "X509None";
case secTypeX509Vnc: return "X509Vnc";
case secTypeX509Plain: return "X509Plain";
+ case secTypeX509Ident: return "X509Ident";
default: return "[unknown secType]";
}
}
diff --git a/java/src/com/tigervnc/rfb/SecurityClient.java b/java/src/com/tigervnc/rfb/SecurityClient.java
index 90c35d8..a8abd9e 100644
--- a/java/src/com/tigervnc/rfb/SecurityClient.java
+++ b/java/src/com/tigervnc/rfb/SecurityClient.java
@@ -19,24 +19,26 @@
package com.tigervnc.rfb;
+import com.tigervnc.vncviewer.CConn;
+
public class SecurityClient extends Security {
public SecurityClient() { super(secTypes); }
public CSecurity GetCSecurity(int secType)
{
- //assert (CSecurity::upg != NULL); /* (upg == NULL) means bug in the viewer */
- //assert (CSecurityTLS::msg != NULL);
+ assert (CConn.upg != null); /* (upg == null) means bug in the viewer */
+ assert (msg != null);
if (!IsSupported(secType))
throw new Exception("Security type not supported");
switch (secType) {
- case Security.secTypeManaged: return (new CSecurityManaged());
case Security.secTypeNone: return (new CSecurityNone());
case Security.secTypeVncAuth: return (new CSecurityVncAuth());
case Security.secTypeVeNCrypt: return (new CSecurityVeNCrypt(this));
case Security.secTypePlain: return (new CSecurityPlain());
+ case Security.secTypeIdent: return (new CSecurityIdent());
case Security.secTypeTLSNone:
return (new CSecurityStack(secTypeTLSNone, "TLS with no password",
new CSecurityTLS(true), null));
@@ -46,15 +48,21 @@
case Security.secTypeTLSPlain:
return (new CSecurityStack(secTypeTLSPlain, "TLS with Username/Password",
new CSecurityTLS(true), new CSecurityPlain()));
+ case Security.secTypeTLSIdent:
+ return (new CSecurityStack(secTypeTLSIdent, "TLS with username only",
+ new CSecurityTLS(true), new CSecurityIdent()));
case Security.secTypeX509None:
return (new CSecurityStack(secTypeX509None, "X509 with no password",
new CSecurityTLS(false), null));
case Security.secTypeX509Vnc:
- return (new CSecurityStack(secTypeX509None, "X509 with VNCAuth",
+ return (new CSecurityStack(secTypeX509Vnc, "X509 with VNCAuth",
new CSecurityTLS(false), new CSecurityVncAuth()));
case Security.secTypeX509Plain:
return (new CSecurityStack(secTypeX509Plain, "X509 with Username/Password",
new CSecurityTLS(false), new CSecurityPlain()));
+ case Security.secTypeX509Ident:
+ return (new CSecurityStack(secTypeX509Ident, "X509 with username only",
+ new CSecurityTLS(false), new CSecurityIdent()));
default:
throw new Exception("Security type not supported");
}
@@ -72,6 +80,6 @@
static StringParameter secTypes
= new StringParameter("SecurityTypes",
"Specify which security scheme to use (None, VncAuth)",
- "Managed,X509Plain,TLSPlain,X509Vnc,TLSVnc,X509None,TLSNone,VncAuth,None");
+ "Ident,TLSIdent,X509Ident,X509Plain,TLSPlain,X509Vnc,TLSVnc,X509None,TLSNone,VncAuth,None");
}