changeset 1606:afde409ac13e

2009-06-17 Omair Majid <omajid@redhat.com> * rt/net/sourceforge/jnlp/runtime/Boot.java: Remove aboutFile. (getAboutFile): Get path from JNLPRuntime. (getBaseDir): Fix comments. * rt/net/sourceforge/jnlp/runtime/JNLPRuntime.java Add HOME_DIR, NETXRC_FILE, NETX_DIR, SECURITY_DIR, CERTIFICATES_FILE, LOCKS_DIR, JAVA_HOME_DIR, and NETX_ABOUT_FILE. (getDefaultBaseDir): Remove calls to loadWindowIcon and isHeadless() because they are unused. Use HOME_DIR and NETX_DIR. Be prepared for existing NETX_DIR. (getProperties): Use NETXRC_FILE instead of hardcoded file name. * rt/net/sourceforge/jnlp/security/SecurityUtil.java Remove homeDir, certDir and certFile. (getTrustedCertsFilename): Use HOME_DIR and CERTIFICATES_FILE. (checkTrustedCertsFile): Find parent directory from certFile.
author Omair Majid <omajid@redhat.com>
date Wed, 17 Jun 2009 17:10:39 -0400
parents 7b223f11f412
children e86b8e1d9de6
files ChangeLog rt/net/sourceforge/jnlp/runtime/Boot.java rt/net/sourceforge/jnlp/runtime/JNLPRuntime.java rt/net/sourceforge/jnlp/security/SecurityUtil.java
diffstat 4 files changed, 61 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jun 17 15:13:34 2009 -0400
+++ b/ChangeLog	Wed Jun 17 17:10:39 2009 -0400
@@ -1,6 +1,23 @@
 2009-06-17  Omair Majid  <omajid@redhat.com>
 
-	*  * rt/javax/jnlp/ExtendedService.java: New file.
+	* rt/net/sourceforge/jnlp/runtime/Boot.java: Remove aboutFile.
+	(getAboutFile): Get path from JNLPRuntime.
+	(getBaseDir): Fix comments.
+	* rt/net/sourceforge/jnlp/runtime/JNLPRuntime.java Add HOME_DIR, 
+	NETXRC_FILE, NETX_DIR, SECURITY_DIR, CERTIFICATES_FILE, LOCKS_DIR, 
+	JAVA_HOME_DIR, and NETX_ABOUT_FILE.
+	(getDefaultBaseDir): Remove calls to loadWindowIcon and isHeadless()
+	because they are unused. Use HOME_DIR and NETX_DIR. Be prepared for
+	existing NETX_DIR.
+	(getProperties): Use NETXRC_FILE instead of hardcoded file name.
+	* rt/net/sourceforge/jnlp/security/SecurityUtil.java
+	Remove homeDir, certDir and certFile.
+	(getTrustedCertsFilename): Use HOME_DIR and CERTIFICATES_FILE.
+	(checkTrustedCertsFile): Find parent directory from certFile.
+
+2009-06-17  Omair Majid  <omajid@redhat.com>
+
+	* rt/javax/jnlp/ExtendedService.java: New file.
 	* rt/net/sourceforge/jnlp/services/XExtendedService.java: New file.
 	* rt/net/sourceforge/jnlp/services/XServiceManagerStub.java: Add 
 	ExtendedService to serviceNames. Create a proxy for XExtendedService to 
--- a/rt/net/sourceforge/jnlp/runtime/Boot.java	Wed Jun 17 15:13:34 2009 -0400
+++ b/rt/net/sourceforge/jnlp/runtime/Boot.java	Wed Jun 17 17:10:39 2009 -0400
@@ -67,10 +67,6 @@
 
     private static final String version = "0.5";
 
-    /** the JNLP file to open to display the network-based about window */
-    private static final String aboutFile = 
-        System.getProperty("java.home") + "/lib/about.jnlp";
-
     /** the text to display before launching the about link */
     private static final String aboutMessage = ""
         + "netx v"+version+" - (C)2001-2003 Jon A. Maxwell (jmaxwell@users.sourceforge.net)\n"
@@ -234,8 +230,8 @@
      */
     private static String getAboutFile() {
 
-        if (new File(aboutFile).exists())
-            return aboutFile;
+        if (new File(JNLPRuntime.NETX_ABOUT_FILE).exists())
+            return JNLPRuntime.NETX_ABOUT_FILE;
         else
             return null;
     }
