KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > iiop > CSIv2SSLTaggedComponentHandlerImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 //
25
// Created : 2005 Jul 29 (Fri) 08:23:33 by Harold Carr.
26
// Last Modified : 2005 Aug 31 (Wed) 19:57:12 by Harold Carr.
27
//
28

29 package com.sun.enterprise.iiop;
30
31 import java.util.ArrayList JavaDoc;
32 import java.util.List JavaDoc;
33 import java.util.logging.Level JavaDoc;
34 import java.util.logging.Logger JavaDoc;
35
36 import org.omg.CORBA.ORBPackage.InvalidName JavaDoc;
37 import org.omg.IOP.TaggedComponent JavaDoc;
38 import org.omg.PortableInterceptor.IORInfo JavaDoc;
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 // BEGIN imports for (extract) getSocketInfo code
52
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 // END imports for getSocketInfo code
57

58 import com.sun.logging.LogDomains;
59 //
60

61 /**
62  * @author Harold Carr
63  */

64 public class CSIv2SSLTaggedComponentHandlerImpl
65     extends org.omg.CORBA.LocalObject JavaDoc
66     implements CSIv2SSLTaggedComponentHandler,
67            ORBConfigurator
68 {
69     private static Logger JavaDoc _logger = null;
70     static {
71         _logger = LogDomains.getLogger(LogDomains.CORBA_LOGGER);
72     }
73
74     private final String JavaDoc baseMsg =
75     CSIv2SSLTaggedComponentHandlerImpl.class.getName();
76
77     private ORB orb;
78
79     ////////////////////////////////////////////////////
80
//
81
// CSIv2SSLTaggedComponentHandler
82
//
83

84     public TaggedComponent JavaDoc insert(IORInfo JavaDoc iorInfo,
85                   List JavaDoc<ClusterInstanceInfo> clusterInstanceInfo)
86     {
87     TaggedComponent JavaDoc result = null;
88     try {
89         if (_logger.isLoggable(Level.FINE)) {
90         _logger.log(Level.FINE, baseMsg + ".insert->:");
91         }
92             List JavaDoc<com.sun.corba.ee.spi.folb.SocketInfo> socketInfos = new ArrayList JavaDoc<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 JavaDoc 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 JavaDoc<SocketInfo> extract(IOR ior)
128     {
129     List JavaDoc<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 JavaDoc 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 JavaDoc 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     ////////////////////////////////////////////////////
169
//
170
// ORBConfigurator
171
//
172

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 JavaDoc 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 // End of file.
195

196
197
Popular Tags