summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Hinz <bphinz@users.sourceforge.net>2011-11-25 01:12:58 +0000
committerBrian Hinz <bphinz@users.sourceforge.net>2011-11-25 01:12:58 +0000
commita0d836befc62b0c5ada6fa93886114ee7d633a5f (patch)
tree2d1ec71dc0c8beb428fa4b3b939606c14e2e4ca0
parentf8b3fc70f4e00e70075c59baf97cdcc65bb0e67d (diff)
downloadtigervnc-a0d836befc62b0c5ada6fa93886114ee7d633a5f.tar.gz
tigervnc-a0d836befc62b0c5ada6fa93886114ee7d633a5f.zip
add PasswordFile parameter as requested in tracker #3441859
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4817 3789f03b-4d11-0410-bbf8-ca57d06f2519
-rw-r--r--java/com/tigervnc/rfb/VncAuth.java2
-rw-r--r--java/com/tigervnc/vncviewer/CConn.java25
-rw-r--r--java/com/tigervnc/vncviewer/VncViewer.java5
3 files changed, 31 insertions, 1 deletions
diff --git a/java/com/tigervnc/rfb/VncAuth.java b/java/com/tigervnc/rfb/VncAuth.java
index cce8d81c..dd84f6af 100644
--- a/java/com/tigervnc/rfb/VncAuth.java
+++ b/java/com/tigervnc/rfb/VncAuth.java
@@ -49,7 +49,7 @@ public class VncAuth {
des.encrypt(obfuscated,0,obfuscated,0);
}
- String unobfuscatePasswd(byte[] obfuscated) {
+ public static String unobfuscatePasswd(byte[] obfuscated) {
DesCipher des = new DesCipher(obfuscationKey);
des.decrypt(obfuscated,0,obfuscated,0);
int len;
diff --git a/java/com/tigervnc/vncviewer/CConn.java b/java/com/tigervnc/vncviewer/CConn.java
index f49e3342..136ad7c5 100644
--- a/java/com/tigervnc/vncviewer/CConn.java
+++ b/java/com/tigervnc/vncviewer/CConn.java
@@ -39,6 +39,8 @@ import java.awt.Event;
import java.io.IOException;
import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import javax.swing.*;
@@ -242,7 +244,30 @@ public class CConn extends CConnection
public final boolean getUserPasswd(StringBuffer user, StringBuffer passwd) {
String title = ("VNC Authentication ["
+csecurity.description() + "]");
+ String passwordFileStr = viewer.passwordFile.getValue();
PasswdDialog dlg;
+
+ if (user == null && passwordFileStr != "") {
+ InputStream fp = null;
+ try {
+ fp = new FileInputStream(passwordFileStr);
+ } catch(FileNotFoundException e) {
+ throw new Exception("Opening password file failed");
+ }
+ byte[] obfPwd = new byte[256];
+ try {
+ fp.read(obfPwd);
+ fp.close();
+ } catch(IOException e) {
+ throw new Exception("Failed to read VncPasswd file");
+ }
+ String PlainPasswd =
+ VncAuth.unobfuscatePasswd(obfPwd);
+ passwd.append(PlainPasswd);
+ passwd.setLength(PlainPasswd.length());
+ return true;
+ }
+
if (user == null) {
dlg = new PasswdDialog(title, (user == null), (passwd == null));
} else {
diff --git a/java/com/tigervnc/vncviewer/VncViewer.java b/java/com/tigervnc/vncviewer/VncViewer.java
index 604069c4..97b9427c 100644
--- a/java/com/tigervnc/vncviewer/VncViewer.java
+++ b/java/com/tigervnc/vncviewer/VncViewer.java
@@ -253,6 +253,11 @@ public class VncViewer extends java.applet.Applet implements Runnable
= new BoolParameter("SendLocalUsername",
"Send the local username for SecurityTypes "+
"such as Plain rather than prompting", true);
+ StringParameter passwordFile
+ = new StringParameter("PasswordFile",
+ "Password file for VNC authentication", "");
+ AliasParameter passwd
+ = new AliasParameter("passwd", "Alias for PasswordFile", passwordFile);
BoolParameter autoSelect
= new BoolParameter("AutoSelect",
"Auto select pixel format and encoding", true);