@@ -424,9 +420,9 @@
 
     /**
      * Return the base dir.  If the base dir parameter is not set
-     * the value is read from the "${user.home}/.netxrc" file (as
-     * defined by JNLPRuntime).  If that file does not exist, an
-     * install dialog is displayed to select the base directory.
+     * the value is read from JNLPRuntime.NETX_ABOUT_FILE file.
+     * If that file does not exist, an install dialog is displayed 
+     * to select the base directory.
      */
     private static File getBaseDir() {
         if (getOption("-basedir") != null) {
@@ -438,7 +434,7 @@
             return basedir;
         }
 
-        // check .netxrc, display dialog
+        // check .netxrc
         File basedir = JNLPRuntime.getDefaultBaseDir();
         if (basedir == null)
             fatalError(R("BNoBase"));
--- a/rt/net/sourceforge/jnlp/runtime/JNLPRuntime.java	Wed Jun 17 15:13:34 2009 -0400
+++ b/rt/net/sourceforge/jnlp/runtime/JNLPRuntime.java	Wed Jun 17 17:10:39 2009 -0400
@@ -104,6 +104,34 @@
     /** contains the arguments passed to the jnlp runtime */
     private static List<String> initialArguments;
 
+    /** User's home directory */
+    public static final String HOME_DIR = System.getProperty("user.home");
+
+    /** the ~/.netxrc file containing netx settings */
+    public static final String NETXRC_FILE = HOME_DIR + File.separator + ".netxrc";
+
+    /** the ~/.netx directory containing user-specific data */
+    public static final String NETX_DIR = HOME_DIR + File.separator + ".netx";
+
+    /** the ~/.netx/security directory containing security related information */
+    public static final String SECURITY_DIR = NETX_DIR + File.separator + "security";
+
+    /** the ~/.netx/security/trusted.certs file containing trusted certificates */
+    public static final String CERTIFICATES_FILE = SECURITY_DIR + File.separator + "trusted.certs";
+
+    /**
+     * the ~/.netx/locks/ directory containing locks for single instance
+     * applications
+     */
+    public static final String LOCKS_DIR = NETX_DIR + File.separator + "locks";
+
+    public static final String JAVA_HOME_DIR = System.getProperty("java.home");
+    
+    /** the JNLP file to open to display the network-based about window */
+    public static final String NETX_ABOUT_FILE = JAVA_HOME_DIR + File.separator + "lib"
+            + File.separator + "about.jnlp";
+
+    
     
     /**
      * Returns whether the JNLP runtime environment has been
@@ -279,18 +307,13 @@
     public static File getDefaultBaseDir() {
         PropertiesFile props = JNLPRuntime.getProperties();
 
-        loadWindowIcon();
-
         String baseStr = props.getProperty("basedir");
         if (baseStr != null)
             return new File(baseStr);
 
-        if (isHeadless())
-            return null;
-
-        String homeDir = System.getProperty("user.home");
-	File baseDir = new File(homeDir + "/.netx/");
-	if (homeDir == null || !baseDir.mkdir())
+        String homeDir = HOME_DIR;
+        File baseDir = new File(NETX_DIR);
+        if (homeDir == null || (!baseDir.isDirectory() && !baseDir.mkdir()))
             return null;
 
         props.setProperty("basedir", baseDir.toString());
@@ -332,8 +355,7 @@
      * properties file.
      */
     public static PropertiesFile getProperties() {
-        File netxrc = new File(System.getProperty("user.home"), ".netxrc");
-
+        File netxrc = new File(NETXRC_FILE);
         return new PropertiesFile(netxrc);
     }
 
--- a/rt/net/sourceforge/jnlp/security/SecurityUtil.java	Wed Jun 17 15:13:34 2009 -0400
+++ b/rt/net/sourceforge/jnlp/security/SecurityUtil.java	Wed Jun 17 17:10:39 2009 -0400
@@ -42,21 +42,20 @@
 import java.io.FileOutputStream;
 import java.security.KeyStore;
 
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
+
 public class SecurityUtil {
 
-	private static String homeDir = null;
-	private static final String certDir = "/.netx/security/";
-	private static final String certFile = "trusted.certs";
 	private static final char[] password = "changeit".toCharArray();
 	
 	public static String getTrustedCertsFilename() throws Exception{
 		
-		homeDir = System.getProperty("user.home");
+		String homeDir = JNLPRuntime.HOME_DIR;
 		
 		if (homeDir == null) {
 			throw new Exception("Could not access home directory");
 		} else {
-			return homeDir + certDir + certFile;
+			return JNLPRuntime.CERTIFICATES_FILE;
 		}
 	}
 	
@@ -90,7 +89,7 @@
 		
 		//file does not exist
 		if (!certFile.isFile()) {
-			File dir = new File(homeDir+certDir);
+			File dir = certFile.getAbsoluteFile().getParentFile();
 			boolean madeDir = false;
 			if (!dir.isDirectory()) {
 				madeDir = dir.mkdirs();