KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > client > AdminRMISSLClientSocketFactoryEnvImpl


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  * $Header: /cvs/glassfish/admin-core/mbeanapi/src/java/com/sun/appserv/management/client/AdminRMISSLClientSocketFactoryEnvImpl.java,v 1.4 2006/03/09 20:30:21 llc Exp $
26  * $Revision: 1.4 $
27  * $Date: 2006/03/09 20:30:21 $
28  */

29 package com.sun.appserv.management.client;
30
31 import java.io.File JavaDoc;
32 import java.util.HashMap JavaDoc;
33 import java.util.Map JavaDoc;
34
35 import javax.net.ssl.TrustManager;
36 import javax.net.ssl.X509TrustManager;
37 import javax.net.ssl.HandshakeCompletedListener;
38
39 /**
40     <b>Not for public use</b>
41     <p>
42     Class which encapsulates knowledge of how to exchange data between the
43     RMISSLClientSocketFactory stub and the JVM into which it gets downloaded.
44     <p>
45     The client code configures this class so the RMI client stub may obtain
46     any environmental overrides, thus enabling the client to control how the RMI
47     stub behaves.
48     <p>
49     This class is global for all outgoing connections for RMI.
50  */

51 public final class AdminRMISSLClientSocketFactoryEnvImpl // do NOT implement Serializable
52
implements AdminRMISSLClientSocketFactoryEnv
53 {
54     private static AdminRMISSLClientSocketFactoryEnvImpl INSTANCE = null;
55     
56     private transient TrustManager[] mTrustManagers = null;
57     private transient HandshakeCompletedListener mHandshakeCompletedListener = null;
58     
59     private transient boolean mTrace = false;
60     
61     // for future extensions
62
private transient Map JavaDoc<String JavaDoc,Object JavaDoc> mValues;
63     
64     
65         public static synchronized AdminRMISSLClientSocketFactoryEnvImpl
66     getInstance()
67     {
68         // these should only ever be a single instance
69
if ( INSTANCE == null )
70         {
71             INSTANCE = new AdminRMISSLClientSocketFactoryEnvImpl();
72         }
73         return( INSTANCE );
74     }
75
76         private
77     AdminRMISSLClientSocketFactoryEnvImpl( )
78     {
79         // important for server side to have these in place, or they
80
// will look for a truststore
81
mTrustManagers = new TrustManager[0];
82         
83         mValues = new HashMap JavaDoc<String JavaDoc,Object JavaDoc>();
84     }
85     
86     
87         public Object JavaDoc
88     getValue( final String JavaDoc key )
89     {
90         return( mValues.get( key ) );
91     }
92     
93     /**
94         No values are currently supported; this routine exists
95         for future extensions.
96         
97         @param key
98         @param value
99      */

100         public Object JavaDoc
101     setValue( final String JavaDoc key, final Object JavaDoc value )
102     {
103         return( mValues.put( key, value ) );
104     }
105     
106     /**
107         Set the TrustManagers. Removes any existing trust-store and trust-store password
108         as the TrustManagers will be used instead.
109         
110         @param trustManagers
111      */

112         public void
113     setTrustManagers( final TrustManager[] trustManagers )
114     {
115         mTrustManagers = trustManagers;
116     }
117
118         public TrustManager[]
119     getTrustManagers( )
120     {
121         return( mTrustManagers );
122     }
123  
124     /**
125         Set a HandshakeCompletedListener (optional).
126         
127         @param listener
128      */

129         public void
130     setHandshakeCompletedListener( final HandshakeCompletedListener listener )
131     {
132         mHandshakeCompletedListener = listener;
133     }
134     
135         public HandshakeCompletedListener
136     getHandshakeCompletedListener( )
137     {
138         return( mHandshakeCompletedListener );
139     }
140     
141     /**
142         Set tracing on or off.
143         
144         @param trace
145      */

146         public void
147     setTrace( final boolean trace )
148     {
149         mTrace = trace;
150     }
151         public boolean
152     getTrace()
153     {
154         return( mTrace );
155     }
156     
157 }
158
Popular Tags