1 23 package com.sun.enterprise.iiop; 24 25 import java.lang.reflect.Constructor ; 26 27 import org.omg.CORBA.ORB ; 28 import org.omg.CORBA.TSIdentification; 29 import org.omg.PortableInterceptor.ClientRequestInterceptor ; 30 import org.omg.PortableInterceptor.ServerRequestInterceptor ; 31 import org.omg.PortableInterceptor.ORBInitializer ; 32 import org.omg.PortableInterceptor.Current ; 33 import org.omg.IOP.Codec ; 34 import org.omg.IOP.CodecFactory ; 35 import org.omg.IOP.Encoding ; 36 import org.omg.IOP.ENCODING_CDR_ENCAPS ; 37 38 import com.sun.enterprise.log.Log; 39 40 import com.sun.enterprise.iiop.security.SecClientRequestInterceptor; 41 import com.sun.enterprise.iiop.security.SecServerRequestInterceptor; 42 import com.sun.enterprise.iiop.security.SecurityService; 43 import com.sun.enterprise.iiop.security.SecurityServiceImpl; 44 import com.sun.enterprise.iiop.security.Csiv2Manager; 45 46 import com.sun.corba.ee.spi.legacy.interceptor.ORBInitInfoExt; 47 import com.sun.jts.pi.InterceptorImpl; 48 import java.util.logging.*; 49 import com.sun.logging.*; 50 51 58 59 public class J2EEInitializer extends org.omg.CORBA.LocalObject 60 implements ORBInitializer 61 { 62 private static Logger _logger=null; 63 static{ 64 _logger=LogDomains.getLogger(LogDomains.CORBA_LOGGER); 65 } 66 67 private static final String SEC_INTEROP_CLIENTINT_PROP = "interop.secinterceptor.client"; 68 private static final String SEC_INTEROP_SERVERINT_PROP = "interop.secinterceptor.server"; 69 70 public J2EEInitializer() { 71 try { 72 System.setProperty( 73 com.sun.jts.pi.InterceptorImpl.CLIENT_POLICY_CHECKING, 74 String.valueOf(false)); 75 } catch ( Exception ex ) { 76 _logger.log(Level.WARNING,"iiop.readproperty_exception",ex); 77 } 78 } 79 80 85 public void pre_init(org.omg.PortableInterceptor.ORBInitInfo info) 86 { 87 } 88 89 94 public void post_init(org.omg.PortableInterceptor.ORBInitInfo info) 95 { 96 Codec codec = null; 97 98 if(_logger.isLoggable(Level.FINE)){ 99 _logger.log(Level.FINE,"J2EE Initializer post_init"); 100 _logger.log(Level.FINE,"Creating Codec for CDR encoding"); 102 } 103 104 CodecFactory cf = info.codec_factory(); 105 106 byte major_version = 1; 107 byte minor_version = 2; 108 Encoding encoding = new Encoding (ENCODING_CDR_ENCAPS.value, 109 major_version, minor_version); 110 try { 111 codec = cf.create_codec(encoding); 112 113 ClientConnectionInterceptor cci = 115 new ClientConnectionInterceptor("ClientConnInterceptor",1); 116 info.add_client_request_interceptor(cci); 117 118 String clientSecInterceptor = System.getProperty(SEC_INTEROP_CLIENTINT_PROP); 119 String serverSecInterceptor = System.getProperty(SEC_INTEROP_SERVERINT_PROP); 120 121 ClientRequestInterceptor creq; 122 ServerRequestInterceptor sreq; 123 124 if( clientSecInterceptor == null ) { 125 creq = new SecClientRequestInterceptor( 126 "SecClientRequestInterceptor", codec); 127 } 128 else { 129 try { 130 Class cInterceptorClass = 131 Class.forName( clientSecInterceptor ); 132 133 Class [] paramTypes = new Class [2]; 135 paramTypes[0] = java.lang.String .class; 136 paramTypes[1] = org.omg.IOP.Codec .class; 137 138 Object [] params = new Object [2]; 139 params[0] = "SecClientRequestInterceptor"; 140 params[1] = codec; 141 142 Constructor constructor = cInterceptorClass.getConstructor( 143 paramTypes ); 144 145 creq = (ClientRequestInterceptor ) 146 constructor.newInstance( params ); 147 } 148 catch( Exception e ) { 149 if (_logger.isLoggable(Level.FINE)) { 150 _logger.log(Level.FINE,"Exception registering security client request receptor",e); 151 _logger.log(Level.FINE,"Going to register default security client request interceptor"); 152 } 153 creq = new SecClientRequestInterceptor( 154 "SecClientRequestInterceptor", codec); 155 } 156 } 157 158 if( serverSecInterceptor == null ) { 159 sreq = new SecServerRequestInterceptor( 160 "SecServerRequestInterceptor", codec); 161 } 162 else { 163 try { 164 Class sInterceptorClass = 165 Class.forName( serverSecInterceptor ); 166 167 Class [] paramTypes = new Class [2]; 169 paramTypes[0] = java.lang.String .class; 170 paramTypes[1] = org.omg.IOP.Codec .class; 171 172 Object [] params = new Object [2]; 173 params[0] = "SecServerRequestInterceptor"; 174 params[1] = codec; 175 176 Constructor constructor = sInterceptorClass.getConstructor( 177 paramTypes ); 178 179 sreq = (ServerRequestInterceptor ) 180 constructor.newInstance( params ); 181 } 182 catch( Exception e ) { 183 if (_logger.isLoggable(Level.FINE)) { 184 _logger.log(Level.FINE,"Exception registering security server request receptor",e); 185 _logger.log(Level.FINE,"Going to register default security server request interceptor"); 186 } 187 sreq = new SecServerRequestInterceptor( 188 "SecServerRequestInterceptor", codec); 189 } 190 } 191 192 info.add_client_request_interceptor(creq); 193 194 ServerConnectionInterceptor sci = 195 new ServerConnectionInterceptor(2); 196 info.add_server_request_interceptor(sci); 197 info.add_server_request_interceptor(sreq); 198 199 SecurityService ss = new SecurityServiceImpl(); 200 Csiv2Manager.setSecurityService(ss); 201 202 203 Current pic = (Current )info.resolve_initial_references("PICurrent"); 206 207 int[] slotIds = new int[2]; 209 slotIds[0] = info.allocate_slot_id(); 210 slotIds[1] = info.allocate_slot_id(); 211 212 InterceptorImpl interceptor = 213 new InterceptorImpl(pic, codec, slotIds, null); 214 info.add_client_request_interceptor(interceptor); 215 info.add_server_request_interceptor(interceptor); 216 217 com.sun.corba.ee.spi.orb.ORB thisORB = ((ORBInitInfoExt)info).getORB(); 220 221 PEORBConfigurator.setJTSInterceptor(interceptor, thisORB); 222 223 TxSecIORInterceptor iorInterceptor = new TxSecIORInterceptor(codec); 225 info.add_ior_interceptor(iorInterceptor); 226 227 } catch (Exception e) { 228 if(_logger.isLoggable(Level.FINE)){ 229 _logger.log(Level.FINE,"Exception registering JTS interceptors",e); 230 } 231 throw new RuntimeException (e.getMessage()); 232 } 233 234 } 235 } 236 237 | Popular Tags |