KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > server > core > jmx > ssl > AdminSslClientSocketFactory


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  * AdminRmiSslClientSocketFactory.java
26  * Indentation Information:
27  * 0. Please (try to) preserve these settings.
28  * 1. No tabs are used, all spaces.
29  * 2. In vi/vim -
30  * :set tabstop=4 :set shiftwidth=4 :set softtabstop=4
31  * 3. In S1 Studio -
32  * 1. Tools->Options->Editor Settings->Java Editor->Tab Size = 4
33  * 2. Tools->Options->Indentation Engines->Java Indentation Engine->Expand Tabs to Spaces = True.
34  * 3. Tools->Options->Indentation Engines->Java Indentation Engine->Number of Spaces per Tab = 4.
35  * Unit Testing Information:
36  * 0. Is Standard Unit Test Written (y/n):
37  * 1. Unit Test Location: (The instructions should be in the Unit Test Class itself).
38  */

39
40 package com.sun.enterprise.admin.server.core.jmx.ssl;
41
42 import java.io.Serializable JavaDoc;
43 import java.io.IOException JavaDoc;
44 import java.net.Socket JavaDoc;
45 import java.rmi.server.RMIClientSocketFactory JavaDoc;
46 import javax.net.ssl.SSLContext;
47 import javax.net.ssl.SSLSocket;
48 import javax.net.ssl.SSLSocketFactory;
49 import com.sun.enterprise.config.serverbeans.Ssl;
50
51 /** This is the custom RMI client socket factory that uses the same keystore, truststore,
52  * certificate databases all the time. This factory will be used to create
53  * the client side sockets when rmi connector server is configured to use SSL. Please
54  * read the package.html.
55  * Since this class is not standard, it is not used.
56  * @author Kedar.Mhaswade@sun.com
57  * @since Application Server 8.1
58  */

59 public class AdminSslClientSocketFactory implements RMIClientSocketFactory JavaDoc, Serializable JavaDoc {
60     private final Ssl sslc;
61     public AdminSslClientSocketFactory(final Ssl sslc) {
62         if (sslc == null)
63             throw new IllegalArgumentException JavaDoc("Internal: null ssl configuration");
64         this.sslc = sslc;
65     }
66     /** Implementation of the only method in {@link RMIClientSocketFactory}. This
67      * method is called for creating the server socket.
68      * @return instance of ServerSocket
69      */

70     
71     public Socket JavaDoc createSocket(final String JavaDoc host, final int port) throws IOException JavaDoc {
72         try {
73             final SSLSocketFactory f = (SSLSocketFactory)SSLSocketFactory.getDefault();
74             final SSLSocket s = (SSLSocket) f.createSocket(host, port);
75             return ( s );
76         }
77         catch (final Exception JavaDoc e) {
78             throw new IOException JavaDoc (e.getMessage());
79         }
80     }
81     
82 }
83
Popular Tags