Java Doc for HttpsConnection.java in  » 6.0-JDK-Modules » j2me » javax » microedition » io » 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 » 6.0 JDK Modules » j2me » javax.microedition.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.microedition.io.HttpsConnection

All known Subclasses:   com.sun.midp.io.j2me.https.Protocol,
HttpsConnection
public interface HttpsConnection extends HttpConnection(Code)
This interface defines the necessary methods and constants to establish a secure network connection. The URI format with scheme https when passed to Connector.open will return a HttpsConnection. RFC 2818 defines the scheme.

A secure connection MUST be implemented by one or more of the following specifications:

HTTPS is the secure version of HTTP (IETF RFC2616), a request-response protocol in which the parameters of the request must be set before the request is sent.

In addition to the normal IOExceptions that may occur during invocation of the various methods that cause a transition to the Connected state, CertificateException (a subtype of IOException) may be thrown to indicate various failures related to establishing the secure link. The secure link is necessary in the Connected state so the headers can be sent securely. The secure link may be established as early as the invocation of Connector.open() and related methods for opening input and output streams and failure related to certificate exceptions may be reported.


Example

Open a HTTPS connection, set its parameters, then read the HTTP response.

Connector.open is used to open the URL and an HttpsConnection is returned. The HTTP headers are read and processed. If the length is available, it is used to read the data in bulk. From the HttpsConnection the InputStream is opened. It is used to read every character until end of file (-1). If an exception is thrown the connection and stream are closed.
 void getViaHttpsConnection(String url) 
 throws CertificateException, IOException {
 HttpsConnection c = null;
 InputStream is = null;
 try {
 c = (HttpsConnection)Connector.open(url);
 // Getting the InputStream ensures that the connection
 // is opened (if it was not already handled by
 // Connector.open()) and the SSL handshake is exchanged,
 // and the HTTP response headers are read.
 // These are stored until requested.
 is = c.openDataInputStream();
 if c.getResponseCode() == HttpConnection.HTTP_OK) {
 // Get the length and process the data
 int len = (int)c.getLength();
 if (len > 0) {
 byte[] data = new byte[len];
 int actual = is.readFully(data);
 ...
 } else {
 int ch;
 while ((ch = is.read()) != -1) {
 ...
 }
 }
 } else {
 ...
 }
 } finally {
 if (is != null)
 is.close();
 if (c != null)
 c.close();
 }
 }
 

See Also:   CertificateException




Method Summary
public  intgetPort()
     Returns the network port number of the URL for this HttpsConnection.
public  SecurityInfogetSecurityInfo()
     Return the security information associated with this successfully opened connection. If the connection is still in Setup state then the connection is initiated to establish the secure connection to the server.



Method Detail
getPort
public int getPort()(Code)
Returns the network port number of the URL for this HttpsConnection. the network port number of the URL for thisHttpsConnection.The default HTTPS port number (443) is returned if there wasno port number in the string passed to Connector.open.



getSecurityInfo
public SecurityInfo getSecurityInfo() throws IOException(Code)
Return the security information associated with this successfully opened connection. If the connection is still in Setup state then the connection is initiated to establish the secure connection to the server. The method returns when the connection is established and the Certificate supplied by the server has been validated. The SecurityInfo is only returned if the connection has been successfully made to the server. the security information associated with this open connection.
exception:
  IOException - if an arbitrary connection failure occurs



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.