1 /*
   2  * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.corba.se.impl.orb ;
  27 
  28 import java.net.URL ;
  29 import java.net.InetSocketAddress;
  30 import java.net.Socket ;
  31 import java.net.ServerSocket ;
  32 
  33 import java.io.IOException ;
  34 
  35 import java.util.HashMap ;
  36 import java.util.List;
  37 import java.util.Map ;
  38 
  39 import java.security.AccessController ;
  40 import java.security.PrivilegedExceptionAction ;
  41 import java.security.PrivilegedActionException ;
  42 
  43 import org.omg.PortableInterceptor.ORBInitializer ;
  44 import org.omg.PortableInterceptor.ORBInitInfo ;
  45 
  46 import com.sun.corba.se.pept.broker.Broker;
  47 import com.sun.corba.se.pept.encoding.InputObject;
  48 import com.sun.corba.se.pept.encoding.OutputObject;
  49 import com.sun.corba.se.pept.protocol.MessageMediator;
  50 import com.sun.corba.se.pept.transport.Acceptor;
  51 import com.sun.corba.se.pept.transport.Connection;
  52 import com.sun.corba.se.pept.transport.ContactInfo;
  53 import com.sun.corba.se.pept.transport.ContactInfoList;
  54 import com.sun.corba.se.pept.transport.EventHandler;
  55 import com.sun.corba.se.pept.transport.InboundConnectionCache;
  56 
  57 import com.sun.corba.se.spi.ior.IOR ;
  58 import com.sun.corba.se.spi.ior.ObjectKey ;
  59 import com.sun.corba.se.spi.ior.iiop.GIOPVersion ;
  60 import com.sun.corba.se.spi.logging.CORBALogDomains ;
  61 import com.sun.corba.se.spi.orb.ORB;
  62 import com.sun.corba.se.spi.orb.Operation ;
  63 import com.sun.corba.se.spi.orb.OperationFactory ;
  64 import com.sun.corba.se.spi.orb.ParserData ;
  65 import com.sun.corba.se.spi.orb.ParserDataFactory ;
  66 import com.sun.corba.se.spi.orb.StringPair ;
  67 import com.sun.corba.se.spi.transport.CorbaContactInfoList;
  68 import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory;
  69 import com.sun.corba.se.spi.transport.CorbaTransportManager;
  70 import com.sun.corba.se.spi.transport.IORToSocketInfo;
  71 import com.sun.corba.se.spi.transport.ReadTimeouts;
  72 import com.sun.corba.se.spi.transport.SocketInfo;
  73 import com.sun.corba.se.spi.transport.IIOPPrimaryToContactInfo;
  74 import com.sun.corba.se.spi.transport.TransportDefault;
  75 
  76 import com.sun.corba.se.impl.encoding.CodeSetComponentInfo ;
  77 import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry ;
  78 import com.sun.corba.se.impl.legacy.connection.USLPort ;
  79 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
  80 import com.sun.corba.se.impl.oa.poa.BadServerIdHandler ;
  81 import com.sun.corba.se.impl.orbutil.ORBClassLoader ;
  82 import com.sun.corba.se.impl.orbutil.ORBConstants ;
  83 import com.sun.corba.se.impl.protocol.giopmsgheaders.KeyAddr ;
  84 import com.sun.corba.se.impl.protocol.giopmsgheaders.ProfileAddr ;
  85 import com.sun.corba.se.impl.protocol.giopmsgheaders.ReferenceAddr ;
  86 import com.sun.corba.se.impl.transport.DefaultIORToSocketInfoImpl;
  87 import com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl;
  88 
  89 /** Initialize the parser data for the standard ORB parser.  This is used both
  90  * to implement ORBDataParserImpl and to provide the basic testing framework
  91  * for ORBDataParserImpl.
  92  */
  93 public class ParserTable {
  94     private static String MY_CLASS_NAME = ParserTable.class.getName() ;
  95 
  96     private static ParserTable myInstance = new ParserTable() ;
  97 
  98     private ORBUtilSystemException wrapper ;
  99 
 100     public static ParserTable get()
 101     {
 102         return myInstance ;
 103     }
 104 
 105     private ParserData[] parserData ;
 106 
 107     public ParserData[] getParserData()
 108     {
 109         ParserData[] parserArray = new ParserData[parserData.length];
 110         System.arraycopy(parserData, 0, parserArray, 0, parserData.length);
 111         return parserArray;
 112     }
 113 
 114     private ParserTable() {
 115         wrapper = ORBUtilSystemException.get( CORBALogDomains.ORB_LIFECYCLE ) ;
 116 
 117         String codeSetTestString =
 118             OSFCodeSetRegistry.ISO_8859_1_VALUE + "," +
 119             OSFCodeSetRegistry.UTF_16_VALUE + "," +
 120             OSFCodeSetRegistry.ISO_646_VALUE ;
 121 
 122         String[] debugTestData = { "subcontract", "poa", "transport" } ;
 123 
 124         USLPort[] USLPorts = { new USLPort( "FOO", 2701 ), new USLPort( "BAR", 3333 ) } ;
 125 
 126         ReadTimeouts readTimeouts =
 127                TransportDefault.makeReadTimeoutsFactory().create(
 128                     ORBConstants.TRANSPORT_TCP_INITIAL_TIME_TO_WAIT,
 129                     ORBConstants.TRANSPORT_TCP_MAX_TIME_TO_WAIT,
 130                     ORBConstants.TRANSPORT_TCP_GIOP_HEADER_MAX_TIME_TO_WAIT,
 131                     ORBConstants.TRANSPORT_TCP_TIME_TO_WAIT_BACKOFF_FACTOR);
 132 
 133         ORBInitializer[] TestORBInitializers =
 134             { null,
 135               new TestORBInitializer1(),
 136               new TestORBInitializer2() }  ;
 137         StringPair[] TestORBInitData = {
 138             new StringPair( "foo.bar.blech.NonExistent", "dummy" ),
 139             new StringPair( MY_CLASS_NAME + "$TestORBInitializer1", "dummy" ),
 140             new StringPair( MY_CLASS_NAME + "$TestORBInitializer2", "dummy" ) } ;
 141 
 142         Acceptor[] TestAcceptors =
 143             { new TestAcceptor2(),
 144               new TestAcceptor1(),
 145               null }  ;
 146         // REVISIT: The test data gets put into a Properties object where
 147         // order is not guaranteed.  Thus the above array is in reverse.
 148         StringPair[] TestAcceptorData = {
 149             new StringPair( "foo.bar.blech.NonExistent", "dummy" ),
 150             new StringPair( MY_CLASS_NAME + "$TestAcceptor1", "dummy" ),
 151             new StringPair( MY_CLASS_NAME + "$TestAcceptor2", "dummy" ) } ;
 152 
 153         StringPair[] TestORBInitRefData =
 154             { new StringPair( "Foo", "ior:930492049394" ),
 155               new StringPair( "Bar", "ior:3453465785633576" ) } ;
 156 
 157         URL testServicesURL = null ;
 158         String testServicesString = "corbaloc::camelot/NameService" ;
 159 
 160         try {
 161             testServicesURL = new URL( testServicesString )  ;
 162         } catch (Exception exc) {
 163         }
 164 
 165         // propertyName,
 166         // operation,
 167         // fieldName, defaultValue,
 168         // testValue, testData (string or Pair[])
 169         ParserData[] pd = {
 170             ParserDataFactory.make( ORBConstants.DEBUG_PROPERTY,
 171                 OperationFactory.listAction( ",", OperationFactory.stringAction()),
 172                 "debugFlags", new String[0],
 173                 debugTestData, "subcontract,poa,transport" ),
 174             ParserDataFactory.make( ORBConstants.INITIAL_HOST_PROPERTY,
 175                 OperationFactory.stringAction(),
 176                 "ORBInitialHost", "",
 177                 "Foo", "Foo" ),
 178             ParserDataFactory.make( ORBConstants.INITIAL_PORT_PROPERTY,
 179                 OperationFactory.integerAction(),
 180                 "ORBInitialPort", new Integer( ORBConstants.DEFAULT_INITIAL_PORT ),
 181                 new Integer( 27314 ), "27314" ),
 182             // Where did this come from?
 183             //ParserDataFactory.make( ORBConstants.INITIAL_PORT_PROPERTY,
 184                 //OperationFactory.booleanAction(),
 185                 //"ORBInitialPortInitialized", Boolean.FALSE,
 186                 //Boolean.TRUE, "27314" ),
 187             ParserDataFactory.make( ORBConstants.SERVER_HOST_PROPERTY,
 188                 OperationFactory.stringAction(),
 189                 "ORBServerHost", "",
 190                 "camelot", "camelot" ),
 191             ParserDataFactory.make( ORBConstants.SERVER_PORT_PROPERTY,
 192                 OperationFactory.integerAction(),
 193                 "ORBServerPort", new Integer( 0 ),
 194                 new Integer( 38143 ), "38143" ),
 195             // NOTE: We are putting SERVER_HOST_NAME configuration info into
 196             // DataCollectorBase to avoid a security hole.  However, that forces
 197             // us to also set LISTEN_ON_ALL_INTERFACES at the same time.
 198             // This all needs to be cleaned up for two reasons: to get configuration
 199             // out of DataCollectorBase and to correctly support multihoming.
 200             ParserDataFactory.make( ORBConstants.LISTEN_ON_ALL_INTERFACES,
 201                 OperationFactory.stringAction(),
 202                 "listenOnAllInterfaces", ORBConstants.LISTEN_ON_ALL_INTERFACES,
 203                 "foo", "foo" ),
 204             ParserDataFactory.make( ORBConstants.ORB_ID_PROPERTY,
 205                 OperationFactory.stringAction(),
 206                 "orbId", "",
 207                 "foo", "foo" ),
 208             ParserDataFactory.make( ORBConstants.OLD_ORB_ID_PROPERTY,
 209                 OperationFactory.stringAction(),
 210                 "orbId", "",
 211                 "foo", "foo" ),
 212             ParserDataFactory.make( ORBConstants.ORB_SERVER_ID_PROPERTY,
 213                 OperationFactory.integerAction(),
 214                 "persistentServerId", new Integer(-1),
 215                 new Integer( 1234), "1234" ),
 216             ParserDataFactory.make(
 217                 ORBConstants.ORB_SERVER_ID_PROPERTY,
 218                 OperationFactory.setFlagAction(),
 219                 "persistentServerIdInitialized", Boolean.FALSE,
 220                 Boolean.TRUE, "1234" ),
 221             ParserDataFactory.make(
 222                 ORBConstants.ORB_SERVER_ID_PROPERTY,
 223                 OperationFactory.setFlagAction(),
 224                 "orbServerIdPropertySpecified", Boolean.FALSE,
 225                 Boolean.TRUE, "1234" ),
 226             // REVISIT after switch
 227             // ParserDataFactory.make( ORBConstants.INITIAL_SERVICES_PROPERTY,
 228                 // OperationFactory.URLAction(),
 229                 // "servicesURL", null,
 230                 // testServicesURL, testServicesString ),
 231             // ParserDataFactory.make( ORBConstants.DEFAULT_INIT_REF_PROPERTY,
 232                 // OperationFactory.stringAction(),
 233                 // "defaultInitRef", null,
 234                 // "Fooref", "Fooref" ),
 235             ParserDataFactory.make( ORBConstants.HIGH_WATER_MARK_PROPERTY,
 236                 OperationFactory.integerAction(),
 237                 "highWaterMark", new Integer( 240 ),
 238                 new Integer( 3745 ), "3745" ),
 239             ParserDataFactory.make( ORBConstants.LOW_WATER_MARK_PROPERTY,
 240                 OperationFactory.integerAction(),
 241                 "lowWaterMark", new Integer( 100 ),
 242                 new Integer( 12 ), "12" ),
 243             ParserDataFactory.make( ORBConstants.NUMBER_TO_RECLAIM_PROPERTY,
 244                 OperationFactory.integerAction(),
 245                 "numberToReclaim", new Integer( 5 ),
 246                 new Integer( 231 ), "231" ),
 247             ParserDataFactory.make( ORBConstants.GIOP_VERSION,
 248                 makeGVOperation(),
 249                 "giopVersion", GIOPVersion.DEFAULT_VERSION,
 250                 new GIOPVersion( 2, 3 ), "2.3" ),
 251             ParserDataFactory.make( ORBConstants.GIOP_FRAGMENT_SIZE,
 252                 makeFSOperation(), "giopFragmentSize",
 253                 new Integer( ORBConstants.GIOP_DEFAULT_FRAGMENT_SIZE ),
 254                 new Integer( 65536 ), "65536" ),
 255             ParserDataFactory.make( ORBConstants.GIOP_BUFFER_SIZE,
 256                 OperationFactory.integerAction(),
 257                 "giopBufferSize", new Integer( ORBConstants.GIOP_DEFAULT_BUFFER_SIZE ),
 258                 new Integer( 234000 ), "234000" ),
 259             ParserDataFactory.make( ORBConstants.GIOP_11_BUFFMGR,
 260                 makeBMGROperation(),
 261                 "giop11BuffMgr", new Integer( ORBConstants.DEFAULT_GIOP_11_BUFFMGR ),
 262                 new Integer( 1 ), "CLCT" ),
 263             ParserDataFactory.make( ORBConstants.GIOP_12_BUFFMGR,
 264                 makeBMGROperation(),
 265                 "giop12BuffMgr", new Integer( ORBConstants.DEFAULT_GIOP_12_BUFFMGR ),
 266                 new Integer( 0 ), "GROW" ),
 267 
 268             // Note that the same property is used to set two different
 269             // fields here.  This requires that both entries use the same test
 270             // data, or the test will fail.
 271             ParserDataFactory.make( ORBConstants.GIOP_TARGET_ADDRESSING,
 272                 OperationFactory.compose( OperationFactory.integerRangeAction( 0, 3 ),
 273                     OperationFactory.convertIntegerToShort() ),
 274                 "giopTargetAddressPreference",
 275                 new Short( ORBConstants.ADDR_DISP_HANDLE_ALL ),
 276                 new Short( (short)2 ), "2" ),
 277             ParserDataFactory.make( ORBConstants.GIOP_TARGET_ADDRESSING,
 278                 makeADOperation(),
 279                 "giopAddressDisposition", new Short( KeyAddr.value ),
 280                 new Short( (short)2 ), "2" ),
 281             ParserDataFactory.make( ORBConstants.ALWAYS_SEND_CODESET_CTX_PROPERTY,
 282                 OperationFactory.booleanAction(),
 283                 "alwaysSendCodeSetCtx", Boolean.TRUE,
 284                 Boolean.FALSE, "false"),
 285             ParserDataFactory.make( ORBConstants.USE_BOMS,
 286                 OperationFactory.booleanAction(),
 287                 "useByteOrderMarkers",
 288                     Boolean.valueOf( ORBConstants.DEFAULT_USE_BYTE_ORDER_MARKERS ),
 289                 Boolean.FALSE, "false" ),
 290             ParserDataFactory.make( ORBConstants.USE_BOMS_IN_ENCAPS,
 291                 OperationFactory.booleanAction(),
 292                 "useByteOrderMarkersInEncaps",
 293                     Boolean.valueOf( ORBConstants.DEFAULT_USE_BYTE_ORDER_MARKERS_IN_ENCAPS ),
 294                 Boolean.FALSE, "false" ),
 295             ParserDataFactory.make( ORBConstants.CHAR_CODESETS,
 296                 makeCSOperation(),
 297                 "charData", CodeSetComponentInfo.JAVASOFT_DEFAULT_CODESETS.getCharComponent(),
 298                 CodeSetComponentInfo.createFromString( codeSetTestString ), codeSetTestString ),
 299             ParserDataFactory.make( ORBConstants.WCHAR_CODESETS,
 300                 makeCSOperation(),
 301                 "wcharData", CodeSetComponentInfo.JAVASOFT_DEFAULT_CODESETS.getWCharComponent(),
 302                 CodeSetComponentInfo.createFromString( codeSetTestString ), codeSetTestString ),
 303             ParserDataFactory.make( ORBConstants.ALLOW_LOCAL_OPTIMIZATION,
 304                 OperationFactory.booleanAction(),
 305                 "allowLocalOptimization", Boolean.FALSE,
 306                 Boolean.TRUE, "true" ),
 307             ParserDataFactory.make( ORBConstants.LEGACY_SOCKET_FACTORY_CLASS_PROPERTY,
 308                 makeLegacySocketFactoryOperation(),
 309                 // No default - must be set by user if they are using
 310                 // legacy socket factory.
 311                 "legacySocketFactory", null,
 312                 new TestLegacyORBSocketFactory(),
 313                 MY_CLASS_NAME + "$TestLegacyORBSocketFactory" ),
 314             ParserDataFactory.make( ORBConstants.SOCKET_FACTORY_CLASS_PROPERTY,
 315                 makeSocketFactoryOperation(),
 316                 "socketFactory", new DefaultSocketFactoryImpl(),
 317                 new TestORBSocketFactory(),
 318                 MY_CLASS_NAME + "$TestORBSocketFactory" ),
 319             ParserDataFactory.make( ORBConstants.LISTEN_SOCKET_PROPERTY,
 320                 makeUSLOperation() ,
 321                 "userSpecifiedListenPorts", new USLPort[0],
 322                 USLPorts, "FOO:2701,BAR:3333" ),
 323             ParserDataFactory.make( ORBConstants.IOR_TO_SOCKET_INFO_CLASS_PROPERTY,
 324                 makeIORToSocketInfoOperation(),
 325                 "iorToSocketInfo", new DefaultIORToSocketInfoImpl(),
 326                 new TestIORToSocketInfo(),
 327                 MY_CLASS_NAME + "$TestIORToSocketInfo" ),
 328             ParserDataFactory.make( ORBConstants.IIOP_PRIMARY_TO_CONTACT_INFO_CLASS_PROPERTY,
 329                 makeIIOPPrimaryToContactInfoOperation(),
 330                 "iiopPrimaryToContactInfo", null,
 331                 new TestIIOPPrimaryToContactInfo(),
 332                 MY_CLASS_NAME + "$TestIIOPPrimaryToContactInfo" ),
 333             ParserDataFactory.make( ORBConstants.CONTACT_INFO_LIST_FACTORY_CLASS_PROPERTY,
 334                 makeContactInfoListFactoryOperation(),
 335                 "corbaContactInfoListFactory", null,
 336                 new TestContactInfoListFactory(),
 337                 MY_CLASS_NAME + "$TestContactInfoListFactory" ),
 338             ParserDataFactory.make( ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY,
 339                 OperationFactory.integerAction(),
 340                 "persistentServerPort", new Integer( 0 ),
 341                 new Integer( 2743 ), "2743" ),
 342             ParserDataFactory.make( ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY,
 343                 OperationFactory.setFlagAction(),
 344                 "persistentPortInitialized", Boolean.FALSE,
 345                 Boolean.TRUE, "2743" ),
 346             ParserDataFactory.make( ORBConstants.SERVER_ID_PROPERTY,
 347                 OperationFactory.integerAction(),
 348                 "persistentServerId", new Integer( 0 ),
 349                 new Integer( 294 ), "294" ),
 350             ParserDataFactory.make( ORBConstants.SERVER_ID_PROPERTY,
 351                 OperationFactory.setFlagAction(),
 352                 "persistentServerIdInitialized", Boolean.FALSE,
 353                 Boolean.TRUE, "294" ),
 354             ParserDataFactory.make( ORBConstants.SERVER_ID_PROPERTY,
 355                 OperationFactory.setFlagAction(),
 356                 "orbServerIdPropertySpecified", Boolean.FALSE,
 357                 Boolean.TRUE, "294" ),
 358             ParserDataFactory.make( ORBConstants.ACTIVATED_PROPERTY,
 359                 OperationFactory.booleanAction(),
 360                 "serverIsORBActivated", Boolean.FALSE,
 361                 Boolean.TRUE, "true" ),
 362             ParserDataFactory.make( ORBConstants.BAD_SERVER_ID_HANDLER_CLASS_PROPERTY,
 363                 OperationFactory.classAction(),
 364                 "badServerIdHandlerClass", null,
 365                 TestBadServerIdHandler.class, MY_CLASS_NAME + "$TestBadServerIdHandler" ),
 366             ParserDataFactory.make( ORBConstants.PI_ORB_INITIALIZER_CLASS_PREFIX,
 367                 makeROIOperation(),
 368                 "orbInitializers", new ORBInitializer[0],
 369                 TestORBInitializers, TestORBInitData, ORBInitializer.class ),
 370             ParserDataFactory.make( ORBConstants.ACCEPTOR_CLASS_PREFIX_PROPERTY,
 371                 makeAcceptorInstantiationOperation(),
 372                 "acceptors", new Acceptor[0],
 373                 TestAcceptors, TestAcceptorData, Acceptor.class ),
 374 
 375             //
 376             // Socket/Channel control
 377             //
 378 
 379             // Acceptor:
 380             // useNIOSelector == true
 381             //   useSelectThreadToWait = true
 382             //   useWorkerThreadForEvent = false
 383             // else
 384             //   useSelectThreadToWait = false
 385             //   useWorkerThreadForEvent = true
 386 
 387             // Connection:
 388             // useNIOSelector == true
 389             //   useSelectThreadToWait = true
 390             //   useWorkerThreadForEvent = true
 391             // else
 392             //   useSelectThreadToWait = false
 393             //   useWorkerThreadForEvent = true
 394 
 395             ParserDataFactory.make( ORBConstants.ACCEPTOR_SOCKET_TYPE_PROPERTY,
 396                 OperationFactory.stringAction(),
 397                 "acceptorSocketType", ORBConstants.SOCKETCHANNEL,
 398                 "foo", "foo" ),
 399 
 400             ParserDataFactory.make( ORBConstants.USE_NIO_SELECT_TO_WAIT_PROPERTY,
 401                 OperationFactory.booleanAction(),
 402                 "acceptorSocketUseSelectThreadToWait", Boolean.TRUE,
 403                 Boolean.TRUE, "true" ),
 404             ParserDataFactory.make( ORBConstants.ACCEPTOR_SOCKET_USE_WORKER_THREAD_FOR_EVENT_PROPERTY,
 405                 OperationFactory.booleanAction(),
 406                 "acceptorSocketUseWorkerThreadForEvent", Boolean.TRUE,
 407                 Boolean.TRUE, "true" ),
 408             ParserDataFactory.make( ORBConstants.CONNECTION_SOCKET_TYPE_PROPERTY,
 409                 OperationFactory.stringAction(),
 410                 "connectionSocketType", ORBConstants.SOCKETCHANNEL,
 411                 "foo", "foo" ),
 412             ParserDataFactory.make( ORBConstants.USE_NIO_SELECT_TO_WAIT_PROPERTY,
 413                 OperationFactory.booleanAction(),
 414                 "connectionSocketUseSelectThreadToWait", Boolean.TRUE,
 415                 Boolean.TRUE, "true" ),
 416             ParserDataFactory.make( ORBConstants.CONNECTION_SOCKET_USE_WORKER_THREAD_FOR_EVENT_PROPERTY,
 417                 OperationFactory.booleanAction(),
 418                 "connectionSocketUseWorkerThreadForEvent", Boolean.TRUE,
 419                 Boolean.TRUE, "true" ),
 420             ParserDataFactory.make( ORBConstants.DISABLE_DIRECT_BYTE_BUFFER_USE_PROPERTY,
 421                 OperationFactory.booleanAction(),
 422                 "disableDirectByteBufferUse", Boolean.FALSE,
 423                 Boolean.TRUE, "true" ),
 424             ParserDataFactory.make(ORBConstants.TRANSPORT_TCP_READ_TIMEOUTS_PROPERTY,
 425                 makeTTCPRTOperation(),
 426                 "readTimeouts",  TransportDefault.makeReadTimeoutsFactory().create(
 427                     ORBConstants.TRANSPORT_TCP_INITIAL_TIME_TO_WAIT,
 428                     ORBConstants.TRANSPORT_TCP_MAX_TIME_TO_WAIT,
 429                     ORBConstants.TRANSPORT_TCP_GIOP_HEADER_MAX_TIME_TO_WAIT,
 430                     ORBConstants.TRANSPORT_TCP_TIME_TO_WAIT_BACKOFF_FACTOR),
 431                 readTimeouts, "100:3000:300:20" ),
 432             ParserDataFactory.make(
 433                 ORBConstants.ENABLE_JAVA_SERIALIZATION_PROPERTY,
 434                 OperationFactory.booleanAction(),
 435                 "enableJavaSerialization", Boolean.FALSE,
 436                 Boolean.FALSE, "false"),
 437             ParserDataFactory.make(
 438                 ORBConstants.USE_REP_ID,
 439                 OperationFactory.booleanAction(),
 440                 "useRepId", Boolean.TRUE,
 441                 Boolean.TRUE, "true"),
 442             ParserDataFactory.make( ORBConstants.ORB_INIT_REF_PROPERTY,
 443                 OperationFactory.identityAction(),
 444                 "orbInitialReferences", new StringPair[0],
 445                 TestORBInitRefData, TestORBInitRefData, StringPair.class )
 446         } ;
 447 
 448         parserData = pd ;
 449     }
 450 
 451     public final class TestBadServerIdHandler implements BadServerIdHandler
 452     {
 453         public boolean equals( Object other )
 454         {
 455             return other instanceof TestBadServerIdHandler ;
 456         }
 457 
 458         public void handle( ObjectKey objectKey )
 459         {
 460         }
 461     }
 462 
 463     private Operation makeTTCPRTOperation()
 464     {
 465         Operation[] fourIop = { OperationFactory.integerAction(),
 466                                 OperationFactory.integerAction(),
 467                                 OperationFactory.integerAction(),
 468                                 OperationFactory.integerAction() } ;
 469 
 470         Operation op2 = OperationFactory.sequenceAction( ":", fourIop ) ;
 471 
 472         Operation rtOp = new Operation() {
 473             public Object operate(Object value)
 474             {
 475                 Object[] values = (Object[])value ;
 476                 Integer initialTime = (Integer)(values[0]) ;
 477                 Integer maxGIOPHdrTime = (Integer)(values[1]) ;
 478                 Integer maxGIOPBodyTime = (Integer)(values[2]) ;
 479                 Integer backoffPercent = (Integer)(values[3]) ;
 480                 return TransportDefault.makeReadTimeoutsFactory().create(
 481                                                    initialTime.intValue(),
 482                                                    maxGIOPHdrTime.intValue(),
 483                                                    maxGIOPBodyTime.intValue(),
 484                                                    backoffPercent.intValue());
 485             }
 486         } ;
 487 
 488         Operation ttcprtOp = OperationFactory.compose(op2, rtOp);
 489         return ttcprtOp;
 490     }
 491 
 492     private Operation makeUSLOperation()
 493     {
 494         Operation[] siop = { OperationFactory.stringAction(),
 495             OperationFactory.integerAction() } ;
 496         Operation op2 = OperationFactory.sequenceAction( ":", siop ) ;
 497 
 498         Operation uslop = new Operation() {
 499             public Object operate( Object value )
 500             {
 501                 Object[] values = (Object[])value ;
 502                 String type = (String)(values[0]) ;
 503                 Integer port = (Integer)(values[1]) ;
 504                 return new USLPort( type, port.intValue() ) ;
 505             }
 506         } ;
 507 
 508         Operation op3 = OperationFactory.compose( op2, uslop ) ;
 509         Operation listenop = OperationFactory.listAction( ",", op3 ) ;
 510         return listenop ;
 511     }
 512 
 513     public static final class TestLegacyORBSocketFactory
 514         implements com.sun.corba.se.spi.legacy.connection.ORBSocketFactory
 515     {
 516         public boolean equals( Object other )
 517         {
 518             return other instanceof TestLegacyORBSocketFactory ;
 519         }
 520 
 521         public ServerSocket createServerSocket( String type, int port )
 522         {
 523             return null ;
 524         }
 525 
 526         public SocketInfo getEndPointInfo( org.omg.CORBA.ORB orb,
 527             IOR ior, SocketInfo socketInfo )
 528         {
 529             return null ;
 530         }
 531 
 532         public Socket createSocket( SocketInfo socketInfo )
 533         {
 534             return null ;
 535         }
 536     }
 537 
 538     public static final class TestORBSocketFactory
 539         implements com.sun.corba.se.spi.transport.ORBSocketFactory
 540     {
 541         public boolean equals( Object other )
 542         {
 543             return other instanceof TestORBSocketFactory ;
 544         }
 545 
 546         public void setORB(ORB orb)
 547         {
 548         }
 549 
 550         public ServerSocket createServerSocket( String type, InetSocketAddress a )
 551         {
 552             return null ;
 553         }
 554 
 555         public Socket createSocket( String type, InetSocketAddress a )
 556         {
 557             return null ;
 558         }
 559 
 560         public void setAcceptedSocketOptions(Acceptor acceptor,
 561                                              ServerSocket serverSocket,
 562                                              Socket socket)
 563         {
 564         }
 565     }
 566 
 567     public static final class TestIORToSocketInfo
 568         implements IORToSocketInfo
 569     {
 570         public boolean equals( Object other )
 571         {
 572             return other instanceof TestIORToSocketInfo;
 573         }
 574 
 575         public List getSocketInfo(IOR ior)
 576         {
 577             return null;
 578         }
 579     }
 580 
 581     public static final class TestIIOPPrimaryToContactInfo
 582         implements IIOPPrimaryToContactInfo
 583     {
 584         public void reset(ContactInfo primary)
 585         {
 586         }
 587 
 588         public boolean hasNext(ContactInfo primary,
 589                                ContactInfo previous,
 590                                List contactInfos)
 591         {
 592             return true;
 593         }
 594 
 595         public ContactInfo next(ContactInfo primary,
 596                                 ContactInfo previous,
 597                                 List contactInfos)
 598         {
 599             return null;
 600         }
 601     }
 602 
 603     public static final class TestContactInfoListFactory
 604         implements CorbaContactInfoListFactory
 605     {
 606         public boolean equals( Object other )
 607         {
 608             return other instanceof TestContactInfoListFactory;
 609         }
 610 
 611         public void setORB(ORB orb) { }
 612 
 613         public CorbaContactInfoList create( IOR ior ) { return null; }
 614     }
 615 
 616     private Operation makeMapOperation( final Map map )
 617     {
 618         return new Operation() {
 619             public Object operate( Object value )
 620             {
 621                 return map.get( value ) ;
 622             }
 623         } ;
 624     }
 625 
 626     private Operation makeBMGROperation()
 627     {
 628         Map map = new HashMap() ;
 629         map.put( "GROW", new Integer(0) ) ;
 630         map.put( "CLCT", new Integer(1) ) ;
 631         map.put( "STRM", new Integer(2) ) ;
 632         return makeMapOperation( map ) ;
 633     }
 634 
 635     private Operation makeLegacySocketFactoryOperation()
 636     {
 637         Operation sfop = new Operation() {
 638             public Object operate( Object value )
 639             {
 640                 String param = (String)value ;
 641 
 642                 try {
 643                     Class legacySocketFactoryClass =
 644                         ORBClassLoader.loadClass(param);
 645                     // For security reasons avoid creating an instance if
 646                     // this socket factory class is not one that would fail
 647                     // the class cast anyway.
 648                     if (com.sun.corba.se.spi.legacy.connection.ORBSocketFactory.class.isAssignableFrom(legacySocketFactoryClass)) {
 649                         return legacySocketFactoryClass.newInstance();
 650                     } else {
 651                         throw wrapper.illegalSocketFactoryType( legacySocketFactoryClass.toString() ) ;
 652                     }
 653                 } catch (Exception ex) {
 654                     // ClassNotFoundException, IllegalAccessException,
 655                     // InstantiationException, SecurityException or
 656                     // ClassCastException
 657                     throw wrapper.badCustomSocketFactory( ex, param ) ;
 658                 }
 659             }
 660         } ;
 661 
 662         return sfop ;
 663     }
 664 
 665     private Operation makeSocketFactoryOperation()
 666     {
 667         Operation sfop = new Operation() {
 668             public Object operate( Object value )
 669             {
 670                 String param = (String)value ;
 671 
 672                 try {
 673                     Class socketFactoryClass = ORBClassLoader.loadClass(param);
 674                     // For security reasons avoid creating an instance if
 675                     // this socket factory class is not one that would fail
 676                     // the class cast anyway.
 677                     if (com.sun.corba.se.spi.transport.ORBSocketFactory.class.isAssignableFrom(socketFactoryClass)) {
 678                         return socketFactoryClass.newInstance();
 679                     } else {
 680                         throw wrapper.illegalSocketFactoryType( socketFactoryClass.toString() ) ;
 681                     }
 682                 } catch (Exception ex) {
 683                     // ClassNotFoundException, IllegalAccessException,
 684                     // InstantiationException, SecurityException or
 685                     // ClassCastException
 686                     throw wrapper.badCustomSocketFactory( ex, param ) ;
 687                 }
 688             }
 689         } ;
 690 
 691         return sfop ;
 692     }
 693 
 694     private Operation makeIORToSocketInfoOperation()
 695     {
 696         Operation op = new Operation() {
 697             public Object operate( Object value )
 698             {
 699                 String param = (String)value ;
 700 
 701                 try {
 702                     Class iorToSocketInfoClass = ORBClassLoader.loadClass(param);
 703                     // For security reasons avoid creating an instance if
 704                     // this socket factory class is not one that would fail
 705                     // the class cast anyway.
 706                     if (IORToSocketInfo.class.isAssignableFrom(iorToSocketInfoClass)) {
 707                         return iorToSocketInfoClass.newInstance();
 708                     } else {
 709                         throw wrapper.illegalIorToSocketInfoType( iorToSocketInfoClass.toString() ) ;
 710                     }
 711                 } catch (Exception ex) {
 712                     // ClassNotFoundException, IllegalAccessException,
 713                     // InstantiationException, SecurityException or
 714                     // ClassCastException
 715                     throw wrapper.badCustomIorToSocketInfo( ex, param ) ;
 716                 }
 717             }
 718         } ;
 719 
 720         return op ;
 721     }
 722 
 723     private Operation makeIIOPPrimaryToContactInfoOperation()
 724     {
 725         Operation op = new Operation() {
 726             public Object operate( Object value )
 727             {
 728                 String param = (String)value ;
 729 
 730                 try {
 731                     Class iiopPrimaryToContactInfoClass = ORBClassLoader.loadClass(param);
 732                     // For security reasons avoid creating an instance if
 733                     // this socket factory class is not one that would fail
 734                     // the class cast anyway.
 735                     if (IIOPPrimaryToContactInfo.class.isAssignableFrom(iiopPrimaryToContactInfoClass)) {
 736                         return iiopPrimaryToContactInfoClass.newInstance();
 737                     } else {
 738                         throw wrapper.illegalIiopPrimaryToContactInfoType( iiopPrimaryToContactInfoClass.toString() ) ;
 739                     }
 740                 } catch (Exception ex) {
 741                     // ClassNotFoundException, IllegalAccessException,
 742                     // InstantiationException, SecurityException or
 743                     // ClassCastException
 744                     throw wrapper.badCustomIiopPrimaryToContactInfo( ex, param ) ;
 745                 }
 746             }
 747         } ;
 748 
 749         return op ;
 750     }
 751 
 752     private Operation makeContactInfoListFactoryOperation()
 753     {
 754         Operation op = new Operation() {
 755             public Object operate( Object value )
 756             {
 757                 String param = (String)value ;
 758 
 759                 try {
 760                     Class contactInfoListFactoryClass =
 761                         ORBClassLoader.loadClass(param);
 762                     // For security reasons avoid creating an instance if
 763                     // this socket factory class is not one that would fail
 764                     // the class cast anyway.
 765                     if (CorbaContactInfoListFactory.class.isAssignableFrom(
 766                         contactInfoListFactoryClass)) {
 767                         return contactInfoListFactoryClass.newInstance();
 768                     } else {
 769                         throw wrapper.illegalContactInfoListFactoryType(
 770                             contactInfoListFactoryClass.toString() ) ;
 771                     }
 772                 } catch (Exception ex) {
 773                     // ClassNotFoundException, IllegalAccessException,
 774                     // InstantiationException, SecurityException or
 775                     // ClassCastException
 776                     throw wrapper.badContactInfoListFactory( ex, param ) ;
 777                 }
 778             }
 779         } ;
 780 
 781         return op ;
 782     }
 783 
 784     private Operation makeCSOperation()
 785     {
 786         Operation csop = new Operation() {
 787             public Object operate( Object value )
 788             {
 789                 String val = (String)value ;
 790                 return CodeSetComponentInfo.createFromString( val ) ;
 791             }
 792         } ;
 793 
 794         return csop ;
 795     }
 796 
 797     private Operation makeADOperation()
 798     {
 799         Operation admap = new Operation() {
 800             private Integer[] map = {
 801                 new Integer( KeyAddr.value ),
 802                 new Integer( ProfileAddr.value ),
 803                 new Integer( ReferenceAddr.value ),
 804                 new Integer( KeyAddr.value ) } ;
 805 
 806             public Object operate( Object value )
 807             {
 808                 int val = ((Integer)value).intValue() ;
 809                 return map[val] ;
 810             }
 811         } ;
 812 
 813         Operation rangeop = OperationFactory.integerRangeAction( 0, 3 ) ;
 814         Operation op1 = OperationFactory.compose( rangeop, admap ) ;
 815         Operation result = OperationFactory.compose( op1, OperationFactory.convertIntegerToShort() ) ;
 816         return result ;
 817     }
 818 
 819     private Operation makeFSOperation() {
 820         Operation fschecker = new Operation() {
 821             public Object operate( Object value )
 822             {
 823                 int giopFragmentSize = ((Integer)value).intValue() ;
 824                 if (giopFragmentSize < ORBConstants.GIOP_FRAGMENT_MINIMUM_SIZE){
 825                     throw wrapper.fragmentSizeMinimum( new Integer( giopFragmentSize ),
 826                         new Integer( ORBConstants.GIOP_FRAGMENT_MINIMUM_SIZE ) ) ;
 827                 }
 828 
 829                 if (giopFragmentSize % ORBConstants.GIOP_FRAGMENT_DIVISOR != 0)
 830                     throw wrapper.fragmentSizeDiv( new Integer( giopFragmentSize ),
 831                             new Integer( ORBConstants.GIOP_FRAGMENT_DIVISOR ) ) ;
 832 
 833                 return value ;
 834             }
 835         } ;
 836 
 837         Operation result = OperationFactory.compose( OperationFactory.integerAction(),
 838             fschecker ) ;
 839         return result ;
 840     }
 841 
 842     private Operation makeGVOperation() {
 843         Operation gvHelper = OperationFactory.listAction( ".",
 844             OperationFactory.integerAction() ) ;
 845         Operation gvMain = new Operation() {
 846             public Object operate( Object value )
 847             {
 848                 Object[] nums = (Object[])value ;
 849                 int major = ((Integer)(nums[0])).intValue() ;
 850                 int minor = ((Integer)(nums[1])).intValue() ;
 851 
 852                 return new GIOPVersion( major, minor ) ;
 853             }
 854         } ;
 855 
 856         Operation result = OperationFactory.compose( gvHelper, gvMain );
 857         return result ;
 858     }
 859 
 860     public static final class TestORBInitializer1 extends org.omg.CORBA.LocalObject
 861         implements ORBInitializer
 862     {
 863         public boolean equals( Object other )
 864         {
 865             return other instanceof TestORBInitializer1 ;
 866         }
 867 
 868         public void pre_init( ORBInitInfo info )
 869         {
 870         }
 871 
 872         public void post_init( ORBInitInfo info )
 873         {
 874         }
 875     }
 876 
 877     public static final class TestORBInitializer2 extends org.omg.CORBA.LocalObject
 878         implements ORBInitializer
 879     {
 880         public boolean equals( Object other )
 881         {
 882             return other instanceof TestORBInitializer2 ;
 883         }
 884 
 885         public void pre_init( ORBInitInfo info )
 886         {
 887         }
 888 
 889         public void post_init( ORBInitInfo info )
 890         {
 891         }
 892     }
 893 
 894     private Operation makeROIOperation() {
 895         Operation clsop = OperationFactory.classAction() ;
 896         Operation indexOp = OperationFactory.suffixAction() ;
 897         Operation op1 = OperationFactory.compose( indexOp, clsop ) ;
 898         Operation mop = OperationFactory.maskErrorAction( op1 ) ;
 899 
 900         Operation mkinst = new Operation() {
 901             public Object operate( Object value )
 902             {
 903                 final Class initClass = (Class)value ;
 904                 if (initClass == null)
 905                     return null ;
 906 
 907                 // For security reasons avoid creating an instance
 908                 // if this class is one that would fail the class cast
 909                 // to ORBInitializer anyway.
 910                 if( org.omg.PortableInterceptor.ORBInitializer.class.isAssignableFrom(
 911                     initClass ) ) {
 912                     // Now that we have a class object, instantiate one and
 913                     // remember it:
 914                     ORBInitializer initializer = null ;
 915 
 916                     try {
 917                         initializer = (ORBInitializer)AccessController.doPrivileged(
 918                             new PrivilegedExceptionAction() {
 919                                 public Object run()
 920                                     throws InstantiationException, IllegalAccessException
 921                                 {
 922                                     return initClass.newInstance() ;
 923                                 }
 924                             }
 925                         ) ;
 926                     } catch (PrivilegedActionException exc) {
 927                         // Unwrap the exception, as we don't care exc here
 928                         throw wrapper.orbInitializerFailure( exc.getException(),
 929                             initClass.getName() ) ;
 930                     } catch (Exception exc) {
 931                         throw wrapper.orbInitializerFailure( exc, initClass.getName() ) ;
 932                     }
 933 
 934                     return initializer ;
 935                 } else {
 936                     throw wrapper.orbInitializerType( initClass.getName() ) ;
 937                 }
 938             }
 939         } ;
 940 
 941         Operation result = OperationFactory.compose( mop, mkinst ) ;
 942 
 943         return result ;
 944     }
 945 
 946     public static final class TestAcceptor1
 947         implements Acceptor
 948     {
 949         public boolean equals( Object other )
 950         {
 951             return other instanceof TestAcceptor1 ;
 952         }
 953         public boolean initialize() { return true; }
 954         public boolean initialized() { return true; }
 955         public String getConnectionCacheType() { return "FOO"; }
 956         public void setConnectionCache(InboundConnectionCache connectionCache){}
 957         public InboundConnectionCache getConnectionCache() { return null; }
 958         public boolean shouldRegisterAcceptEvent() { return true; }
 959         public void setUseSelectThreadForConnections(boolean x) { }
 960         public boolean shouldUseSelectThreadForConnections() { return true; }
 961         public void setUseWorkerThreadForConnections(boolean x) { }
 962         public boolean shouldUseWorkerThreadForConnections() { return true; }
 963         public void accept() { }
 964         public void close() { }
 965         public EventHandler getEventHandler() { return null; }
 966         public MessageMediator createMessageMediator(
 967             Broker xbroker, Connection xconnection) { return null; }
 968         public MessageMediator finishCreatingMessageMediator(
 969             Broker xbroker, Connection xconnection,
 970             MessageMediator messageMediator) { return null; }
 971         public InputObject createInputObject(
 972             Broker broker, MessageMediator messageMediator) { return null; }
 973         public OutputObject createOutputObject(
 974             Broker broker, MessageMediator messageMediator) { return null; }
 975     }
 976 
 977     public static final class TestAcceptor2
 978         implements Acceptor
 979     {
 980         public boolean equals( Object other )
 981         {
 982             return other instanceof TestAcceptor2 ;
 983         }
 984         public boolean initialize() { return true; }
 985         public boolean initialized() { return true; }
 986         public String getConnectionCacheType() { return "FOO"; }
 987         public void setConnectionCache(InboundConnectionCache connectionCache){}
 988         public InboundConnectionCache getConnectionCache() { return null; }
 989         public boolean shouldRegisterAcceptEvent() { return true; }
 990         public void setUseSelectThreadForConnections(boolean x) { }
 991         public boolean shouldUseSelectThreadForConnections() { return true; }
 992         public void setUseWorkerThreadForConnections(boolean x) { }
 993         public boolean shouldUseWorkerThreadForConnections() { return true; }
 994         public void accept() { }
 995         public void close() { }
 996         public EventHandler getEventHandler() { return null; }
 997         public MessageMediator createMessageMediator(
 998             Broker xbroker, Connection xconnection) { return null; }
 999         public MessageMediator finishCreatingMessageMediator(
1000             Broker xbroker, Connection xconnection,
1001             MessageMediator messageMediator) { return null; }
1002         public InputObject createInputObject(
1003             Broker broker, MessageMediator messageMediator) { return null; }
1004         public OutputObject createOutputObject(
1005             Broker broker, MessageMediator messageMediator) { return null; }
1006     }
1007 
1008     // REVISIT - this is a cut and paste modification of makeROIOperation.
1009     private Operation makeAcceptorInstantiationOperation() {
1010         Operation clsop = OperationFactory.classAction() ;
1011         Operation indexOp = OperationFactory.suffixAction() ;
1012         Operation op1 = OperationFactory.compose( indexOp, clsop ) ;
1013         Operation mop = OperationFactory.maskErrorAction( op1 ) ;
1014 
1015         Operation mkinst = new Operation() {
1016             public Object operate( Object value )
1017             {
1018                 final Class initClass = (Class)value ;
1019                 if (initClass == null)
1020                     return null ;
1021 
1022                 // For security reasons avoid creating an instance
1023                 // if this class is one that would fail the class cast
1024                 // to ORBInitializer anyway.
1025                 if( Acceptor.class.isAssignableFrom( initClass ) ) {
1026                     // Now that we have a class object, instantiate one and
1027                     // remember it:
1028                     Acceptor acceptor = null ;
1029 
1030                     try {
1031                         acceptor = (Acceptor)AccessController.doPrivileged(
1032                             new PrivilegedExceptionAction() {
1033                                 public Object run()
1034                                     throws InstantiationException, IllegalAccessException
1035                                 {
1036                                     return initClass.newInstance() ;
1037                                 }
1038                             }
1039                         ) ;
1040                     } catch (PrivilegedActionException exc) {
1041                         // Unwrap the exception, as we don't care exc here
1042                         throw wrapper.acceptorInstantiationFailure( exc.getException(),
1043                             initClass.getName() ) ;
1044                     } catch (Exception exc) {
1045                         throw wrapper.acceptorInstantiationFailure( exc, initClass.getName() ) ;
1046                     }
1047 
1048                     return acceptor ;
1049                 } else {
1050                     throw wrapper.acceptorInstantiationTypeFailure( initClass.getName() ) ;
1051                 }
1052             }
1053         } ;
1054 
1055         Operation result = OperationFactory.compose( mop, mkinst ) ;
1056 
1057         return result ;
1058     }
1059 
1060     private Operation makeInitRefOperation() {
1061         return new Operation() {
1062             public Object operate( Object value )
1063             {
1064                 // Object is String[] of length 2.
1065                 String[] values = (String[])value ;
1066                 if (values.length != 2)
1067                     throw wrapper.orbInitialreferenceSyntax() ;
1068 
1069                 return values[0] + "=" + values[1] ;
1070             }
1071         } ;
1072     }
1073 }
1074 
1075 // End of file.