Source Code Cross Referenced for NetletApplet.java in  » Portal » Open-Portal » com » sun » portal » netlet » client » applet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.netlet.client.applet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // %Z%%M% %I%     "%W% %E% Sun Microsystems"
002:        package com.sun.portal.netlet.client.applet;
003:
004:        import com.sun.portal.netlet.client.common.*;
005:        import netscape.javascript.JSObject;
006:        import java.applet.Applet;
007:        import java.net.URLEncoder;
008:        import java.util.Hashtable;
009:        import java.awt.*;
010:        import java.awt.event.ActionListener;
011:        import java.awt.event.ActionEvent;
012:
013:        public class NetletApplet extends Applet implements  ActionListener {
014:
015:            private static NetletApplet instance = null;
016:            private SClientMgr scm = null;
017:            private PortInfoDialog pid = null;
018:            private boolean netletRunning = false;
019:            private boolean netscapePrivilegesGranted = true;
020:            private NetletErrorDialog cbiped = null;
021:
022:            public void init() {
023:                BrowserType browser;
024:                synchronized (getClass()) {
025:                    if (instance != null) {
026:                        System.out.println("Netlet is already running.");
027:                        return;
028:                    }
029:                    instance = this ;
030:                    browser = BrowserType.getInstance();
031:                }
032:                if (browser.getNetscapeBrowser()
033:                        && browser.getJavaVMVersion() == 1) {
034:                    try {
035:                        BrowserType.SecurityCall sc = browser
036:                                .enablePermission(BrowserType.NETSCAPE_UNIVERSAL_CONNECT);
037:                        sc.getMethod().invoke(null, sc.getArgs());
038:                        sc = browser
039:                                .enablePermission(BrowserType.NETSCAPE_UNIVERSAL_LISTEN);
040:                        sc.getMethod().invoke(null, sc.getArgs());
041:                        sc = browser
042:                                .enablePermission(BrowserType.NETSCAPE_UNIVERSAL_ACCEPT);
043:                        sc.getMethod().invoke(null, sc.getArgs());
044:                    } catch (Exception ex) {
045:                        netscapePrivilegesGranted = false;
046:                        System.out.println("NetletApplet Exception " + ex);
047:                        makeInfoframe("nc5");
048:                        return;
049:                    }
050:                }
051:                cbiped = new NetletErrorDialog(new Frame(), this ,
052:                        ResourceProperties.getString("cbiped.1"),
053:                        ResourceProperties.getString("cbiped.2"));
054:            }
055:
056:            public void start() {
057:                if (!netscapePrivilegesGranted) {
058:                    return;
059:                }
060:                if (netletRunning) {
061:                    resetSessionId();
062:                    return;
063:                }
064:                loadAll();
065:
066:                if (scm == null) {
067:                    scm = new SClientMgr(ClientConfig.getNumOfRules());
068:                }
069:
070:                loadRules();
071:
072:                String cbip = ClientConfig.getClientBindIP();
073:                if (!ClientUtil.isClientBindIPValid(cbip)) {
074:                    // pop up error dialog
075:                    cbiped.setErrorMessage(ResourceProperties
076:                            .getString("cbiped.3")
077:                            + " "
078:                            + cbip
079:                            + ". "
080:                            + ResourceProperties.getString("cbiped.4"));
081:                    cbiped.setVisible(true);
082:                    cbiped.toFront();
083:                    cbiped.waitForAction();
084:                    return;
085:                }
086:
087:                if (scm != null) {
088:                    scm.start();
089:                    /**
090:                     * wait until all the SClient threads start, and send the clientport
091:                     * information to the servlet.
092:                     */
093:                    scm.waitToStart();
094:                    String clientPorts = scm.getFormattedClientPorts();
095:                    netletRunning = true;
096:                    ClientUtil.sendByPost("setLoaded", "clientPorts="
097:                            + URLEncoder.encode(clientPorts));
098:                    makeInfoframe("nc1");
099:                } else {
100:                    makeInfoframe("nc5");
101:                }
102:            }
103:
104:            private void loadAll() {
105:                loadParameters();
106:                ClientConfig.init();
107:                ResourceProperties.loadResources();
108:                loadProxyDetails();
109:            }
110:
111:            private void loadParameters() {
112:                ClientConfig.addParam("encryptionType", this 
113:                        .getParameter("encryptionType"));
114:                ClientConfig.addParam("isJSSEEnabled", this 
115:                        .getParameter("isJSSEEnabled"));
116:                ClientConfig.addParam("isPDCEnabled", this 
117:                        .getParameter("isPDCEnabled"));
118:                ClientConfig
119:                        .addParam("numParms", this .getParameter("numParms"));
120:                ClientConfig.addParam("doPortWarning", this 
121:                        .getParameter("doPortWarning"));
122:                ClientConfig.addParam("showPortWarnCheckbox", this 
123:                        .getParameter("showPortWarnCheckbox"));
124:                ClientConfig
125:                        .addParam("doReauth", this .getParameter("doReauth"));
126:                ClientConfig.addParam("clientBindIP", this 
127:                        .getParameter("clientBindIP"));
128:                ClientConfig.addParam("sessionId", this 
129:                        .getParameter("sessionId"));
130:                String confURL = this .getParameter("configURL");
131:                ClientConfig.addParam("jsDocumentDomain", this 
132:                        .getParameter("document.domain"));
133:                ClientConfig.addParam("configURL", confURL);
134:                ClientConfig.addParam("gwURL", this .getParameter("gwURL"));
135:                ClientConfig.addParam("cookiename", this 
136:                        .getParameter("cookiename"));
137:                ClientConfig.addParam("proxyoverride", this 
138:                        .getParameter("proxyoverride"));
139:                ClientConfig.addParam("proxytype", this 
140:                        .getParameter("proxytype"));
141:                ClientConfig.addParam("proxyhost", this 
142:                        .getParameter("proxyhost"));
143:                ClientConfig.addParam("proxyport", this 
144:                        .getParameter("proxyport"));
145:
146:                // code base url for proxylet mode.
147:                ClientConfig.addParam("codebaseURL", this .getCodeBase()
148:                        .toString());
149:
150:                if (confURL != null && confURL.startsWith("/")) {
151:                    ClientConfig.addParam("proxyletMode", "true");
152:                }
153:                //System.out.println(">>> configURL" + this.getParameter("configURL"));
154:            }
155:
156:            private void resetSessionId() {
157:                ClientConfig.setSessionID(this .getParameter("sessionId"));
158:            }
159:
160:            private void loadProxyDetails() {
161:                ProxyInfo appletPI = new AppletProxyInfo();
162:                ClientConfig.loadProxyDetails(appletPI);
163:            }
164:
165:            private void loadRules() {
166:                int srcPort = 0;
167:                String ruleName;
168:                String serverHost;
169:                String serverPort;
170:                String threadname;
171:                String cipherName;
172:
173:                int nor = ClientConfig.getNumOfRules();
174:
175:                for (int i = 0; i < nor; i++) {
176:                    //  read in the parms...
177:                    try {
178:                        srcPort = Integer.parseInt(this 
179:                                .getParameter("listenPort_" + i));
180:                    } catch (NumberFormatException n) {
181:                        System.out
182:                                .println("Netlet unable to parse source port: "
183:                                        + i);
184:                    }
185:
186:                    ruleName = this .getParameter("ruleName_" + i);
187:                    serverHost = this .getParameter("serverHost_" + i);
188:                    serverPort = this .getParameter("serverPort_" + i);
189:
190:                    System.out.println("Netlet rule " + i + ": local:"
191:                            + srcPort + "  destination:" + serverHost + ":"
192:                            + serverPort);
193:
194:                    //  create "unique" thread name...
195:                    threadname = "atprox_" + i + "_"
196:                            + ClientConfig.getDestPort() + "_"
197:                            + ClientConfig.getDestHost();
198:
199:                    cipherName = this .getParameter("cipher_" + i);
200:
201:                    scm.addconfig(ruleName, srcPort, serverPort, serverHost,
202:                            threadname, cipherName);
203:                }
204:            }
205:
206:            //  handle differently for Netscape vs. IE.  In Netscape, close down
207:            //  everthing, and rebuild on start().  With IE (on Win95), close
208:            //  down existing connections, but leave applet running in accept()
209:            //  mode; only reread sessionId in that case.
210:            public void stopProcessing() {
211:                scm.stopProcessing();
212:                if (scm != null) {
213:                    scm.stop();
214:                    scm = null;
215:                }
216:                netletRunning = false;
217:            }
218:
219:            public void stop() {
220:                // any clean to do?
221:                if (netletRunning) {
222:                    System.out.println("Netlet Stopping");
223:                    stopProcessing();
224:                }
225:            }
226:
227:            public void destroy() {
228:                // any clean to do?
229:                ClientUtil.netletConfig("unload");
230:                instance = null;
231:            }
232:
233:            public static NetletApplet getInstance() {
234:                return instance;
235:            }
236:
237:            /*
238:             *  Added for bug 4644648
239:             *  Changes the message in the Netlet info frame
240:             *  based on the key passed by making appropriate
241:             *  call to NetletConfig servlet.
242:             */
243:
244:            public void makeInfoframe(String stat) {
245:                try {
246:                    JSObject jswin = JSObject.getWindow(this );
247:                    JSObject parent = (JSObject) jswin.getMember("parent");
248:                    JSObject frames = (JSObject) parent.getMember("frames");
249:                    JSObject infoFrame = (JSObject) frames.getMember("info");
250:
251:                    String jsDocumentDomain = ClientConfig
252:                            .getParam("jsDocumentDomain");
253:                    String cmd = null;
254:                    if (jsDocumentDomain != null) {
255:                        cmd = "parent.frames[0].location = \""
256:                                + ClientConfig.getConfigURL()
257:                                + "?func=makeInfoFrame&stat=" + stat
258:                                + "&document.domain=" + jsDocumentDomain + "\"";
259:                    } else {
260:                        cmd = "parent.frames[0].location = \""
261:                                + ClientConfig.getConfigURL()
262:                                + "?func=makeInfoFrame&stat=" + stat + "\"";
263:                    }
264:
265:                    infoFrame.eval(cmd);
266:
267:                } catch (Exception ex) {
268:                    System.out
269:                            .println("Netlet unable connect back to server : status update failed.");
270:                }
271:            }
272:
273:            public void showClientPorts() {
274:                System.out.println("showclientports() called...");
275:                if (scm != null) {
276:                    if (pid == null || !pid.isShowing()) {
277:                        System.out.println("creating portinfodialog...");
278:                        Hashtable clientPorts = scm.getClientPorts();
279:                        pid = new PortInfoDialog(new Frame(), clientPorts);
280:                    }
281:                    pid.show();
282:                    pid.toFront();
283:                }
284:                System.out.println("showclientports() done...");
285:            }
286:
287:            public void actionPerformed(ActionEvent evt) {
288:                if ("OK".equals(evt.getActionCommand())) {
289:                    Object obj = evt.getSource();
290:                    if (obj == cbiped.okButton) {
291:                        cbiped.notifyAction();
292:                        cbiped.setVisible(false);
293:                    }
294:                }
295:            }
296:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.