|
1 /* |
|
2 * Copyright (c) 2005 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: Authorization in transaction handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPEngAuthorizationTransactionIn.h" |
|
21 #include "CPEngAuthorizationRequest.h" |
|
22 #include "CPEngAuthorizationResponse.h" |
|
23 #include "MPEngAuthorizationEngine.h" |
|
24 #include "MPEngXMLParser.h" |
|
25 |
|
26 #include "MPEngPresenceAttrManager.h" |
|
27 #include "PEngWVPresenceErrors2.h" |
|
28 #include "PresenceDebugPrint.h" |
|
29 |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CPEngAuthorizationTransactionIn::CPEngAuthorizationTransactionIn() |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CPEngAuthorizationTransactionIn::CPEngAuthorizationTransactionIn( |
|
38 MPEngAuthorizationEngine& aAuthEngine, |
|
39 MPEngPresenceAttrManager& aAttrManager, |
|
40 MPEngXMLParser& aXMLParser, |
|
41 const TDesC8& aParseBlock, |
|
42 TPEngAuthorizationTransType aType ) |
|
43 : iAuthEngine( aAuthEngine ), |
|
44 iAttributeManager( aAttrManager ), |
|
45 iXMLParser( aXMLParser ), |
|
46 iParseBlock( aParseBlock ), |
|
47 iResponseType( aType ) |
|
48 { |
|
49 PENG_DP( D_PENG_LIT( "CPEngAuthorizationTransactionIn::CPEngAuthorizationTransactionIn" ) ); |
|
50 } |
|
51 |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CPEngAuthorizationTransactionIn::ConstructL() |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void CPEngAuthorizationTransactionIn::ConstructL() |
|
58 { |
|
59 } |
|
60 |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CPEngAuthorizationTransactionIn::NewL() |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CPEngAuthorizationTransactionIn* CPEngAuthorizationTransactionIn::NewL( |
|
67 MPEngAuthorizationEngine& aAuthEngine, |
|
68 MPEngPresenceAttrManager& aAttrManager, |
|
69 MPEngXMLParser& aXMLParser, |
|
70 const TDesC8& aParseBlock, |
|
71 TPEngAuthorizationTransType aType ) |
|
72 { |
|
73 CPEngAuthorizationTransactionIn* self = NewLC( aAuthEngine, |
|
74 aAttrManager, |
|
75 aXMLParser, |
|
76 aParseBlock, |
|
77 aType ); |
|
78 |
|
79 CleanupStack::Pop(); |
|
80 return self; |
|
81 } |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CPEngAuthorizationTransactionIn::NewLC() |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 CPEngAuthorizationTransactionIn* CPEngAuthorizationTransactionIn::NewLC( |
|
89 MPEngAuthorizationEngine& aAuthEngine, |
|
90 MPEngPresenceAttrManager& aAttrManager, |
|
91 MPEngXMLParser& aXMLParser, |
|
92 const TDesC8& aParseBlock, |
|
93 TPEngAuthorizationTransType aType ) |
|
94 { |
|
95 CPEngAuthorizationTransactionIn* self = |
|
96 new ( ELeave ) CPEngAuthorizationTransactionIn( |
|
97 aAuthEngine, |
|
98 aAttrManager, |
|
99 aXMLParser, |
|
100 aParseBlock, |
|
101 aType ); |
|
102 CleanupStack::PushL( self ); |
|
103 self->ConstructL( ); |
|
104 |
|
105 return self; |
|
106 } |
|
107 |
|
108 |
|
109 // Destructor |
|
110 CPEngAuthorizationTransactionIn::~CPEngAuthorizationTransactionIn() |
|
111 { |
|
112 } |
|
113 |
|
114 |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CPEngAuthorizationTransactionIn::ProcessRequestL() |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void CPEngAuthorizationTransactionIn::ProcessRequestL( |
|
121 const TDesC8& /*aRequest*/, |
|
122 TRequestStatus& /*aStatus*/ ) |
|
123 { |
|
124 HBufC* userId = ParseUserIdLC(); |
|
125 switch ( iResponseType ) |
|
126 { |
|
127 case EPEngAuthorizationRequest: |
|
128 { |
|
129 PENG_DP( D_PENG_LIT( "CPEngAuthorizationTransactionIn::ProcessRequestL() - AuthRequest[%S]" ), |
|
130 userId ); |
|
131 |
|
132 |
|
133 CPEngAuthorizationRequest* authRequest = |
|
134 CPEngAuthorizationRequest::NewLC( *userId, |
|
135 iAuthEngine.SizeCounter() ); |
|
136 ParseAttrListL( *authRequest, |
|
137 &CPEngAuthorizationRequest::AddRequestedAttributeL ); |
|
138 |
|
139 // store authorization request |
|
140 // removes authRequest from cleanupstack |
|
141 iAuthEngine.AddAuthRequestLX( authRequest ); |
|
142 break; |
|
143 } |
|
144 |
|
145 |
|
146 case EPEngAuthorizationResponse: |
|
147 { |
|
148 PENG_DP( D_PENG_LIT( "CPEngAuthorizationTransactionIn::ProcessRequestL() - AuthResponse[%S]" ), |
|
149 userId ); |
|
150 |
|
151 CPEngAuthorizationResponse* authStatus = |
|
152 CPEngAuthorizationResponse::NewLC( *userId, |
|
153 iAuthEngine.SizeCounter() ); |
|
154 |
|
155 ParseAttrListL( *authStatus, |
|
156 &CPEngAuthorizationResponse::AddAttributeL ); |
|
157 ParseAuthorizationStatusL( *authStatus ); |
|
158 |
|
159 // store authorization status |
|
160 // removes authStatus from cleanupstack |
|
161 iAuthEngine.AddAuthStatusLX( authStatus ); |
|
162 break; |
|
163 } |
|
164 |
|
165 |
|
166 default: |
|
167 { |
|
168 break; |
|
169 } |
|
170 } |
|
171 |
|
172 CleanupStack::PopAndDestroy( userId ); |
|
173 } |
|
174 |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CPEngAuthorizationTransactionIn::CancelProcessing() |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 void CPEngAuthorizationTransactionIn::CancelProcessing() |
|
181 { |
|
182 } |
|
183 |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CPEngAuthorizationTransactionIn::ParseUserIdL() |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 HBufC* CPEngAuthorizationTransactionIn::ParseUserIdLC() |
|
190 { |
|
191 if ( !iXMLParser.DecodeL( iParseBlock, KUserIDXMLTag, EFalse ) ) |
|
192 { |
|
193 // message is corrupted, ignore it |
|
194 User::Leave( KErrArgument ); |
|
195 return NULL; |
|
196 } |
|
197 |
|
198 HBufC* userId = iXMLParser.ResultAsWVAddressL(); |
|
199 CleanupStack::PushL( userId ); |
|
200 return userId; |
|
201 } |
|
202 |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CPEngAuthorizationTransactionIn::ParseAttrListL() |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 template <class AuthItem> |
|
209 void CPEngAuthorizationTransactionIn::ParseAttrListL( |
|
210 AuthItem& aAuthItem, |
|
211 void ( AuthItem::* aAddFunc )( TUint32 ) ) |
|
212 { |
|
213 // read list of attributes |
|
214 if ( iXMLParser.DecodeL( iParseBlock, KPresenceSubList, ETrue ) ) |
|
215 { |
|
216 // store list of attributes |
|
217 TPtrC8 attributesBlock = iXMLParser.ResultL(); |
|
218 |
|
219 //look for all supported attributes |
|
220 TArray<TUint32> supportedAt = iAttributeManager.KnownAttributeTypes(); |
|
221 TInt count( supportedAt.Count() ); |
|
222 for ( TInt x( 0 ); x < count ; ++x ) |
|
223 { |
|
224 // get attribute's name |
|
225 TPtrC8 nameSpace; |
|
226 TPtrC8 attrName; |
|
227 if ( ( KErrNone == iAttributeManager.GetAttributeXmlNameAndNameSpace( |
|
228 supportedAt[ x ], |
|
229 attrName, |
|
230 nameSpace ) ) |
|
231 && |
|
232 ( iXMLParser.DecodeL( attributesBlock, attrName, EFalse ) ) ) |
|
233 { |
|
234 ( aAuthItem.*aAddFunc )( supportedAt[ x ] ); |
|
235 } |
|
236 } |
|
237 } |
|
238 } |
|
239 |
|
240 |
|
241 // ----------------------------------------------------------------------------- |
|
242 // CPEngAuthorizationTransactionIn::ParseAuthorizationStatusL() |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 void CPEngAuthorizationTransactionIn::ParseAuthorizationStatusL( |
|
246 CPEngAuthorizationResponse& aAuthStatus ) |
|
247 { |
|
248 TBool acceptance( EFalse ); |
|
249 if ( iXMLParser.DecodeL( iParseBlock, |
|
250 KAcceptance, |
|
251 EFalse ) ) |
|
252 { |
|
253 acceptance = ( iXMLParser.ResultL().CompareF( KXMLValueTrue ) == KErrNone ); |
|
254 } |
|
255 |
|
256 if ( acceptance ) |
|
257 { |
|
258 aAuthStatus.SetResponseType( MPEngAuthorizationStatus::EPEngAuthAccepted ); |
|
259 } |
|
260 else |
|
261 { |
|
262 aAuthStatus.SetResponseType( MPEngAuthorizationStatus::EPEngAuthDenied ); |
|
263 } |
|
264 } |
|
265 |
|
266 |
|
267 // End of File |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |