KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > agent > client > util > types > HtmlApplicationType


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.util.types;
21
22 import java.io.IOException JavaDoc;
23 import java.net.URLEncoder JavaDoc;
24 import java.util.Enumeration JavaDoc;
25
26 import com.sslexplorer.agent.client.util.AbstractApplicationLauncher;
27 import com.sslexplorer.agent.client.util.ApplicationLauncherEvents;
28 import com.sslexplorer.agent.client.util.ApplicationType;
29 import com.sslexplorer.agent.client.util.ProcessMonitor;
30 import com.sslexplorer.agent.client.util.TunnelConfiguration;
31 import com.sslexplorer.agent.client.util.XMLElement;
32
33 /**
34  * Application type that launchs an HTML application. Nothing is really executed
35  * locally, merely the correct redirect parameters are returned when the
36  * agent gives control back to SSL-Explorer during launch.
37  *
38  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
39  */

40 public class HtmlApplicationType implements ApplicationType {
41
42     private AbstractApplicationLauncher launcher;
43
44     /*
45      * (non-Javadoc)
46      *
47      * @see com.sslexplorer.vpn.util.ApplicationType#prepare(com.sslexplorer.vpn.util.ApplicationLauncher,
48      * com.sslexplorer.vpn.util.XMLElement)
49      */

50     public void prepare(AbstractApplicationLauncher launcher, ApplicationLauncherEvents events, XMLElement element) throws IOException JavaDoc {
51         this.launcher = launcher;
52     }
53
54     public void start() {
55
56     }
57
58     /*
59      * (non-Javadoc)
60      *
61      * @see com.sslexplorer.vpn.util.ApplicationType#getProcessMonitor()
62      */

63     public ProcessMonitor getProcessMonitor() {
64         return null;
65     }
66
67     /*
68      * (non-Javadoc)
69      *
70      * @see com.sslexplorer.vpn.util.ApplicationType#getRedirectParameters()
71      */

72     public String JavaDoc getRedirectParameters() {
73         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
74         for (Enumeration JavaDoc e = launcher.getTunnels().elements(); e.hasMoreElements();) {
75             TunnelConfiguration l = (TunnelConfiguration) e.nextElement();
76             if (buf.length() == 0) {
77                 buf.append("tunnels="); //$NON-NLS-1$
78
} else {
79                 buf.append(","); //$NON-NLS-1$
80
}
81             buf.append(l.getName());
82             buf.append(":"); //$NON-NLS-1$
83
buf.append("localhost"); //$NON-NLS-1$
84
buf.append(":"); //$NON-NLS-1$
85
buf.append(l.getSourcePort());
86             buf.append("&"); //$NON-NLS-1$
87
}
88         buf.append("sslexplorer="); //$NON-NLS-1$
89
buf.append(URLEncoder.encode(launcher.getApplicationStoreProtocol() + "://" //$NON-NLS-1$
90
+ launcher.getApplicationStoreHost()
91             + ":" //$NON-NLS-1$
92
+ launcher.getApplicationStorePort()));
93         return buf.toString();
94     }
95
96     /* (non-Javadoc)
97      * @see com.sslexplorer.agent.client.util.ApplicationType#getTypeName()
98      */

99     public String JavaDoc getTypeName() {
100         return "html";
101     }
102
103 }
104
Popular Tags