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