db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1620389 - in /db/derby/code/branches/10.11: ./ java/drda/org/apache/derby/drda/ java/drda/org/apache/derby/impl/drda/ java/tools/org/apache/derby/iapi/tools/i18n/ java/tools/org/apache/derby/impl/tools/sysinfo/
Date Mon, 25 Aug 2014 17:47:18 GMT
Author: dag
Date: Mon Aug 25 17:47:18 2014
New Revision: 1620389

URL: http://svn.apache.org/r1620389
Log:
DERBY-6680 Other jar files may need to be granted permission to read derby.ui.* properties

Backported from trunk at svn 1620378.

derby-6680-2. This patch moves the reading of the two system
properties up into NetworkServerControlImpl. Other usage of
LocalizedResource is unaffected and might still try to read those
system properties, i.e. as called from ij. This side-steps the problem
so no further permissions need be granted.

Removes the note about LocalizedResource in the policy template file.


Modified:
    db/derby/code/branches/10.11/   (props changed)
    db/derby/code/branches/10.11/java/drda/org/apache/derby/drda/NetServlet.java
    db/derby/code/branches/10.11/java/drda/org/apache/derby/drda/template.policy
    db/derby/code/branches/10.11/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/branches/10.11/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
    db/derby/code/branches/10.11/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java

Propchange: db/derby/code/branches/10.11/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1620378

Modified: db/derby/code/branches/10.11/java/drda/org/apache/derby/drda/NetServlet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.11/java/drda/org/apache/derby/drda/NetServlet.java?rev=1620389&r1=1620388&r2=1620389&view=diff
==============================================================================
--- db/derby/code/branches/10.11/java/drda/org/apache/derby/drda/NetServlet.java (original)
+++ db/derby/code/branches/10.11/java/drda/org/apache/derby/drda/NetServlet.java Mon Aug 25
17:47:18 2014
@@ -122,7 +122,7 @@ public class NetServlet extends HttpServ
             boolean start = Boolean.valueOf(startup).booleanValue();
             if (start)
             {
-                LocalizedResource langUtil = new LocalizedResource(null,null,SERVLET_PROP_MESSAGES);
+                LocalizedResource langUtil = new LocalizedResource(SERVLET_PROP_MESSAGES);
                 runServer(langUtil, null, null);
                 return;
             }
