]> source.dussan.org Git - tigervnc.git/commitdiff
Display security state when asking for password (java)
authorBrian P. Hinz <bphinz@users.sf.net>
Fri, 1 Dec 2017 02:23:46 +0000 (21:23 -0500)
committerBrian P. Hinz <bphinz@users.sf.net>
Fri, 1 Dec 2017 02:24:55 +0000 (21:24 -0500)
13 files changed:
java/CMakeLists.txt
java/com/tigervnc/rfb/CConnection.java
java/com/tigervnc/rfb/CSecurity.java
java/com/tigervnc/rfb/CSecurityIdent.java
java/com/tigervnc/rfb/CSecurityPlain.java
java/com/tigervnc/rfb/CSecurityStack.java
java/com/tigervnc/rfb/CSecurityTLS.java
java/com/tigervnc/rfb/CSecurityVeNCrypt.java
java/com/tigervnc/rfb/CSecurityVncAuth.java
java/com/tigervnc/rfb/UserPasswdGetter.java
java/com/tigervnc/vncviewer/UserDialog.java
java/com/tigervnc/vncviewer/insecure.png [new file with mode: 0644]
java/com/tigervnc/vncviewer/secure.png [new file with mode: 0644]

index 7d6c70a896b67d54831399d56803ebcbdbd0fd98..82de6c09e5bfffd54ccf34e41a81ffce3b60baaa 100644 (file)
@@ -126,15 +126,18 @@ configure_file(${CLASSPATH}/timestamp.in ${CLASSPATH}/timestamp)
 
 if(NOT "${SRCDIR}" STREQUAL "${BINDIR}")
 
-add_custom_command(OUTPUT ${BINDIR}/${CLASSPATH}/tigervnc.png
-  COMMAND ${CMAKE_COMMAND} -E copy_if_different
-    ${SRCDIR}/${CLASSPATH}/tigervnc.png ${BINDIR}/${CLASSPATH}/tigervnc.png
-  DEPENDS ${SRCDIR}/${CLASSPATH}/tigervnc.png)
-
-add_custom_command(OUTPUT ${BINDIR}/${CLASSPATH}/tigervnc.ico
-  COMMAND ${CMAKE_COMMAND} -E copy_if_different
-    ${SRCDIR}/${CLASSPATH}/tigervnc.ico ${BINDIR}/${CLASSPATH}/tigervnc.ico
-  DEPENDS ${SRCDIR}/${CLASSPATH}/tigervnc.ico)
+set(ICONS
+tigervnc.ico
+tigervnc.png
+insecure.png
+secure.png)
+
+foreach(icon ${ICONS})
+  add_custom_command(OUTPUT ${BINDIR}/${CLASSPATH}/${icon}
+    COMMAND ${CMAKE_COMMAND} -E copy_if_different
+      ${SRCDIR}/${CLASSPATH}/${icon} ${BINDIR}/${CLASSPATH}/${icon}
+    DEPENDS ${SRCDIR}/${CLASSPATH}/${icon})
+endforeach()
 
 endif()
 
