river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From foli...@apache.org
Subject svn commit: r634771 - in /incubator/river/jtsk/trunk/src: com/sun/jini/tool/ComputeDigest.java com/sun/jini/tool/ComputeHttpmdCodebase.java net/jini/jeri/ssl/SslConnection.java net/jini/jeri/ssl/SslEndpointImpl.java
Date Fri, 07 Mar 2008 18:23:13 GMT
Author: foliver
Date: Fri Mar  7 10:23:13 2008
New Revision: 634771

URL: http://svn.apache.org/viewvc?rev=634771&view=rev
Log:

Fixes to RIVER-253, RIVER-252, RIVER-233, RIVER-231, and RIVER-209.

 - minor clarifications in ComputeHttpmdCodebase and ComputeDigest with
   respect to algorithms used.

 - avoid NullPointerExceptions in these classes when resource bundles 
   cannot be found.

 - fix NullPointerException in SslConnection.checkConnectPermission().

Modified:
    incubator/river/jtsk/trunk/src/com/sun/jini/tool/ComputeDigest.java
    incubator/river/jtsk/trunk/src/com/sun/jini/tool/ComputeHttpmdCodebase.java
    incubator/river/jtsk/trunk/src/net/jini/jeri/ssl/SslConnection.java
    incubator/river/jtsk/trunk/src/net/jini/jeri/ssl/SslEndpointImpl.java

