You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by ri...@apache.org on 2006/10/20 12:33:28 UTC
svn commit: r466092 - in /incubator/yoko/trunk:
core/src/main/java/org/apache/yoko/orb/OBCORBA/
core/src/main/java/org/apache/yoko/orb/csi/
core/src/main/java/org/apache/yoko/orb/util/ rmi/src/main/java/javax/rmi/
rmi/src/main/java/javax/rmi/CORBA/ rmi...
Author: rickmcguire
Date: Fri Oct 20 05:33:25 2006
New Revision: 466092
URL: http://svn.apache.org/viewvc?view=rev&rev=466092
Log:
YOKO-195 Yoko code needs to use AccessController to retrieve system properties.
Also fixed up a few more usages of Class.forName();
Added:
incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/util/
incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/util/GetSystemPropertyAction.java (with props)
incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/util/GetSystemPropertyAction.java (with props)
Modified:
incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java
incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/csi/SecurityContext.java
incubator/yoko/trunk/rmi/src/main/java/javax/rmi/CORBA/Stub.java
incubator/yoko/trunk/rmi/src/main/java/javax/rmi/CORBA/Util.java
incubator/yoko/trunk/rmi/src/main/java/javax/rmi/PortableRemoteObject.java
incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/api/PortableRemoteObjectExt.java
incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java
incubator/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/ORB.java
Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java?view=diff&rev=466092&r1=466091&r2=466092
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java Fri Oct 20 05:33:25 2006
@@ -16,6 +16,9 @@
package org.apache.yoko.orb.OBCORBA;
+import java.security.AccessController;
+import org.apache.yoko.orb.util.GetSystemPropertyAction;
+
// This class must be public and not final
public class ORB_impl extends org.apache.yoko.orb.CORBA.ORBSingleton {
//
@@ -81,7 +84,7 @@
java.util.Properties properties,
org.apache.yoko.orb.OB.Logger logger, int nativeCs, int nativeWcs,
int defaultWcs) {
- String javaVersion = System.getProperty("java.version");
+ String javaVersion = getSystemProperty("java.version");
float version = Float.parseFloat(javaVersion.substring(0, 3));
if (version < 1.3f) {
throw new org.omg.CORBA.INITIALIZE("Unsupported Java version: "
@@ -1462,7 +1465,7 @@
orbClassName = props.getProperty(propName);
if (orbClassName == null)
- orbClassName = System.getProperty(propName);
+ orbClassName = getSystemProperty(propName);
if (orbClassName == null)
orbClassName = "org.apache.yoko.orb.CORBA.ORB";
@@ -1485,7 +1488,7 @@
public static org.omg.CORBA.ORB init(java.applet.Applet app,
java.util.Properties props, org.apache.yoko.orb.OB.Logger logger) {
- String javaVersion = System.getProperty("java.vm.version");
+ String javaVersion = getSystemProperty("java.vm.version");
float version = Float.parseFloat(javaVersion);
if (version < 1.5) {
throw new org.omg.CORBA.INITIALIZE("Unsupported Java version: "
@@ -1500,7 +1503,7 @@
try {
if (orbClassName == null)
- orbClassName = System.getProperty(propName);
+ orbClassName = getSystemProperty(propName);
} catch (SecurityException ex) {
// ignore
}
@@ -1835,5 +1838,18 @@
public org.apache.yoko.orb.OB.ORBInstance _OB_ORBInstance() {
return orbInstance_;
+ }
+
+
+ /**
+ * Simple utility for retrieving a system property
+ * using the AccessController.
+ *
+ * @param name The property name
+ *
+ * @return The property value.
+ */
+ private static String getSystemProperty(String name) {
+ return (String)AccessController.doPrivileged(new GetSystemPropertyAction(name));
}
}
Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/csi/SecurityContext.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/csi/SecurityContext.java?view=diff&rev=466092&r1=466091&r2=466092
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/csi/SecurityContext.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/csi/SecurityContext.java Fri Oct 20 05:33:25 2006
@@ -19,6 +19,9 @@
import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
+import java.security.AccessController;
+import org.apache.yoko.orb.util.GetSystemPropertyAction;
+
public abstract class SecurityContext {
private static SecurityContextDelegate delegate;
@@ -38,9 +41,9 @@
private static SecurityContextDelegate allocateDelegate() {
- String className = System.getProperty(
+ String className = (String)AccessController.doPrivileged(new GetSystemPropertyAction(
"org.freeorb.csi.SecurityContextClass",
- "org.freeorb.csi.DefaultSecurityContextDelegate");
+ "org.freeorb.csi.DefaultSecurityContextDelegate"));
try {
// get the appropriate class for the loading.
Added: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/util/GetSystemPropertyAction.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/util/GetSystemPropertyAction.java?view=auto&rev=466092
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/util/GetSystemPropertyAction.java (added)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/util/GetSystemPropertyAction.java Fri Oct 20 05:33:25 2006
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.yoko.orb.util;
+
+import java.security.PrivilegedAction;
+
+/**
+ * Simple utility class for retrieving a system property
+ * value using the AccessController.
+ */
+public class GetSystemPropertyAction implements PrivilegedAction {
+ // property name to retrieve
+ String name;
+ // potential default value
+ String defaultValue = null;
+
+ /**
+ * Retrive a value using the name with no default value.
+ *
+ * @param name The property name.
+ */
+ public GetSystemPropertyAction(String name) {
+ this.name = name;
+ this.defaultValue = null;
+ }
+
+ /**
+ * Retrieve a property using a name and a specified default value.
+ *
+ * @param name The property name.
+ * @param defaultValue
+ * The default value if the property has not been set.
+ */
+ public GetSystemPropertyAction(String name, String defaultValue) {
+ this.name = name;
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * Perform the AccessController action of retrieving the system property.
+ *
+ * @return The retrieved property. Returns either null or the
+ * specified default value if this has not been set.
+ */
+ public java.lang.Object run() {
+ if (defaultValue == null) {
+ return System.getProperty(name);
+ }
+ else {
+ return System.getProperty(name, defaultValue);
+ }
+ }
+}
+
Propchange: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/util/GetSystemPropertyAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/util/GetSystemPropertyAction.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/util/GetSystemPropertyAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/yoko/trunk/rmi/src/main/java/javax/rmi/CORBA/Stub.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi/src/main/java/javax/rmi/CORBA/Stub.java?view=diff&rev=466092&r1=466091&r2=466092
==============================================================================
--- incubator/yoko/trunk/rmi/src/main/java/javax/rmi/CORBA/Stub.java (original)
+++ incubator/yoko/trunk/rmi/src/main/java/javax/rmi/CORBA/Stub.java Fri Oct 20 05:33:25 2006
@@ -21,34 +21,37 @@
import org.omg.CORBA.ORB;
import org.omg.CORBA_2_3.portable.ObjectImpl;
+import java.security.AccessController;
+import org.apache.yoko.rmi.util.GetSystemPropertyAction;
+
public abstract class Stub extends ObjectImpl implements Serializable {
private StubDelegate delegate = null;
private final String defaultDelegate = "org.apache.yoko.rmi.impl.StubImpl";
-
+
public Stub() {
super();
-
+
// Initialize delegate
- String delegateName = System.getProperty("javax.rmi.CORBA.StubClass", defaultDelegate);
+ String delegateName = (String)AccessController.doPrivileged(new GetSystemPropertyAction("javax.rmi.CORBA.StubClass", defaultDelegate));
try {
- delegate = (StubDelegate)Class.forName(delegateName).newInstance();
+ delegate = (StubDelegate)Util.loadClass(delegateName, null, null).newInstance();
} catch (Exception e) {
- throw new RuntimeException("Can not create Stub delegate: "+delegateName, e);
+ throw new org.omg.CORBA.INITIALIZE("Can not create Stub delegate: "+delegateName);
}
}
-
+
public void connect(ORB orb) throws RemoteException {
delegate.connect(this, orb);
}
-
+
public boolean equals(Object o) {
return delegate.equals(this, o);
}
-
+
public int hashCode() {
return delegate.hashCode(this);
}
-
+
public String toString() {
return delegate.toString(this);
}
Modified: incubator/yoko/trunk/rmi/src/main/java/javax/rmi/CORBA/Util.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi/src/main/java/javax/rmi/CORBA/Util.java?view=diff&rev=466092&r1=466091&r2=466092
==============================================================================
--- incubator/yoko/trunk/rmi/src/main/java/javax/rmi/CORBA/Util.java (original)
+++ incubator/yoko/trunk/rmi/src/main/java/javax/rmi/CORBA/Util.java Fri Oct 20 05:33:25 2006
@@ -19,11 +19,13 @@
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.NoSuchObjectException;
+import java.security.AccessController;
import org.omg.CORBA.ORB;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.apache.yoko.rmi.util.GetSystemPropertyAction;
import org.apache.yoko.rmi.impl.UtilImpl;
public class Util {
@@ -32,7 +34,7 @@
static {
// Initialize delegate
- String delegateName = System.getProperty("javax.rmi.CORBA.UtilClass", defaultDelegate);
+ String delegateName = (String)AccessController.doPrivileged(new GetSystemPropertyAction("javax.rmi.CORBA.UtilClass", defaultDelegate));
try {
// this is a little bit recursive, but this will use the full default search order for locating
Modified: incubator/yoko/trunk/rmi/src/main/java/javax/rmi/PortableRemoteObject.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi/src/main/java/javax/rmi/PortableRemoteObject.java?view=diff&rev=466092&r1=466091&r2=466092
==============================================================================
--- incubator/yoko/trunk/rmi/src/main/java/javax/rmi/PortableRemoteObject.java (original)
+++ incubator/yoko/trunk/rmi/src/main/java/javax/rmi/PortableRemoteObject.java Fri Oct 20 05:33:25 2006
@@ -19,16 +19,19 @@
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.NoSuchObjectException;
+import java.security.AccessController;
import javax.rmi.CORBA.PortableRemoteObjectDelegate;
import javax.rmi.CORBA.Util;
+import org.apache.yoko.rmi.util.GetSystemPropertyAction;
+
public class PortableRemoteObject {
private static PortableRemoteObjectDelegate delegate = null;
private static final String defaultDelegate = "org.apache.yoko.rmi.impl.PortableRemoteObjectImpl";
static {
// Initialize delegate
- String delegateName = System.getProperty("javax.rmi.CORBA.PortableRemoteObjectClass", defaultDelegate);
+ String delegateName = (String)AccessController.doPrivileged(new GetSystemPropertyAction("javax.rmi.CORBA.PortableRemoteObjectClass", defaultDelegate));
try {
delegate = (PortableRemoteObjectDelegate)Util.loadClass(delegateName, null, null).newInstance();
} catch (Exception e) {
Modified: incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/api/PortableRemoteObjectExt.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/api/PortableRemoteObjectExt.java?view=diff&rev=466092&r1=466091&r2=466092
==============================================================================
--- incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/api/PortableRemoteObjectExt.java (original)
+++ incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/api/PortableRemoteObjectExt.java Fri Oct 20 05:33:25 2006
@@ -13,21 +13,24 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-*/
+*/
package org.apache.yoko.rmi.api;
+import java.security.AccessController;
+import org.apache.yoko.rmi.util.GetSystemPropertyAction;
+
public class PortableRemoteObjectExt {
private static PortableRemoteObjectExtDelegate delegate;
-
+
private static void init() {
if (delegate != null)
return;
- String name = System.getProperty(
+ String name = (String)AccessController.doPrivileged(new GetSystemPropertyAction(
"trifork.rmi.PortableRemoteObjectExtClass",
- "org.apache.yoko.rmi.impl.PortableRemoteObjectExtImpl");
+ "org.apache.yoko.rmi.impl.PortableRemoteObjectExtImpl"));
Class clz = null;
try {
Modified: incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java?view=diff&rev=466092&r1=466091&r2=466092
==============================================================================
--- incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java (original)
+++ incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/impl/UtilImpl.java Fri Oct 20 05:33:25 2006
@@ -46,6 +46,8 @@
import org.omg.CORBA.portable.IDLEntity;
import org.omg.CORBA.portable.UnknownException;
+import org.apache.yoko.rmi.util.GetSystemPropertyAction;
+
public class UtilImpl implements UtilDelegate {
static final Logger logger = Logger.getLogger(UtilImpl.class.getName());
@@ -53,7 +55,7 @@
static {
Class userTransactionClass;
try {
- userTransactionClass =Class.forName("javax.transaction.userTransaction");
+ userTransactionClass = Util.loadClass("javax.transaction.userTransaction", null, null);
}
catch(ClassNotFoundException e) {
userTransactionClass = null;
@@ -491,7 +493,7 @@
// ignore
}
- return System.getProperty("java.rmi.server.codebase");
+ return (String)AccessController.doPrivileged(new GetSystemPropertyAction("java.rmi.server.codebase"));
}
static class SecMan extends java.rmi.RMISecurityManager {
@@ -588,7 +590,7 @@
} else {
- codebase = System.getProperty("java.rmi.server.codebase");
+ codebase = (String)AccessController.doPrivileged(new GetSystemPropertyAction("java.rmi.server.codebase"));
if (codebase != null) {
try {
@@ -855,28 +857,28 @@
Class[] rmiToCorba;
try {
rmiToCorba = new Class[] {
- Class.forName("javax.transaction.HeuresticMixexException"),
+ Util.loadClass("javax.transaction.HeuresticMixexException", null, null),
org.omg.CosTransactions.HeuristicMixed.class,
- Class.forName("javax.transaction.HeuristicRollbackException"),
+ Util.loadClass("javax.transaction.HeuristicRollbackException", null, null),
org.omg.CosTransactions.HeuristicRollback.class,
- Class.forName("javax.transaction.HeuristicCommitException"),
+ Util.loadClass("javax.transaction.HeuristicCommitException", null, null),
org.omg.CosTransactions.HeuristicCommit.class,
- Class.forName("javax.transaction.NotSupportedException"),
+ Util.loadClass("javax.transaction.NotSupportedException", null, null),
org.omg.CosTransactions.SubtransactionsUnavailable.class,
- Class.forName("javax.transaction.InvalidTransactionException"),
+ Util.loadClass("javax.transaction.InvalidTransactionException", null, null),
org.omg.CORBA.INVALID_TRANSACTION.class,
- Class.forName("javax.transaction.TransactionRequiredException"),
+ Util.loadClass("javax.transaction.TransactionRequiredException", null, null),
org.omg.CORBA.TRANSACTION_REQUIRED.class,
- Class.forName("javax.transaction.TransactionRolledbackException"),
+ Util.loadClass("javax.transaction.TransactionRolledbackException", null, null),
org.omg.CORBA.TRANSACTION_ROLLEDBACK.class,
- Class.forName("javax.transaction.RollbackException"),
+ Util.loadClass("javax.transaction.RollbackException", null, null),
org.omg.CORBA.TRANSACTION_ROLLEDBACK.class
};
Added: incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/util/GetSystemPropertyAction.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/util/GetSystemPropertyAction.java?view=auto&rev=466092
==============================================================================
--- incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/util/GetSystemPropertyAction.java (added)
+++ incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/util/GetSystemPropertyAction.java Fri Oct 20 05:33:25 2006
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.yoko.rmi.util;
+
+import java.security.PrivilegedAction;
+
+/**
+ * Simple utility class for retrieving a system property
+ * value using the AccessController.
+ */
+public class GetSystemPropertyAction implements PrivilegedAction {
+ // property name to retrieve
+ String name;
+ // potential default value
+ String defaultValue = null;
+
+ /**
+ * Retrive a value using the name with no default value.
+ *
+ * @param name The property name.
+ */
+ public GetSystemPropertyAction(String name) {
+ this.name = name;
+ this.defaultValue = null;
+ }
+
+ /**
+ * Retrieve a property using a name and a specified default value.
+ *
+ * @param name The property name.
+ * @param defaultValue
+ * The default value if the property has not been set.
+ */
+ public GetSystemPropertyAction(String name, String defaultValue) {
+ this.name = name;
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * Perform the AccessController action of retrieving the system property.
+ *
+ * @return The retrieved property. Returns either null or the
+ * specified default value if this has not been set.
+ */
+ public java.lang.Object run() {
+ if (defaultValue == null) {
+ return System.getProperty(name);
+ }
+ else {
+ return System.getProperty(name, defaultValue);
+ }
+ }
+}
+
Propchange: incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/util/GetSystemPropertyAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/util/GetSystemPropertyAction.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/yoko/trunk/rmi/src/main/java/org/apache/yoko/rmi/util/GetSystemPropertyAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/ORB.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/ORB.java?view=diff&rev=466092&r1=466091&r2=466092
==============================================================================
--- incubator/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/ORB.java (original)
+++ incubator/yoko/trunk/yoko-spec-corba/src/main/java/org/omg/CORBA/ORB.java Fri Oct 20 05:33:25 2006
@@ -15,6 +15,9 @@
*/
package org.omg.CORBA;
+import java.security.PrivilegedAction;
+import java.security.AccessController;
+
public abstract class ORB {
public abstract String[] list_initial_services();
@@ -169,7 +172,7 @@
orbClassName = props.getProperty("DEFAULT_ORB_CLASS_NAME");
if (orbClassName == null)
- orbClassName = System.getProperty("DEFAULT_ORB_CLASS_NAME");
+ orbClassName = getSystemProperty("DEFAULT_ORB_CLASS_NAME");
if (orbClassName == null)
orbClassName = "org.apache.yoko.orb.CORBA.ORB";
@@ -200,7 +203,7 @@
try {
if (orbClassName == null)
- orbClassName = System.getProperty("DEFAULT_ORB_CLASS_NAME");
+ orbClassName = getSystemProperty("DEFAULT_ORB_CLASS_NAME");
} catch (SecurityException ex) {
// ignore
}
@@ -252,4 +255,23 @@
protected abstract void set_parameters(java.applet.Applet app,
java.util.Properties props);
+
+
+ /**
+ * Simple utility for retrieving a system property
+ * using the AccessController.
+ *
+ * @param name The property name
+ *
+ * @return The property value.
+ */
+ private static String getSystemProperty(final String name) {
+ return (String) AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public java.lang.Object run() {
+ return System.getProperty(name);
+ }
+ }
+ );
+ }
}