|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CWPPushMessage helps in saving/restoring a push message. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CWPPUSHMESSAGE_H |
|
20 #define CWPPUSHMESSAGE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 // FORWARD DECLARATIONS |
|
26 class CMsvStore; |
|
27 class CHTTPResponse; |
|
28 class RWriteStream; |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // Authentication result: Authenticated |
|
33 const TInt KWPAuthResultAuthenticated = 0; |
|
34 |
|
35 // Authentication result: PIN required, but not supplied |
|
36 const TInt KWPAuthResultPinRequired = 1; |
|
37 |
|
38 // Authentication result: Authentication failed |
|
39 const TInt KWPAuthResultAuthenticationFailed = 2; |
|
40 |
|
41 // Authentication result: No authentication contained in message |
|
42 const TInt KWPAuthResultNoAuthentication = 3; |
|
43 |
|
44 // Security parameter NETWPIN |
|
45 const TUint8 KSECNETWPIN = 0x00; |
|
46 |
|
47 // Security parameter USERPIN |
|
48 const TUint8 KSECUSERPIN = 0x01; |
|
49 |
|
50 // Security parameter USERNETWPIN |
|
51 const TUint8 KSECUSERNETWPIN = 0x02; |
|
52 |
|
53 // Security parameter USERPINMAC |
|
54 const TUint8 KSECUSERPINMAC = 0x03; |
|
55 |
|
56 // No security parameter |
|
57 const TUint8 KSECNONE = 0xff; |
|
58 |
|
59 |
|
60 // CLASS DECLARATION |
|
61 |
|
62 /** |
|
63 * CWPPushMessage helps in saving/restoring a push message. |
|
64 * |
|
65 * @lib ProvisioningEngine |
|
66 * @since 2.0 |
|
67 */ |
|
68 class CWPPushMessage : public CBase |
|
69 { |
|
70 public: // Constructors and destructor |
|
71 |
|
72 /** |
|
73 * Two-phased constructor. |
|
74 */ |
|
75 IMPORT_C static CWPPushMessage* NewL(); |
|
76 |
|
77 /** |
|
78 * Two-phased constructor. |
|
79 */ |
|
80 IMPORT_C static CWPPushMessage* NewLC(); |
|
81 |
|
82 /** |
|
83 * Destructor. |
|
84 */ |
|
85 ~CWPPushMessage(); |
|
86 |
|
87 public: // New methods |
|
88 |
|
89 /** |
|
90 * Stores the message to a message store. |
|
91 * @param aStore The store. |
|
92 */ |
|
93 IMPORT_C void StoreL( CMsvStore& aStore ) const; |
|
94 |
|
95 /** |
|
96 * Restores the message from a message store. |
|
97 * @param aStore The store. |
|
98 */ |
|
99 IMPORT_C void RestoreL( CMsvStore& aStore ); |
|
100 |
|
101 /** |
|
102 * Externalizes the message to a stream. |
|
103 * @param aStream The stream |
|
104 */ |
|
105 IMPORT_C void ExternalizeL( RWriteStream& aStream ) const; |
|
106 |
|
107 /** |
|
108 * Internalizes the message from a stream. |
|
109 * @param aStream The stream. |
|
110 */ |
|
111 IMPORT_C void InternalizeL( RReadStream& aStream ); |
|
112 |
|
113 /** |
|
114 * Sets the message header and body. |
|
115 * @param aHeader The message header |
|
116 * @param aBody The message body |
|
117 */ |
|
118 IMPORT_C void SetL( const TDesC8& aHeader, const TDesC8& aBody ); |
|
119 |
|
120 /** |
|
121 * Sets the message header and body. Ownership is transferred. |
|
122 * @param aHeader The message header |
|
123 * @param aBody The message body |
|
124 */ |
|
125 IMPORT_C void Set( HBufC8* aHeader, HBufC8* aBody ); |
|
126 |
|
127 /** |
|
128 * Sets the originator of the message. |
|
129 * @param aOrig Originator of the message |
|
130 */ |
|
131 IMPORT_C void SetOriginatorL( const TDesC8& aOrig ); |
|
132 |
|
133 /** |
|
134 * Returns the message header. |
|
135 * @return The message header |
|
136 */ |
|
137 IMPORT_C const TDesC8& Header() const; |
|
138 |
|
139 /** |
|
140 * Returns the message body. |
|
141 * @return The message body |
|
142 */ |
|
143 IMPORT_C const TDesC8& Body() const; |
|
144 |
|
145 /** |
|
146 * Returns the originator of the message. |
|
147 * @return The originator |
|
148 */ |
|
149 IMPORT_C const TDesC8& Originator() const; |
|
150 |
|
151 /** |
|
152 * Sets the authenticated flag. |
|
153 * @param aAuthenticated ETrue to set the message authenticated. |
|
154 */ |
|
155 IMPORT_C void SetAuthenticated( TBool aAuthenticated ); |
|
156 |
|
157 /** |
|
158 * Returns ETrue if the message is authenticated. |
|
159 * @return Whether the message is authenticated. |
|
160 */ |
|
161 IMPORT_C TBool Authenticated() const; |
|
162 |
|
163 /** |
|
164 * Sets the saved flag. |
|
165 * @param aSaved ETrue to set the message saved. |
|
166 */ |
|
167 IMPORT_C void SetSaved( TBool aSaved ); |
|
168 |
|
169 /** |
|
170 * Returns ETrue if the message is saved. |
|
171 * @return Whether the message is saved. |
|
172 */ |
|
173 IMPORT_C TBool Saved() const; |
|
174 |
|
175 /** |
|
176 * Returns the initiator URI of the message. |
|
177 * @return Initiator URI |
|
178 */ |
|
179 IMPORT_C const TDesC8& InitiatorURI() const; |
|
180 |
|
181 /** |
|
182 * Returns the MAC of the message. |
|
183 * @return MAC |
|
184 */ |
|
185 IMPORT_C const TDesC8& MAC() const; |
|
186 |
|
187 /** |
|
188 * Returns the SEC of the message. |
|
189 * @return SEC |
|
190 */ |
|
191 IMPORT_C TUint SEC() const; |
|
192 |
|
193 /** |
|
194 * Returns the push flag of the message. |
|
195 * @return Push flag |
|
196 */ |
|
197 IMPORT_C TInt PushFlag() const; |
|
198 |
|
199 /** |
|
200 * Parse the header. |
|
201 */ |
|
202 IMPORT_C void ParseHeaderL(); |
|
203 |
|
204 /** |
|
205 * Try to authenticate the message with HMAC. |
|
206 * @param aIMSI The SIM card number |
|
207 * @param aPIN The PIN entered by user |
|
208 * @return The result of authentication |
|
209 */ |
|
210 IMPORT_C TInt AuthenticateL( const TDesC& aIMSI, const TDesC& aPIN ); |
|
211 |
|
212 private: |
|
213 /** |
|
214 * C++ default constructor. |
|
215 */ |
|
216 CWPPushMessage(); |
|
217 |
|
218 /** |
|
219 * By default Symbian 2nd phase constructor is private. |
|
220 */ |
|
221 void ConstructL(); |
|
222 |
|
223 private: |
|
224 /** |
|
225 * Parse the content-type header. |
|
226 * @param aPointer Lexer pointing to content-type header. |
|
227 */ |
|
228 void ParseContentType( TLex8& aPointer ); |
|
229 |
|
230 /** |
|
231 * Parse the content-type header. |
|
232 * @param aPointer Lexer pointing to content-type header. |
|
233 */ |
|
234 void ParseInitiatorURI( TLex8& aPointer ); |
|
235 |
|
236 /** |
|
237 * Parse the content-type header. |
|
238 * @param aPointer Lexer pointing to content-type header. |
|
239 */ |
|
240 void ParsePushFlag( TLex8& aPointer ); |
|
241 |
|
242 /** |
|
243 * Retrieve a Short-integer. |
|
244 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
245 * @param aPointer Lexer pointing to content-type header. |
|
246 * @return The short integer |
|
247 */ |
|
248 TUint GetShortInteger( TLex8& aPointer ) const; |
|
249 |
|
250 /** |
|
251 * Retrieve a Long-integer. |
|
252 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
253 * @param aPointer Lexer pointing to content-type header. |
|
254 * @return The long integer. |
|
255 */ |
|
256 TInt64 GetLongInteger( TLex8& aPointer ) const; |
|
257 |
|
258 /** |
|
259 * Retrieve a Text-string. |
|
260 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
261 * @param aPointer Lexer pointing to content-type header. |
|
262 * @return The string |
|
263 */ |
|
264 TPtrC8 GetTextString( TLex8& aPointer ) const; |
|
265 |
|
266 /** |
|
267 * Retrieve a Text-value. |
|
268 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
269 * @param aPointer Lexer pointing to content-type header. |
|
270 * @return The string |
|
271 */ |
|
272 TPtrC8 GetTextValue( TLex8& aPointer ) const; |
|
273 |
|
274 /** |
|
275 * Retrieve a Token-text. |
|
276 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
277 * @param aPointer Lexer pointing to content-type header. |
|
278 * @return The text string |
|
279 */ |
|
280 TPtrC8 GetTokenText( TLex8& aPointer ) const; |
|
281 |
|
282 /** |
|
283 * Retrieve a Q-value. |
|
284 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
285 * @param aPointer Lexer pointing to content-type header. |
|
286 * @return The integer |
|
287 */ |
|
288 TUint GetQValue( TLex8& aPointer ) const; |
|
289 |
|
290 /** |
|
291 * Retrieve a Well-known-charset value. |
|
292 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
293 * @param aPointer Lexer pointing to content-type header. |
|
294 * @return The character set number |
|
295 */ |
|
296 TInt64 GetWellKnownCharset( TLex8& aPointer ) const; |
|
297 |
|
298 /** |
|
299 * Retrieve a Version-value. |
|
300 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
301 * @param aPointer Lexer pointing to content-type header. |
|
302 * @return The version |
|
303 */ |
|
304 TUint GetVersionValue( TLex8& aPointer ) const; |
|
305 |
|
306 /** |
|
307 * Retrieve a Constrained-encoding value. |
|
308 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
309 * @param aPointer Lexer pointing to content-type header. |
|
310 * @return The constrained encoding value |
|
311 */ |
|
312 TUint GetConstrainedEncoding( TLex8& aPointer ) const; |
|
313 |
|
314 /** |
|
315 * Retrieve an Integer-Value. |
|
316 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
317 * @param aPointer Lexer pointing to content-type header. |
|
318 * @return The integer value |
|
319 */ |
|
320 TInt64 GetIntegerValue( TLex8& aPointer ) const; |
|
321 |
|
322 /** |
|
323 * Check if lexer points to an Integer-value. |
|
324 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
325 * @param aPointer Lexer pointing to content-type header. |
|
326 * @return ETrue if lexer points to an integer |
|
327 */ |
|
328 TBool IsIntegerValue( TLex8& aPointer ) const; |
|
329 |
|
330 /** |
|
331 * Retrieve a Field-name. |
|
332 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
333 * @param aPointer Lexer pointing to content-type header. |
|
334 * @return Field name |
|
335 */ |
|
336 TUint GetFieldName( TLex8& aPointer ) const; |
|
337 |
|
338 /** |
|
339 * Retrieve a Delta-seconds-value. |
|
340 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
341 * @param aPointer Lexer pointing to content-type header. |
|
342 * @return The seconds found |
|
343 */ |
|
344 TInt64 GetDeltaSecondsValue( TLex8& aPointer ) const; |
|
345 |
|
346 /** |
|
347 * Retrieve a No-value. |
|
348 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
349 * @param aPointer Lexer pointing to content-type header. |
|
350 */ |
|
351 void GetNoValue( TLex8& aPointer ) const; |
|
352 |
|
353 /** |
|
354 * Retrieve a Date-value. |
|
355 * @see Wireless Session Protocol Specification WAP-230-WSP-20010705-a |
|
356 * @param aPointer Lexer pointing to content-type header. |
|
357 * @return The time value |
|
358 */ |
|
359 TTime GetDateValue( TLex8& aPointer ) const; |
|
360 |
|
361 /** |
|
362 * Skip to content-type. |
|
363 * @return The Content-Type header |
|
364 */ |
|
365 TPtrC8 ContentTypeHeader( CHTTPResponse& aResponse ) const; |
|
366 |
|
367 /** |
|
368 * Skip to x-wap-initiator-uri. |
|
369 * @return The X-WAP-Initiator-URI header |
|
370 */ |
|
371 TPtrC8 InitiatorURIHeader( CHTTPResponse& aResponse ) const; |
|
372 |
|
373 /** |
|
374 * Skip to push-flag. |
|
375 * @return The Push-Flag header |
|
376 */ |
|
377 TPtrC8 PushFlagHeader( CHTTPResponse& aResponse ) const; |
|
378 |
|
379 /** |
|
380 * Converts a HEX ASCII strings to binary. |
|
381 * @param aHex The hex ascii version |
|
382 * @return The binary version |
|
383 */ |
|
384 HBufC8* PackLC( const TDesC8& aHex ) const; |
|
385 |
|
386 /** |
|
387 * Create a HMAC key from the IMSI. |
|
388 * @param aIMSI The IMSI |
|
389 * @param aKey Space for HMAC key. |
|
390 */ |
|
391 void ConvertIMSIL( const TDesC& aIMSI, TPtr8& aKey ) const; |
|
392 |
|
393 private: // Data |
|
394 /// The message body. Owns. |
|
395 HBufC8* iBody; |
|
396 |
|
397 /// The message header. Owns. |
|
398 CHTTPResponse* iHeader; |
|
399 |
|
400 /// The originator of the message. Owns. |
|
401 HBufC8* iOriginator; |
|
402 |
|
403 /// Whether the message is authenticated |
|
404 TBool iAuthenticated; |
|
405 |
|
406 /// Whether the message is saved |
|
407 TBool iSaved; |
|
408 |
|
409 /// The initiator URI |
|
410 TPtrC8 iInitiator; |
|
411 |
|
412 /// The security parameter |
|
413 TUint iSEC; |
|
414 |
|
415 /// The MAC value. Owns. |
|
416 TPtrC8 iMAC; |
|
417 |
|
418 /// The Push Flag |
|
419 TInt iPushFlag; |
|
420 }; |
|
421 |
|
422 #endif /* CWPPUSHMESSAGE_H */ |