Source Code Cross Referenced for HttpsMessage.java in  » Groupware » hipergate » com » oreilly » servlet » 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 » Groupware » hipergate » com.oreilly.servlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (C) 2000 by Matt Towers <eBozo_AT_hotmail_DOT_com>.
002:        // All rights reserved.  Use of this class is limited.
003:        // Please see the LICENSE for more information.
004:
005:        /*
006:         The source code and object code, of the HttpsMessage class is copyright and
007:         owned by Matt Towers. 
008:
009:         Feel free to use the HttpsMessage class in the development of any development
010:         project. For this use you are granted a non-exclusive, non-transferable 
011:         limited license at no cost.
012:
013:         Redistribution of the HttpsMessage source code is permitted provided that the
014:         following conditions are met: 
015:
016:         1.You maintain the original copyright notice in the source code. 
017:         2.This license file is redistributed with the source code. 
018:         3.You acknowledge that the parent HttpMessage class, with which this class
019:         is intended to be used, is owned and copyrighted by Jason Hunter
020:         <jhunter_AT_acm_DOT_org>. (For more information see
021:         http://www.servlets.com) 
022:
023:         To clarify, you may use the HttpsMessage class to build new software and may
024:         distribute the object code as you see fit. You may NOT distribute the source
025:         code as part of a software development kit, other library, or development tool
026:         without consent of the copyright holder. Any modified form of the HttpsMessage
027:         class is bound by these same restrictions.
028:
029:         Note that the HttpsMessage class is provided "as is" and the author will not
030:         be liable for any damages suffered as a result of your use. 
031:         Furthermore, you understand the source code comes without any technical
032:         support.
033:
034:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
035:         OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
036:         WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
037:         ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
038:         FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
039:         DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
040:         OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
041:         HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
042:         LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
043:         OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
044:         SUCH DAMAGE.
045:
046:         Matt Towers <eBozo_AT_hotmail_DOT_com> 
047:         */
048:
049:        package com.oreilly.servlet;
050:
051:        import java.io.*;
052:        import java.net.*;
053:        import java.util.*;
054:        import java.security.Security;
055:        import java.security.Provider;
056:
057:        /**
058:         * A class to simplify HTTP/HTTPS client-server communication.	It abstracts
059:         * the communication into messages, which can be either GET or POST.
060:         * <p>
061:         * It can be used like this:
062:         * <blockquote><pre>
063:         * &nbsp;
064:         * HttpsMessage msg = new HttpsMessage("https://[some server]");
065:         * &nbsp;
066:         * Properties props = new Properties();
067:         * props.put("name", "value");
068:         * &nbsp;
069:         * InputStream in = msg.sendGetMessage(props);
070:         * </pre></blockquote>
071:         * This class extends the HttpMessage class
072:         * written by Jason Hunter at servlets.com.
073:         * The HttpMessage class can be found in the com.oreilly.servlet
074:         * package found at www.servlets.com
075:         * <p>
076:         * For information see http://www.javaworld.com/javatips/jw-javatip96.html
077:         * Note this class works with JDK 1.2 or later only.
078:         * <p>
079:         * @author <b>Matt Towers</b>
080:         * @author Copyright &#169; 2000
081:         * @version 1.0, 2000/05/05
082:         */
083:        public class HttpsMessage extends com.oreilly.servlet.HttpMessage {
084:
085:            //A flag to indicate weather or not the stream handler has been set
086:            static boolean m_bStreamHandlerSet = false;
087:
088:            /**
089:             * Constructs a new HttpsMessage that can be used to communicate with the 
090:             * servlet at the specified URL using HTTPS.
091:             *
092:             * @param szURL the server resource (typically a servlet) with which 
093:             * to communicate
094:             */
095:            public HttpsMessage(String szURL) throws Exception {
096:                super (null);
097:                //If the stream handler has already been set
098:                //there is no need to do anything
099:                if (!m_bStreamHandlerSet) {
100:                    String szVendor = System.getProperty("java.vendor");
101:                    String szVersion = System.getProperty("java.version");
102:                    //Assumes a system version string of the form [major].[minor].[release]  (eg. 1.2.2)
103:                    Double dVersion = new Double(szVersion.substring(0, 3));
104:
105:                    //Otherwise, if we are running in a MS environment, use the MS stream handler.
106:                    if (-1 < szVendor.indexOf("Microsoft")) {
107:                        try {
108:                            Class clsFactory = Class
109:                                    .forName("com.ms.net.wininet.WininetStreamHandlerFactory");
110:                            if (null != clsFactory)
111:                                URL
112:                                        .setURLStreamHandlerFactory((URLStreamHandlerFactory) clsFactory
113:                                                .newInstance());
114:                        } catch (ClassNotFoundException cfe) {
115:                            throw new Exception(
116:                                    "Unable to load the Microsoft SSL stream handler.  Check classpath."
117:                                            + cfe.toString());
118:                        }
119:                        //If the stream handler factory has already been successfuly set
120:                        //make sure our flag is set and eat the error
121:                        catch (Error err) {
122:                            m_bStreamHandlerSet = true;
123:                        }
124:                    }
125:                    //If we are in a normal Java environment, try to use the JSSE handler.
126:                    else if (1.2 <= dVersion.doubleValue()) {
127:                        System.getProperties().put(
128:                                "java.protocol.handler.pkgs",
129:                                "com.sun.net.ssl.internal.www.protocol");
130:                        try {
131:                            //if we have the JSSE provider available, and it has not already been
132:                            //set, add it as a new provide to the Security class.
133:                            Class clsFactory = Class
134:                                    .forName("com.sun.net.ssl.internal.ssl.Provider");
135:                            if ((null != clsFactory)
136:                                    && (null == Security.getProvider("SunJSSE")))
137:                                Security.addProvider((Provider) clsFactory
138:                                        .newInstance());
139:                        } catch (ClassNotFoundException cfe) {
140:                            throw new Exception(
141:                                    "Unable to load the JSSE SSL stream handler.  Check classpath."
142:                                            + cfe.toString());
143:                        }
144:                    }
145:
146:                    m_bStreamHandlerSet = true;
147:                }
148:
149:                super .servlet = new URL(szURL);
150:            }
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.