Modified: incubator/river/jtsk/trunk/src/com/sun/jini/tool/ComputeDigest.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/com/sun/jini/tool/ComputeDigest.java?rev=634771&r1=634770&r2=634771&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/com/sun/jini/tool/ComputeDigest.java (original)
+++ incubator/river/jtsk/trunk/src/com/sun/jini/tool/ComputeDigest.java Fri Mar  7 10:23:13
2008
@@ -30,19 +30,19 @@
  * Prints the message digest for the contents of a URL. This utility is run
  * from the {@linkplain #main command line}. <p>
  *
- * An example command line usage is:
+ * An example command line (shown with lines wrapped for readability) is:
  *
  * <blockquote>
  * <pre>
  * java -jar <var><b>install_dir</b></var>/lib/computedigest.jar
  *      <var><b>install_dir</b></var>/lib/reggie.jar
- *      sha
+ *      sha1
  * </pre>
  * </blockquote>
  *
  * where <var><b>install_dir</b></var> is the directory where the
Apache River release
  * is installed. This command prints out the message digest for the
- * <code>reggie.jar</code> JAR file, using the <code>sha</code> algorithm.
+ * <code>reggie.jar</code> JAR file, using the <code>sha1</code>
algorithm.
  *
  * @author Sun Microsystems, Inc.
  * @since 2.0
@@ -85,18 +85,17 @@
     }
 
     private static synchronized String getString(String key) {
-	if (!resinit) {
-	    try {
+	try {
+	    if (!resinit) {
 		resources = ResourceBundle.getBundle(
 				 "com.sun.jini.tool.resources.computedigest");
 		resinit = true;
-	    } catch (MissingResourceException e) {
-		e.printStackTrace();
 	    }
-	}
-	try {
 	    return resources.getString(key);
 	} catch (MissingResourceException e) {
+	    e.printStackTrace();
+	    System.err.println("Unable to find a required resource.");
+	    System.exit(1);
 	    return null;
 	}
     }

Modified: incubator/river/jtsk/trunk/src/com/sun/jini/tool/ComputeHttpmdCodebase.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/com/sun/jini/tool/ComputeHttpmdCodebase.java?rev=634771&r1=634770&r2=634771&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/com/sun/jini/tool/ComputeHttpmdCodebase.java (original)
+++ incubator/river/jtsk/trunk/src/com/sun/jini/tool/ComputeHttpmdCodebase.java Fri Mar  7
10:23:13 2008
@@ -31,8 +31,10 @@
 /**
  * Computes the message digests for a codebase with HTTPMD URLs. This utility
  * is run from the {@linkplain #main command line}. <p>
+ * A description of HTTPMD URLs can be found in the {@link net.jini.url.httpmd}
+ * package and its {@link net.jini.url.httpmd.Handler} class.<p>
  *
- * An example command line usage is:
+ * An example command line (shown with lines wrapped for readability) is:
  *
  * <blockquote>
  * <pre>
@@ -48,7 +50,9 @@
  * <var><b>http_port</b></var> is the port for that server. This
command prints
  * out the download codebase for use by a client that uses the {@link
  * net.jini.lookup.ServiceDiscoveryManager}, using an HTTPMD URL to guarantee
- * integrity for the classes in the <code>sdm-dl.jar</code> JAR file.
+ * integrity for the classes in the <code>sdm-dl.jar</code> JAR file. The
+ * message digest will be computed using the <code>md5</code> algorithm, and
+ * the <code>0</code> will be replaced by the computed digest.
  *
  * @author Sun Microsystems, Inc.
  * @since 2.0
@@ -154,18 +158,17 @@
     }
 
     private static synchronized String getString(String key) {
-	if (!resinit) {
-	    try {
+	try {
+	    if (!resinit) {
 		resources = ResourceBundle.getBundle(
 			       "com.sun.jini.tool.resources.computecodebase");
 		resinit = true;
-	    } catch (MissingResourceException e) {
-		e.printStackTrace();
 	    }
-	}
-	try {
 	    return resources.getString(key);
 	} catch (MissingResourceException e) {
+	    e.printStackTrace();
+	    System.err.println("Unable to find a required resource.");
+	    System.exit(1);
 	    return null;
 	}
     }

Modified: incubator/river/jtsk/trunk/src/net/jini/jeri/ssl/SslConnection.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/jeri/ssl/SslConnection.java?rev=634771&r1=634770&r2=634771&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/jeri/ssl/SslConnection.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/jeri/ssl/SslConnection.java Fri Mar  7 10:23:13
2008
@@ -657,11 +657,24 @@
 	return "";
     }
 
-    void checkConnectPermission() {
+    /**
+     * Determine whether the caller has "connect" SocketPermission for the
+     * connection's underlying socket.
+     *
+     * @return true if there is an underlying socket and the caller has
+     * permission to use it, or false if there is no underlying socket.
+     *
+     * @throws SecurityException if the underlying socket exists but
+     * the caller does not have permission to use it.
+     */
+    boolean checkConnectPermission() {
+	Socket socket = sslSocket;
+	if (socket == null) {
+	    return false;
+	}
+
 	SecurityManager sm = System.getSecurityManager();
 	if (sm != null) {
-	    Socket socket = sslSocket;
-
 	    // This depends on the SslSocket returning information about
 	    // its underlying plain socket.
 	    InetSocketAddress address =
@@ -674,5 +687,6 @@
 				socket.getPort());
 	    }
 	}
+	return true;
     }
 }

Modified: incubator/river/jtsk/trunk/src/net/jini/jeri/ssl/SslEndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/net/jini/jeri/ssl/SslEndpointImpl.java?rev=634771&r1=634770&r2=634771&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/net/jini/jeri/ssl/SslEndpointImpl.java (original)
+++ incubator/river/jtsk/trunk/src/net/jini/jeri/ssl/SslEndpointImpl.java Fri Mar  7 10:23:13
2008
@@ -314,7 +314,7 @@
 	List contexts = new CopyOnRemoveList(
 	    getConnectionContexts(constraints, clientPrincipals));
 	if (constrainedServer) {
-	    /* Server prinicipals were named in constraints.  Remove from the
+	    /* Server principals were named in constraints.  Remove from the
 	     * context list any ConnectionContexts for which there is no
 	     * permission to authenticate the context's client principal with
 	     * the context's server principal.
@@ -905,7 +905,9 @@
 			checkedResolvePermission = true;
 		    }
 		    try {
-			connection.checkConnectPermission();
+			if (!connection.checkConnectPermission()) {
+			    continue;
+			}
 		    } catch (SecurityException e) {
 			if (logger.isLoggable(Levels.HANDLED)) {
 			    LogUtil.logThrow(logger, Levels.HANDLED,



Mime
View raw message