KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > iiop > jacorb > SSLSocketFactory


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.iiop.jacorb;
23
24 import java.io.IOException JavaDoc;
25 import java.net.Socket JavaDoc;
26 import java.net.UnknownHostException JavaDoc;
27 import javax.net.ssl.SSLSocket;
28
29 import org.jboss.iiop.CorbaORBService;
30 import org.jboss.logging.Logger;
31 import org.jboss.security.SecurityDomain;
32 import org.jboss.security.ssl.DomainSocketFactory;
33 import org.jboss.system.Registry;
34
35 /**
36  * This implementation of the JacORB-specific interface
37  * <code>org.jacorb.orb.factory.SocketFactory</code> uses the JSSE
38  * KeyManagerFactory and TrustManagerFactory objects encapsulated by
39  * a JBossSX SecurityDomain. It looks up the
40  * <code>org.jboss.security.SecurityDomain</code> instance bound to the
41  * name <code>CorbaORBService.SSL_DOMAIN</code> in the JBoss registry.
42  *
43  * @author <a HREF="mailto:reverbel@ime.usp.br">Francisco Reverbel</a>
44  * @version $Revision: 37459 $
45  */

46 public class SSLSocketFactory
47    implements org.jacorb.orb.factory.SocketFactory,
48               org.apache.avalon.framework.configuration.Configurable
49 {
50    // Static --------------------------------------------------------
51

52    private static Logger log = Logger.getLogger(SSLSocketFactory.class);
53
54    // Attributes ----------------------------------------------------
55

56    private DomainSocketFactory domainFactory = null;
57    private String JavaDoc[] cipher_suites = null;
58    
59    // Constructor ---------------------------------------------------
60

61    public SSLSocketFactory(org.jacorb.orb.ORB orb)
62       throws IOException JavaDoc
63    {
64       log.info("Creating");
65
66       SecurityDomain securityDomain =
67          (SecurityDomain)Registry.lookup(CorbaORBService.SSL_DOMAIN);
68
69       try
70       {
71          domainFactory = new DomainSocketFactory(securityDomain);
72       }
73       catch (IOException JavaDoc e)
74       {
75          log.warn("Could not create DomainSocketFactory: " + e);
76          log.debug("Exception creating DomainSockedFactory: ", e);
77          throw e;
78       }
79    }
80    
81    // JacORB SSLSocketFactory implementation ------------------------
82
// (interface org.jacorb.orb.factory.SSLSocketFactory)
83

84    public Socket JavaDoc createSocket(String JavaDoc host, int port)
85       throws IOException JavaDoc, UnknownHostException JavaDoc
86    {
87       return domainFactory.createSocket(host, port);
88    }
89    
90    public boolean isSSL (java.net.Socket JavaDoc s)
91    {
92       return (s instanceof SSLSocket);
93    }
94    
95    // Avalon Configurable implementation ----------------------------
96

97    public void configure(
98          org.apache.avalon.framework.configuration.Configuration configuration)
99       throws org.apache.avalon.framework.configuration.ConfigurationException
100    {
101       // no-op
102
}
103
104 }
105
Popular Tags