mirror of
https://github.com/openjdk/jdk8u.git
synced 2025-12-10 10:44:16 -06:00
8303384: Improved communication in CORBA
Reviewed-by: mbalao, andrew
This commit is contained in:
parent
dc7013e0d9
commit
6930f19077
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Azul Systems, Inc. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.corba.se.impl.orbutil;
|
||||
|
||||
import java.io.InvalidObjectException;
|
||||
import java.security.AccessController;
|
||||
import java.util.*;
|
||||
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
public final class IORCheckImpl {
|
||||
|
||||
private static final Set<String> stubsToCheck;
|
||||
|
||||
static {
|
||||
boolean checkLocalStubs =
|
||||
!getBooleanProperty(ORBConstants.DISABLE_IOR_CHECK_FOR_LOCAL_STUBS,
|
||||
getBooleanProperty(ORBConstants.ALLOW_DESERIALIZE_OBJECT, false));
|
||||
|
||||
boolean checkRemoteStubs =
|
||||
getBooleanProperty(ORBConstants.ENABLE_IOR_CHECK_FOR_REMOTE_STUBS, false);
|
||||
|
||||
stubsToCheck = getStubsToCheck(checkLocalStubs, checkRemoteStubs);
|
||||
}
|
||||
|
||||
private static Set<String> getStubsToCheck(boolean checkLocalStubs, boolean checkRemoteStubs) {
|
||||
if (!checkLocalStubs && !checkRemoteStubs) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
List<String> stubs = new ArrayList<>();
|
||||
if (checkLocalStubs) {
|
||||
stubs.addAll(getLocalStubs());
|
||||
}
|
||||
if (checkRemoteStubs) {
|
||||
stubs.addAll(getRemoteStubs());
|
||||
}
|
||||
return Collections.unmodifiableSet(new HashSet<>(stubs));
|
||||
}
|
||||
|
||||
private static List<String> getLocalStubs() {
|
||||
String[] localStubs = {
|
||||
"org.omg.DynamicAny._DynAnyFactoryStub",
|
||||
"org.omg.DynamicAny._DynAnyStub",
|
||||
"org.omg.DynamicAny._DynArrayStub",
|
||||
"org.omg.DynamicAny._DynEnumStub",
|
||||
"org.omg.DynamicAny._DynFixedStub",
|
||||
"org.omg.DynamicAny._DynSequenceStub",
|
||||
"org.omg.DynamicAny._DynStructStub",
|
||||
"org.omg.DynamicAny._DynUnionStub",
|
||||
"org.omg.DynamicAny._DynValueStub"
|
||||
};
|
||||
return Arrays.asList(localStubs);
|
||||
}
|
||||
|
||||
private static List<String> getRemoteStubs() {
|
||||
String[] remoteStubs = {
|
||||
"com.sun.corba.se.spi.activation._ActivatorStub",
|
||||
"com.sun.corba.se.spi.activation._InitialNameServiceStub",
|
||||
"com.sun.corba.se.spi.activation._LocatorStub",
|
||||
"com.sun.corba.se.spi.activation._RepositoryStub",
|
||||
"com.sun.corba.se.spi.activation._ServerManagerStub",
|
||||
"com.sun.corba.se.spi.activation._ServerStub",
|
||||
"org.omg.CosNaming._BindingIteratorStub",
|
||||
"org.omg.CosNaming._NamingContextExtStub",
|
||||
"org.omg.CosNaming._NamingContextStub",
|
||||
"org.omg.PortableServer._ServantActivatorStub",
|
||||
"org.omg.PortableServer._ServantLocatorStub"
|
||||
};
|
||||
return Arrays.asList(remoteStubs);
|
||||
}
|
||||
|
||||
/*
|
||||
* The str parameter is expected to start with "IOR:".
|
||||
* Otherwise, the method throws the InvalidObjectException exception.
|
||||
*/
|
||||
public static void check(String str, String stubClassName) throws InvalidObjectException {
|
||||
if (stubsToCheck.contains(stubClassName) && !str.startsWith(ORBConstants.STRINGIFY_PREFIX)) {
|
||||
throw new InvalidObjectException("IOR: expected");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean getBooleanProperty(String property, boolean defaultValue) {
|
||||
String value = AccessController.doPrivileged(
|
||||
new GetPropertyAction(property, String.valueOf(defaultValue)));
|
||||
return "true".equalsIgnoreCase(value);
|
||||
}
|
||||
}
|
||||
@ -317,8 +317,14 @@ public class ORBConstants {
|
||||
public static final String DYNAMIC_STUB_FACTORY_FACTORY_CLASS =
|
||||
SUN_PREFIX + "ORBDynamicStubFactoryFactoryClass" ;
|
||||
|
||||
// This property is provided for backward compatibility reasons
|
||||
public static final String ALLOW_DESERIALIZE_OBJECT = SUN_PREFIX + "ORBAllowDeserializeObject" ;
|
||||
|
||||
// Disables the IOR check for the ORB constrained stubs
|
||||
public static final String DISABLE_IOR_CHECK_FOR_LOCAL_STUBS = ORG_OMG_PREFIX + "DynamicAny.disableIORCheck" ;
|
||||
// Enables the IOR check for the Remote CORBA services stubs
|
||||
public static final String ENABLE_IOR_CHECK_FOR_REMOTE_STUBS = ORG_OMG_CORBA_PREFIX + "IDL.Stubs.enableIORCheck";
|
||||
|
||||
// Constants for NameService properties ************************************
|
||||
|
||||
public static final int DEFAULT_INITIAL_PORT = 900;
|
||||
|
||||
@ -101,6 +101,7 @@ public class Stub implements AuxGen
|
||||
Util.mkdir (pkg);
|
||||
name = pkg + '/' + name;
|
||||
}
|
||||
stubClassName = name.replace('/', '.');
|
||||
stream = Util.getStream (name.replace ('/', File.separatorChar) + ".java", i);
|
||||
} // openStream
|
||||
|
||||
@ -342,11 +343,7 @@ public class Stub implements AuxGen
|
||||
stream.println (" private void readObject (java.io.ObjectInputStream s) throws java.io.IOException");
|
||||
stream.println (" {");
|
||||
stream.println (" String str = s.readUTF ();");
|
||||
if ("DynAnyFactory".equals (i.name ())) {
|
||||
stream.println (" if (!str.startsWith(com.sun.corba.se.impl.orbutil.ORBConstants.STRINGIFY_PREFIX) &&");
|
||||
stream.println (" !Boolean.getBoolean(com.sun.corba.se.impl.orbutil.ORBConstants.ALLOW_DESERIALIZE_OBJECT))");
|
||||
stream.println (" throw new java.io.InvalidObjectException(\"IOR: expected\");");
|
||||
}
|
||||
stream.println (" com.sun.corba.se.impl.orbutil.IORCheckImpl.check(str, \"" + stubClassName + "\");");
|
||||
stream.println (" String[] args = null;");
|
||||
stream.println (" java.util.Properties props = null;");
|
||||
stream.println (" org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);");
|
||||
@ -382,4 +379,5 @@ public class Stub implements AuxGen
|
||||
protected String classSuffix = "";
|
||||
protected boolean localStub = false;
|
||||
private boolean isAbstract = false;
|
||||
private String stubClassName = null;
|
||||
} // class Stub
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user