1 /* 2 * Copyright (c) 1997, 2017, 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 * Licensed Materials - Property of IBM 27 * RMI-IIOP v1.0 28 * Copyright IBM Corp. 1998 1999 All Rights Reserved 29 * 30 */ 31 32 package com.sun.corba.se.impl.orb; 33 34 import java.util.Collection; 35 import java.util.Properties; 36 import java.util.Hashtable; 37 38 import java.applet.Applet; 39 40 import java.net.URL; 41 42 import java.io.IOException ; 43 44 import java.util.logging.Logger ; 45 46 import org.omg.CORBA.Context; 47 import org.omg.CORBA.ContextList; 48 import org.omg.CORBA.Environment; 49 import org.omg.CORBA.ExceptionList; 50 import org.omg.CORBA.ORBPackage.InvalidName; 51 import org.omg.CORBA.NVList; 52 import org.omg.CORBA.TCKind; 53 import org.omg.CORBA.NamedValue; 54 import org.omg.CORBA.NO_IMPLEMENT; 55 import org.omg.CORBA.Object; 56 import org.omg.CORBA.Request; 57 import org.omg.CORBA.TypeCode; 58 import org.omg.CORBA.Any; 59 import org.omg.CORBA.StructMember; 60 import org.omg.CORBA.UnionMember; 61 import org.omg.CORBA.ValueMember; 62 import org.omg.CORBA.Policy; 63 import org.omg.CORBA.PolicyError; 64 65 import org.omg.CORBA.portable.OutputStream; 66 import org.omg.CORBA.portable.RemarshalException; 67 68 import com.sun.corba.se.pept.protocol.ClientInvocationInfo ; 69 import com.sun.corba.se.pept.transport.ContactInfo; 70 import com.sun.corba.se.pept.transport.ConnectionCache; 71 import com.sun.corba.se.pept.transport.Selector ; 72 import com.sun.corba.se.pept.transport.TransportManager; 73 74 import com.sun.corba.se.spi.legacy.connection.ORBSocketFactory; 75 import com.sun.corba.se.spi.orb.ORBData; 76 import com.sun.corba.se.spi.orb.Operation; 77 import com.sun.corba.se.spi.orb.ORB; 78 import com.sun.corba.se.spi.orb.ORBVersion; 79 import com.sun.corba.se.spi.orb.ORBVersionFactory; 80 import com.sun.corba.se.spi.oa.OAInvocationInfo; 81 import com.sun.corba.se.spi.oa.ObjectAdapter; 82 import com.sun.corba.se.spi.protocol.CorbaMessageMediator; 83 import com.sun.corba.se.spi.protocol.ClientDelegateFactory; 84 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry; 85 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher; 86 import com.sun.corba.se.spi.protocol.PIHandler; 87 import com.sun.corba.se.spi.resolver.Resolver; 88 import com.sun.corba.se.spi.resolver.LocalResolver; 89 import com.sun.corba.se.spi.ior.IOR; 90 import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder; 91 import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder; 92 import com.sun.corba.se.spi.ior.ObjectKey; 93 import com.sun.corba.se.spi.ior.ObjectKeyFactory; 94 import com.sun.corba.se.spi.ior.iiop.GIOPVersion; 95 import com.sun.corba.se.pept.transport.ByteBufferPool ; 96 import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory ; 97 import com.sun.corba.se.spi.transport.CorbaTransportManager; 98 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager; 99 import com.sun.corba.se.spi.orbutil.closure.Closure; 100 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager; 101 import com.sun.corba.se.spi.logging.LogWrapperFactory; 102 import com.sun.corba.se.spi.logging.LogWrapperBase; 103 import com.sun.corba.se.spi.copyobject.CopierManager; 104 import com.sun.corba.se.spi.presentation.rmi.PresentationManager; 105 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults; 106 107 import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry; 108 import com.sun.corba.se.spi.servicecontext.ServiceContexts; 109 110 import com.sun.corba.se.impl.corba.TypeCodeFactory; 111 import com.sun.corba.se.impl.corba.TypeCodeImpl; 112 import com.sun.corba.se.impl.corba.NVListImpl; 113 import com.sun.corba.se.impl.corba.NamedValueImpl; 114 import com.sun.corba.se.impl.corba.ExceptionListImpl; 115 import com.sun.corba.se.impl.corba.ContextListImpl; 116 import com.sun.corba.se.impl.corba.EnvironmentImpl; 117 import com.sun.corba.se.impl.corba.AnyImpl; 118 import com.sun.corba.se.impl.encoding.BufferManagerFactory; 119 import com.sun.corba.se.impl.encoding.CodeSetComponentInfo; 120 import com.sun.corba.se.impl.encoding.MarshalInputStream; 121 import com.sun.corba.se.impl.encoding.EncapsOutputStream; 122 import com.sun.corba.se.impl.encoding.MarshalOutputStream; 123 import com.sun.corba.se.impl.oa.poa.BadServerIdHandler; 124 import com.sun.corba.se.impl.orbutil.ORBConstants; 125 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo; 126 127 /* 128 * The restricted singleton ORB implementation. 129 * 130 * For now, this class must implement just enough functionality to be 131 * used as a factory for immutable TypeCode instances. 132 * 133 * See ORBImpl.java for the real ORB implementation. 134 */ 135 public class ORBSingleton extends ORB 136 { 137 // This is used to support read_Object. 138 private ORB fullORB; 139 private static PresentationManager.StubFactoryFactory staticStubFactoryFactory = 140 PresentationDefaults.getStaticStubFactoryFactory() ; 141 142 public void set_parameters( Properties props ) { 143 } 144 145 protected void set_parameters(Applet app, Properties props) { 146 } 147 148 protected void set_parameters (String params[], Properties props) { 149 } 150 151 public OutputStream create_output_stream() { 152 return sun.corba.OutputStreamFactory.newEncapsOutputStream(this); 153 } 154 155 public TypeCode create_struct_tc(String id, 156 String name, 157 StructMember[] members) 158 { 159 return new TypeCodeImpl(this, TCKind._tk_struct, id, name, members); 160 } 161 162 public TypeCode create_union_tc(String id, 163 String name, 164 TypeCode discriminator_type, 165 UnionMember[] members) 166 { 167 return new TypeCodeImpl(this, 168 TCKind._tk_union, 169 id, 170 name, 171 discriminator_type, 172 members); 173 } 174 175 public TypeCode create_enum_tc(String id, 176 String name, 177 String[] members) 178 { 179 return new TypeCodeImpl(this, TCKind._tk_enum, id, name, members); 180 } 181 182 public TypeCode create_alias_tc(String id, 183 String name, 184 TypeCode original_type) 185 { 186 return new TypeCodeImpl(this, TCKind._tk_alias, id, name, original_type); 187 } 188 189 public TypeCode create_exception_tc(String id, 190 String name, 191 StructMember[] members) 192 { 193 return new TypeCodeImpl(this, TCKind._tk_except, id, name, members); 194 } 195 196 public TypeCode create_interface_tc(String id, 197 String name) 198 { 199 return new TypeCodeImpl(this, TCKind._tk_objref, id, name); 200 } 201 202 public TypeCode create_string_tc(int bound) { 203 return new TypeCodeImpl(this, TCKind._tk_string, bound); 204 } 205 206 public TypeCode create_wstring_tc(int bound) { 207 return new TypeCodeImpl(this, TCKind._tk_wstring, bound); 208 } 209 210 public TypeCode create_sequence_tc(int bound, 211 TypeCode element_type) 212 { 213 return new TypeCodeImpl(this, TCKind._tk_sequence, bound, element_type); 214 } 215 216 public TypeCode create_recursive_sequence_tc(int bound, 217 int offset) 218 { 219 return new TypeCodeImpl(this, TCKind._tk_sequence, bound, offset); 220 } 221 222 public TypeCode create_array_tc(int length, 223 TypeCode element_type) 224 { 225 return new TypeCodeImpl(this, TCKind._tk_array, length, element_type); 226 } 227 228 public org.omg.CORBA.TypeCode create_native_tc(String id, 229 String name) 230 { 231 return new TypeCodeImpl(this, TCKind._tk_native, id, name); 232 } 233 234 public org.omg.CORBA.TypeCode create_abstract_interface_tc( 235 String id, 236 String name) 237 { 238 return new TypeCodeImpl(this, TCKind._tk_abstract_interface, id, name); 239 } 240 241 public org.omg.CORBA.TypeCode create_fixed_tc(short digits, short scale) 242 { 243 return new TypeCodeImpl(this, TCKind._tk_fixed, digits, scale); 244 } 245 246 // orbos 98-01-18: Objects By Value -- begin 247 248 public org.omg.CORBA.TypeCode create_value_tc(String id, 249 String name, 250 short type_modifier, 251 TypeCode concrete_base, 252 ValueMember[] members) 253 { 254 return new TypeCodeImpl(this, TCKind._tk_value, id, name, 255 type_modifier, concrete_base, members); 256 } 257 258 public org.omg.CORBA.TypeCode create_recursive_tc(String id) { 259 return new TypeCodeImpl(this, id); 260 } 261 262 public org.omg.CORBA.TypeCode create_value_box_tc(String id, 263 String name, 264 TypeCode boxed_type) 265 { 266 return new TypeCodeImpl(this, TCKind._tk_value_box, id, name, boxed_type); 267 } 268 269 public TypeCode get_primitive_tc( TCKind tckind ) 270 { 271 return get_primitive_tc( tckind.value() ) ; 272 } 273 274 public Any create_any() { 275 return new AnyImpl(this); 276 } 277 278 // TypeCodeFactory interface methods. 279 // Keeping track of type codes by repository id. 280 /* 281 * Not strictly needed for TypeCode factory duty but these seem 282 * harmless enough. 283 */ 284 285 public NVList create_list(int count) { 286 return new NVListImpl(this, count); 287 } 288 289 public org.omg.CORBA.NVList 290 create_operation_list(org.omg.CORBA.Object oper) { 291 throw wrapper.genericNoImpl() ; 292 } 293 294 public org.omg.CORBA.NamedValue 295 create_named_value(String s, Any any, int flags) { 296 return new NamedValueImpl(this, s, any, flags); 297 } 298 299 public org.omg.CORBA.ExceptionList create_exception_list() { 300 return new ExceptionListImpl(); 301 } 302 303 public org.omg.CORBA.ContextList create_context_list() { 304 return new ContextListImpl(this); 305 } 306 307 public org.omg.CORBA.Context get_default_context() 308 { 309 throw wrapper.genericNoImpl() ; 310 } 311 312 public org.omg.CORBA.Environment create_environment() 313 { 314 return new EnvironmentImpl(); 315 } 316 317 public org.omg.CORBA.Current get_current() 318 { 319 throw wrapper.genericNoImpl() ; 320 } 321 322 /* 323 * Things that aren't allowed. 324 */ 325 326 public String[] list_initial_services () 327 { 328 throw wrapper.genericNoImpl() ; 329 } 330 331 public org.omg.CORBA.Object resolve_initial_references(String identifier) 332 throws InvalidName 333 { 334 throw wrapper.genericNoImpl() ; 335 } 336 337 public void register_initial_reference( 338 String id, org.omg.CORBA.Object obj ) throws InvalidName 339 { 340 throw wrapper.genericNoImpl() ; 341 } 342 343 public void send_multiple_requests_oneway(Request[] req) { 344 throw new SecurityException("ORBSingleton: access denied"); 345 } 346 347 public void send_multiple_requests_deferred(Request[] req) { 348 throw new SecurityException("ORBSingleton: access denied"); 349 } 350 351 public boolean poll_next_response() { 352 throw new SecurityException("ORBSingleton: access denied"); 353 } 354 355 public org.omg.CORBA.Request get_next_response() { 356 throw new SecurityException("ORBSingleton: access denied"); 357 } 358 359 public String object_to_string(org.omg.CORBA.Object obj) { 360 throw new SecurityException("ORBSingleton: access denied"); 361 } 362 363 public org.omg.CORBA.Object string_to_object(String s) { 364 throw new SecurityException("ORBSingleton: access denied"); 365 } 366 367 public java.rmi.Remote string_to_remote(String s) 368 throws java.rmi.RemoteException 369 { 370 throw new SecurityException("ORBSingleton: access denied"); 371 } 372 373 public void connect(org.omg.CORBA.Object servant) { 374 throw new SecurityException("ORBSingleton: access denied"); 375 } 376 377 public void disconnect(org.omg.CORBA.Object obj) { 378 throw new SecurityException("ORBSingleton: access denied"); 379 } 380 381 public void run() 382 { 383 throw new SecurityException("ORBSingleton: access denied"); 384 } 385 386 public void shutdown(boolean wait_for_completion) 387 { 388 throw new SecurityException("ORBSingleton: access denied"); 389 } 390 391 protected void shutdownServants(boolean wait_for_completion) { 392 throw new SecurityException("ORBSingleton: access denied"); 393 } 394 395 protected void destroyConnections() { 396 throw new SecurityException("ORBSingleton: access denied"); 397 } 398 399 public void destroy() { 400 throw new SecurityException("ORBSingleton: access denied"); 401 } 402 403 public boolean work_pending() 404 { 405 throw new SecurityException("ORBSingleton: access denied"); 406 } 407 408 public void perform_work() 409 { 410 throw new SecurityException("ORBSingleton: access denied"); 411 } 412 413 public org.omg.CORBA.portable.ValueFactory register_value_factory(String repositoryID, 414 org.omg.CORBA.portable.ValueFactory factory) 415 { 416 throw new SecurityException("ORBSingleton: access denied"); 417 } 418 419 public void unregister_value_factory(String repositoryID) 420 { 421 throw new SecurityException("ORBSingleton: access denied"); 422 } 423 424 public org.omg.CORBA.portable.ValueFactory lookup_value_factory(String repositoryID) 425 { 426 throw new SecurityException("ORBSingleton: access denied"); 427 } 428 429 public TransportManager getTransportManager() 430 { 431 throw new SecurityException("ORBSingleton: access denied"); 432 } 433 434 public CorbaTransportManager getCorbaTransportManager() 435 { 436 throw new SecurityException("ORBSingleton: access denied"); 437 } 438 439 public LegacyServerSocketManager getLegacyServerSocketManager() 440 { 441 throw new SecurityException("ORBSingleton: access denied"); 442 } 443 444 /************************************************************************* 445 These are methods from com.sun.corba.se.impl.se.core.ORB 446 ************************************************************************/ 447 448 private synchronized ORB getFullORB() 449 { 450 if (fullORB == null) { 451 Properties props = new Properties() ; 452 fullORB = new ORBImpl() ; 453 fullORB.set_parameters( props ) ; 454 } 455 456 return fullORB ; 457 } 458 459 public RequestDispatcherRegistry getRequestDispatcherRegistry() 460 { 461 // To enable read_Object. 462 463 return getFullORB().getRequestDispatcherRegistry(); 464 } 465 466 /** 467 * Return the service context registry 468 */ 469 public ServiceContextRegistry getServiceContextRegistry() 470 { 471 throw new SecurityException("ORBSingleton: access denied"); 472 } 473 474 /** 475 * Get the transient server ID 476 */ 477 public int getTransientServerId() 478 { 479 throw new SecurityException("ORBSingleton: access denied"); 480 } 481 482 /** 483 * Return the bootstrap naming port specified in the ORBInitialPort param. 484 */ 485 public int getORBInitialPort() 486 { 487 throw new SecurityException("ORBSingleton: access denied"); 488 } 489 490 /** 491 * Return the bootstrap naming host specified in the ORBInitialHost param. 492 */ 493 public String getORBInitialHost() 494 { 495 throw new SecurityException("ORBSingleton: access denied"); 496 } 497 498 public String getORBServerHost() 499 { 500 throw new SecurityException("ORBSingleton: access denied"); 501 } 502 503 public int getORBServerPort() 504 { 505 throw new SecurityException("ORBSingleton: access denied"); 506 } 507 508 public CodeSetComponentInfo getCodeSetComponentInfo() 509 { 510 return new CodeSetComponentInfo(); 511 } 512 513 public boolean isLocalHost( String host ) 514 { 515 // To enable read_Object. 516 return false; 517 } 518 519 public boolean isLocalServerId( int subcontractId, int serverId ) 520 { 521 // To enable read_Object. 522 return false; 523 } 524 525 /* 526 * Things from corba.ORB. 527 */ 528 529 public ORBVersion getORBVersion() 530 { 531 // Always use our latest ORB version (latest fixes, etc) 532 return ORBVersionFactory.getORBVersion(); 533 } 534 535 public void setORBVersion(ORBVersion verObj) 536 { 537 throw new SecurityException("ORBSingleton: access denied"); 538 } 539 540 public String getAppletHost() 541 { 542 throw new SecurityException("ORBSingleton: access denied"); 543 } 544 545 public URL getAppletCodeBase() 546 { 547 throw new SecurityException("ORBSingleton: access denied"); 548 } 549 550 public int getHighWaterMark(){ 551 throw new SecurityException("ORBSingleton: access denied"); 552 } 553 554 public int getLowWaterMark(){ 555 throw new SecurityException("ORBSingleton: access denied"); 556 } 557 558 public int getNumberToReclaim(){ 559 throw new SecurityException("ORBSingleton: access denied"); 560 } 561 562 public int getGIOPFragmentSize() { 563 return ORBConstants.GIOP_DEFAULT_BUFFER_SIZE; 564 } 565 566 public int getGIOPBuffMgrStrategy(GIOPVersion gv) { 567 return BufferManagerFactory.GROW; 568 } 569 570 public IOR getFVDCodeBaseIOR(){ 571 throw new SecurityException("ORBSingleton: access denied"); 572 } 573 574 public Policy create_policy( int type, Any val ) throws PolicyError 575 { 576 throw new NO_IMPLEMENT(); 577 } 578 579 public LegacyServerSocketEndPointInfo getServerEndpoint() 580 { 581 return null ; 582 } 583 584 public void setPersistentServerId( int id ) 585 { 586 } 587 588 public TypeCodeImpl getTypeCodeForClass( Class c ) 589 { 590 return null ; 591 } 592 593 public void setTypeCodeForClass( Class c, TypeCodeImpl tcimpl ) 594 { 595 } 596 597 public boolean alwaysSendCodeSetServiceContext() 598 { 599 return true ; 600 } 601 602 public boolean isDuringDispatch() 603 { 604 return false ; 605 } 606 607 public void notifyORB() { } 608 609 public PIHandler getPIHandler() 610 { 611 return null ; 612 } 613 614 public void checkShutdownState() 615 { 616 } 617 618 public void startingDispatch() 619 { 620 } 621 622 public void finishedDispatch() 623 { 624 } 625 626 public void registerInitialReference( String id, Closure closure ) 627 { 628 } 629 630 public ORBData getORBData() 631 { 632 return getFullORB().getORBData() ; 633 } 634 635 public void setClientDelegateFactory( ClientDelegateFactory factory ) 636 { 637 } 638 639 public ClientDelegateFactory getClientDelegateFactory() 640 { 641 return getFullORB().getClientDelegateFactory() ; 642 } 643 644 public void setCorbaContactInfoListFactory( CorbaContactInfoListFactory factory ) 645 { 646 } 647 648 public CorbaContactInfoListFactory getCorbaContactInfoListFactory() 649 { 650 return getFullORB().getCorbaContactInfoListFactory() ; 651 } 652 653 public Operation getURLOperation() 654 { 655 return null ; 656 } 657 658 public void setINSDelegate( CorbaServerRequestDispatcher sdel ) 659 { 660 } 661 662 public TaggedComponentFactoryFinder getTaggedComponentFactoryFinder() 663 { 664 return getFullORB().getTaggedComponentFactoryFinder() ; 665 } 666 667 public IdentifiableFactoryFinder getTaggedProfileFactoryFinder() 668 { 669 return getFullORB().getTaggedProfileFactoryFinder() ; 670 } 671 672 public IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder() 673 { 674 return getFullORB().getTaggedProfileTemplateFactoryFinder() ; 675 } 676 677 public ObjectKeyFactory getObjectKeyFactory() 678 { 679 return getFullORB().getObjectKeyFactory() ; 680 } 681 682 public void setObjectKeyFactory( ObjectKeyFactory factory ) 683 { 684 throw new SecurityException("ORBSingleton: access denied"); 685 } 686 687 public void handleBadServerId( ObjectKey okey ) 688 { 689 } 690 691 public OAInvocationInfo peekInvocationInfo() 692 { 693 return null ; 694 } 695 696 public void pushInvocationInfo( OAInvocationInfo info ) 697 { 698 } 699 700 public OAInvocationInfo popInvocationInfo() 701 { 702 return null ; 703 } 704 705 public ClientInvocationInfo createOrIncrementInvocationInfo() 706 { 707 return null ; 708 } 709 710 public void releaseOrDecrementInvocationInfo() 711 { 712 } 713 714 public ClientInvocationInfo getInvocationInfo() 715 { 716 return null ; 717 } 718 719 public ConnectionCache getConnectionCache(ContactInfo contactInfo) 720 { 721 return null; 722 } 723 724 public void setResolver( Resolver resolver ) 725 { 726 } 727 728 public Resolver getResolver() 729 { 730 return null ; 731 } 732 733 public void setLocalResolver( LocalResolver resolver ) 734 { 735 } 736 737 public LocalResolver getLocalResolver() 738 { 739 return null ; 740 } 741 742 public void setURLOperation( Operation stringToObject ) 743 { 744 } 745 746 // NOTE: REMOVE THIS METHOD ONCE WE HAVE A ORT BASED ORBD 747 public void setBadServerIdHandler( BadServerIdHandler handler ) 748 { 749 } 750 751 // NOTE: REMOVE THIS METHOD ONCE WE HAVE A ORT BASED ORBD 752 public void initBadServerIdHandler() 753 { 754 } 755 756 public Selector getSelector(int x) 757 { 758 return null; 759 } 760 761 public void setThreadPoolManager(ThreadPoolManager mgr) { 762 } 763 764 public ThreadPoolManager getThreadPoolManager() { 765 return null; 766 } 767 768 public CopierManager getCopierManager() { 769 return null ; 770 } 771 772 @Override 773 public void validateIORClass(String iorClassName) { 774 getFullORB().validateIORClass(iorClassName); 775 776 } 777 778 } 779 780 // End of file.