00001 /* 00002 * Funambol is a mobile platform developed by Funambol, Inc. 00003 * Copyright (C) 2003 - 2007 Funambol, Inc. 00004 * 00005 * This program is free software; you can redistribute it and/or modify it under 00006 * the terms of the GNU Affero General Public License version 3 as published by 00007 * the Free Software Foundation with the addition of the following permission 00008 * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED 00009 * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE 00010 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. 00011 * 00012 * This program is distributed in the hope that it will be useful, but WITHOUT 00013 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00014 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00015 * details. 00016 * 00017 * You should have received a copy of the GNU Affero General Public License 00018 * along with this program; if not, see http://www.gnu.org/licenses or write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00020 * MA 02110-1301 USA. 00021 * 00022 * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite 00023 * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com. 00024 * 00025 * The interactive user interfaces in modified source and object code versions 00026 * of this program must display Appropriate Legal Notices, as required under 00027 * Section 5 of the GNU Affero General Public License version 3. 00028 * 00029 * In accordance with Section 7(b) of the GNU Affero General Public License 00030 * version 3, these Appropriate Legal Notices must retain the display of the 00031 * "Powered by Funambol" logo. If the display of the logo is not reasonably 00032 * feasible for technical reasons, the Appropriate Legal Notices must display 00033 * the words "Powered by Funambol". 00034 */ 00035 00036 00037 /* 00038 How to test SSL connections 00039 ---------------------------- 00040 00041 On the server: 00042 1) create the keystore: 00043 %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA 00044 2) In $CATALINA_HOME/conf/server.xml uncomment the lines: 00045 <Connector className="org.apache.catalina.connector.http.HttpConnector" 00046 port="8443" minProcessors="5" maxProcessors="75" 00047 enableLookups="true" 00048 acceptCount="10" debug="0" scheme="https" secure="true"> 00049 <Factory className="org.apache.catalina.net.SSLServerSocketFactory" clientAuth="false" protocol="TLS"/> 00050 </Connector> 00051 2) Export the certificate from the key store: 00052 %JAVA_HOME%\bin\keytool -export -alias tomcat -file myroot.cer 00053 00054 On the client: 00055 [for _WIN32_WCE] 00056 1) Copy myroot.cer in a device/emulator directory 00057 2) Click on it to import the certificate as a trusted CA 00058 [for WIN32] 00059 1) Connect (via https) to the server using a web-browser (type "https://<server_address>:8443) 00060 2) Accept and install the certificate sent from the server 00061 */ 00062 00063 #ifndef INCL_WIN_TRANSPORT_AGENT 00064 #define INCL_WIN_TRANSPORT_AGENT 00065 00067 #include "base/fscapi.h" 00068 #include "http/URL.h" 00069 #include "http/Proxy.h" 00070 #include "http/TransportAgent.h" 00071 00073 #define MAX_RETRIES 3 // Max number of attempts sending http requests. 00074 00075 // FIXME: should these go to http/errors.h ? 00076 #define ERR_HTTP_TIME_OUT ERR_TRANSPORT_BASE+ 7 00077 #define ERR_HTTP_NOT_FOUND ERR_TRANSPORT_BASE+60 00078 #define ERR_HTTP_REQUEST_TIMEOUT ERR_TRANSPORT_BASE+61 00079 #define ERR_HTTP_INFLATE ERR_TRANSPORT_BASE+70 00080 #define ERR_HTTP_DEFLATE ERR_TRANSPORT_BASE+71 00081 00082 #define ERROR_INTERNET_OFFLINE_MODE 0x0002 // Not sure why it's not defined under wininet.h ... 00083 #include "base/globalsdef.h" 00084 00085 BEGIN_NAMESPACE 00086 00087 typedef enum { 00088 HTTP_POST = 0, 00089 HTTP_GET 00090 } HTTPVerbs; 00091 00097 class WinTransportAgent : public TransportAgent { 00098 00099 00100 public: 00101 WinTransportAgent(); 00102 WinTransportAgent(URL& url, Proxy& proxy, 00103 unsigned int responseTimeout = DEFAULT_MAX_TIMEOUT, 00104 unsigned int maxmsgsize = DEFAULT_MAX_MSG_SIZE); 00105 ~WinTransportAgent(); 00106 00116 char* sendMessage(const char* msg); 00117 00123 void setHttpVerb(HTTPVerbs value) { httpVerb = value; } 00124 00125 private: 00126 bool isToDeflate; // to be zipped 00127 bool isFirstMessage; // first message is clear 00128 bool isToInflate; // to be unzipped 00129 00130 HTTPVerbs httpVerb; // It uses the HTTP_GET and HTTP_POST (default). 00131 HTTPVerbs getHttpVerb() const { return httpVerb; } 00132 00133 char* createHttpErrorMessage(DWORD errorCode); 00134 void dumpMessage(const char* msg, const int msgLen); 00135 }; 00136 00137 00138 END_NAMESPACE 00139 00141 #endif