|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // ocsptransport.h |
|
15 // Declare implementations of OCSP transport interface. Links the OCSP module |
|
16 // to the HTTP module. |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 */ |
|
24 |
|
25 #ifndef __OCSP_TRANSPORT_HTTP_H__ |
|
26 #define __OCSP_TRANSPORT_HTTP_H__ |
|
27 |
|
28 #include <e32std.h> |
|
29 #include <ocsp.h> |
|
30 #include <http.h> |
|
31 #include <uri8.h> |
|
32 #include <callbacktimer.h> |
|
33 #include <http/rexplicithttpsession.h> |
|
34 #include <ocsprequestandresponse.h> |
|
35 |
|
36 // Forward declaration |
|
37 class CTransportTimer; |
|
38 |
|
39 /** |
|
40 * OCSP transport object that uses the default transport appropriate to the |
|
41 * request URI. Currently, only HTTP POST is supported. |
|
42 */ |
|
43 class COCSPTransportDefault : public CBase, public MOCSPTransport |
|
44 { |
|
45 public: |
|
46 /** |
|
47 * Create a new instance of the transport. |
|
48 * @leave OCSP::KErrInvalidURI If the URI is not supported. |
|
49 */ |
|
50 IMPORT_C static COCSPTransportDefault* NewL(TUint32& aIap); |
|
51 |
|
52 virtual ~COCSPTransportDefault(); |
|
53 |
|
54 private: |
|
55 COCSPTransportDefault(TUint32& aIap); |
|
56 |
|
57 // Methods from MOCSPTransport |
|
58 virtual void SendRequest(const TDesC8& aURI, |
|
59 const TDesC8& aRequest, |
|
60 const TInt aTimeout, |
|
61 TRequestStatus& iStatus); |
|
62 virtual void CancelRequest(); |
|
63 virtual TPtrC8 GetResponse() const; |
|
64 |
|
65 private: |
|
66 // Use string pool for case-independent comparisons.... |
|
67 enum TTransportScheme |
|
68 { |
|
69 ETransportSchemeNotSupported, |
|
70 ETransportSchemeHTTP |
|
71 }; |
|
72 |
|
73 static TTransportScheme IdentifySchemeL(const TDesC8& aURI); |
|
74 |
|
75 void CreateTransportL(const TDesC8& aURI); |
|
76 |
|
77 private: |
|
78 MOCSPTransport* iTransport; |
|
79 TTransportScheme iScheme; |
|
80 |
|
81 TUint32& iIap; |
|
82 }; |
|
83 |
|
84 |
|
85 enum THTTPTransportState |
|
86 { |
|
87 ETransportConnectingState, |
|
88 ETransportSendRequestState |
|
89 }; |
|
90 |
|
91 |
|
92 /** |
|
93 * OCSP transport object that send requests via HTTP GET or POST depending on size of the request |
|
94 */ |
|
95 class COCSPTransportHttp : public CActive, |
|
96 public MOCSPTransport, |
|
97 public MHTTPDataSupplier, |
|
98 public MHTTPTransactionCallback, |
|
99 public MTimerObserver |
|
100 { |
|
101 public: |
|
102 /** |
|
103 * Create a new instance of the HTTP POST transport. |
|
104 */ |
|
105 IMPORT_C static COCSPTransportHttp* NewL(const TDesC8& aUri, TUint32& aIap); |
|
106 |
|
107 ~COCSPTransportHttp(); |
|
108 |
|
109 private: |
|
110 COCSPTransportHttp(TUint32& aIap); |
|
111 |
|
112 void ConstructL(const TDesC8& aUri); |
|
113 |
|
114 // Methods from MOCSPTransport |
|
115 void SendRequest(const TDesC8& aURI, |
|
116 const TDesC8& aRequest, |
|
117 const TInt aTimeout, |
|
118 TRequestStatus& iStatus); |
|
119 void CancelRequest(); |
|
120 TPtrC8 GetResponse() const; |
|
121 |
|
122 // From CActive |
|
123 void RunL(); |
|
124 void DoCancel(); |
|
125 TInt RunError(TInt aError); |
|
126 |
|
127 // Methods from MHTTPDataSupplier |
|
128 TBool GetNextDataPart(TPtrC8& aDataPart); |
|
129 void ReleaseData(); |
|
130 TInt OverallDataSize(); |
|
131 TInt Reset(); |
|
132 |
|
133 // Methods from MHTTPTransactionCallback |
|
134 void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent); |
|
135 TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent); |
|
136 |
|
137 // Methods from MTransportTimer |
|
138 void TimerRun(TInt aError); |
|
139 |
|
140 private: |
|
141 // Internal methods |
|
142 void InstallHttpFilterL(); |
|
143 void DoSendRequestL(const TDesC8& aURI, |
|
144 const TDesC8& aRequest); |
|
145 void AddHttpHeadersL(); |
|
146 void ProcessHeadersL(); |
|
147 void ProcessDataL(); |
|
148 void CheckDataCompleteL() const; |
|
149 void SetIAPL(); |
|
150 void Complete(TInt aError); |
|
151 void AbortTransaction(TInt aError); |
|
152 |
|
153 private: |
|
154 TRequestStatus* iCallBack; |
|
155 |
|
156 // Data to send, from OCSP module |
|
157 TPtrC8 iOCSPRequest; |
|
158 |
|
159 TUriParser8 iURI; |
|
160 |
|
161 RExplicitHTTPSession iHTTPSession; |
|
162 RHTTPTransaction iHTTPTransaction; |
|
163 |
|
164 // request data |
|
165 HBufC8* iUri; |
|
166 HBufC8* iRequest; |
|
167 |
|
168 // The data in the response |
|
169 HBufC8* iResponseData; |
|
170 TInt iResponseLength; |
|
171 |
|
172 TUint32& iIap; |
|
173 THTTPTransportState iState; |
|
174 |
|
175 // ETrue if HTTP GET method support should be enabled (default is EFalse) |
|
176 TBool iUseHTTPGETMethod; |
|
177 |
|
178 // Timer class |
|
179 CCallbackTimer* iTimer; |
|
180 |
|
181 // Flag to indicate whether we were able to contact the responder |
|
182 TBool iServerFound; |
|
183 |
|
184 // Reponse timeout out value in Milliseconds |
|
185 TInt iTimeout; |
|
186 }; |
|
187 |
|
188 |
|
189 #endif // __OCSP_TRANSPORT_HTTP_H__ |