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; }
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() {}
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;
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");
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;
}
--- /dev/null
+/* 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"; }
+
+}
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;
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;
public boolean supportsDesktopResize;
public boolean supportsExtendedDesktopSize;
public boolean supportsDesktopRename;
+ public boolean supportsClientRedirect;
public boolean supportsLastRect;
public boolean supportsSetDesktopSize;
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;
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;
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
//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;
}
//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]";
}
}
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));
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");
}
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");
}
resizeFramebuffer();
}\r
\r
+ // clientRedirect() migrates the client to another host/port
+ public void clientRedirect(int port, String host,
+ String x509subject) {
+ try {
+ getSocket().close();
+ setServerPort(port);
+ sock = new java.net.Socket(host, port);
+ sock.setTcpNoDelay(true);
+ sock.setTrafficClass(0x10);
+ setSocket(sock);
+ vlog.info("Redirected to "+host+":"+port);
+ setStreams(new JavaInStream(sock.getInputStream()),
+ new JavaOutStream(sock.getOutputStream()));
+ initialiseProtocol();
+ } catch (java.io.IOException e) {
+ e.printStackTrace();
+ }
+ }
+
// setName() is called when the desktop name changes\r
public void setName(String name) {\r
super.setName(name);\r
\r
private void resizeFramebuffer()\r
{\r
+ if ((cp.width == 0) && (cp.height == 0))\r
+ return;\r
if (desktop == null)\r
return;\r
if ((desktop.width() == cp.width) && (desktop.height() == cp.height))\r
options.encX509.setEnabled(false);\r
options.ca.setEnabled(false);\r
options.crl.setEnabled(false);\r
- options.secManaged.setEnabled(false);\r
+ options.secIdent.setEnabled(false);\r
options.secNone.setEnabled(false);\r
options.secVnc.setEnabled(false);\r
options.secPlain.setEnabled(false);\r
case Security.secTypeVeNCrypt:\r
options.secVeNCrypt.setSelected(true);\r
break;\r
- case Security.secTypeManaged:\r
- options.encNone.setSelected(true);\r
- options.secManaged.setSelected(true);\r
- options.sendLocalUsername.setSelected(true);\r
- break;\r
case Security.secTypeNone:\r
options.encNone.setSelected(true);\r
options.secNone.setSelected(true);\r
options.secPlain.setSelected(true);\r
options.sendLocalUsername.setSelected(true);\r
break;\r
+ case Security.secTypeIdent:\r
+ options.secIdent.setSelected(true);\r
+ options.sendLocalUsername.setSelected(true);\r
+ break;\r
case Security.secTypeTLSNone:\r
options.encTLS.setSelected(true);\r
options.secNone.setSelected(true);\r
options.secPlain.setSelected(true);\r
options.sendLocalUsername.setSelected(true);\r
break;\r
+ case Security.secTypeTLSIdent:\r
+ options.encTLS.setSelected(true);\r
+ options.secIdent.setSelected(true);\r
+ options.sendLocalUsername.setSelected(true);\r
+ break;\r
case Security.secTypeX509None:\r
options.encX509.setSelected(true);\r
options.secNone.setSelected(true);\r
options.secPlain.setSelected(true);\r
options.sendLocalUsername.setSelected(true);\r
break;\r
+ case Security.secTypeX509Ident:\r
+ options.encX509.setSelected(true);\r
+ options.secIdent.setSelected(true);\r
+ options.sendLocalUsername.setSelected(true);\r
+ break;\r
}\r
}\r
}\r
options.sendLocalUsername.setEnabled(options.secPlain.isSelected()||\r
- options.secManaged.isSelected());\r
+ options.secIdent.isSelected());\r
}\r
\r
options.fullScreen.setSelected(fullScreen);\r
if (state() != RFBSTATE_NORMAL) {\r
/* Process security types which don't use encryption */\r
if (options.encNone.isSelected()) {\r
- if (options.secManaged.isSelected())\r
- Security.EnableSecType(Security.secTypeManaged);\r
if (options.secNone.isSelected())\r
Security.EnableSecType(Security.secTypeNone);\r
if (options.secVnc.isSelected())\r
Security.EnableSecType(Security.secTypeVncAuth);\r
if (options.secPlain.isSelected())\r
Security.EnableSecType(Security.secTypePlain);\r
+ if (options.secIdent.isSelected())\r
+ Security.EnableSecType(Security.secTypeIdent);\r
} else {\r
- Security.DisableSecType(Security.secTypeManaged);\r
Security.DisableSecType(Security.secTypeNone);\r
Security.DisableSecType(Security.secTypeVncAuth);\r
Security.DisableSecType(Security.secTypePlain);\r
+ Security.DisableSecType(Security.secTypeIdent);\r
}\r
\r
/* Process security types which use TLS encryption */\r
Security.EnableSecType(Security.secTypeTLSVnc);\r
if (options.secPlain.isSelected())\r
Security.EnableSecType(Security.secTypeTLSPlain);\r
+ if (options.secIdent.isSelected())\r
+ Security.EnableSecType(Security.secTypeTLSIdent);\r
} else {\r
Security.DisableSecType(Security.secTypeTLSNone);\r
Security.DisableSecType(Security.secTypeTLSVnc);\r
Security.DisableSecType(Security.secTypeTLSPlain);\r
+ Security.DisableSecType(Security.secTypeTLSIdent);\r
}\r
\r
/* Process security types which use X509 encryption */\r
Security.EnableSecType(Security.secTypeX509Vnc);\r
if (options.secPlain.isSelected())\r
Security.EnableSecType(Security.secTypeX509Plain);\r
+ if (options.secIdent.isSelected())\r
+ Security.EnableSecType(Security.secTypeX509Ident);\r
} else {\r
Security.DisableSecType(Security.secTypeX509None);\r
Security.DisableSecType(Security.secTypeX509Vnc);\r
Security.DisableSecType(Security.secTypeX509Plain);\r
+ Security.DisableSecType(Security.secTypeX509Ident);\r
}\r
\r
/* Process *None security types */\r
Security.DisableSecType(Security.secTypeX509Plain);\r
}\r
\r
+ /* Process *Ident security types */\r
+ if (options.secIdent.isSelected()) {\r
+ if (options.encNone.isSelected())\r
+ Security.EnableSecType(Security.secTypeIdent);\r
+ if (options.encTLS.isSelected())\r
+ Security.EnableSecType(Security.secTypeTLSIdent);\r
+ if (options.encX509.isSelected())\r
+ Security.EnableSecType(Security.secTypeX509Ident);\r
+ } else {\r
+ Security.DisableSecType(Security.secTypeIdent);\r
+ Security.DisableSecType(Security.secTypeTLSIdent);\r
+ Security.DisableSecType(Security.secTypeX509Ident);\r
+ }\r
+ \r
CSecurityTLS.x509ca.setParam(options.ca.getText());\r
CSecurityTLS.x509crl.setParam(options.crl.getText());\r
}\r
JCheckBox viewOnly, acceptClipboard, sendClipboard;\r
JCheckBox fullScreen, shared, useLocalCursor, fastCopyRect;\r
JCheckBox secVeNCrypt, encNone, encTLS, encX509;\r
- JCheckBox secNone, secVnc, secPlain, secManaged, sendLocalUsername;\r
+ JCheckBox secNone, secVnc, secPlain, secIdent, sendLocalUsername;\r
JButton okButton, cancelButton;\r
JButton ca, crl;\r
JButton defSaveButton;\r
secNone = addCheckbox("None", null, authPanel);\r
secVnc = addCheckbox("Standard VNC", null, authPanel);\r
secPlain = addJCheckBox("Plaintext", null, authPanel, new GridBagConstraints(0,2,1,1,1,1,GridBagConstraints.LINE_START,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0));\r
- secManaged = addJCheckBox("Managed", null, authPanel, new GridBagConstraints(0,3,1,1,1,1,GridBagConstraints.LINE_START,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0));\r
+ secIdent = addJCheckBox("Ident", null, authPanel, new GridBagConstraints(0,3,1,1,1,1,GridBagConstraints.LINE_START,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0));\r
sendLocalUsername = new JCheckBox("Send Local Username");\r
sendLocalUsername.addItemListener(this);\r
addGBComponent(sendLocalUsername, authPanel, 1, 2, 1, 2, 0, 0, 2, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,20,0,0));\r
compressLevel.setEnabled(customCompressLevel.isSelected());\r
qualityLevel.setEnabled(noJpeg.isSelected());\r
sendLocalUsername.setEnabled(secVeNCrypt.isEnabled()&&\r
- (secPlain.isSelected()||secManaged.isSelected()));\r
+ (secPlain.isSelected()||secIdent.isSelected()));\r
}\r
\r
JRadioButton addRadioCheckbox(String str, ButtonGroup group, JPanel panel) {\r
encX509.setEnabled(secVeNCrypt.isSelected());\r
ca.setEnabled(secVeNCrypt.isSelected());\r
crl.setEnabled(secVeNCrypt.isSelected());\r
- secManaged.setEnabled(secVeNCrypt.isSelected());\r
+ secIdent.setEnabled(secVeNCrypt.isSelected());\r
secNone.setEnabled(secVeNCrypt.isSelected());\r
secVnc.setEnabled(secVeNCrypt.isSelected());\r
secPlain.setEnabled(secVeNCrypt.isSelected());\r
sendLocalUsername.setEnabled(secVeNCrypt.isSelected());\r
}\r
- if (s instanceof JCheckBox && (JCheckBox)s == secManaged ||\r
+ if (s instanceof JCheckBox && (JCheckBox)s == secIdent ||\r
s instanceof JCheckBox && (JCheckBox)s == secPlain) {\r
- sendLocalUsername.setEnabled(secManaged.isSelected()||secPlain.isSelected());\r
+ sendLocalUsername.setEnabled(secIdent.isSelected()||secPlain.isSelected());\r
}\r
}\r
\r