|
1 // Copyright (c) 2003-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 // |
|
15 |
|
16 |
|
17 #ifndef __TESTFILTER_H_ |
|
18 #define __TESTFILTER_H_ |
|
19 #include "Timer.h" |
|
20 #include <http/mhttpfilter.h> |
|
21 #include <http/rhttpsession.h> |
|
22 #include <http/cecomfilter.h> |
|
23 #include <http/framework/httplogger.h> |
|
24 #include <ecom/ecom.h> |
|
25 |
|
26 class RHTTPResponse; |
|
27 class RHTTPTransaction; |
|
28 class CMD5; |
|
29 |
|
30 const TInt KMaxTypeLength = 255; |
|
31 const TInt KBsfAddressSize = 128; |
|
32 |
|
33 class CShutdown : public CTimer |
|
34 { |
|
35 enum { EShutdownDelay = 0x4000000 }; // approx 2s |
|
36 public: |
|
37 CShutdown(); |
|
38 void ConstructL(); |
|
39 void Start(); |
|
40 void Stop(); |
|
41 private: |
|
42 void RunL(); |
|
43 }; |
|
44 |
|
45 class CTestFilterInterface : public CBase |
|
46 /** |
|
47 The ECOM interface definition for an HTTP authentication filter. Implementations |
|
48 of an authentication filter must inherit this class. |
|
49 @publishedAll |
|
50 @released |
|
51 */ |
|
52 { |
|
53 public: // Methods |
|
54 /** |
|
55 @fn InstallFilterL(RHTTPSession& aSession, MHTTPAuthenticationCallback* aCallback) |
|
56 Intended Usage: This method is used to install the authentication filter to the filter queue. |
|
57 The returned pointer is not owned as the filters must be self-destroying when |
|
58 they are unloaded. |
|
59 @param aSession A handle to the transport session |
|
60 @param aCallback A pointer to the object implementing the callback function |
|
61 @return Pointer to the newly installed plugin |
|
62 @pre The session had already been setup |
|
63 @post The filter(s) have been installed |
|
64 */ |
|
65 inline static void InstallFilterL(RHTTPSession& aSession); |
|
66 |
|
67 /** |
|
68 @fn ~CTestFilterInterface() |
|
69 Intended Usage: Virtual destructor |
|
70 @pre The object identified by the destructor key in iEcomDtorID exists |
|
71 @post The object is destroyed |
|
72 */ |
|
73 inline ~CTestFilterInterface(); |
|
74 |
|
75 private: |
|
76 // Attributes |
|
77 /// The ECom destructor key identifier |
|
78 TUid iEcomDtorID; |
|
79 }; |
|
80 |
|
81 //---------------------------------------------------------------------------------------- |
|
82 |
|
83 inline void CTestFilterInterface::InstallFilterL(RHTTPSession& aSession) |
|
84 { |
|
85 const TUid KUidAuthenticationFilter = {0x2002CE96}; |
|
86 |
|
87 REComSession::CreateImplementationL(KUidAuthenticationFilter, _FOFF(CTestFilterInterface,iEcomDtorID), &aSession); |
|
88 } |
|
89 |
|
90 inline CTestFilterInterface::~CTestFilterInterface() |
|
91 { |
|
92 REComSession::DestroyedImplementation(iEcomDtorID); |
|
93 } |
|
94 |
|
95 |
|
96 class CTestFilter : public CTestFilterInterface, public MHTTPFilter, public MTimerObserver |
|
97 { |
|
98 enum |
|
99 { |
|
100 EAlgUnknown, |
|
101 EAlgMd5, |
|
102 EAlgMd5Sess |
|
103 }; |
|
104 |
|
105 public: |
|
106 |
|
107 static CTestFilterInterface* InstallFilterL(TAny* aSession); |
|
108 |
|
109 virtual ~CTestFilter(); |
|
110 |
|
111 public: // Methods from MHTTPFilterBase |
|
112 |
|
113 /// @see MHTTPFilterBase::MHFRunL |
|
114 virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent); |
|
115 |
|
116 /// @see MHTTPFilterBase::MHFSessionRunL |
|
117 virtual void MHFSessionRunL(const THTTPSessionEvent& aEvent); |
|
118 |
|
119 /// @see MHTTPFilterBase::MHFRunError |
|
120 virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent); |
|
121 |
|
122 /// @see MHTTPFilterBase::MHFSessionRunError |
|
123 virtual TInt MHFSessionRunError(TInt aError, const THTTPSessionEvent& aEvent); |
|
124 |
|
125 public: // Methods from MHTTPFilter |
|
126 |
|
127 /// @see MHTTPFilter::MHFUnload |
|
128 virtual void MHFUnload(RHTTPSession aSession, THTTPFilterHandle aHandle); |
|
129 |
|
130 /// @see MHTTPFilter::MHFLoad |
|
131 virtual void MHFLoad(RHTTPSession aSession, THTTPFilterHandle aHandle); |
|
132 |
|
133 private: |
|
134 |
|
135 CTestFilter(); |
|
136 |
|
137 ///ContructL also Installs the filter. |
|
138 void ConstructL( RHTTPSession aSession ); |
|
139 |
|
140 void CheckHeadersL( RHTTPTransaction& aTrans ); |
|
141 |
|
142 void CleanupAll(); |
|
143 |
|
144 TBool FindAuth(const TDesC8& aQop) const; |
|
145 |
|
146 void DoSubmitL( RHTTPTransaction aTransaction ); |
|
147 |
|
148 void EncodeBasicAuthL(RString& aUsername,RString& aPW, RHTTPTransaction& aTransaction); |
|
149 |
|
150 TBool HandleTimerEventL(TTimerEventType aEventType); |
|
151 |
|
152 /// A count to make sure we delete at the right time. |
|
153 TInt iLoadCount; |
|
154 RStringPool iStringPool; |
|
155 RStringF iUsernameStr; |
|
156 RStringF iPasswordStr; |
|
157 RStringF iUserAgent; |
|
158 RStringF iAuthInfo; |
|
159 TInt64 iSeed; |
|
160 TInt iOffset; |
|
161 TUint8 iFlags; |
|
162 TBuf8<5> iProtocolIdentifier; |
|
163 TInt iBootstrapCount; |
|
164 TBool iBootstrapPending; |
|
165 TBool iHaveCredentials; |
|
166 CActiveSchedulerWait iBootstrapWait; |
|
167 CTimerOut* iTimeOut; |
|
168 |
|
169 }; |
|
170 |
|
171 #endif //__TESTFILTER_H_ |
|
172 |
|
173 //EOF |