8160104: CORBA communication improvements

Tue, 12 Sep 2017 16:53:35 +0100

author
aefimov
date
Tue, 12 Sep 2017 16:53:35 +0100
changeset 1618
4145ba26d9ff
parent 1617
880a9f4ce67a
child 1625
968a7e1a6e6c

8160104: CORBA communication improvements
Reviewed-by: dfuchs, msheppar

src/share/classes/com/sun/corba/se/impl/encoding/BufferManagerWriteGrow.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/corba/se/impl/encoding/CDRInputStream_1_0.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/corba/se/impl/ior/IORTypeCheckRegistryImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/corba/se/impl/orb/ORBSingleton.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/corba/se/spi/ior/IORTypeCheckRegistry.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/corba/se/spi/orb/ORB.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/corba/se/impl/encoding/BufferManagerWriteGrow.java	Tue Aug 08 12:01:59 2017 +0100
     1.2 +++ b/src/share/classes/com/sun/corba/se/impl/encoding/BufferManagerWriteGrow.java	Tue Sep 12 16:53:35 2017 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -26,11 +26,13 @@
    1.11  package com.sun.corba.se.impl.encoding;
    1.12  
    1.13  import com.sun.corba.se.impl.orbutil.ORBConstants;
    1.14 +import com.sun.corba.se.impl.orbutil.ORBUtility;
    1.15  import com.sun.corba.se.impl.encoding.ByteBufferWithInfo;
    1.16  import com.sun.corba.se.impl.encoding.BufferManagerWrite;
    1.17  import com.sun.corba.se.pept.encoding.OutputObject;
    1.18  import com.sun.corba.se.pept.transport.Connection;
    1.19  import com.sun.corba.se.spi.orb.ORB;
    1.20 +import com.sun.corba.se.spi.orb.ORBData;
    1.21  
    1.22  public class BufferManagerWriteGrow extends BufferManagerWrite
    1.23  {
    1.24 @@ -48,7 +50,20 @@
    1.25       * buffer manager as set in the ORB.
    1.26       */
    1.27      public int getBufferSize() {
    1.28 -        return orb.getORBData().getGIOPBufferSize();
    1.29 +        ORBData orbData = null;
    1.30 +        int bufferSize = ORBConstants.GIOP_DEFAULT_BUFFER_SIZE;
    1.31 +        if (orb != null) {
    1.32 +            orbData = orb.getORBData();
    1.33 +            if (orbData != null) {
    1.34 +                bufferSize = orbData.getGIOPBufferSize();
    1.35 +                dprint("BufferManagerWriteGrow.getBufferSize: bufferSize == " + bufferSize);
    1.36 +            } else {
    1.37 +                dprint("BufferManagerWriteGrow.getBufferSize: orbData reference is NULL");
    1.38 +            }
    1.39 +        } else {
    1.40 +            dprint("BufferManagerWriteGrow.getBufferSize: orb reference is NULL");
    1.41 +        }
    1.42 +        return bufferSize;
    1.43      }
    1.44  
    1.45      public void overflow (ByteBufferWithInfo bbwi)
    1.46 @@ -89,4 +104,9 @@
    1.47       */
    1.48      public void close() {}
    1.49  
    1.50 +    private void dprint(String msg) {
    1.51 +        if (orb.transportDebugFlag) {
    1.52 +            ORBUtility.dprint(this, msg);
    1.53 +        }
    1.54 +    }
    1.55  }
     2.1 --- a/src/share/classes/com/sun/corba/se/impl/encoding/CDRInputStream_1_0.java	Tue Aug 08 12:01:59 2017 +0100
     2.2 +++ b/src/share/classes/com/sun/corba/se/impl/encoding/CDRInputStream_1_0.java	Tue Sep 12 16:53:35 2017 +0100
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -32,18 +32,9 @@
    2.11  
    2.12  package com.sun.corba.se.impl.encoding;
    2.13  
    2.14 +import java.io.Serializable;
    2.15  import java.io.IOException;
    2.16 -import java.io.Serializable;
    2.17 -import java.io.ByteArrayInputStream;
    2.18 -import java.io.ObjectInputStream;
    2.19 -import java.io.IOException;
    2.20 -import java.io.StreamCorruptedException;
    2.21 -import java.io.OptionalDataException;
    2.22 -import java.io.IOException;
    2.23 -
    2.24 -import java.util.Stack;
    2.25 -
    2.26 -import java.net.URL;
    2.27 +
    2.28  import java.net.MalformedURLException;
    2.29  
    2.30  import java.nio.ByteBuffer;
    2.31 @@ -53,19 +44,11 @@
    2.32  
    2.33  import java.math.BigDecimal;
    2.34  
    2.35 -import java.rmi.Remote;
    2.36 -import java.rmi.StubNotFoundException;
    2.37 -
    2.38  import java.security.AccessController;
    2.39  import java.security.PrivilegedExceptionAction;
    2.40  import java.security.PrivilegedActionException;
    2.41  
    2.42  import org.omg.CORBA.SystemException;
    2.43 -import org.omg.CORBA.Object;
    2.44 -import org.omg.CORBA.Principal;
    2.45 -import org.omg.CORBA.TypeCode;
    2.46 -import org.omg.CORBA.Any;
    2.47 -import org.omg.CORBA.portable.Delegate;
    2.48  import org.omg.CORBA.portable.ValueBase;
    2.49  import org.omg.CORBA.portable.IndirectionException;
    2.50  import org.omg.CORBA.CompletionStatus;
    2.51 @@ -82,15 +65,12 @@
    2.52  import org.omg.CORBA.MARSHAL;
    2.53  import org.omg.CORBA.portable.IDLEntity;
    2.54  
    2.55 -import javax.rmi.PortableRemoteObject;
    2.56  import javax.rmi.CORBA.Tie;
    2.57 -import javax.rmi.CORBA.Util;
    2.58  import javax.rmi.CORBA.ValueHandler;
    2.59  
    2.60  import com.sun.corba.se.pept.protocol.MessageMediator;
    2.61  import com.sun.corba.se.pept.transport.ByteBufferPool;
    2.62  
    2.63 -import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry;
    2.64  import com.sun.corba.se.spi.protocol.CorbaClientDelegate;
    2.65  
    2.66  import com.sun.corba.se.spi.ior.IOR;
    2.67 @@ -99,9 +79,6 @@
    2.68  
    2.69  import com.sun.corba.se.spi.orb.ORB;
    2.70  import com.sun.corba.se.spi.orb.ORBVersionFactory;
    2.71 -import com.sun.corba.se.spi.orb.ORBVersion;
    2.72 -
    2.73 -import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
    2.74  
    2.75  import com.sun.corba.se.spi.logging.CORBALogDomains;
    2.76  import com.sun.corba.se.spi.presentation.rmi.PresentationManager;
    2.77 @@ -725,12 +702,14 @@
    2.78      //    IDLEntity.class.isAssignableFrom( clz ).
    2.79      // 3. If clz is an interface, use it to create the appropriate
    2.80      //    stub factory.
    2.81 +
    2.82      public org.omg.CORBA.Object read_Object(Class clz)
    2.83      {
    2.84          // In any case, we must first read the IOR.
    2.85          IOR ior = IORFactories.makeIOR(parent) ;
    2.86 -        if (ior.isNil())
    2.87 +        if (ior.isNil()) {
    2.88              return null ;
    2.89 +        }
    2.90  
    2.91          PresentationManager.StubFactoryFactory sff = ORB.getStubFactoryFactory() ;
    2.92          String codeBase = ior.getProfile().getCodebase() ;
    2.93 @@ -739,6 +718,7 @@
    2.94          if (clz == null) {
    2.95              RepositoryId rid = RepositoryId.cache.getId( ior.getTypeId() ) ;
    2.96              String className = rid.getClassName() ;
    2.97 +            orb.validateIORClass(className);
    2.98              boolean isIDLInterface = rid.isIDLType() ;
    2.99  
   2.100              if (className == null || className.equals( "" ))
   2.101 @@ -761,11 +741,9 @@
   2.102          } else {
   2.103              // clz is an interface class
   2.104              boolean isIDL = IDLEntity.class.isAssignableFrom( clz ) ;
   2.105 -
   2.106              stubFactory = sff.createStubFactory( clz.getName(),
   2.107                  isIDL, codeBase, clz, clz.getClassLoader() ) ;
   2.108          }
   2.109 -
   2.110          return internalIORToObject( ior, stubFactory, orb ) ;
   2.111      }
   2.112  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/share/classes/com/sun/corba/se/impl/ior/IORTypeCheckRegistryImpl.java	Tue Sep 12 16:53:35 2017 +0100
     3.3 @@ -0,0 +1,180 @@
     3.4 +/*
     3.5 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.  Oracle designates this
    3.11 + * particular file as subject to the "Classpath" exception as provided
    3.12 + * by Oracle in the LICENSE file that accompanied this code.
    3.13 + *
    3.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.17 + * version 2 for more details (a copy is included in the LICENSE file that
    3.18 + * accompanied this code).
    3.19 + *
    3.20 + * You should have received a copy of the GNU General Public License version
    3.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.23 + *
    3.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.25 + * or visit www.oracle.com if you need additional information or have any
    3.26 + * questions.
    3.27 + */
    3.28 +
    3.29 +package com.sun.corba.se.impl.ior;
    3.30 +
    3.31 +import java.util.Arrays;
    3.32 +import java.util.Collections;
    3.33 +import java.util.HashSet;
    3.34 +import java.util.Set;
    3.35 +
    3.36 +import com.sun.corba.se.impl.orbutil.ORBUtility;
    3.37 +import com.sun.corba.se.spi.ior.IORTypeCheckRegistry;
    3.38 +import com.sun.corba.se.spi.orb.ORB;
    3.39 +
    3.40 +public class IORTypeCheckRegistryImpl implements IORTypeCheckRegistry {
    3.41 +
    3.42 +    private final Set<String> iorTypeNames;
    3.43 +    private static final Set<String> builtinIorTypeNames;
    3.44 +    private ORB theOrb;
    3.45 +
    3.46 +    static {
    3.47 +        builtinIorTypeNames = initBuiltinIorTypeNames();
    3.48 +    }
    3.49 +
    3.50 +    public IORTypeCheckRegistryImpl(String filterProperties, ORB orb) {
    3.51 +        theOrb = orb;
    3.52 +        iorTypeNames = parseIorClassNameList(filterProperties);
    3.53 +    }
    3.54 +
    3.55 +    /*
    3.56 +     *
    3.57 +     * A note on the validation flow:
    3.58 +     * 1. against the filter class name list
    3.59 +     * 2. against the builtin class name list
    3.60 +     */
    3.61 +    @Override
    3.62 +    public boolean isValidIORType(String iorClassName) {
    3.63 +        dprintTransport(".isValidIORType : iorClassName == " + iorClassName);
    3.64 +        return validateIorTypeByName(iorClassName);
    3.65 +    }
    3.66 +
    3.67 +
    3.68 +    private boolean validateIorTypeByName(String iorClassName) {
    3.69 +        dprintTransport(".validateIorTypeByName : iorClassName == " + iorClassName);
    3.70 +        boolean isValidType;
    3.71 +
    3.72 +        isValidType = checkIorTypeNames(iorClassName);
    3.73 +
    3.74 +        if (!isValidType) {
    3.75 +            isValidType = checkBuiltinClassNames(iorClassName);
    3.76 +        }
    3.77 +
    3.78 +        dprintTransport(".validateIorTypeByName : isValidType == " + isValidType);
    3.79 +        return isValidType;
    3.80 +    }
    3.81 +
    3.82 +
    3.83 +    /*
    3.84 +     * check if the class name corresponding to an IOR Type name
    3.85 +     * is in the ior class name list as generated from the filter property.
    3.86 +     * So if the IOR type is recorded in the registry then allow the creation of the
    3.87 +     * stub factory and let it resolve and load the class. That is if current
    3.88 +     * type check deliberation permits.
    3.89 +     * IOR Type names are configured by the filter property
    3.90 +     */
    3.91 +    private boolean checkIorTypeNames(
    3.92 +            String theIorClassName) {
    3.93 +        return (iorTypeNames != null) && (iorTypeNames.contains(theIorClassName));
    3.94 +    }
    3.95 +
    3.96 +    /*
    3.97 +     * Check the IOR interface class name against the set of
    3.98 +     * class names that correspond to the builtin JDK IDL stub classes.
    3.99 +     */
   3.100 +    private boolean checkBuiltinClassNames(
   3.101 +            String theIorClassName) {
   3.102 +        return builtinIorTypeNames.contains(theIorClassName);
   3.103 +    }
   3.104 +
   3.105 +    private Set<String> parseIorClassNameList(String filterProperty) {
   3.106 +        Set<String> _iorTypeNames = null;
   3.107 +        if (filterProperty != null) {
   3.108 +            String[] tempIorClassNames = filterProperty.split(";");
   3.109 +            _iorTypeNames = Collections.unmodifiableSet(new HashSet<>(Arrays
   3.110 +                    .asList(tempIorClassNames)));
   3.111 +            if (theOrb.orbInitDebugFlag) {
   3.112 +                dprintConfiguredIorTypeNames();
   3.113 +            }
   3.114 +        }
   3.115 +        return _iorTypeNames;
   3.116 +    }
   3.117 +
   3.118 +    private static Set<String> initBuiltinIorTypeNames() {
   3.119 +        Set<Class<?>> builtInCorbaStubTypes = initBuiltInCorbaStubTypes();
   3.120 +        String[] tempBuiltinIorTypeNames = new String[builtInCorbaStubTypes.size()];
   3.121 +        int i = 0;
   3.122 +        for (Class<?> _stubClass : builtInCorbaStubTypes) {
   3.123 +            tempBuiltinIorTypeNames[i++] = _stubClass.getName();
   3.124 +        }
   3.125 +        return Collections.unmodifiableSet(new HashSet<>(Arrays
   3.126 +                .asList(tempBuiltinIorTypeNames)));
   3.127 +    }
   3.128 +
   3.129 +    private static Set<Class<?>> initBuiltInCorbaStubTypes() {
   3.130 +        Class<?> tempBuiltinCorbaStubTypes[] = {
   3.131 +            com.sun.corba.se.spi.activation.Activator.class,
   3.132 +            com.sun.corba.se.spi.activation._ActivatorStub.class,
   3.133 +            com.sun.corba.se.spi.activation._InitialNameServiceStub.class,
   3.134 +            com.sun.corba.se.spi.activation._LocatorStub.class,
   3.135 +            com.sun.corba.se.spi.activation._RepositoryStub.class,
   3.136 +            com.sun.corba.se.spi.activation._ServerManagerStub.class,
   3.137 +            com.sun.corba.se.spi.activation._ServerStub.class,
   3.138 +            org.omg.CosNaming.BindingIterator.class,
   3.139 +            org.omg.CosNaming._BindingIteratorStub.class,
   3.140 +            org.omg.CosNaming.NamingContextExt.class,
   3.141 +            org.omg.CosNaming._NamingContextExtStub.class,
   3.142 +            org.omg.CosNaming.NamingContext.class,
   3.143 +            org.omg.CosNaming._NamingContextStub.class,
   3.144 +            org.omg.DynamicAny.DynAnyFactory.class,
   3.145 +            org.omg.DynamicAny._DynAnyFactoryStub.class,
   3.146 +            org.omg.DynamicAny.DynAny.class,
   3.147 +            org.omg.DynamicAny._DynAnyStub.class,
   3.148 +            org.omg.DynamicAny.DynArray.class,
   3.149 +            org.omg.DynamicAny._DynArrayStub.class,
   3.150 +            org.omg.DynamicAny.DynEnum.class,
   3.151 +            org.omg.DynamicAny._DynEnumStub.class,
   3.152 +            org.omg.DynamicAny.DynFixed.class,
   3.153 +            org.omg.DynamicAny._DynFixedStub.class,
   3.154 +            org.omg.DynamicAny.DynSequence.class,
   3.155 +            org.omg.DynamicAny._DynSequenceStub.class,
   3.156 +            org.omg.DynamicAny.DynStruct.class,
   3.157 +            org.omg.DynamicAny._DynStructStub.class,
   3.158 +            org.omg.DynamicAny.DynUnion.class,
   3.159 +            org.omg.DynamicAny._DynUnionStub.class,
   3.160 +            org.omg.DynamicAny._DynValueStub.class,
   3.161 +            org.omg.DynamicAny.DynValue.class,
   3.162 +            org.omg.PortableServer.ServantActivator.class,
   3.163 +            org.omg.PortableServer._ServantActivatorStub.class,
   3.164 +            org.omg.PortableServer.ServantLocator.class,
   3.165 +            org.omg.PortableServer._ServantLocatorStub.class};
   3.166 +        return new HashSet<>(
   3.167 +                Arrays.asList(tempBuiltinCorbaStubTypes));
   3.168 +    }
   3.169 +
   3.170 +    private void dprintConfiguredIorTypeNames() {
   3.171 +        if (iorTypeNames != null) {
   3.172 +            for (String iorTypeName : iorTypeNames) {
   3.173 +                ORBUtility.dprint(this, ".dprintConfiguredIorTypeNames: " + iorTypeName);
   3.174 +            }
   3.175 +        }
   3.176 +    }
   3.177 +
   3.178 +    private void dprintTransport(String msg) {
   3.179 +        if (theOrb.transportDebugFlag) {
   3.180 +            ORBUtility.dprint(this, msg);
   3.181 +        }
   3.182 +    }
   3.183 +}
     4.1 --- a/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java	Tue Aug 08 12:01:59 2017 +0100
     4.2 +++ b/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java	Tue Sep 12 16:53:35 2017 +0100
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -32,37 +32,25 @@
    4.11  import java.lang.reflect.Constructor;
    4.12  import java.lang.reflect.Field;
    4.13  import java.lang.reflect.Modifier;
    4.14 -import java.lang.reflect.InvocationTargetException;
    4.15  
    4.16  import java.util.Set;
    4.17  import java.util.HashSet;
    4.18 -import java.util.ArrayList;
    4.19 -import java.util.Iterator;
    4.20  import java.util.Properties;
    4.21  import java.util.Vector;
    4.22  import java.util.Hashtable;
    4.23  import java.util.Map;
    4.24 -import java.util.HashMap;
    4.25 -import java.util.LinkedList;
    4.26 -import java.util.Collection;
    4.27  import java.util.Collections;
    4.28 -import java.util.StringTokenizer;
    4.29  import java.util.Enumeration;
    4.30  import java.util.WeakHashMap;
    4.31  
    4.32  import java.net.InetAddress;
    4.33  
    4.34  import java.security.PrivilegedAction;
    4.35 +import java.security.Security;
    4.36  import java.security.AccessController;
    4.37  
    4.38 -import javax.rmi.CORBA.Util;
    4.39  import javax.rmi.CORBA.ValueHandler;
    4.40  
    4.41 -import org.omg.CORBA.Context;
    4.42 -import org.omg.CORBA.ContextList;
    4.43 -import org.omg.CORBA.Environment;
    4.44 -import org.omg.CORBA.ExceptionList;
    4.45 -import org.omg.CORBA.ORBPackage.InvalidName;
    4.46  import org.omg.CORBA.NVList;
    4.47  import org.omg.CORBA.TCKind;
    4.48  import org.omg.CORBA.NamedValue;
    4.49 @@ -75,7 +63,6 @@
    4.50  import org.omg.CORBA.UnionMember;
    4.51  import org.omg.CORBA.ValueMember;
    4.52  import org.omg.CORBA.BAD_PARAM;
    4.53 -import org.omg.CORBA.MARSHAL;
    4.54  
    4.55  import org.omg.CORBA.portable.ValueFactory;
    4.56  
    4.57 @@ -83,10 +70,7 @@
    4.58  
    4.59  import com.sun.org.omg.SendingContext.CodeBase;
    4.60  
    4.61 -import com.sun.corba.se.pept.broker.Broker;
    4.62  import com.sun.corba.se.pept.protocol.ClientInvocationInfo;
    4.63 -import com.sun.corba.se.pept.transport.ContactInfo;
    4.64 -import com.sun.corba.se.pept.transport.ConnectionCache;
    4.65  import com.sun.corba.se.pept.transport.TransportManager;
    4.66  
    4.67  import com.sun.corba.se.spi.ior.IOR;
    4.68 @@ -95,8 +79,6 @@
    4.69  import com.sun.corba.se.spi.ior.IORFactories;
    4.70  import com.sun.corba.se.spi.ior.ObjectKey;
    4.71  import com.sun.corba.se.spi.ior.ObjectKeyFactory;
    4.72 -import com.sun.corba.se.spi.ior.iiop.IIOPFactories;
    4.73 -import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
    4.74  import com.sun.corba.se.spi.oa.OAInvocationInfo;
    4.75  import com.sun.corba.se.spi.oa.ObjectAdapterFactory;
    4.76  import com.sun.corba.se.spi.orb.DataCollector;
    4.77 @@ -113,24 +95,18 @@
    4.78  import com.sun.corba.se.spi.protocol.ClientDelegateFactory;
    4.79  import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry;
    4.80  import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher;
    4.81 -import com.sun.corba.se.spi.protocol.RequestDispatcherDefault;
    4.82  import com.sun.corba.se.spi.protocol.PIHandler;
    4.83 -import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
    4.84 -import com.sun.corba.se.spi.protocol.ForwardException;
    4.85  import com.sun.corba.se.spi.resolver.Resolver;
    4.86  import com.sun.corba.se.spi.resolver.LocalResolver;
    4.87 -import com.sun.corba.se.spi.orb.StringPair;
    4.88 -import com.sun.corba.se.spi.orb.StringPair;
    4.89  import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory;
    4.90  import com.sun.corba.se.spi.transport.CorbaTransportManager;
    4.91 +import com.sun.corba.se.spi.ior.IORTypeCheckRegistry;
    4.92  import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
    4.93 +import com.sun.corba.se.spi.logging.CORBALogDomains;
    4.94  import com.sun.corba.se.spi.copyobject.CopierManager;
    4.95 -import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults;
    4.96 -import com.sun.corba.se.spi.presentation.rmi.PresentationManager;
    4.97  import com.sun.corba.se.spi.presentation.rmi.StubAdapter;
    4.98  import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry;
    4.99  
   4.100 -import com.sun.corba.se.impl.corba.TypeCodeFactory;
   4.101  import com.sun.corba.se.impl.corba.TypeCodeImpl;
   4.102  import com.sun.corba.se.impl.corba.NVListImpl;
   4.103  import com.sun.corba.se.impl.corba.ExceptionListImpl;
   4.104 @@ -139,9 +115,6 @@
   4.105  import com.sun.corba.se.impl.corba.EnvironmentImpl;
   4.106  import com.sun.corba.se.impl.corba.AsynchInvoke;
   4.107  import com.sun.corba.se.impl.corba.AnyImpl;
   4.108 -import com.sun.corba.se.impl.corba.RequestImpl;
   4.109 -import com.sun.corba.se.impl.dynamicany.DynAnyFactoryImpl;
   4.110 -import com.sun.corba.se.impl.encoding.EncapsOutputStream;
   4.111  import com.sun.corba.se.impl.encoding.CachedCodeBase;
   4.112  import com.sun.corba.se.impl.interceptors.PIHandlerImpl;
   4.113  import com.sun.corba.se.impl.interceptors.PINoOpHandlerImpl;
   4.114 @@ -150,12 +123,10 @@
   4.115  import com.sun.corba.se.impl.ior.TaggedProfileTemplateFactoryFinderImpl;
   4.116  import com.sun.corba.se.impl.oa.toa.TOAFactory;
   4.117  import com.sun.corba.se.impl.oa.poa.BadServerIdHandler;
   4.118 -import com.sun.corba.se.impl.oa.poa.DelegateImpl;
   4.119  import com.sun.corba.se.impl.oa.poa.POAFactory;
   4.120  import com.sun.corba.se.impl.orbutil.ORBConstants;
   4.121  import com.sun.corba.se.impl.orbutil.ORBUtility;
   4.122  import com.sun.corba.se.impl.orbutil.StackImpl;
   4.123 -import com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl;
   4.124  import com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolManagerImpl;
   4.125  import com.sun.corba.se.impl.protocol.RequestDispatcherRegistryImpl;
   4.126  import com.sun.corba.se.impl.protocol.CorbaInvocationInfo;
   4.127 @@ -164,7 +135,7 @@
   4.128  import com.sun.corba.se.impl.util.Utility;
   4.129  import com.sun.corba.se.impl.logging.ORBUtilSystemException;
   4.130  import com.sun.corba.se.impl.copyobject.CopierManagerImpl;
   4.131 -import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl;
   4.132 +import com.sun.corba.se.impl.ior.IORTypeCheckRegistryImpl;
   4.133  
   4.134  /**
   4.135   * The JavaIDL ORB implementation.
   4.136 @@ -226,6 +197,8 @@
   4.137  
   4.138      private ServiceContextRegistry serviceContextRegistry ;
   4.139  
   4.140 +    private IORTypeCheckRegistry iorTypeCheckRegistry;
   4.141 +
   4.142      // Needed here to implement connect/disconnect
   4.143      private TOAFactory toaFactory ;
   4.144  
   4.145 @@ -274,6 +247,8 @@
   4.146      // insNamingDelegate.
   4.147      private final Object resolverLock = new Object() ;
   4.148  
   4.149 +    private static final String IORTYPECHECKREGISTRY_FILTER_PROPNAME = "com.sun.CORBA.ORBIorTypeCheckRegistryFilter";
   4.150 +
   4.151      private TaggedComponentFactoryFinder taggedComponentFactoryFinder ;
   4.152  
   4.153      private IdentifiableFactoryFinder taggedProfileFactoryFinder ;
   4.154 @@ -413,6 +388,37 @@
   4.155          serviceContextRegistry = new ServiceContextRegistry( this ) ;
   4.156      }
   4.157  
   4.158 +    private void initIORTypeCheckRegistry() {
   4.159 +        String filterProps = AccessController
   4.160 +                .doPrivileged(new PrivilegedAction<String>() {
   4.161 +                    public String run() {
   4.162 +                        String props = System
   4.163 +                                .getProperty(IORTYPECHECKREGISTRY_FILTER_PROPNAME);
   4.164 +                        if (props == null) {
   4.165 +                            props = Security
   4.166 +                                    .getProperty(IORTYPECHECKREGISTRY_FILTER_PROPNAME);
   4.167 +                        }
   4.168 +                        return props;
   4.169 +                    }
   4.170 +                });
   4.171 +        if (filterProps != null) {
   4.172 +            try {
   4.173 +                iorTypeCheckRegistry = new IORTypeCheckRegistryImpl(filterProps, this);
   4.174 +            } catch (Exception ex) {
   4.175 +                throw wrapper.bootstrapException(ex);
   4.176 +            }
   4.177 +
   4.178 +            if (this.orbInitDebugFlag) {
   4.179 +                dprint(".initIORTypeCheckRegistry, IORTypeCheckRegistryImpl created for properties == "
   4.180 +                        + filterProps);
   4.181 +            }
   4.182 +        } else {
   4.183 +            if (this.orbInitDebugFlag) {
   4.184 +                dprint(".initIORTypeCheckRegistry, IORTypeCheckRegistryImpl NOT created for properties == ");
   4.185 +            }
   4.186 +        }
   4.187 +    }
   4.188 +
   4.189      protected void setDebugFlags( String[] args )
   4.190      {
   4.191          for (int ctr=0; ctr<args.length; ctr++ ) {
   4.192 @@ -494,6 +500,8 @@
   4.193          getThreadPoolManager();
   4.194  
   4.195          super.getByteBufferPool();
   4.196 +
   4.197 +        initIORTypeCheckRegistry();
   4.198      }
   4.199  
   4.200      private synchronized POAFactory getPOAFactory()
   4.201 @@ -2089,6 +2097,17 @@
   4.202          }
   4.203          return copierManager ;
   4.204      }
   4.205 +
   4.206 +    @Override
   4.207 +    public void validateIORClass(String iorClassName) {
   4.208 +        if (iorTypeCheckRegistry != null) {
   4.209 +            if (!iorTypeCheckRegistry.isValidIORType(iorClassName)) {
   4.210 +                throw ORBUtilSystemException.get( this,
   4.211 +                        CORBALogDomains.OA_IOR ).badStringifiedIor();
   4.212 +            }
   4.213 +        }
   4.214 +    }
   4.215 +
   4.216  } // Class ORBImpl
   4.217  
   4.218  ////////////////////////////////////////////////////////////////////////
     5.1 --- a/src/share/classes/com/sun/corba/se/impl/orb/ORBSingleton.java	Tue Aug 08 12:01:59 2017 +0100
     5.2 +++ b/src/share/classes/com/sun/corba/se/impl/orb/ORBSingleton.java	Tue Sep 12 16:53:35 2017 +0100
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -31,28 +31,16 @@
    5.11  
    5.12  package com.sun.corba.se.impl.orb;
    5.13  
    5.14 -import java.util.Collection;
    5.15  import java.util.Properties;
    5.16 -import java.util.Hashtable;
    5.17  
    5.18  import java.applet.Applet;
    5.19  
    5.20  import java.net.URL;
    5.21  
    5.22 -import java.io.IOException ;
    5.23 -
    5.24 -import java.util.logging.Logger ;
    5.25 -
    5.26 -import org.omg.CORBA.Context;
    5.27 -import org.omg.CORBA.ContextList;
    5.28 -import org.omg.CORBA.Environment;
    5.29 -import org.omg.CORBA.ExceptionList;
    5.30  import org.omg.CORBA.ORBPackage.InvalidName;
    5.31  import org.omg.CORBA.NVList;
    5.32  import org.omg.CORBA.TCKind;
    5.33 -import org.omg.CORBA.NamedValue;
    5.34  import org.omg.CORBA.NO_IMPLEMENT;
    5.35 -import org.omg.CORBA.Object;
    5.36  import org.omg.CORBA.Request;
    5.37  import org.omg.CORBA.TypeCode;
    5.38  import org.omg.CORBA.Any;
    5.39 @@ -63,7 +51,6 @@
    5.40  import org.omg.CORBA.PolicyError;
    5.41  
    5.42  import org.omg.CORBA.portable.OutputStream;
    5.43 -import org.omg.CORBA.portable.RemarshalException;
    5.44  
    5.45  import com.sun.corba.se.pept.protocol.ClientInvocationInfo ;
    5.46  import com.sun.corba.se.pept.transport.ContactInfo;
    5.47 @@ -71,15 +58,12 @@
    5.48  import com.sun.corba.se.pept.transport.Selector ;
    5.49  import com.sun.corba.se.pept.transport.TransportManager;
    5.50  
    5.51 -import com.sun.corba.se.spi.legacy.connection.ORBSocketFactory;
    5.52  import com.sun.corba.se.spi.orb.ORBData;
    5.53  import com.sun.corba.se.spi.orb.Operation;
    5.54  import com.sun.corba.se.spi.orb.ORB;
    5.55  import com.sun.corba.se.spi.orb.ORBVersion;
    5.56  import com.sun.corba.se.spi.orb.ORBVersionFactory;
    5.57  import com.sun.corba.se.spi.oa.OAInvocationInfo;
    5.58 -import com.sun.corba.se.spi.oa.ObjectAdapter;
    5.59 -import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
    5.60  import com.sun.corba.se.spi.protocol.ClientDelegateFactory;
    5.61  import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry;
    5.62  import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher;
    5.63 @@ -92,22 +76,17 @@
    5.64  import com.sun.corba.se.spi.ior.ObjectKey;
    5.65  import com.sun.corba.se.spi.ior.ObjectKeyFactory;
    5.66  import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
    5.67 -import com.sun.corba.se.pept.transport.ByteBufferPool ;
    5.68  import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory ;
    5.69  import com.sun.corba.se.spi.transport.CorbaTransportManager;
    5.70  import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
    5.71  import com.sun.corba.se.spi.orbutil.closure.Closure;
    5.72  import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
    5.73 -import com.sun.corba.se.spi.logging.LogWrapperFactory;
    5.74 -import com.sun.corba.se.spi.logging.LogWrapperBase;
    5.75  import com.sun.corba.se.spi.copyobject.CopierManager;
    5.76  import com.sun.corba.se.spi.presentation.rmi.PresentationManager;
    5.77  import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults;
    5.78  
    5.79  import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry;
    5.80 -import com.sun.corba.se.spi.servicecontext.ServiceContexts;
    5.81  
    5.82 -import com.sun.corba.se.impl.corba.TypeCodeFactory;
    5.83  import com.sun.corba.se.impl.corba.TypeCodeImpl;
    5.84  import com.sun.corba.se.impl.corba.NVListImpl;
    5.85  import com.sun.corba.se.impl.corba.NamedValueImpl;
    5.86 @@ -117,9 +96,6 @@
    5.87  import com.sun.corba.se.impl.corba.AnyImpl;
    5.88  import com.sun.corba.se.impl.encoding.BufferManagerFactory;
    5.89  import com.sun.corba.se.impl.encoding.CodeSetComponentInfo;
    5.90 -import com.sun.corba.se.impl.encoding.MarshalInputStream;
    5.91 -import com.sun.corba.se.impl.encoding.EncapsOutputStream;
    5.92 -import com.sun.corba.se.impl.encoding.MarshalOutputStream;
    5.93  import com.sun.corba.se.impl.oa.poa.BadServerIdHandler;
    5.94  import com.sun.corba.se.impl.orbutil.ORBConstants;
    5.95  import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
    5.96 @@ -768,6 +744,12 @@
    5.97      public CopierManager getCopierManager() {
    5.98          return null ;
    5.99      }
   5.100 +
   5.101 +    @Override
   5.102 +    public void validateIORClass(String iorClassName) {
   5.103 +        getFullORB().validateIORClass(iorClassName);
   5.104 +    }
   5.105 +
   5.106  }
   5.107  
   5.108  // End of file.
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/share/classes/com/sun/corba/se/spi/ior/IORTypeCheckRegistry.java	Tue Sep 12 16:53:35 2017 +0100
     6.3 @@ -0,0 +1,31 @@
     6.4 +/*
     6.5 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.  Oracle designates this
    6.11 + * particular file as subject to the "Classpath" exception as provided
    6.12 + * by Oracle in the LICENSE file that accompanied this code.
    6.13 + *
    6.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.17 + * version 2 for more details (a copy is included in the LICENSE file that
    6.18 + * accompanied this code).
    6.19 + *
    6.20 + * You should have received a copy of the GNU General Public License version
    6.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.23 + *
    6.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.25 + * or visit www.oracle.com if you need additional information or have any
    6.26 + * questions.
    6.27 + */
    6.28 +
    6.29 +package com.sun.corba.se.spi.ior;
    6.30 +
    6.31 +public interface IORTypeCheckRegistry {
    6.32 +    public boolean isValidIORType(String iorClassName);
    6.33 +}
    6.34 +
     7.1 --- a/src/share/classes/com/sun/corba/se/spi/orb/ORB.java	Tue Aug 08 12:01:59 2017 +0100
     7.2 +++ b/src/share/classes/com/sun/corba/se/spi/orb/ORB.java	Tue Sep 12 16:53:35 2017 +0100
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -42,16 +42,13 @@
    7.11  import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry ;
    7.12  import com.sun.corba.se.spi.protocol.ClientDelegateFactory ;
    7.13  import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher ;
    7.14 -import com.sun.corba.se.spi.protocol.CorbaMessageMediator ;
    7.15  import com.sun.corba.se.spi.protocol.PIHandler ;
    7.16  import com.sun.corba.se.spi.resolver.LocalResolver ;
    7.17  import com.sun.corba.se.spi.resolver.Resolver ;
    7.18  import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory ;
    7.19 -import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
    7.20  import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
    7.21  import com.sun.corba.se.spi.monitoring.MonitoringConstants;
    7.22  import com.sun.corba.se.spi.monitoring.MonitoringManager;
    7.23 -import com.sun.corba.se.spi.monitoring.MonitoringManagerFactory;
    7.24  import com.sun.corba.se.spi.monitoring.MonitoringFactories;
    7.25  
    7.26  import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder ;
    7.27 @@ -60,8 +57,6 @@
    7.28  import com.sun.corba.se.spi.ior.ObjectKeyFactory ;
    7.29  import com.sun.corba.se.spi.ior.IOR ;
    7.30  
    7.31 -import com.sun.corba.se.spi.orbutil.closure.Closure ;
    7.32 -
    7.33  import com.sun.corba.se.spi.orb.Operation ;
    7.34  import com.sun.corba.se.spi.orb.ORBData ;
    7.35  import com.sun.corba.se.spi.orb.ORBVersion ;
    7.36 @@ -135,6 +130,7 @@
    7.37      public boolean shutdownDebugFlag = false;
    7.38      public boolean giopDebugFlag = false;
    7.39      public boolean invocationTimingDebugFlag = false ;
    7.40 +    public boolean orbInitDebugFlag = false;
    7.41  
    7.42      // SystemException log wrappers.  Protected so that they can be used in
    7.43      // subclasses.
    7.44 @@ -564,6 +560,24 @@
    7.45      public abstract ThreadPoolManager getThreadPoolManager();
    7.46  
    7.47      public abstract CopierManager getCopierManager() ;
    7.48 +
    7.49 +    /*
    7.50 +     * This method is called to verify that a stringified IOR passed to
    7.51 +     * an org.omg.CORBA.ORB::string_to_object method contains a valid and acceptable IOR type.
    7.52 +     * If an ORB is configured with IOR type checking enabled,
    7.53 +     * the ORB executes a IOR type registry lookup to
    7.54 +     * validate that the class name extract from a type id in
    7.55 +     * a stringified IOR is a known and accepted type.
    7.56 +     * A CORBA {@code org.omg.CORBA.DATA_CONVERSION} exception will be thrown should the type check fail.
    7.57 +     *
    7.58 +     * @param iorClassName
    7.59 +     *        a string representing the class name corresponding to the type id of an IOR
    7.60 +     * @throws org.omg.CORBA.DATA_CONVERSION
    7.61 +     *           exception with an indication that it is a "Bad stringified IOR", which is thrown
    7.62 +     *           when the type check fails.
    7.63 +     */
    7.64 +    public abstract void validateIORClass(String iorClassName);
    7.65 +
    7.66  }
    7.67  
    7.68  // End of file.

mercurial