aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorAdam Tkac <atkac@redhat.com>2010-11-11 13:21:55 +0000
committerAdam Tkac <atkac@redhat.com>2010-11-11 13:21:55 +0000
commit053597c700f0471b4bb49219a1e62c6b319c70b8 (patch)
tree28d3011457b8782eaeb451b7d18d2560299cdd0f /java/src
parent9260a443a175731994fb8642365cd3969b605cfe (diff)
downloadtigervnc-053597c700f0471b4bb49219a1e62c6b319c70b8.tar.gz
tigervnc-053597c700f0471b4bb49219a1e62c6b319c70b8.zip
[Development] java: Implement VeNCrypt chooser (Martin Koegler)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4191 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/tigervnc/vncviewer/RfbProto.java33
-rw-r--r--java/src/com/tigervnc/vncviewer/VncViewer.java43
2 files changed, 58 insertions, 18 deletions
diff --git a/java/src/com/tigervnc/vncviewer/RfbProto.java b/java/src/com/tigervnc/vncviewer/RfbProto.java
index dc7aa2e5..ab3c1521 100644
--- a/java/src/com/tigervnc/vncviewer/RfbProto.java
+++ b/java/src/com/tigervnc/vncviewer/RfbProto.java
@@ -391,7 +391,8 @@ class RfbProto {
// Find first supported security type.
for (int i = 0; i < nSecTypes; i++) {
- if (secTypes[i] == SecTypeNone || secTypes[i] == SecTypeVncAuth) {
+ if (secTypes[i] == SecTypeNone || secTypes[i] == SecTypeVncAuth
+ || secTypes[i] == SecTypeVeNCrypt) {
secType = secTypes[i];
break;
}
@@ -406,6 +407,36 @@ class RfbProto {
return secType;
}
+ int authenticateVeNCrypt() throws Exception {
+ int majorVersion = readU8();
+ int minorVersion = readU8();
+ int Version = (majorVersion << 8) | minorVersion;
+ if (Version < 0x0002) {
+ os.write(0);
+ os.write(0);
+ throw new Exception("Server reported an unsupported VeNCrypt version");
+ }
+ os.write(0);
+ os.write(2);
+ if (readU8() != 0)
+ throw new Exception("Server reported it could not support the VeNCrypt version");
+ int nSecTypes = readU8();
+ int[] secTypes = new int[nSecTypes];
+ for(int i = 0; i < nSecTypes; i++)
+ secTypes[i] = readU32();
+
+ for(int i = 0; i < nSecTypes; i++)
+ switch(secTypes[i])
+ {
+ case SecTypeNone:
+ case SecTypeVncAuth:
+ writeInt(secTypes[i]);
+ return secTypes[i];
+ }
+
+ throw new Exception("No valid VeNCrypt sub-type");
+ }
+
//
// Perform "no authentication".
//
diff --git a/java/src/com/tigervnc/vncviewer/VncViewer.java b/java/src/com/tigervnc/vncviewer/VncViewer.java
index 3c527ba7..711b1c95 100644
--- a/java/src/com/tigervnc/vncviewer/VncViewer.java
+++ b/java/src/com/tigervnc/vncviewer/VncViewer.java
@@ -361,25 +361,34 @@ public class VncViewer extends java.applet.Applet
authType = secType;
}
- switch (authType) {
- case RfbProto.AuthNone:
- showConnectionStatus("No authentication needed");
- rfb.authenticateNone();
- break;
- case RfbProto.AuthVNC:
- showConnectionStatus("Performing standard VNC authentication");
- if (passwordParam != null) {
- rfb.authenticateVNC(passwordParam);
- } else {
- String pw = askPassword();
- rfb.authenticateVNC(pw);
- }
- break;
- default:
- throw new Exception("Unknown authentication scheme " + authType);
- }
+ doAuthentification(authType);
}
+ void doAuthentification(int secType) throws Exception {
+ switch (secType) {
+ case RfbProto.SecTypeNone:
+ showConnectionStatus("No authentication needed");
+ rfb.authenticateNone();
+ break;
+ case RfbProto.SecTypeVncAuth:
+ showConnectionStatus("Performing standard VNC authentication");
+ if (passwordParam != null) {
+ rfb.authenticateVNC(passwordParam);
+ } else {
+ String pw = askPassword();
+ rfb.authenticateVNC(pw);
+ }
+ break;
+ case RfbProto.SecTypeVeNCrypt:
+ showConnectionStatus("VeNCrypt chooser");
+ secType = rfb.authenticateVeNCrypt();
+ doAuthentification(secType);
+ break;
+ default:
+ throw new Exception("Unknown authentication scheme " + secType);
+ }
+ }
+
//
// Show a message describing the connection status.