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


001:        package com.sun.portal.netlet.client.common;
002:
003:        import java.util.Hashtable;
004:        import java.util.Enumeration;
005:
006:        public class ClientConfig {
007:
008:            private static Hashtable parameters = new Hashtable();
009:
010:            private static String destProtocol;
011:            private static String destHost;
012:            private static int destPort;
013:
014:            private static boolean doPortWarning = false;
015:            private static boolean showPortWarnCheckbox = false;
016:            private static boolean doReauth = false;
017:            private static boolean JSSEEnabled = false;
018:            private static boolean PDCEnabled = false;
019:            private static boolean proxyletMode = false;
020:
021:            private static boolean proxyMode;
022:            private static String proxyHost;
023:            private static int proxyPort;
024:
025:            private static String proxyAuthUsername;
026:            private static String proxyAuthPassword;
027:
028:            //Proxy Types
029:            public static final int DIRECT = 0; // Direct connection to the Internet
030:            public static final int MANUAL = 1; // Manual proxy configuration
031:            public static final int AUTO = 2; // Automatic proxy configuration
032:            public static final int BROWSER = 3; // 1.4 plugin on Netscaoe 6.2
033:
034:            //Connection Type
035:            public static final int NORMAL = 0;
036:            public static final int FTP = 1;
037:            public static final int EXCHANGE = 2;
038:
039:            public static void addParams(Hashtable params) {
040:        Enumeration enum = params.keys();
041:        while (enum.hasMoreElements()) {
042:            String key = (String) enum.nextElement();
043:            parameters.put(key, params.get(key));
044:        }
045:    }
046:
047:            public static void addParam(String key, String value) {
048:                if (key != null && value != null) {
049:                    parameters.put(key, value);
050:                }
051:            }
052:
053:            public static void init() {
054:                //printMap();
055:                initParams();
056:            }
057:
058:            private static void initParams() {
059:                getGWNameAndPort();
060:                String tmp = null;
061:                if ((tmp = getParam("doPortWarning")) != null
062:                        && tmp.equalsIgnoreCase("true")) {
063:                    doPortWarning = true;
064:                }
065:                if ((tmp = getParam("showPortWarnCheckbox")) != null
066:                        && tmp.equalsIgnoreCase("true")) {
067:                    showPortWarnCheckbox = true;
068:                }
069:                if ((tmp = getParam("doReauth")) != null
070:                        && tmp.equalsIgnoreCase("true")) {
071:                    doReauth = true;
072:                }
073:                if ((tmp = getParam("isPDCEnabled")) != null
074:                        && tmp.equalsIgnoreCase("true")) {
075:                    PDCEnabled = true;
076:                }
077:                if ((tmp = getParam("isJSSEEnabled")) != null
078:                        && tmp.equalsIgnoreCase("true")) {
079:                    JSSEEnabled = true;
080:                }
081:                if ((tmp = getParam("proxyletMode")) != null
082:                        && tmp.equalsIgnoreCase("true")) {
083:                    proxyletMode = true;
084:                }
085:            }
086:
087:            private static void getGWNameAndPort() {
088:                String gwURL = getGWURL();
089:                if ((gwURL != null) || !(gwURL.equals(""))) {
090:                    String tmp = null;
091:                    destProtocol = gwURL.substring(0, gwURL.indexOf(':'));
092:                    tmp = gwURL.substring((destProtocol.length() + 3), gwURL
093:                            .length());
094:                    tmp = tmp.substring(0, tmp.indexOf('/'));
095:                    int gwPortIndex = tmp.indexOf(':');
096:                    if (gwPortIndex == -1) {
097:                        destHost = tmp;
098:                        if (destProtocol.equals("http")) {
099:                            destPort = 80;
100:                        } else if (destProtocol.equals("https")) {
101:                            destPort = 443;
102:                        }
103:                    } else {
104:                        destHost = tmp.substring(0, gwPortIndex);
105:                        try {
106:                            destPort = Integer.parseInt(tmp.substring(
107:                                    gwPortIndex + 1, tmp.length()));
108:                        } catch (NumberFormatException n) {
109:                            System.out
110:                                    .println("Netlet unable to parse gwination port");
111:                        }
112:                    }
113:                }
114:                System.out.println("gateway protocol : " + destProtocol);
115:                System.out.println("gateway host : " + destHost);
116:                System.out.println("gateway port : " + destPort);
117:            }
118:
119:            public static String getParam(String name) {
120:                return (String) parameters.get(name);
121:            }
122:
123:            public static void loadProxyDetails(ProxyInfo pi) {
124:                proxyHost = pi.getProxySSL();
125:                proxyPort = pi.getProxySSLPort();
126:                proxyMode = pi.getProxyMode();
127:                System.out.println("Client Config proxyHost " + proxyHost);
128:                System.out.println("Client Config proxyPort " + proxyPort);
129:                System.out.println("Client Config proxyMode " + proxyMode);
130:            }
131:
132:            public static String getConfigURL() {
133:                return getParam("configURL");
134:            }
135:
136:            public static String getGWURL() {
137:                return getParam("gwURL");
138:            }
139:
140:            public static String getTargetURL() {
141:                String targetURL = getParam("targetURL");
142:                if (targetURL == null || targetURL.length() <= 0) {
143:                    String confURL = getConfigURL();
144:
145:                    targetURL = confURL;
146:                    if (proxyletMode && confURL.startsWith("/")) {
147:                        System.out.println("ClientConfig : proxylet running");
148:                        String codebaseURL = getParam("codebaseURL");
149:                        if (codebaseURL != null && codebaseURL.length() > 0) {
150:                            int hostIndex = codebaseURL.indexOf("/");
151:                            int portIndex = codebaseURL.indexOf("/",
152:                                    hostIndex + 2);
153:                            targetURL = getGWURL()
154:                                    + codebaseURL.substring(0, portIndex)
155:                                    + confURL;
156:                        } else {
157:                            System.err.println("Enable to get codebase url");
158:                        }
159:                    } else {
160:                        targetURL = confURL;
161:                    }
162:                    addParam("targetURL", targetURL);
163:                }
164:                System.out.println("ClientConfig targetURL " + targetURL);
165:                return targetURL;
166:            }
167:
168:            public static String getServerURL() {
169:                String serverURL;
170:                int doubleSlashIndex = getConfigURL().indexOf("//");
171:                serverURL = getConfigURL().substring(0,
172:                        getConfigURL().indexOf("/", doubleSlashIndex + 2));
173:                System.out.println("serverURL " + serverURL);
174:                return serverURL;
175:            }
176:
177:            public static String getDestProtocol() {
178:                return destProtocol;
179:            }
180:
181:            public static String getDestHost() {
182:                return destHost;
183:            }
184:
185:            public static int getDestPort() {
186:                return destPort;
187:            }
188:
189:            public static String getCookieName() {
190:                return getParam("cookiename");
191:            }
192:
193:            public static String getClientBindIP() {
194:                return getParam("clientBindIP");
195:            }
196:
197:            public static String getSessionID() {
198:                return getParam("sessionId");
199:            }
200:
201:            public static void setSessionID(String id) {
202:                addParam("sessionId", new String(id));
203:            }
204:
205:            public static int getNumOfRules() {
206:                return Integer.parseInt(getParam("numParms"));
207:            }
208:
209:            public static boolean doPortWarning() {
210:                return doPortWarning;
211:            }
212:
213:            public static boolean showPortWarnCheckbox() {
214:                return showPortWarnCheckbox;
215:            }
216:
217:            public static boolean doReauth() {
218:                return doReauth;
219:            }
220:
221:            public static boolean isJSSEEnabled() {
222:                return JSSEEnabled;
223:            }
224:
225:            public static boolean isPDCEnabled() {
226:                return PDCEnabled;
227:            }
228:
229:            public static boolean isProxyletMode() {
230:                return proxyletMode;
231:            }
232:
233:            public static boolean isProxyMode() {
234:                return proxyMode;
235:            }
236:
237:            public static String getProxyHost() {
238:                return proxyHost;
239:            }
240:
241:            public static int getProxyPort() {
242:                return proxyPort;
243:            }
244:
245:            /*
246:             * util methods called by ProxySConn so that it doesn't have to redo
247:             * the proxy auth each time it makes a connection
248:             */
249:            public static void setProxyAuthUsername(String name) {
250:                proxyAuthUsername = name;
251:            }
252:
253:            public static void setProxyAuthPassword(String name) {
254:                proxyAuthPassword = name;
255:            }
256:
257:            public static String getProxyAuthUsername() {
258:                return proxyAuthUsername;
259:            }
260:
261:            public static String getProxyAuthPassword() {
262:                return proxyAuthPassword;
263:            }
264:
265:            public static boolean getProxyAuth() {
266:                return (proxyAuthUsername != null && proxyAuthPassword != null);
267:            }
268:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.