KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > agent > client > AgentConfiguration


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.agent.client;
21
22 import java.io.File JavaDoc;
23 import java.util.Enumeration JavaDoc;
24 import java.util.Vector JavaDoc;
25
26 import com.sslexplorer.agent.client.util.Utils;
27
28
29 /**
30  * Holds various configuration options for the <i>Agent</i>.
31  *
32  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
33  */

34 public class AgentConfiguration {
35     
36     // Protected instance variables
37
protected String JavaDoc guiClassName;
38     protected boolean displayInformationPopups = true;
39     protected boolean remoteTunnelsRequireConfirmation = false;
40     protected int shutdownPeriod = 10000;
41     protected boolean systemExitOnDisconnect = false;
42     protected int webForwardInactivity = 300000; // 5 mins
43
protected int tunnelInactivity = 600000; // 10 mins
44
protected String JavaDoc agentType = "sslexplorerAgent";
45     protected boolean getResources = true;
46     protected boolean cleanonExit = false;
47     protected File JavaDoc cacheDir = new File JavaDoc(Utils.getHomeDirectory(), ".sslexplorer");
48     protected Vector JavaDoc removeFiles = new Vector JavaDoc();
49     protected int keepAlivePeriod = 30000;
50     protected int keepAliveTimeout = 30000;
51     protected String JavaDoc localhostAddress = "127.0.0.1";
52     
53     /**
54      * Get the <i>Localhost Address</i>. This is used whenever
55      * the 'localhost' address should be used. For example, this may be
56      * set to 127.0.0.2 as a work around on systems where 127.0.0.1
57      * does not work correctly (RDP on Windows XP SP1).
58      *
59      * @return localhost address
60      */

61     public String JavaDoc getLocalhostAddress() {
62         return localhostAddress;
63     }
64     
65     /**
66      * Set the <i>Localhost Address</i>. This is used whenever
67      * the 'localhost' address should be used. For example, this may be
68      * set to 127.0.0.2 as a work around on systems where 127.0.0.1
69      * does not work correctly (RDP on Windows XP SP1).
70      *
71      * @return localhost address
72      */

73     public void setLocalhostAddress(String JavaDoc localhostAddress) {
74         this.localhostAddress = localhostAddress;
75     }
76     
77     /**
78      * Get the <i>Agent Type</i>. This is a name the agent will
79      * be identified to the server. For example, the name may
80      * be used on the server as if this client requires particular
81      * authentication behaviour.
82      *
83      * @return agent
84      */

85     public String JavaDoc getAgentType() {
86         return agentType;
87     }
88     
89     /**
90      * Get the <i>Agent Type</i>. This is a name the agent will
91      * be identified to the server. For example, the name may
92      * be used on the server as if this client requires particular
93      * authentication behaviour.
94      *
95      * @param agentType agent
96      */

97     public void setAgentType(String JavaDoc agentType) {
98         this.agentType = agentType;
99     }
100
101     /**
102      * Set whether the agent should attempt to get SSL-Explorer resources and
103      * add launcher shortcuts to the {@link AgentClientGUI} implementation.
104      *
105      * @param getResources whether to get SSL-Explorer resources
106      */

107     public void setGetResources(boolean getResources) {
108         this.getResources = getResources;
109     }
110
111     /**
112      * Get whether the agent should attempt to get SSL-Explorer resources and
113      * add launcher shortcuts to the {@link AgentClientGUI} implementation.
114      *
115      * @return whether to get SSL-Explorer resources
116      */

117     public boolean isGetResources() {
118         return getResources;
119     }
120
121     /**
122      * Set the number of milliseconds a web forward tunnel must be inactive for
123      * before being considered stale.
124      *
125      * @param webForwardInactivity web forward tunnel inactivity timeout (ms)
126      */

127     public void setWebForwardInactivity(int webForwardInactivity) {
128         this.webForwardInactivity = webForwardInactivity;
129     }
130
131     /**
132      * Set the number of milliseconds a tunnel must be inactive for before being
133      * considered stale.
134      *
135      * @param tunnelInactivity tunnel inactivity timeout (ms)
136      */

137     public void setTunnelInactivity(int tunnelInactivity) {
138         this.tunnelInactivity = tunnelInactivity;
139     }
140     
141     /**
142      * Get the number of milliseconds a web forward tunnel must be inactive for
143      * before being considered stale.
144      *
145      * @return web forward tunnel inactivity timeout (ms)
146      */

147     public int getWebForwardInactivity() {
148         return webForwardInactivity;
149     }
150
151     /**
152      * Get the number of milliseconds a tunnel must be inactive for before being
153      * considered stale.
154      *
155      * @return tunnel inactivity timeout (ms)
156      */

157     public int getTunnelInactivity() {
158         return tunnelInactivity;
159     }
160     
161     /**
162      * Get if information popup messages should be displayed. Most messages are
163      * informational, it is only really remote tunnel confirmation and agent
164      * messages that are not.
165      *
166      * @return display information popups
167      */

168     public boolean isDisplayInformationPopups() {
169         return displayInformationPopups;
170     }
171     
172     /**
173      * Set if information popup messages should be displayed. Most messages are
174      * informational, it is only really remote tunnel confirmation and agent
175      * messages that are not.
176      *
177      * @param displayInformationPopups display information popups
178      */

179     public void setDisplayInformationPopups(boolean displayInformationPopups) {
180         this.displayInformationPopups = displayInformationPopups;
181     }
182     
183     /**
184      * Get the class name to use for the GUI.
185      *
186      * @return gui class name
187      */

188     public String JavaDoc getGUIClass() {
189         return guiClassName;
190     }
191     
192     /**
193      * Set the class name to use for the GUI.
194      *
195      * @param guiClassName gui class
196      */

197     public void setGUIClass(String JavaDoc guiClassName) {
198         this.guiClassName = guiClassName;
199     }
200     
201     /**
202      * Get if incoming remote tunnels should require acceptance by the
203      * local user.
204      *
205      * @return remote tunnels require confirmation
206      */

207     public boolean isRemoteTunnelsRequireConfirmation() {
208         return remoteTunnelsRequireConfirmation;
209     }
210
211     /**
212      * Set if incoming remote tunnels should require acceptance by the
213      * local user.
214      *
215      * @param remoteTunnelsRequireConfirmation remote tunnels require confirmation
216      */

217     public void setRemoteTunnelsRequireConfirmation(boolean remoteTunnelsRequireConfirmation) {
218         this.remoteTunnelsRequireConfirmation = remoteTunnelsRequireConfirmation;
219     }
220
221     /**
222      * Get the shutdown period in milliseconds
223      *
224      * @return shutdown period
225      */

226     public int getShutdownPeriod() {
227         return shutdownPeriod;
228     }
229
230     /**
231      * Set the shutdown period in milliseconds
232      *
233      * @parm shutdownPeriod shutdown period
234      */

235     public void setShutdownPeriod(int shutdownPeriod) {
236         this.shutdownPeriod = shutdownPeriod;
237     }
238
239     /**
240      * Get if {@link System#exit(int)} should be called when
241      * the agent disconnects.
242      *
243      * @return system exit on disconnect
244      */

245     public boolean isSystemExitOnDisconnect() {
246         return systemExitOnDisconnect;
247     }
248
249     /**
250      * Set if {@link System#exit(int)} should be called when
251      * the agent disconnects.
252      *
253      * @param systemExitOnDisconnect system exit on disconnect
254      */

255     public void setSystemExitOnDisconnect(boolean systemExitOnDisconnect) {
256         this.systemExitOnDisconnect = systemExitOnDisconnect;
257     }
258
259     /**
260      * Get whether the agent should clean up all downloaded files
261      * (except itself) when it exists. Use with care and ensure {@link getCacheDir} is
262      * pointing to the correct directory as all files in this
263      * directory will be removed without confirmation.
264      *
265      * @return clean on exit
266      * @see #getCacheDir()
267      */

268     public boolean isCleanOnExit() {
269         return cleanonExit;
270     }
271
272     /**
273      * Set whether the agent should clean up its cache directory upon
274      * logging out. Use with care and ensure {@link getCacheDir} is
275      * pointing to the correct directory as all files in this
276      * directory will be removed without confirmation.
277      *
278      * @param clean on exit
279      * @see #getCacheDir()
280      */

281     public void setCleanOnExit(boolean cleanonExit) {
282         this.cleanonExit = cleanonExit;
283     }
284     
285     /**
286      * Set the Agent cache directory. This is the temporary directory
287      * where resources such as application files are stored.
288      *
289      * @param cacheDir agent cache directory
290      */

291     public void setCacheDir(File JavaDoc cacheDir) {
292         this.cacheDir = cacheDir;
293     }
294     
295     /**
296      * Get the Agent cache directory. This is the temporary directory
297      * where resources such as application files are stored.
298      *
299      * @return agent cache directory
300      */

301     public File JavaDoc getCacheDir() {
302         return cacheDir;
303     }
304
305     /**
306      * The keep alive period. A fake request will be sent to the server
307      * to ensure that traffic flows over the connection and that firewalls
308      * etc do not timeout the connection.
309      * @return
310      */

311     public int getKeepAlivePeriod() {
312         return keepAlivePeriod;
313     }
314
315     /**
316      * The keep alive period. A fake request will be sent to the server
317      * to ensure that traffic flows over the connection and that firewalls
318      * etc do not timeout the connection.
319      * @param keepAlivePeriod
320      */

321     public void setKeepAlivePeriod(int keepAlivePeriod) {
322         this.keepAlivePeriod = keepAlivePeriod;
323     }
324     
325     /**
326      * In addition to the cache dir, the command line can also specify files or directories
327      * that require removal when the agent exits.
328      * @param f
329      */

330     public void removeFileOnExit(File JavaDoc f) {
331         removeFiles.addElement(f);
332     }
333     
334     public Enumeration JavaDoc getFilesToRemove() {
335         return removeFiles.elements();
336     }
337
338     /**
339      * The number of milliseconds to wait before timing out a keep alive
340      * request.
341      * @return
342      */

343     public int getKeepAliveTimeout() {
344         return keepAliveTimeout;
345     }
346
347     /**
348      * The number of milliseconds to wait before timing out a keep alive
349      * request.
350      * @param keepAliveTimeout
351      */

352     public void setKeepAliveTimeout(int keepAliveTimeout) {
353         this.keepAliveTimeout = keepAliveTimeout;
354     }
355
356 }
357
Popular Tags