1 23 24 package com.sun.enterprise.iiop; 25 26 import java.util.logging.*; 27 import java.util.Properties ; 28 import java.io.IOException ; 29 30 import org.omg.CORBA.Any ; 31 import org.omg.CORBA.ORB ; 32 import org.omg.CORBA.INV_POLICY ; 33 import org.omg.CORBA.INTERNAL ; 34 import org.omg.IOP.Codec ; 35 import org.omg.IOP.Encoding ; 36 import org.omg.IOP.TaggedComponent ; 37 import org.omg.PortableInterceptor.IORInfo ; 38 39 import org.omg.CosTransactions.*; 40 import org.omg.CosTSInteroperation.TAG_OTS_POLICY; 41 import org.omg.CosTSInteroperation.TAG_INV_POLICY; 42 43 import com.sun.logging.*; 44 import com.sun.enterprise.deployment.EjbDescriptor; 45 import com.sun.enterprise.util.ORBManager; 46 import com.sun.enterprise.util.Utility; 47 import com.sun.enterprise.iiop.ASORBUtilities; 48 49 50 public class TxSecIORInterceptor extends org.omg.CORBA.LocalObject 51 implements org.omg.PortableInterceptor.IORInterceptor { 52 53 54 private static Logger _logger=null; 55 56 static { 57 _logger=LogDomains.getLogger(LogDomains.CORBA_LOGGER); 58 } 59 60 private Codec codec; 61 62 63 public TxSecIORInterceptor(Codec c) { 64 codec = c; 65 } 66 67 public void destroy() { 68 } 69 70 public String name() { 71 return "TxSecIORInterceptor"; 72 } 73 74 public void establish_components(IORInfo iorInfo) { 77 try { 78 _logger.log(Level.FINE, 79 "TxSecIORInterceptor.establish_components->:"); 80 81 OTSPolicy otsPolicy = null; 83 try { 84 otsPolicy = (OTSPolicy)iorInfo.get_effective_policy( 85 POARemoteReferenceFactory.OTS_POLICY_TYPE); 86 } catch ( INV_POLICY ex ) { 87 _logger.log(Level.FINE, 88 "TxSecIORInterceptor.establish_components: OTSPolicy not present"); 89 } 90 if ( otsPolicy != null ) { 91 addOTSComponents(iorInfo); 92 } 93 94 CSIv2Policy csiv2Policy = null; 96 try { 97 csiv2Policy = (CSIv2Policy)iorInfo.get_effective_policy( 98 POARemoteReferenceFactory.CSIv2_POLICY_TYPE); 99 } catch ( INV_POLICY ex ) { 101 _logger.log(Level.FINE, 102 "TxSecIORInterceptor.establish_components: CSIv2Policy not present"); 103 } 104 105 if(_logger.isLoggable(Level.FINE)) { 107 _logger.log(Level.FINE, 108 "TxSecIORInterceptor.establish_components: CSIv2Policy: " + csiv2Policy); 109 } 110 addCSIv2Components(iorInfo, csiv2Policy); 111 112 } catch (Exception e) { 113 _logger.log(Level.WARNING,"Exception in establish_components", e); 114 } finally { 115 _logger.log(Level.FINE, 116 "TxSecIORInterceptor.establish_components<-:"); 117 } 118 } 119 120 private void addOTSComponents(IORInfo iorInfo) 121 { 122 short invPolicyValue = SHARED.value; 123 short otsPolicyValue = ADAPTS.value; 124 125 Any otsAny = ORB.init().create_any(); 126 Any invAny = ORB.init().create_any(); 127 128 otsAny.insert_short(otsPolicyValue); 129 invAny.insert_short(invPolicyValue); 130 131 byte[] otsCompValue = null; 132 byte[] invCompValue = null; 133 try { 134 otsCompValue = codec.encode_value(otsAny); 135 invCompValue = codec.encode_value(invAny); 136 } catch (org.omg.IOP.CodecPackage.InvalidTypeForEncoding e) { 137 throw new INTERNAL ("InvalidTypeForEncoding "+e.getMessage()); 138 } 139 140 TaggedComponent otsComp = new TaggedComponent (TAG_OTS_POLICY.value, 141 otsCompValue); 142 iorInfo.add_ior_component(otsComp); 143 144 TaggedComponent invComp = new TaggedComponent (TAG_INV_POLICY.value, 145 invCompValue); 146 iorInfo.add_ior_component(invComp); 147 } 148 149 private void addCSIv2Components(IORInfo iorInfo, CSIv2Policy csiv2Policy) 150 { 151 try { 152 if(_logger.isLoggable(Level.FINE)) { 153 _logger.log(Level.FINE, 154 ".addCSIv2Components->: " 155 + " " + iorInfo + " " + csiv2Policy); 156 } 157 if (ASORBUtilities.isGMSAvailableAndClusterHeartbeatEnabled()) { 158 return; 159 } 160 161 EjbDescriptor ejbDesc = null; 162 163 if ( csiv2Policy != null ) { 164 ejbDesc = csiv2Policy.getEjbDescriptor(); 165 } 166 167 if(_logger.isLoggable(Level.FINE)) { 168 _logger.log(Level.FINE, 169 ".addCSIv2Components: ejbDesc: " + ejbDesc); 170 } 171 172 ORB orb = ORBManager.getORB(); 173 174 int sslMutualAuthPort = -1; 175 try { 176 sslMutualAuthPort = ((com.sun.corba.ee.spi.legacy.interceptor.IORInfoExt)iorInfo). 177 getServerPort("SSL_MUTUALAUTH"); 178 } catch (com.sun.corba.ee.spi.legacy.interceptor.UnknownType ute) { 179 _logger.log(Level.FINE,"UnknownType exception", ute); 180 } 181 182 if(_logger.isLoggable(Level.FINE)) { 183 _logger.log(Level.FINE, 184 ".addCSIv2Components: sslMutualAuthPort: " 185 + sslMutualAuthPort); 186 } 187 188 CSIV2TaggedComponentInfo ctc = new CSIV2TaggedComponentInfo(orb); 189 ctc.setSSLMutualAuthPort(sslMutualAuthPort); 190 191 int sslport = -1; 193 try { 194 sslport = ((com.sun.corba.ee.spi.legacy.interceptor.IORInfoExt)iorInfo). 195 getServerPort("SSL"); 196 } catch (com.sun.corba.ee.spi.legacy.interceptor.UnknownType ute) { 197 _logger.log(Level.FINE,"UnknownType exception", ute); 198 } 199 200 if(_logger.isLoggable(Level.FINE)) { 201 _logger.log(Level.FINE, 202 ".addCSIv2Components: sslport: " 203 + sslport); 204 } 205 206 TaggedComponent csiv2Comp = null; 207 if ( ejbDesc != null ) { 208 csiv2Comp = ctc.createSecurityTaggedComponent(sslport, ejbDesc); 209 } 210 else { 211 csiv2Comp = ctc.createSecurityTaggedComponent(sslport); 213 } 214 215 iorInfo.add_ior_component(csiv2Comp); 216 217 } finally { 218 if(_logger.isLoggable(Level.FINE)) { 219 _logger.log(Level.FINE, 220 ".addCSIv2Components<-: " 221 + " " + iorInfo + " " + csiv2Policy); 222 } 223 } 224 } 225 } 226 227 | Popular Tags |