Source Code Cross Referenced for Win32Reg.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:        // Copyright 07/16/01 Sun Microsystems, Inc. All Rights Reserved.
002:
003:        package com.sun.portal.netlet.client.applet;
004:
005:        import com.ms.lang.*;
006:        import com.ms.security.*;
007:        import com.sun.portal.netlet.client.common.LocalhostWarning;
008:        import com.sun.portal.netlet.client.common.ProxyInfo;
009:        import com.sun.portal.netlet.client.common.ClientUtil;
010:        import com.sun.portal.netlet.client.common.ResourceProperties;
011:
012:        import java.awt.*;
013:        import java.awt.event.ActionEvent;
014:        import java.awt.event.ActionListener;
015:        import java.util.Enumeration;
016:        import java.util.StringTokenizer;
017:        import java.util.Vector;
018:
019:        public class Win32Reg implements  ActionListener {
020:
021:            String ProxyString = "notStarted";
022:            boolean AutoConfig = false;
023:
024:            private String over = null;
025:
026:            private Frame f = new Frame();
027:            private LocalhostWarning pw;
028:
029:            private Vector noProxiesFor = new Vector();
030:
031:            //added only for using the parsed PAC file result
032:            //if these two following values are null and AutoConfig = true, it failed in parsing the PAC file
033:            String autoProxyHost = null;
034:            String autoProxyPort = null;
035:            String proxySSL = null;
036:            String proxySSLPort = null;
037:            ProxyInfo pi;
038:
039:            public Win32Reg(ProxyInfo pi) {
040:                this .pi = pi;
041:            }
042:
043:            public void startWin32Reg(boolean displayMsg) {
044:
045:                pw = new LocalhostWarning(f, this );
046:
047:                String keyName = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
048:
049:                //System.out.println("Netlet IE Proxy Setup");
050:                try {
051:                    PolicyEngine.assertPermission(PermissionID.REGISTRY);
052:
053:                    RegKey rk = new RegKey(RegKey.USER_ROOT, keyName,
054:                            RegKey.KEYOPEN_ALL);
055:                    boolean proxyEnable = rk.getIntValue("ProxyEnable") == 1 ? true
056:                            : false;
057:
058:                    if (proxyEnable) {
059:
060:                        PolicyEngine.assertPermission(PermissionID.CLIENTSTORE);
061:                        ProxyString = rk.getStringValue("ProxyServer");
062:                        System.out.println("Netlet IE Proxy String: "
063:                                + ProxyString);
064:                        /* 
065:                         * Added to fix Bug - 4625690
066:                         * Parse the proxy string, get proxy host and port 
067:                         */
068:                        String tmp = null;
069:                        if (ProxyString.indexOf("https") == -1) { // Same proxy for all protocols
070:                            tmp = ProxyString;
071:                        } else {
072:                            tmp = ProxyString.substring(ProxyString
073:                                    .indexOf("https") + 6);
074:                        }
075:                        if (tmp.indexOf(';') != -1) {
076:                            tmp = tmp.substring(0, tmp.indexOf(';'));
077:                        }
078:                        proxySSL = tmp.substring(0, tmp.indexOf(':'));
079:                        proxySSLPort = tmp.substring(tmp.indexOf(':') + 1);
080:
081:                        PolicyEngine.assertPermission(PermissionID.REGISTRY);
082:
083:                        //StringTokenizer st = new StringTokenizer(ProxyString, ";");
084:                        //if the ProxyOverride is blank it fails in IE 5
085:                        try {
086:                            over = rk.getStringValue("ProxyOverride");
087:                        } catch (Exception ex) {
088:                            ex.printStackTrace();
089:                        }
090:                        if (over == null)
091:                            over = new String("");
092:                        System.out.println("Netlet IE ProxyOverride: " + over);
093:                        if (over.indexOf("localhost") < 0) {
094:                            rk.setValue("ProxyOverride", over + ";localhost");
095:                            if (over.indexOf("<local>") < 0) {
096:                                //						String os = System.getProperty("os.name");
097:                                //						System.out.println("os version = " + os);
098:                                //						if (os.equals("Windows NT")) {
099:                                pw.setVisible(true);
100:                                //						}
101:                            }
102:                        }
103:                        StringTokenizer nst = new StringTokenizer(over, ";");
104:                        while (nst.hasMoreTokens()) {
105:                            String s = nst.nextToken().toLowerCase().trim();
106:                            if (!s.equals("")) {
107:                                noProxiesFor.addElement(s);
108:                                //System.out.println("no proxy for putting " + s);
109:                            }
110:                        }
111:                        System.out.println("Proxy override - "
112:                                + noProxiesFor.toString());
113:                    } else {
114:                        ProxyString = "0";
115:                    }
116:                    String autoConfigURL = rk.getStringValue("AutoConfigURL");
117:                    if (autoConfigURL.equals("") || autoConfigURL == null) {
118:                        AutoConfig = false;
119:                    } else {
120:                        //give it the permission to connect to the server where the pac file resides
121:                        try {
122:                            //if the file is on a webserver
123:                            com.ms.security.PolicyEngine
124:                                    .assertPermission(com.ms.security.PermissionID.NETIO);
125:                            //if the file is on a local machine
126:                            com.ms.security.PolicyEngine
127:                                    .assertPermission(com.ms.security.PermissionID.FILEIO);
128:                        } catch (Exception e) {
129:                            e.printStackTrace();
130:                        }
131:
132:                        //try to parse the PAC file
133:                        String inputLine = ClientUtil
134:                                .parsePACFile(autoConfigURL);
135:
136:                        if (inputLine.equalsIgnoreCase("DIRECT")) {
137:                            //no proxy required
138:                            AutoConfig = false;
139:                        } else {
140:                            if (inputLine.startsWith("PROXY")) {
141:                                /*
142:                                 * @ modified by bshankar@sun.com for Bug - 4625682. 
143:                                 * Instead of taking the first proxy, use the first valid proxy
144:                                 */
145:                                boolean isValid = false;
146:                                StringTokenizer tok = new StringTokenizer(
147:                                        inputLine, ";");
148:                                while (tok.hasMoreTokens() && !isValid) {
149:                                    String str = tok.nextToken().trim();
150:                                    String proxyString = (str.indexOf("PROXY") == 0) ? str
151:                                            .substring("PROXY".length()).trim()
152:                                            : str;
153:                                    int index = proxyString.indexOf(":");
154:                                    if (index == -1) {
155:                                        autoProxyHost = proxyString;
156:                                        autoProxyPort = new String("80");
157:                                    } else {
158:                                        autoProxyHost = proxyString.substring(
159:                                                0, index);
160:                                        autoProxyPort = proxyString
161:                                                .substring(index + 1);
162:                                    }
163:                                    isValid = ClientUtil.isProxySettingsValid(
164:                                            autoProxyHost, Integer
165:                                                    .parseInt(autoProxyPort));
166:                                }
167:                                if (!isValid) {
168:                                    pi.getProxyWarning().setMessage(
169:                                            ResourceProperties
170:                                                    .getString("pwarn.4"));
171:                                    autoProxyHost = "";
172:                                }
173:                                AutoConfig = true;
174:                            } else {
175:                                //else it would have failed,
176:                                //donot do anything , so that it will show the message.
177:                                AutoConfig = true;
178:                            }
179:                        }
180:                    }
181:                } catch (RegKeyException e) {
182:                    //System.out.println("Netlet IE key exception: "+e);
183:                }
184:            }
185:
186:            public void actionPerformed(ActionEvent evt) {
187:                if ("OK".equals(evt.getActionCommand())) {
188:                    pw.setVisible(false);
189:                }
190:            }
191:
192:            public boolean autoConfig() {
193:                return (AutoConfig);
194:            }
195:
196:            public boolean inLocalhostNoProxy(String host) {
197:                int i = 0;
198:                boolean match = false;
199:                boolean done = false;
200:                for (Enumeration e = noProxiesFor.elements(); e
201:                        .hasMoreElements();) {
202:                    String leftover = host;
203:                    String s = (String) e.nextElement();
204:                    StringTokenizer token = new StringTokenizer(s, "*");
205:                    match = true;
206:                    while (token.hasMoreTokens()) {
207:                        String stk = token.nextToken().toLowerCase().trim();
208:                        //				System.out.println("checking " + leftover + " against " + stk);
209:                        i = leftover.indexOf(stk);
210:                        if (i == -1) {
211:                            match = false;
212:                            break;
213:                        } else {
214:                            leftover = leftover.substring(i + stk.length());
215:                        }
216:                    }
217:                    if (match) {
218:                        break;
219:                    }
220:                }
221:                return (match);
222:            }
223:
224:            public String getLocalhostNoProxy() {
225:                return (over);
226:            }
227:
228:            public String getProxyHost() {
229:                if (autoConfig())
230:                    return autoProxyHost;
231:                //return  System.getProperty("http.proxyHost");
232:                return proxySSL;
233:            }
234:
235:            public int getProxyPort() {
236:                String pport_s = null;
237:                int pport = 0;
238:                if (autoConfig()) {
239:                    pport_s = autoProxyPort;
240:                } else {
241:                    //pport_s  =  System.getProperty("http.proxyPort");
242:                    pport_s = proxySSLPort;
243:                }
244:                try {
245:                    pport = Integer.parseInt(pport_s);
246:                } catch (NumberFormatException e) {
247:                    pport = 0;
248:                }
249:                return pport;
250:            }
251:
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.