Source Code Cross Referenced for SRAProxyletProvider.java in  » Portal » Open-Portal » com » sun » portal » proxylet » provider » 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.proxylet.provider 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /** 
002:         * Copyright 2002 Sun Microsystems, Inc. All 
003:         * rights reserved. Use of this product is subject 
004:         * to license terms. Federal Acquisitions: 
005:         * Commercial Software -- Government Users 
006:         * Subject to Standard License Terms and 
007:         * Conditions. 
008:         * 
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE 
010:         * are trademarks or registered trademarks of Sun Microsystems, 
011:         * Inc. in the United States and other countries. 
012:         *
013:         * Functionality:
014:         *  1. Gets ths contents of the Proxylet channel. (getContent() method).
015:         *  2. Gets the contents of the Proxylet provider. (getEdit() method).
016:         *  3. Process the contents of the Proxylet provider and stores to the backend (processEdit() method).
017:         *
018:         *  @ Author vr121038
019:         */package com.sun.portal.proxylet.provider;
020:
021:        import com.sun.portal.proxylet.util.ProxyletConstants;
022:        import com.sun.portal.proxylet.util.ProxyletUtil;
023:        import com.sun.portal.proxylet.util.SSOUtil;
024:        import com.sun.portal.proxylet.util.UserAttributes;
025:        import com.sun.portal.proxylet.util.ParameterMap;
026:
027:        import javax.servlet.http.HttpServletRequest;
028:        import javax.servlet.http.HttpServletResponse;
029:        import javax.servlet.http.HttpUtils;
030:        import java.net.URL;
031:        import java.net.URLEncoder;
032:        import java.util.*;
033:
034:        /*
035:         * Provider class to retrieve and store the contents of Proxylet channel and provider.
036:         */
037:
038:        public class SRAProxyletProvider implements  ProxyletConstants {
039:
040:            private ResourceBundle bundle = null;
041:            private String editContainer = null;
042:            private String container = null;
043:            private String statusMsg = null;
044:            private String clientBindIP = null;
045:            private String clientBindPort = null;
046:            private int clientBindPortNum = PROXYLET_DEFAULT_CLIENT_BIND_PORT;
047:            private boolean autoDownloadFlag = false;
048:            private boolean storePacfileFlag = false;
049:            private String pacfileLocation = null;
050:            private SSOUtil ssoUtil = null;
051:
052:            /*
053:             *  Initialize the provider and get the resource bundle
054:             */
055:            public void init(String n, HttpServletRequest req) throws Exception {
056:                ssoUtil = new SSOUtil(req);
057:                bundle = ssoUtil
058:                        .getResourceBundle(PROXYLET_PROVIDER_RES_BUNDLE);
059:            }
060:
061:            /*
062:             * Main method to get the Proxylet channel contents.
063:             * This method is invoked by DesktopServlet
064:             */
065:            public StringBuffer getContent(HttpServletRequest req,
066:                    HttpServletResponse res) throws Exception {
067:
068:                StringBuffer content = null;
069:                UserAttributes attrs = ProxyletUtil.getUserAttributes(req);
070:                Map tagTable = new Hashtable();
071:                content = checkProxyletEnabled(req, attrs);
072:                if (null != content) {
073:                    return content;
074:                    //            tagTable.put("content", content);
075:                    //            return tagTable;
076:                }
077:
078:                content = new StringBuffer();
079:
080:                tagTable.put("proxyletURI", getProxyletURI(req));
081:                tagTable.put("hostName", ProxyletUtil.getGWHostName(req));
082:                if (attrs.getBoolean(PROXYLET_AUTO_DOWNLOAD)) {
083:                    StringBuffer scriptlet = new StringBuffer();
084:                    scriptlet.append("<script language=\"JavaScript\">\n")
085:                            .append("loadProxylet();\n").append("</script>\n");
086:                    tagTable.put("scriptlet", scriptlet);
087:                    tagTable
088:                            .put("content", bundle.getString("proxyletLoading"));
089:                } else {
090:                    tagTable.put("scriptlet", " ");
091:                    tagTable.put("content", getProxyletLink(req));
092:                }
093:
094:                //        tagTable.put("iwtDesktop-fontFace1", getStringProperty("fontFace1"));
095:                content = getContentTemplate(tagTable);
096:
097:                return content;
098:
099:            }
100:
101:            /*
102:             * Method to get the contents of Proxylet Edit Provider.
103:             * Invoked by DesktopServlet.
104:             */
105:            public StringBuffer getEdit(HttpServletRequest req,
106:                    HttpServletResponse res) throws Exception {
107:                StringBuffer content = new StringBuffer();
108:                editContainer = req.getParameter("provider");
109:                container = req.getParameter("containerName");
110:                UserAttributes attrs = ProxyletUtil.getUserAttributes(req);
111:                Hashtable tagTable = new Hashtable();
112:
113:                tagTable.put("addNewTargetLable", bundle
114:                        .getString("addNewTargetLable"));
115:                tagTable.put("downloadAutomaticallyLable", bundle
116:                        .getString("downloadAutomaticallyLable"));
117:                tagTable.put("clientBindIPLable", bundle
118:                        .getString("clientBindIPLable"));
119:                tagTable.put("clientBindPortLable", bundle
120:                        .getString("clientBindPortLable"));
121:                tagTable.put("storePacfileLocallyLable", bundle
122:                        .getString("storePacfileLocallyLable"));
123:                tagTable.put("pacfileLocationLable", bundle
124:                        .getString("pacfileLocationLable"));
125:                tagTable.put("pacfileLocationNote", bundle
126:                        .getString("pacfileLocationNote"));
127:                if ((statusMsg != null) && (statusMsg.trim().length() != 0)) {
128:                    tagTable.put("errorMsg", statusMsg);
129:                    tagTable.put("clientBindIP", clientBindIP);
130:                    tagTable.put("clientBindPort", clientBindPort);
131:                    if (autoDownloadFlag) {
132:                        tagTable.put("autoDownload", "Checked");
133:                    } else {
134:                        tagTable.put("autoDownload", "");
135:                    }
136:                    if (storePacfileFlag) {
137:                        tagTable.put("storePacfileLocally", "Checked");
138:                    } else {
139:                        tagTable.put("storePacfileLocally", "");
140:                    }
141:                    tagTable.put("pacfileLocation", pacfileLocation);
142:                    statusMsg = null;
143:                } else {
144:                    tagTable.put("errorMsg", "");
145:                    if (attrs.getBoolean(PROXYLET_AUTO_DOWNLOAD)) {
146:                        tagTable.put("autoDownload", "Checked");
147:                    } else {
148:                        tagTable.put("autoDownload", "");
149:                    }
150:                    tagTable.put("clientBindIP", attrs.getString(
151:                            PROXYLET_CLIENT_BIND_IP,
152:                            PROXYLET_DEFAULT_CLIENT_BIND_IP));
153:                    tagTable.put("clientBindPort", String.valueOf(attrs.getInt(
154:                            PROXYLET_CLIENT_BIND_PORT,
155:                            PROXYLET_DEFAULT_CLIENT_BIND_PORT)));
156:                    if (attrs.getBoolean(PROXYLET_STORE_PACFILE_LOCALLY)) {
157:                        tagTable.put("storePacfileLocally", "Checked");
158:                    } else {
159:                        tagTable.put("storePacfileLocally", "");
160:                    }
161:                    tagTable.put("pacfileLocation", attrs.getString(
162:                            PROXYLET_PACFILE_LOCATION,
163:                            PROXYLET_DEFAULT_PACFILE_LOCATION));
164:                }
165:
166:                tagTable.put("iwtDesktop-fontFace1", "Sans-serif");
167:                tagTable.put("fontFace1", "Sans-serif");
168:                //        content = oldTagReplaceEditTemplate(tagTable, req);
169:                content = tagReplaceEditTemplate(tagTable, req);
170:                return content;
171:            }
172:
173:            /*
174:             * Processes the Values of the Proxylet Edit Provider and stores the values to the backend.
175:             */
176:            public URL processEdit(HttpServletRequest req,
177:                    HttpServletResponse res) throws Exception {
178:
179:                ParameterMap params = getParameterMap(req);
180:
181:                if (null != params) {
182:                    setProcessParameters(params);
183:                    UserAttributes attrs = ProxyletUtil.getUserAttributes(req);
184:                    validateClientBindIP();
185:                    if (null == statusMsg) {
186:                        validateClientBindPort();
187:                    }
188:                    if (null == statusMsg) {
189:                        validatePacfileLocation();
190:                    }
191:                    if (null != statusMsg) {
192:                        return getProxyletProviderURL(req);
193:                    }
194:                    commitNewValues(attrs);
195:                }
196:                return null;
197:            }
198:
199:            /*
200:             * Returns the Proxylet User Attributes.
201:             */
202:            private UserAttributes getProxyletUserAttributes(
203:                    HttpServletRequest req) {
204:                return new UserAttributes(ssoUtil.getSSOToken(),
205:                        PROXYLET_SERVICE_NAME, PROXYLET_POLICY);
206:            }
207:
208:            private StringBuffer getContentTemplate(Map tagTable) {
209:
210:                StringBuffer sb = new StringBuffer(256);
211:                String proxyletURI = (String) tagTable.get("proxyletURI");
212:                String scriptlet = (String) tagTable.get("scriptlet");
213:                // Fetch the values
214:                sb.append("<SCRIPT LANGUAGE=\"JavaScript\">\n\n");
215:                sb
216:                        .append("function getCookie(Name) {\n"
217:                                + "   var search = Name + \"=\"\n"
218:                                + "   if (document.cookie.length > 0) { // if there are any cookies\n"
219:                                + "      offset = document.cookie.indexOf(search) \n"
220:                                + "      if (offset != -1) { // if cookie exists \n"
221:                                + "         offset += search.length \n"
222:                                + "         // set index of beginning of value\n"
223:                                + "         end = document.cookie.indexOf(\";\", offset) \n"
224:                                + "         // set index of end of cookie value\n"
225:                                + "         if (end == -1) \n"
226:                                + "            end = document.cookie.length\n"
227:                                + "         return unescape(document.cookie.substring(offset, end))\n"
228:                                + "      } \n" + "   }\n" + "   return null;\n"
229:                                + "}\n");
230:                sb.append("function loadProxylet()\n");
231:                sb.append("{\n\n");
232:                sb.append("   host = removespcchar(\""
233:                        + tagTable.get("hostName") + "\");");
234:                sb.append("\n");
235:                sb.append("   var pscookie = getCookie(\"PS-Cookie\");\n");
236:                sb.append("\n");
237:                sb
238:                        .append("if( pscookie == null || pscookie == \"\" || pscookie.indexOf(host) == -1 )\n");
239:                sb.append("   {\n");
240:                sb
241:                        .append("      var helpWin=window.open('"
242:                                + (proxyletURI == null ? "" : proxyletURI)
243:                                + "&location=' + window.location ,host , 'width=400,height=345,hotkeys=no,status=no,resizable=no,scrollbars=no,toolbar=no');\n");
244:                sb.append("      helpWin.focus();\n");
245:                sb.append("   }\n}");
246:                sb
247:                        .append("\n\n"
248:                                + "function removespcchar(host)\n"
249:                                + "{\n"
250:                                + "       var shost=\"\";\n"
251:                                + "       var c=\"\";\n"
252:                                + "       for(i=0; i<host.length; i++)\n"
253:                                + "       {\n"
254:                                + "         c = host.charAt(i);\n"
255:                                + "         if( ( c >= 'a' && c <= 'z') || (c>='A' && c<='Z' ) || (c>='0' && c<='9') )\n"
256:                                + "         shost += c;\n" + "       }\n"
257:                                + "       return shost;\n" + "}\n" + "\n"
258:                                + "</SCRIPT>\n");
259:
260:                sb.append(scriptlet == null ? " " : scriptlet);
261:                sb.append(tagTable.get("content"));
262:
263:                return sb;
264:
265:            }
266:
267:            private StringBuffer tagReplaceEditTemplate(Map tagTable,
268:                    HttpServletRequest req) {
269:                StringBuffer sb = new StringBuffer(256);
270:                sb
271:                        .append("<!--\n"
272:                                + "  Copyright 2003 Sun Microsystems, Inc. All rights reserved\n"
273:                                + "  Use is subject to license terms.\n"
274:                                + "\"@(#)edit.template\t1.1 19th Dec 03 Sun Microsystems\"\n"
275:                                + "-->\n"
276:                                + "\n"
277:                                + "<SCRIPT LANGUAGE=JavaScript>\n"
278:                                + "\n"
279:                                + "var pageLoaded = 0;\n"
280:                                + "function isPageCompletelyLoaded() {\n"
281:                                + "    if( (pageLoaded) && (pageLoaded == 1)) {\n"
282:                                + "        pageLoaded=0;\n"
283:                                + "\treturn true;\n" + "    } else {\n"
284:                                + "        return false;\n" + "    }\n" + "}\n"
285:                                + "</SCRIPT>\n" + "\n" + "\n"
286:                                + "<FORM ACTION=\""
287:                                + req.getRequestURI()
288:                                + "\" onSubmit=\"return isPageCompletelyLoaded()\" TARGET=\"_parent\" NAME=\"edit_form\" METHOD=POST ENCTYPE=\"application/x-www-form-urlencoded\"><!--\n"
289:                                + "<INPUT TYPE=HIDDEN NAME=\"action\" SIZE=-1 VALUE=\"processProxyletEdit\">"
290:                                + " <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=0 WIDTH=\"100%\">\n"
291:                                + "   <TR>\n"
292:                                + "      <TD BGCOLOR=\"#666699\" colspan=\"2\">\n"
293:                                + "        <FONT FACE=\""
294:                                + tagTable.get("fontFace1")
295:                                + "\" color=\"#FFFFFF\" size=\"+1\">\n"
296:                                + "          <B>"
297:                                + tagTable.get("addNewTargetLable")
298:                                + " </B>\n"
299:                                + "        </FONT>\n"
300:                                + "        <BR>\n"
301:                                + "      </TD>\n"
302:                                + "   </TR>\n"
303:                                + "   <TR>\n"
304:                                + "       <TD ALIGN=CENTER>\n"
305:                                + "          <FONT FACE=\""
306:                                + tagTable.get("iwtDesktop-fontFace1")
307:                                + "\" color=\"#FF0000\" SIZE=+0>\n"
308:                                + "          <br><B>"
309:                                + tagTable.get("errorMsg")
310:                                + "<B></FONT> <br>\n"
311:                                + "       </TD>\n"
312:                                + "   </TR>\n"
313:                                + "   <TR>\n"
314:                                + "      <TD>\n"
315:                                + "        <CENTER>\n"
316:                                + "        <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 WIDTH=\"100%\">\n"
317:                                + "          <TR>\n"
318:                                + "            <TD ALIGN=RIGHT>\n"
319:                                + "              <FONT FACE=\""
320:                                + tagTable.get("iwtDesktop-fontFace1")
321:                                + "\" SIZE=+0>\n"
322:                                + "              <B>"
323:                                + tagTable.get("downloadAutomaticallyLable")
324:                                + "</B></FONT>\n"
325:                                + "            </TD>\n"
326:                                + "            <TD>\n"
327:                                + "              <FONT FACE=\""
328:                                + tagTable.get("iwtDesktop-fontFace1")
329:                                + "\" SIZE=+0>\n"
330:                                + "               <input type=\"checkbox\" name=\"autoDownload\" value=\"true\""
331:                                + tagTable.get("autoDownload")
332:                                + ">\n"
333:                                + "              </FONT>\n"
334:                                + "            </TD>\n"
335:                                + "          </TR>\n"
336:                                + "          <TR>\n"
337:                                + "            <TD ALIGN=RIGHT>\n"
338:                                + "              <FONT FACE=\""
339:                                + tagTable.get("iwtDesktop-fontFace1")
340:                                + "\" SIZE=+0>\n"
341:                                + "              <B> "
342:                                + tagTable.get("clientBindIPLable")
343:                                + "</B></FONT>\n"
344:                                + "            </TD>\n"
345:                                + "            <TD>\n"
346:                                + "              <FONT FACE=\""
347:                                + tagTable.get("iwtDesktop-fontFace1")
348:                                + "\" SIZE=+0>\n"
349:                                + "                <INPUT TYPE=TEXT NAME=\"clientBindIP\" VALUE=\""
350:                                + tagTable.get("clientBindIP")
351:                                + "\" SIZE=45>\n"
352:                                + "              </FONT>\n"
353:                                + "            </TD>\n"
354:                                + "          </TR>\n"
355:                                + "          <TR>\n"
356:                                + "            <TD ALIGN=RIGHT WIDTH=\"35%\">\n"
357:                                + "              <FONT FACE=\""
358:                                + tagTable.get("iwtDesktop-fontFace1")
359:                                + "\" SIZE=+0>\n"
360:                                + "              <B> "
361:                                + tagTable.get("clientBindPortLable")
362:                                + "</B></FONT>\n"
363:                                + "            </TD>\n"
364:                                + "            <TD>\n"
365:                                + "              <FONT FACE=\""
366:                                + tagTable.get("iwtDesktop-fontFace1")
367:                                + "\" SIZE=+0>\n"
368:                                + "              <INPUT TYPE=TEXT NAME=\"clientBindPort\" VALUE=\""
369:                                + tagTable.get("clientBindPort")
370:                                + "\" SIZE=45>\n"
371:                                + "              </FONT>\n"
372:                                + "            </TD>\n"
373:                                + "          </TR>\n"
374:                                + "          <TR>\n"
375:                                + "            <TD ALIGN=RIGHT WIDTH=\"35%\">\n"
376:                                + "              <FONT FACE=\""
377:                                + tagTable.get("iwtDesktop-fontFace1")
378:                                + "\" SIZE=+0>\n"
379:                                + "              <B> "
380:                                + tagTable.get("storePacfileLocallyLable")
381:                                + "</B></FONT>\n"
382:                                + "            </TD>\n"
383:                                + "            <TD>\n"
384:                                + "              <FONT FACE=\""
385:                                + tagTable.get("iwtDesktop-fontFace1")
386:                                + "\" SIZE=+0>\n"
387:                                + "              <input type=\"checkbox\" name=\"storePacfileLocally\" value=\"true\""
388:                                + tagTable.get("storePacfileLocally")
389:                                + ">\n"
390:                                + "              </FONT>\n"
391:                                + "            </TD>\n"
392:                                + "          </TR>\n"
393:                                + "          <TR>\n"
394:                                + "            <TD ALIGN=RIGHT WIDTH=\"35%\">\n"
395:                                + "              <FONT FACE=\""
396:                                + tagTable.get("iwtDesktop-fontFace1")
397:                                + "\" SIZE=+0>\n"
398:                                + "              <B> "
399:                                + tagTable.get("pacfileLocationLable")
400:                                + "</B></FONT>\n"
401:                                + "            </TD>\n"
402:                                + "            <TD>\n"
403:                                + "              <FONT FACE=\""
404:                                + tagTable.get("iwtDesktop-fontFace1")
405:                                + "\" SIZE=+0>\n"
406:                                + "              <INPUT TYPE=TEXT NAME=\"pacfileLocation\" VALUE=\""
407:                                + tagTable.get("pacfileLocation")
408:                                + "\" SIZE=45>\n"
409:                                + "              </FONT>\n"
410:                                + "            </TD>\n"
411:                                + "          </TR>\n"
412:                                + "          <TR>\n"
413:                                + "            <TD ALIGN=RIGHT WIDTH=\"35%\">\n"
414:                                + "            </TD>\n"
415:                                + "            <TD>\n"
416:                                + "              "
417:                                + tagTable.get("pacfileLocationNote")
418:                                + "\n"
419:                                + "            </TD>\n"
420:                                + "          </TR\n"
421:                                + "        </TABLE>\n"
422:                                + "        </CENTER>\n"
423:                                + "      </TD>\n"
424:                                + "   </TR>\n"
425:                                + " </TABLE>\n"
426:                                + " <BR>\n"
427:                                + " </CENTER>\n"
428:                                + "\n"
429:                                + "</TD></TR>\n"
430:                                + "</TABLE>\n"
431:                                + "<BR>\n"
432:                                + "<CENTER>\n"
433:                                + "<FONT SIZE=+0 FACE="
434:                                + tagTable.get("iwtDesktop-fontFace1")
435:                                + ">\n"
436:                                + "<INPUT TYPE=SUBMIT NAME=\"Submit\" VALUE=\"Finished\" style='background-color:#999999;color:#ffffff'>\n"
437:                                + "<INPUT TYPE=BUTTON OnClick=\"document.location.href='"
438:                                + req.getRequestURI()
439:                                + "?action=getDefault'\" VALUE=\"Cancel\" style='background-color:#999999;color:#ffffff'>\n"
440:                                + "</font>\n"
441:                                + "</CENTER>\n"
442:                                + "<br>\n"
443:                                + "<P>\n"
444:                                + "</FORM><SCRIPT>\n"
445:                                + "pageLoaded=1;\n" + "</SCRIPT>");
446:                return sb;
447:
448:            }
449:
450:            private StringBuffer oldTagReplaceEditTemplate(Map tagTable,
451:                    HttpServletRequest req) {
452:                StringBuffer sb = new StringBuffer(256);
453:                String error = (String) tagTable.get("errorMsg");
454:                sb
455:                        .append("<SCRIPT LANGUAGE=JavaScript>\n"
456:                                + "\n"
457:                                + "var pageLoaded = 0;\n"
458:                                + "function isPageCompletelyLoaded() {\n"
459:                                + "    if( (pageLoaded) && (pageLoaded == 1)) {\n"
460:                                + "        pageLoaded=0;\n"
461:                                + "\treturn true;\n" + "    } else {\n"
462:                                + "        return false;\n" + "    }\n" + "}\n"
463:                                + "</SCRIPT>\n" + "\n" + "\n"
464:                                + "<FORM ACTION=\""
465:                                + req.getRequestURI()
466:                                + "?action=processProxyletEdit\" onSubmit=\"return isPageCompletelyLoaded()\" TARGET=\"_parent\" NAME=\"edit_form\" METHOD=POST ENCTYPE=\"application/x-www-form-urlencoded\"><!--\n"
467:                                + "<INPUT TYPE=HIDDEN NAME=\"action\" SIZE=-1 VALUE=\"processProxyletEdit\">"
468:                                + "  Copyright 2003 Sun Microsystems, Inc. All rights reserved\n"
469:                                + "  Use is subject to license terms.\n"
470:                                + "\"@(#)edit.template\t1.1 19th Dec 03 Sun Microsystems\"\n"
471:                                + "-->\n"
472:                                + "\n"
473:                                + " <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=0 WIDTH=\"100%\">\n"
474:                                + "   <TR>\n"
475:                                + "      <TD BGCOLOR=\"#666699\" colspan=\"2\">\n"
476:                                + "        <FONT FACE=\""
477:                                + tagTable.get("iwtDesktop-fontFace1")
478:                                + "\" color=\"#FFFFFF\" size=\"+1\">\n"
479:                                + "          <B>"
480:                                + tagTable.get("addNewTargetLable")
481:                                + "</B>\n"
482:                                + "        </FONT>\n"
483:                                + "        <BR>\n"
484:                                + "      </TD>\n"
485:                                + "   </TR>\n"
486:                                + "   <TR>\n"
487:                                + "       <TD ALIGN=CENTER>\n"
488:                                + "          <FONT FACE=\""
489:                                + tagTable.get("iwtDesktop-fontFace1")
490:                                + "\" color=\"#FF0000\" SIZE=+0>\n"
491:                                + "          <br><B>"
492:                                + (error == null ? "" : error)
493:                                + " <B></FONT> <br>\n"
494:                                + "       </TD>\n"
495:                                + "   </TR>\n"
496:                                + "   <TR>\n"
497:                                + "      <TD>\n"
498:                                + "        <CENTER>\n"
499:                                + "        <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 WIDTH=\"100%\">\n"
500:                                + "          <TR>\n"
501:                                + "            <TD ALIGN=RIGHT>\n"
502:                                + "              <FONT FACE=\""
503:                                + tagTable.get("iwtDesktop-fontFace1")
504:                                + "\" SIZE=+0>\n"
505:                                + "              <B>"
506:                                + tagTable.get("downloadAutomaticallyLable")
507:                                + "</B></FONT>\n"
508:                                + "            </TD>\n"
509:                                + "            <TD>\n"
510:                                + "              <FONT FACE=\""
511:                                + tagTable.get("[tag:iwtDesktop-fontFace1")
512:                                + "\" SIZE=+0>\n"
513:                                + "               <input type=\"checkbox\" name=\"autoDownload\" value=\"true\""
514:                                + tagTable.get("autoDownload")
515:                                + ">\n"
516:                                + "              </FONT>\n"
517:                                + "            </TD>\n"
518:                                + "          </TR>\n"
519:                                + "          <TR>\n"
520:                                + "            <TD ALIGN=RIGHT>\n"
521:                                + "              <FONT FACE=\""
522:                                + tagTable.get("iwtDesktop-fontFace1")
523:                                + "\" SIZE=+0>\n"
524:                                + "              <B> "
525:                                + tagTable.get("clientBindIPLable")
526:                                + "</B></FONT>\n"
527:                                + "            </TD>\n"
528:                                + "            <TD>\n"
529:                                + "              <FONT FACE=\""
530:                                + tagTable.get("iwtDesktop-fontFace1")
531:                                + "\" SIZE=+0>\n"
532:                                + "                <INPUT TYPE=TEXT NAME=\"clientBindIP\" VALUE=\""
533:                                + tagTable.get("clientBindIP")
534:                                + "\" SIZE=45>\n"
535:                                + "              </FONT>\n"
536:                                + "            </TD>\n"
537:                                + "          </TR>\n"
538:                                + "          <TR>\n"
539:                                + "            <TD ALIGN=RIGHT WIDTH=\"35%\">\n"
540:                                + "              <FONT FACE=\""
541:                                + tagTable.get("iwtDesktop-fontFace1")
542:                                + "\" SIZE=+0>\n"
543:                                + "              <B> "
544:                                + tagTable.get("clientBindPortLable")
545:                                + "</B></FONT>\n"
546:                                + "            </TD>\n"
547:                                + "            <TD>\n"
548:                                + "              <FONT FACE=\""
549:                                + tagTable.get("iwtDesktop-fontFace1")
550:                                + "\" SIZE=+0>\n"
551:                                + "              <INPUT TYPE=TEXT NAME=\"clientBindPort\" VALUE=\""
552:                                + tagTable.get("clientBindPort")
553:                                + "\" SIZE=45>\n"
554:                                + "              </FONT>\n"
555:                                + "            </TD>\n"
556:                                + "          </TR>\n"
557:                                + "        </TABLE>\n"
558:                                + "        </CENTER>\n"
559:                                + "      </TD>\n"
560:                                + "   </TR>\n"
561:                                + " </TABLE>\n"
562:                                + " <BR>\n"
563:                                + " </CENTER>\n"
564:                                + "\n"
565:                                + "</TD></TR>\n"
566:                                + "</TABLE>\n"
567:                                + "\n\n\n"
568:                                + "</CENTER>\n"
569:                                + "</TD>\n"
570:                                + "</TR>\n"
571:                                + "</TABLE>\n"
572:                                + "<BR>\n"
573:                                + "<CENTER>\n"
574:                                + "<FONT SIZE=+0 FACE=\""
575:                                + tagTable.get("iwtDesktop-fontFace1")
576:                                + "\">\n"
577:                                + "<INPUT TYPE=SUBMIT NAME=\"Submit\" VALUE=\"Finished\" style='background-color:#999999;color:#ffffff'>\n"
578:                                + "<INPUT TYPE=BUTTON OnClick=\"top.document.location.href='"
579:                                + req.getRequestURI()
580:                                + "'\" VALUE=\"Cancel\" style='background-color:#999999;color:#ffffff'>\n"
581:                                + "</font>\n"
582:                                + "</CENTER>\n"
583:                                + "<br>\n"
584:                                + "<P>\n"
585:                                + "</FORM><SCRIPT>\n"
586:                                + "pageLoaded=1;\n" + "</SCRIPT>");
587:                return sb;
588:            }
589:
590:            /*
591:             * Returns the page parameter map
592:             */
593:            private ParameterMap getParameterMap(HttpServletRequest req) {
594:                ParameterMap map = null;
595:                try {
596:                    map = new ParameterMap("ISO-8859-1", req, true);
597:                    for (Enumeration e = req.getParameterNames(); e
598:                            .hasMoreElements();) {
599:                        String name = (String) e.nextElement();
600:                        String[] val = req.getParameterValues(name);
601:                        map.put(name, val);
602:                    }
603:                } catch (Exception de) {
604:                    System.out
605:                            .println("SRAProxyletProvider: Unable to get page parameters -> "
606:                                    + de);
607:                }
608:                return map;
609:            }
610:
611:            /*
612:             * Return the Proxylet URL link for the Proxylet provider channel
613:             */
614:            private StringBuffer checkProxyletEnabled(HttpServletRequest req,
615:                    UserAttributes attrs) throws Exception {
616:                StringBuffer content = null;
617:
618:                /**
619:                 *  Check whether proxylet service is enabled for this user
620:                 */
621:                boolean serviceEnabled = attrs.isAllowed();
622:
623:                /**
624:                 * Check whether the request is via the Gateway and whether the proxylet is enabled.
625:                 */
626:                boolean openPortal = true;
627:                boolean proxyletDisabled = true;
628:                boolean routedThroughProxylet = false;
629:                String psProxyletHeader = req.getHeader(PROXYLET_HEADER);
630:                System.out.println("Proxylet header -> " + psProxyletHeader);
631:                if (psProxyletHeader != null) {
632:                    openPortal = false;
633:                    if (-1 != psProxyletHeader.indexOf("enabled=true")) {
634:                        proxyletDisabled = false;
635:                    }
636:                    if (-1 != psProxyletHeader.indexOf("RT-Proxylet=true")) {
637:                        routedThroughProxylet = true;
638:                    }
639:                }
640:
641:                /*
642:                 *  Return appropriate error messages if Proxylet service is not enabled at gateway or uer level.
643:                 */
644:                if (!serviceEnabled || openPortal || proxyletDisabled
645:                        || routedThroughProxylet) {
646:                    content = new StringBuffer();
647:                    //            content.append("<table><tr><td>\n");
648:                    //                    .append("<font FACE=\"")
649:                    //                    .append(getStringProperty("fontFace1"))
650:                    //                    .append("\" size=\"-1\">\n");
651:                    if (openPortal) {
652:                        content.append(bundle.getString("noGateway"));
653:                    } else if (proxyletDisabled) {
654:                        content.append(bundle.getString("proxyletDisabled"));
655:                    } else if (!serviceEnabled) {
656:                        content.append(bundle.getString("noService"));
657:                    } else if (routedThroughProxylet) {
658:                        content.append(bundle
659:                                .getString("proxyletAlreadyRunning"));
660:                    }
661:                    //            content.append("</font></td></tr></table>\n");
662:                }
663:                return content;
664:            }
665:
666:            /*
667:             * Return the Proxylet URL link for the Proxylet provider channel
668:             */
669:            private String getProxyletLink(HttpServletRequest req) {
670:                StringBuffer href = new StringBuffer()
671:                        .append("<a href=\"")
672:                        .append(getProxyletURI(req))
673:                        .append("\" TARGET=\"Proxylet\"")
674:                        .append(
675:                                " onClick=\"javascript:loadProxylet();return false;\">")
676:                        .append(
677:                                " " + bundle.getString("downloadProxylet")
678:                                        + " ").append("</a>\n");
679:
680:                StringBuffer row = new StringBuffer()
681:                //                           .append("<tr><td><font FACE=\"[tag:iwtDesktop-fontFace1]\" ")
682:                        //                           .append("size=\"-1\">")
683:                        .append(href.toString()).append("\n");
684:                //                           .append("</font></td></tr>\n");
685:                return row.toString();
686:            }
687:
688:            /*
689:             * Return the Proxylet URI to download the applet
690:             */
691:            private String getProxyletURI(HttpServletRequest req) {
692:
693:                return req.getContextPath() + PROXYLET_COMMAND_URI + "&"
694:                        + FOLLOWUP_PARAM + "=" + getSRADesktopURL(req) + "&"
695:                        + LOGOUT_PARAM + "=" + getSRADesktopURL(req)
696:                        + LOGOUT_COMMAND_URI;
697:
698:                //        return null;
699:            }
700:
701:            private String getSRADesktopURL(HttpServletRequest req) {
702:                String url = HttpUtils.getRequestURL(req).toString();
703:                return url;
704:                //        String uri = req.getRequestURI();
705:                //        int pos = url.indexOf(uri);
706:                //        return url.substring(0,pos);
707:            }
708:
709:            /*
710:             * Return the Proxylet Provider URL
711:             */
712:            private URL getProxyletProviderURL(HttpServletRequest req) {
713:                URL proxyletProviderURL = null;
714:                try {
715:
716:                    proxyletProviderURL = new URL(getSRADesktopURL(req)
717:                            + "?action=edit&provider="
718:                            + URLEncoder.encode(editContainer, "UTF-8")
719:                            + "&targetprovider="
720:                            + URLEncoder.encode(getName(), "UTF-8")
721:                            + "&containerName="
722:                            + URLEncoder.encode(container, "UTF-8"));
723:
724:                } catch (java.io.UnsupportedEncodingException ee) {
725:                    System.out
726:                            .println("ProxyletProvider: Unsupported encoding -> "
727:                                    + ee);
728:                } catch (java.net.MalformedURLException ue) {
729:                    System.out
730:                            .println("ProxyletProvider: Unable to create proxylet provider URL -> "
731:                                    + ue);
732:                }
733:                return proxyletProviderURL;
734:            }
735:
736:            public String getName() {
737:                return null;
738:            }
739:
740:            /*
741:             * Set the parameters to local variables so that it can retain the values in the form
742:             * if there is a invalid input.
743:             */
744:            private void setProcessParameters(ParameterMap params) {
745:                String newAutoDownload = (String) params.get("autoDownload");
746:                if (null != newAutoDownload) {
747:                    autoDownloadFlag = true;
748:                } else {
749:                    autoDownloadFlag = false;
750:                }
751:                clientBindIP = params.getString("clientBindIP");
752:                if (null != clientBindIP) {
753:                    clientBindIP = clientBindIP.trim();
754:                } else {
755:                    clientBindIP = "";
756:                }
757:                clientBindPort = params.getString("clientBindPort");
758:                if (null != clientBindPort) {
759:                    clientBindPort = clientBindPort.trim();
760:                } else {
761:                    clientBindPort = "";
762:                }
763:                String newStorePacfileLocally = params
764:                        .getString("storePacfileLocally");
765:                if (null != newStorePacfileLocally) {
766:                    storePacfileFlag = true;
767:                } else {
768:                    storePacfileFlag = false;
769:                }
770:                pacfileLocation = params.getString("pacfileLocation");
771:                if (null != pacfileLocation) {
772:                    pacfileLocation = pacfileLocation.trim();
773:                } else {
774:                    pacfileLocation = "";
775:                }
776:            }
777:
778:            /*
779:             * Validate client bind IP selected by the user.
780:             */
781:            private void validateClientBindIP() {
782:                String[] tokens = clientBindIP.split("\\.");
783:                if ((null != tokens) && (tokens.length == 4)) {
784:                    for (int i = 0; i < 4; i++) {
785:                        try {
786:                            Integer.parseInt(tokens[i]);
787:                        } catch (NumberFormatException nfe) {
788:                            statusMsg = bundle.getString("invalidIP");
789:                        }
790:                    }
791:                } else {
792:                    statusMsg = bundle.getString("invalidIP");
793:                }
794:                return;
795:            }
796:
797:            /*
798:             * Validate client bind Port selected by the user.
799:             */
800:            private void validateClientBindPort() {
801:                try {
802:                    if (clientBindPort != null) {
803:                        clientBindPortNum = Integer.parseInt(clientBindPort);
804:                        if ((clientBindPortNum < 1025)
805:                                || (clientBindPortNum > 65535)) {
806:                            statusMsg = bundle.getString("portOutOfRange");
807:                        }
808:                    }
809:                } catch (NumberFormatException nfe) {
810:                    statusMsg = bundle.getString("invalidPort");
811:                }
812:
813:            }
814:
815:            /*
816:             * Validate pacfile Location entered by the user.
817:             */
818:            private void validatePacfileLocation() {
819:                if ((storePacfileFlag) && ("".equals(pacfileLocation))) {
820:                    statusMsg = bundle.getString("invalidPacfileLocation");
821:                }
822:            }
823:
824:            /*
825:             * Store all the new values selected by the user if these values are different from old values.
826:             */
827:            private void commitNewValues(UserAttributes attrs) {
828:                boolean autoDownload = attrs.getBoolean(PROXYLET_AUTO_DOWNLOAD);
829:                if (!autoDownloadFlag && autoDownload) {
830:                    attrs.setBoolean(PROXYLET_AUTO_DOWNLOAD, false);
831:                } else if (autoDownloadFlag && !autoDownload) {
832:                    attrs.setBoolean(PROXYLET_AUTO_DOWNLOAD, true);
833:                }
834:
835:                String oldClientBindIP = attrs
836:                        .getString(PROXYLET_CLIENT_BIND_IP);
837:                if (clientBindIP != null
838:                        && !clientBindIP.equals(oldClientBindIP)) {
839:                    attrs.setString(PROXYLET_CLIENT_BIND_IP, clientBindIP);
840:                }
841:
842:                int oldClientBindPort = attrs.getInt(PROXYLET_CLIENT_BIND_PORT);
843:                if (clientBindPortNum != oldClientBindPort) {
844:                    attrs.setInt(PROXYLET_CLIENT_BIND_PORT, clientBindPortNum);
845:                }
846:
847:                boolean storePacfile = attrs
848:                        .getBoolean(PROXYLET_STORE_PACFILE_LOCALLY);
849:                if (!storePacfileFlag && storePacfile) {
850:                    attrs.setBoolean(PROXYLET_STORE_PACFILE_LOCALLY, false);
851:                } else if (storePacfileFlag && !storePacfile) {
852:                    attrs.setBoolean(PROXYLET_STORE_PACFILE_LOCALLY, true);
853:                }
854:
855:                String oldPacfileLocation = attrs
856:                        .getString(PROXYLET_PACFILE_LOCATION);
857:                if (pacfileLocation != null
858:                        && !pacfileLocation.equals(oldPacfileLocation)) {
859:                    attrs.setString(PROXYLET_PACFILE_LOCATION, pacfileLocation);
860:                }
861:            }
862:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.