More fixes for bug #3418256. Copied jarsigning routine from TurboVNC in order to produce a signed applet so the system clipboard can be accessed from when used in applet mode. These changes will need some testing to make sure that there aren't any corner-cases where something breaks.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4695 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tigervnc/vncviewer/UserPrefs.java b/java/src/com/tigervnc/vncviewer/UserPrefs.java
index 51b8b90..b370221 100644
--- a/java/src/com/tigervnc/vncviewer/UserPrefs.java
+++ b/java/src/com/tigervnc/vncviewer/UserPrefs.java
@@ -58,13 +58,19 @@
public UserPrefs(String appName_) {
appName = appName_;
- systemprops=System.getProperties();
+ try {
+ systemprops=System.getProperties();
+ } catch(java.security.AccessControlException e) {
+ System.out.println("Cannot access system properties");
+ }
// This is guaranteed as always being some valid directory,
// according to spec.
prefFile= getHomeDir()+getFileSeperator()+
"."+appName;
try {
load(new java.io.FileInputStream(prefFile));
+ } catch(java.security.AccessControlException e) {
+ System.out.println("Cannot access system properties");
} catch (Exception err) {
if(err instanceof java.io.FileNotFoundException) {
try {
@@ -109,33 +115,55 @@
*/
final public static String getHomeDir() {
String homeDir = null;
- String os = System.getProperty("os.name");
- try {
- if (os.startsWith("Windows")) {
- // JRE prior to 1.5 cannot reliably determine USERPROFILE
- // return user.home and hope it's right...
- if (Integer.parseInt(System.getProperty("java.version").split("\\.")[1]) < 5) {
- homeDir = System.getProperty("user.home");
+ try {
+ String os = System.getProperty("os.name");
+ try {
+ if (os.startsWith("Windows")) {
+ // JRE prior to 1.5 cannot reliably determine USERPROFILE
+ // return user.home and hope it's right...
+ if (Integer.parseInt(System.getProperty("java.version").split("\\.")[1]) < 5) {
+ try {
+ homeDir = System.getProperty("user.home");
+ } catch(java.security.AccessControlException e) {
+ System.out.println("Cannot access user.home system property");
+ }
+ } else {
+ homeDir = System.getenv("USERPROFILE");
+ }
} else {
- homeDir = System.getenv("USERPROFILE");
+ try {
+ homeDir = FileSystemView.getFileSystemView().
+ getDefaultDirectory().getCanonicalPath();
+ } catch(java.security.AccessControlException e) {
+ System.out.println("Cannot access system property");
+ }
}
- } else {
- homeDir = FileSystemView.getFileSystemView().
- getDefaultDirectory().getCanonicalPath();
+ } catch (Exception e) {
+ e.printStackTrace();
}
- } catch (Exception e) {
- e.printStackTrace();
- }
+ } catch(java.security.AccessControlException e) {
+ System.out.println("Cannot access os.name system property");
+ }
return homeDir;
}
final private String getUserName() {
- String userName = (String) System.getProperties().get("user.name");
+ String userName = null;
+ try {
+ userName = (String) System.getProperties().get("user.name");
+ } catch(java.security.AccessControlException e) {
+ System.out.println("Cannot access user.name system property");
+ }
return userName;
}
final public static String getFileSeperator() {
- String seperator = System.getProperties().get("file.separator").toString();
+ String seperator = null;
+ try {
+ seperator = System.getProperties().get("file.separator").toString();
+ } catch(java.security.AccessControlException e) {
+ System.out.println("Cannot access file.separator system property");
+ }
return seperator;
}