@@ -145,8 +148,10 @@ add_custom_command(OUTPUT VncViewer.jar
   DEPENDS ${JAVA_CLASSES}
     ${SRCDIR}/${CLASSPATH}/MANIFEST.MF
     ${BINDIR}/${CLASSPATH}/timestamp
-    ${BINDIR}/${CLASSPATH}/tigervnc.png
     ${BINDIR}/${CLASSPATH}/tigervnc.ico
+    ${BINDIR}/${CLASSPATH}/tigervnc.png
+    ${BINDIR}/${CLASSPATH}/insecure.png
+    ${BINDIR}/${CLASSPATH}/secure.png
   COMMAND ${JAVA_ARCHIVE}
   ARGS cfm VncViewer.jar
     ${SRCDIR}/${CLASSPATH}/MANIFEST.MF
@@ -159,7 +164,7 @@ add_custom_command(OUTPUT VncViewer.jar
     com/jcraft/jsch/jcraft/*.class
     com/jcraft/jsch/jce/*.class
     com/jcraft/jsch/*.class
-    com/tigervnc/vncviewer/tigervnc.png
+    com/tigervnc/vncviewer/*.png
     com/tigervnc/vncviewer/tigervnc.ico
   COMMAND ${CMAKE_COMMAND}
   ARGS -DJava_PATH=${Java_PATH} -DJAR_FILE=${BINDIR}/VncViewer.jar
index aefc27608bbe5a687efd673d6d5094d9d475f870..c9b6b89a552c87b1efb1f6b723a84e283b6d0dfb 100644 (file)
@@ -389,6 +389,8 @@ abstract public class CConnection extends CMsgHandler {
   // Identities, to determine the unique(ish) name of the server.
   public String getServerName() { return serverName; }
 
+  public boolean isSecure() { return csecurity != null ? csecurity.isSecure() : false; }
+
   public static final int RFBSTATE_UNINITIALISED = 0;
   public static final int RFBSTATE_PROTOCOL_VERSION = 1;
   public static final int RFBSTATE_SECURITY_TYPES = 2;
index a99a5f87794cc4220ad3e66590a752dd440c1d2a..f192d30172c9e79edc9496b20d160e54c5af950d 100644 (file)
@@ -37,6 +37,7 @@ abstract public class CSecurity {
   abstract public boolean processMsg(CConnection cc);
   abstract public int getType();
   abstract public String description();
+  public boolean isSecure() { return false; }
 
   /*
    * Use variable directly instead of dumb get/set methods.
index e53432bf7652f3f7754455552c3fa5eaced69ec7..872b84a052a8923ed443f37e882438469f04bb49 100644 (file)
@@ -30,7 +30,7 @@ public class CSecurityIdent extends CSecurity {
 
     StringBuffer username = new StringBuffer();
 
-    upg.getUserPasswd(username, null);
+    upg.getUserPasswd(cc.isSecure(), username, null);
 
     // Return the response to the server
     os.writeU32(username.length());
index 98f6b8cc5177b5d9fc1420dc7d6a7e9be332f2f5..ef7a10eeeb9fdda5f6bb3d951adc685d743d5027 100644 (file)
@@ -34,7 +34,7 @@ public class CSecurityPlain extends CSecurity {
     StringBuffer username = new StringBuffer();
     StringBuffer password = new StringBuffer();
 
-    upg.getUserPasswd(username, password);
+    upg.getUserPasswd(cc.isSecure(), username, password);
 
     // Return the response to the server
     os.writeU32(username.length());
index e4f5988eeaa5ee2d4f64c891568ac4fbad221a07..31e21f726bb830cd34f544b18c4bda3f98b3232f 100644 (file)
@@ -59,6 +59,15 @@ public class CSecurityStack extends CSecurity {
     return res;
   }
 
+  public boolean isSecure()
+  {
+    if (state0 != null && state0.isSecure())
+      return true;
+    if (state == 1 && state1 != null && state1.isSecure())
+      return true;
+    return false;
+  }
+
   public final int getType() { return type; }
   public final String description() { return name; }
 
index c91f36a1e66e01ba00959db502dc1d4c88de61db..e07ab9bbc29aff744226dcc2f10231bceb3ce814 100644 (file)
@@ -462,6 +462,7 @@ public class CSecurityTLS extends CSecurity {
   public final int getType() { return anon ? Security.secTypeTLSNone : Security.secTypeX509None; }
   public final String description()
     { return anon ? "TLS Encryption without VncAuth" : "X509 Encryption without VncAuth"; }
+  public boolean isSecure() { return !anon; }
 
   protected CConnection client;
 
index daf205cda6a2445ebca8f704777a4982e46efc56..8bffedfd2c0d982f92e93a9b7c03d7be8851d45a 100644 (file)
@@ -185,6 +185,12 @@ public class CSecurityVeNCrypt extends CSecurity {
     return "VeNCrypt";
   }
 
+  public final boolean isSecure()
+  {
+    if (csecurity != null && csecurity.isSecure())
+      return true;
+    return false;
+  }
 
   public static StringParameter secTypesStr;
 
index e8c5686d1cf94ad823505b7709c5167218c18a7b..06154953726406ed5dbe9faa707d9468da807522 100644 (file)
@@ -36,7 +36,7 @@ public class CSecurityVncAuth extends CSecurity {
     byte[] challenge = new byte[vncAuthChallengeSize];
     is.readBytes(challenge, 0, vncAuthChallengeSize);
     StringBuffer passwd = new StringBuffer();
-    upg.getUserPasswd(null, passwd);
+    upg.getUserPasswd(cc.isSecure(), null, passwd);
 
     // Calculate the correct response
     byte[] key = new byte[8];
index 7390b11a20a6c8207bc552092e8446cbd8a6a5b0..457eaf28cb3a65fada9ca818c306d3a71aa7f484 100644 (file)
@@ -23,5 +23,5 @@
 package com.tigervnc.rfb;
 
 public interface UserPasswdGetter {
-  public void getUserPasswd(StringBuffer user, StringBuffer password);
+  public void getUserPasswd(boolean secure, StringBuffer user, StringBuffer password);
 }
index fad836a577f39488fc1f0f91ea8978ad296de4f6..dfced983a9623376fbd318ae6489fd727653188e 100644 (file)
@@ -68,7 +68,7 @@ public class UserDialog implements UserPasswdGetter, UserMsgBox
     }
   }
 
-  public final void getUserPasswd(StringBuffer user, StringBuffer password)
+  public final void getUserPasswd(boolean secure, StringBuffer user, StringBuffer password)
   {
     String passwordFileStr = passwordFile.getValue();
 
@@ -98,6 +98,7 @@ public class UserDialog implements UserPasswdGetter, UserMsgBox
     }
 
     JDialog win;
+    JLabel banner;
     JTextField username = null;
     JPasswordField passwd = null;
     JLayer icon;
@@ -107,7 +108,27 @@ public class UserDialog implements UserPasswdGetter, UserMsgBox
     JPanel msg = new JPanel(null);
     msg.setSize(410, 145);
 
-    y = 10;
+    banner = new JLabel();
+    banner.setBounds(0, 0, msg.getPreferredSize().width, 20);
+    banner.setHorizontalAlignment(JLabel.CENTER);
+    banner.setOpaque(true);
+
+    if (secure) {
+      banner.setText("This connection is secure");
+      banner.setBackground(Color.GREEN);
+      ImageIcon secure_icon =
+        new ImageIcon(VncViewer.class.getResource("secure.png"));
+      banner.setIcon(secure_icon);
+    } else {
+      banner.setText("This connection is not secure");
+      banner.setBackground(Color.RED);
+      ImageIcon insecure_icon =
+        new ImageIcon(VncViewer.class.getResource("insecure.png"));
+      banner.setIcon(insecure_icon);
+    }
+    msg.add(banner);
+
+    y = 20 + 10;
 
     JButton iconb = new JButton("?");
     iconb.setVerticalAlignment(JLabel.CENTER);
diff --git a/java/com/tigervnc/vncviewer/insecure.png b/java/com/tigervnc/vncviewer/insecure.png
new file mode 100644 (file)
index 0000000..f48faff
Binary files /dev/null and b/java/com/tigervnc/vncviewer/insecure.png differ
diff --git a/java/com/tigervnc/vncviewer/secure.png b/java/com/tigervnc/vncviewer/secure.png
new file mode 100644 (file)
index 0000000..9383371
Binary files /dev/null and b/java/com/tigervnc/vncviewer/secure.png differ