1 23 24 29 package com.sun.enterprise.iiop; 30 31 import java.util.ArrayList ; 32 import java.util.List ; 33 import java.util.logging.Level ; 34 import java.util.logging.Logger ; 35 36 import org.omg.CORBA.ORBPackage.InvalidName ; 37 import org.omg.IOP.TaggedComponent ; 38 import org.omg.PortableInterceptor.IORInfo ; 39 40 import com.sun.corba.ee.spi.folb.ClusterInstanceInfo; 41 import com.sun.corba.ee.spi.folb.CSIv2SSLTaggedComponentHandler; 42 import com.sun.corba.ee.spi.ior.IOR; 43 import com.sun.corba.ee.spi.orb.DataCollector; 44 import com.sun.corba.ee.spi.orb.ORB; 45 import com.sun.corba.ee.spi.orb.ORBConfigurator; 46 import com.sun.corba.ee.spi.transport.SocketInfo; 47 48 import com.sun.corba.ee.impl.orbutil.ORBConstants; 49 import com.sun.corba.ee.impl.orbutil.ORBUtility; 50 51 import com.sun.corba.ee.spi.ior.iiop.IIOPProfileTemplate ; 53 import com.sun.corba.ee.spi.ior.iiop.IIOPAddress ; 54 import com.sun.enterprise.iiop.security.SecurityMechanismSelector; 55 import com.sun.enterprise.iiop.security.ConnectionContext; 56 58 import com.sun.logging.LogDomains; 59 61 64 public class CSIv2SSLTaggedComponentHandlerImpl 65 extends org.omg.CORBA.LocalObject 66 implements CSIv2SSLTaggedComponentHandler, 67 ORBConfigurator 68 { 69 private static Logger _logger = null; 70 static { 71 _logger = LogDomains.getLogger(LogDomains.CORBA_LOGGER); 72 } 73 74 private final String baseMsg = 75 CSIv2SSLTaggedComponentHandlerImpl.class.getName(); 76 77 private ORB orb; 78 79 84 public TaggedComponent insert(IORInfo iorInfo, 85 List <ClusterInstanceInfo> clusterInstanceInfo) 86 { 87 TaggedComponent result = null; 88 try { 89 if (_logger.isLoggable(Level.FINE)) { 90 _logger.log(Level.FINE, baseMsg + ".insert->:"); 91 } 92 List <com.sun.corba.ee.spi.folb.SocketInfo> socketInfos = new ArrayList <com.sun.corba.ee.spi.folb.SocketInfo>(); 93 for(ClusterInstanceInfo clInstInfo : clusterInstanceInfo){ 94 for(int endPIndex=0; endPIndex < clInstInfo.endpoints.length; endPIndex++){ 95 com.sun.corba.ee.spi.folb.SocketInfo socketInfo = clInstInfo.endpoints[endPIndex]; 96 if(socketInfo.type.equals("SSL") || socketInfo.type.equals("SSL_MUTUALAUTH")){ 97 socketInfos.add(socketInfo); 98 } 99 } 100 } 101 org.omg.CORBA.ORB orb = com.sun.enterprise.util.ORBManager.getORB(); 102 int sslMutualAuthPort = -1; 103 try { 104 sslMutualAuthPort = ((com.sun.corba.ee.spi.legacy.interceptor.IORInfoExt)iorInfo). 105 getServerPort("SSL_MUTUALAUTH"); 106 } catch (com.sun.corba.ee.spi.legacy.interceptor.UnknownType ute) { 107 _logger.log(Level.FINE,".isnert: UnknownType exception", ute); 108 } 109 110 if(_logger.isLoggable(Level.FINE)) { 111 _logger.log(Level.FINE, 112 ".insert: sslMutualAuthPort: " 113 + sslMutualAuthPort); 114 } 115 116 CSIV2TaggedComponentInfo ctc = new CSIV2TaggedComponentInfo(orb); 117 ctc.setSSLMutualAuthPort(sslMutualAuthPort); 118 result = ctc.createSecurityTaggedComponent(socketInfos); 119 return result; 120 } finally { 121 if (_logger.isLoggable(Level.FINE)) { 122 _logger.log(Level.FINE, baseMsg + ".insert<-: " + result); 123 } 124 } 125 } 126 127 public List <SocketInfo> extract(IOR ior) 128 { 129 List <SocketInfo> socketInfo = null; 130 try { 131 if (_logger.isLoggable(Level.FINE)) { 132 _logger.log(Level.FINE, baseMsg + ".extract->:"); 133 } 134 SecurityMechanismSelector selector = new SecurityMechanismSelector(); 135 IIOPProfileTemplate iiopProfileTemplate = (IIOPProfileTemplate)ior. 136 getProfile().getTaggedProfileTemplate(); 137 IIOPAddress primary = iiopProfileTemplate.getPrimaryAddress() ; 138 String host = primary.getHost().toLowerCase(); 139 140 ConnectionContext ctx = new ConnectionContext(); 141 socketInfo = selector.getSSLPorts(ior, ctx); 142 selector.setClientConnectionContext(ctx); 143 if (socketInfo == null) { 144 if (_logger.isLoggable(Level.FINE)) { 145 _logger.log(Level.FINE, baseMsg 146 + ".extract: did not find SSL SocketInfo"); 147 } 148 } else { 149 if (_logger.isLoggable(Level.FINE)) { 150 _logger.log(Level.FINE, baseMsg 151 + ".extract: found SSL socketInfo"); 152 } 153 } 154 if (_logger.isLoggable(Level.FINE)) { 155 _logger.log(Level.FINE, baseMsg 156 + ".extract: Connection Context:" + ctx); 157 } 158 } catch ( Exception ex ) { 159 _logger.log(Level.WARNING, "Exception getting SocketInfo", ex); 160 } finally { 161 if (_logger.isLoggable(Level.FINE)) { 162 _logger.log(Level.FINE, baseMsg + ".extract<-: " + socketInfo); 163 } 164 } 165 return socketInfo; 166 } 167 168 173 public void configure(DataCollector collector, ORB orb) 174 { 175 if (_logger.isLoggable(Level.FINE)) { 176 _logger.log(Level.FINE, ".configure->:"); 177 } 178 179 this.orb = orb; 180 try { 181 orb.register_initial_reference( 182 ORBConstants.CSI_V2_SSL_TAGGED_COMPONENT_HANDLER, 183 this); 184 } catch (InvalidName e) { 185 _logger.log(Level.WARNING, ".configure: ", e); 186 } 187 188 if (_logger.isLoggable(Level.FINE)) { 189 _logger.log(Level.FINE, ".configure<-:"); 190 } 191 } 192 } 193 194 196 197 | Popular Tags |