Source Code Cross Referenced for NetletSocketFactory.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:        /*
002:         * Factory for creating appropriate scoket wrappers. The code above this layer
003:         * depends only on java.net.Socket inteface however the actual implementation
004:         * can be of any Socket type Eg: KSSL, JSSE, Plain sockets
005:         *
006:         * @author  Rajesh 
007:         * @date 16-July-2003
008:         */
009:        package com.sun.portal.netlet.client.common;
010:
011:        import java.net.Socket;
012:
013:        public class NetletSocketFactory {
014:
015:            private static boolean isHTTPSGW = true;
016:            private NetletSocketWrapper nsw = null;
017:            private static NetletSocketFactory nsf = null;
018:            private boolean isJSSEEnabled = false;
019:            private boolean requireClientCert = false;
020:
021:            /*
022:             * Creates a new instance of NetletSocketFactory.
023:             * Creating only instance of Factory per Netlet Applet
024:             * Instance
025:             */
026:
027:            private NetletSocketFactory(String gwProtocol,
028:                    boolean isJSSEEnabled, boolean requireClientCert) {
029:                if (gwProtocol.equalsIgnoreCase("https")) {
030:                    isHTTPSGW = true;
031:                } else {
032:                    isHTTPSGW = false;
033:                }
034:                this .isJSSEEnabled = isJSSEEnabled;
035:                this .requireClientCert = requireClientCert;
036:                init();
037:            }
038:
039:            /*
040:             *
041:             */
042:
043:            public Socket getSocket(String destHost, int destPort,
044:                    String[] cipherSuites) {
045:                return nsw.getSocket(destHost, destPort, cipherSuites);
046:            }
047:
048:            /*
049:             * Wraps around a plain socket that was used for Proxy tunneling.
050:             * Proxy tunneling uses plain sockets to communicate. Basically this method
051:             * just upgrades a Plain Socket to the underlying actual encryption socket
052:             */
053:
054:            public Socket getSocket(Socket tunnelSocket, String host, int port,
055:                    String[] cipherSuites) {
056:                return nsw.getSocket(tunnelSocket, host, port, cipherSuites);
057:            }
058:
059:            /*
060:             * Creates and returns a reference to the SocketFactory.
061:             */
062:
063:            public synchronized static NetletSocketFactory getNetletSocketFactory(
064:                    String gwProtocol, boolean isJSSE, boolean requireClientCert) {
065:                if (nsf == null) {
066:                    nsf = new NetletSocketFactory(gwProtocol, isJSSE,
067:                            requireClientCert);
068:                }
069:                return nsf;
070:            }
071:
072:            /*
073:             * Dynamically Loading the wrappers as its not alway necessary all the socket
074:             * implementation are available/downloaded as the part of Netlet Applet.
075:             * For Eg : On Java 1 VM there is no need to download JSSE wrapper implementations
076:             */
077:
078:            private void init() {
079:
080:                try {
081:                    if (!isHTTPSGW) {
082:                        nsw = (NetletSocketWrapper) Class
083:                                .forName(
084:                                        "com.sun.portal.netlet.client.common.PlainSocketWrapper")
085:                                .newInstance();
086:                    } else if (!isJSSEEnabled) {
087:                        nsw = (NetletSocketWrapper) Class
088:                                .forName(
089:                                        "com.sun.portal.netlet.client.common.KSSLSocketWrapper")
090:                                .newInstance();
091:                    } else {
092:                        nsw = (NetletSocketWrapper) Class
093:                                .forName(
094:                                        "com.sun.portal.netlet.client.common.JSSEWrapper")
095:                                .newInstance();
096:                    }
097:                    nsw.init(this .requireClientCert);
098:                } catch (Exception e) {
099:                    e.printStackTrace();
100:                }
101:            }
102:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.