@@ -967,7 +967,7 @@ public class NetServlet extends HttpServ
     {
         LocalizedResource localUtil;
         String acceptLanguage = request.getHeader("Accept-Language");
-        localUtil = new LocalizedResource(null,null,SERVLET_PROP_MESSAGES);
+        localUtil = new LocalizedResource(SERVLET_PROP_MESSAGES);
         // if no language specified use one set by derby.locale, derby.codeset
         locale[ 0 ] = null;
         if (acceptLanguage == null)

Modified: db/derby/code/branches/10.11/java/drda/org/apache/derby/drda/template.policy
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.11/java/drda/org/apache/derby/drda/template.policy?rev=1620389&r1=1620388&r2=1620389&view=diff
==============================================================================
--- db/derby/code/branches/10.11/java/drda/org/apache/derby/drda/template.policy (original)
+++ db/derby/code/branches/10.11/java/drda/org/apache/derby/drda/template.policy Mon Aug 25
17:47:18 2014
@@ -27,15 +27,6 @@ grant codeBase "${derby.install.url}derb
 
   // Next, the permission to read "derby.*" properties is granted to
   // derby.jar. This is necessary for the engine to read derby properties.
-  // 
-  // NOTE: This works under the assumption that derby.jar precedes
-  // derbytools.jar (and possibly derbyclient.jar) - if present. If that is
-  // *not* the case, i.e. derby.jar follows any of those other jars, you will
-  // need to *also* grant this permission to the first of those jar files in
-  // your classpath. The reason is that some Derby properties (derby.ui.locale,
-  // derby.ui.codeset) are read by the class LocalizedResource which is present
-  // in more than one jar file. The first jar in the path gets used to load
-  // the class and hence that jar needs the permission.
   permission java.util.PropertyPermission "derby.*", "read";
 
   permission java.util.PropertyPermission "user.dir", "read";

Modified: db/derby/code/branches/10.11/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.11/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=1620389&r1=1620388&r2=1620389&view=diff
==============================================================================
--- db/derby/code/branches/10.11/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/branches/10.11/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Mon Aug 25 17:47:18 2014
@@ -464,8 +464,12 @@ public final class NetworkServerControlI
     private void init() throws Exception
     {
 
+        final String codeSet = 
+                PropertyUtil.getSystemProperty(LocalizedResource.ENV_CODESET);
+        final String locale = 
+                PropertyUtil.getSystemProperty(LocalizedResource.ENV_LOCALE);
         // adjust the application in accordance with derby.ui.locale and derby.ui.codeset
-        langUtil = new LocalizedResource(null,null,DRDA_PROP_MESSAGES);
+        langUtil = new LocalizedResource(codeSet, locale, DRDA_PROP_MESSAGES);
 
         serverInstance = this;
         
@@ -1689,7 +1693,8 @@ public final class NetworkServerControlI
         try {
             String protocolStr = reader.readCmdString(4);
             String locale = DEFAULT_LOCALE;
-            String codeset = null;
+            String codeset = 
+                PropertyUtil.getSystemProperty(LocalizedResource.ENV_CODESET);
             // get the version
             int version = reader.readNetworkShort();
             if (version <= 0 || version > MAX_ALLOWED_PROTOCOL_VERSION) {

Modified: db/derby/code/branches/10.11/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.11/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java?rev=1620389&r1=1620388&r2=1620389&view=diff
==============================================================================
--- db/derby/code/branches/10.11/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
(original)
+++ db/derby/code/branches/10.11/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
Mon Aug 25 17:47:18 2014
@@ -23,24 +23,21 @@ package org.apache.derby.iapi.tools.i18n
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
-
-import java.util.ResourceBundle;
-import java.util.Date;
-import java.util.Locale;
-import java.util.StringTokenizer;
-
-import java.text.MessageFormat;
-import java.text.NumberFormat;
-import java.text.DecimalFormat;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.FieldPosition;
-
-import java.sql.Timestamp;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
+import java.sql.Timestamp;
 import java.sql.Types;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.FieldPosition;
+import java.text.MessageFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.StringTokenizer;
 
 
 public final class LocalizedResource  implements java.security.PrivilegedAction<String>
{
@@ -49,8 +46,8 @@ public final class LocalizedResource  im
 	private Locale locale;
 	private String encode;
 	private final static String MESSAGE_FILE = "org.apache.derby.loc.toolsmessages";
-	private final static String ENV_CODESET = "derby.ui.codeset";
-	private final static String ENV_LOCALE = "derby.ui.locale";
+    public final static String ENV_CODESET = "derby.ui.codeset";
+    public final static String ENV_LOCALE = "derby.ui.locale";
 	private String messageFileName;
 	private String resourceKey;
 	private LocalizedOutput out;
@@ -65,13 +62,27 @@ public final class LocalizedResource  im
 	private DateFormat formatTimestamp;
 	private NumberFormat formatNumber;
     private DecimalFormat formatDecimal;
-	public LocalizedResource(){
+
+    private LocalizedResource(){
 		init();
 	}
-	public LocalizedResource(String encStr, String locStr, String msgF){
-		init(encStr,locStr,msgF);
+    public LocalizedResource(String msgF){
+        init(null, null, msgF, true);
 	}
-	public static LocalizedResource getInstance(){
+
+    /**
+     * This overload version does <b>not</b> check the environment for values
of
+     * encoding via {@link #ENV_CODESET} and locale via {@link #ENV_LOCALE}.
+     * The others do if value of either is null. DERBY-6680.
+     * @param encStr encoding
+     * @param locStr locale
+     * @param msgF message file
+     */
+    public LocalizedResource(String encStr, String locStr, String msgF){
+        init(encStr,locStr,msgF, false);
+    }
+
+    public static LocalizedResource getInstance(){
 		if (local == null){
 			local = new  LocalizedResource();
 		}
@@ -88,12 +99,18 @@ public final class LocalizedResource  im
 	public void init(){
 		init(null,null,null);
 	}
-	public void init (String encStr, String locStr, String msgF){
+
+
+    public void init (String encStr, String locStr, String msgF) {
+        init(encStr, locStr, msgF, true);
+    }
+
+    private void init (String encStr, String locStr, String msgF, boolean readEnv){
 		if (encStr != null){
 			encode = encStr;
 		}
 		//then get encoding string from environment
-		if (encode == null) {
+        if (encode == null && readEnv) {
 			String eEncode = getEnvProperty(ENV_CODESET);
 			if ( eEncode != null ){
 				encode = eEncode;
@@ -107,7 +124,7 @@ public final class LocalizedResource  im
 		locale = getNewLocale(locStr);
 
 		//if null, get locale again from the environment variable
-		if (locale==null) {
+        if (locale==null && readEnv) {
 			String s = getEnvProperty(ENV_LOCALE);
 			locale = getNewLocale(s);
 		}

Modified: db/derby/code/branches/10.11/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.11/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java?rev=1620389&r1=1620388&r2=1620389&view=diff
==============================================================================
--- db/derby/code/branches/10.11/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
(original)
+++ db/derby/code/branches/10.11/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
Mon Aug 25 17:47:18 2014
@@ -106,7 +106,7 @@ public final class Main {
      * <code>main()</code>.
      */
     private final static LocalizedResource LOCALIZED_RESOURCE =
-        new LocalizedResource(null, null, MESSAGE_FILE);
+        new LocalizedResource(MESSAGE_FILE);
 
   /**
     Application entry point for SysInfo.   This will print out



Mime
View raw message