|
1 /* |
|
2 * Copyright (c) 2002-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 // INCLUDE FILES |
|
29 |
|
30 #include <SenServiceConnection.h> // framework IDs |
|
31 #include <SenXmlElement.h> // check if this include is needed(?) |
|
32 #include <SenXmlUtils.h> |
|
33 |
|
34 // #include "SenDebug.h" |
|
35 |
|
36 //#include "MSenIdentityManager.h" |
|
37 #include "SenIdentityProvider.h" |
|
38 |
|
39 // CONSTANTS |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 namespace |
|
45 { |
|
46 _LIT8(KDefaultIdentityAttributeName, "default"); |
|
47 _LIT8(KNewElementName, "IdentityProvider"); |
|
48 _LIT8(KServiceID, "ServiceID"); |
|
49 // _LIT8(KFakeIMEI8, "012345678901234"); |
|
50 } |
|
51 |
|
52 EXPORT_C CSenIdentityProvider::CSenIdentityProvider( |
|
53 TDescriptionClassType aType) |
|
54 : CSenXmlServiceDescription(aType) |
|
55 { |
|
56 } |
|
57 |
|
58 EXPORT_C const TDesC8& CSenIdentityProvider::NewElementName() |
|
59 { |
|
60 return KNewElementName(); |
|
61 } |
|
62 |
|
63 EXPORT_C CSenIdentityProvider* CSenIdentityProvider::NewL( |
|
64 const TDesC8& aEndpoint) |
|
65 { |
|
66 CSenIdentityProvider* pNew = NewLC(aEndpoint); |
|
67 CleanupStack::Pop(); |
|
68 return(pNew); |
|
69 } |
|
70 EXPORT_C CSenIdentityProvider* CSenIdentityProvider::NewLC( |
|
71 const TDesC8& aEndpoint) |
|
72 { |
|
73 CSenIdentityProvider* pNew = |
|
74 new (ELeave) CSenIdentityProvider(EIdentityProvider); |
|
75 |
|
76 CleanupStack::PushL(pNew); |
|
77 pNew->ConstructL(aEndpoint); |
|
78 return pNew; |
|
79 } |
|
80 |
|
81 EXPORT_C CSenIdentityProvider* CSenIdentityProvider::NewL( |
|
82 const TDesC8& aEndpoint, |
|
83 const TDesC8& aContract ) |
|
84 { |
|
85 CSenIdentityProvider* pNew = NewLC(aEndpoint, aContract); |
|
86 CleanupStack::Pop(); |
|
87 return(pNew) ; |
|
88 } |
|
89 |
|
90 EXPORT_C CSenIdentityProvider* CSenIdentityProvider::NewLC( |
|
91 const TDesC8& aEndpoint, |
|
92 const TDesC8& aContract ) |
|
93 { |
|
94 CSenIdentityProvider* pNew = |
|
95 new (ELeave) CSenIdentityProvider(EIdentityProvider); |
|
96 |
|
97 CleanupStack::PushL(pNew); |
|
98 pNew->ConstructL(aEndpoint, aContract); |
|
99 return pNew; |
|
100 } |
|
101 |
|
102 EXPORT_C CSenIdentityProvider* CSenIdentityProvider::NewL( |
|
103 const TDesC8& aEndpoint, |
|
104 const TDesC8& aContract, |
|
105 const TDesC8& aProviderID) |
|
106 { |
|
107 CSenIdentityProvider* pNew = NewLC(aEndpoint, aContract, aProviderID); |
|
108 CleanupStack::Pop(); |
|
109 return(pNew) ; |
|
110 } |
|
111 |
|
112 EXPORT_C CSenIdentityProvider* CSenIdentityProvider::NewLC( |
|
113 const TDesC8& aEndpoint, |
|
114 const TDesC8& aContract, |
|
115 const TDesC8& aProviderID) |
|
116 { |
|
117 CSenIdentityProvider* pNew = |
|
118 new (ELeave) CSenIdentityProvider(EIdentityProvider); |
|
119 |
|
120 CleanupStack::PushL(pNew); |
|
121 pNew->ConstructL(aEndpoint, aContract, aProviderID); |
|
122 return pNew; |
|
123 } |
|
124 |
|
125 EXPORT_C CSenIdentityProvider* CSenIdentityProvider::NewL( |
|
126 const TDesC8& aEndpoint, |
|
127 const TDesC8& aContract, |
|
128 const TDesC8& aProviderID, |
|
129 const TDesC8& aServiceID) |
|
130 { |
|
131 CSenIdentityProvider* pNew = NewLC(aEndpoint, aContract, |
|
132 aProviderID, aServiceID); |
|
133 CleanupStack::Pop(); |
|
134 return(pNew) ; |
|
135 } |
|
136 |
|
137 EXPORT_C CSenIdentityProvider* CSenIdentityProvider::NewLC( |
|
138 const TDesC8& aEndpoint, |
|
139 const TDesC8& aContract, |
|
140 const TDesC8& aProviderID, |
|
141 const TDesC8& aServiceID) |
|
142 { |
|
143 CSenIdentityProvider* pNew = |
|
144 new (ELeave) CSenIdentityProvider(EIdentityProvider); |
|
145 |
|
146 CleanupStack::PushL(pNew); |
|
147 pNew->ConstructL(aEndpoint, aContract, aProviderID, aServiceID); |
|
148 return pNew; |
|
149 } |
|
150 |
|
151 |
|
152 |
|
153 EXPORT_C void CSenIdentityProvider::ConstructL(const TDesC8& aEndpoint) |
|
154 { |
|
155 if(aEndpoint.Length()>0) |
|
156 { |
|
157 CSenXmlServiceDescription::ConstructL(aEndpoint, KSenIdpLibertyIdWsfAsContract); |
|
158 SetFrameworkIdL( KDefaultIdWsfFrameworkID ); |
|
159 } |
|
160 else |
|
161 { |
|
162 CSenXmlServiceDescription::ConstructL(); |
|
163 } |
|
164 } |
|
165 |
|
166 EXPORT_C void CSenIdentityProvider::ConstructL( const TDesC8& aEndpoint, |
|
167 const TDesC8& aContract) |
|
168 { |
|
169 if(aContract.Length()>0) |
|
170 { |
|
171 CSenXmlServiceDescription::ConstructL(aEndpoint, aContract); |
|
172 } |
|
173 else |
|
174 { |
|
175 // Defaults to ID-WSF framework authentication service contract: |
|
176 // - "urn:liberty:as:2004-04". |
|
177 ConstructL(aEndpoint); |
|
178 } |
|
179 } |
|
180 |
|
181 EXPORT_C void CSenIdentityProvider::ConstructL( const TDesC8& aEndpoint, |
|
182 const TDesC8& aContract, |
|
183 const TDesC8& aProviderID) |
|
184 { |
|
185 ConstructL(aEndpoint, aContract); |
|
186 if(aProviderID.Length()>0) |
|
187 { |
|
188 SetProviderID(aProviderID); |
|
189 } |
|
190 // else: no <ProviderID> child element will be added |
|
191 } |
|
192 |
|
193 EXPORT_C void CSenIdentityProvider::ConstructL( const TDesC8& aEndpoint, |
|
194 const TDesC8& aContract, |
|
195 const TDesC8& aProviderID, |
|
196 const TDesC8& aServiceID) |
|
197 { |
|
198 ConstructL(aEndpoint, aContract, aProviderID); |
|
199 if(aServiceID.Length()>0) |
|
200 { |
|
201 SetServiceID(aServiceID); |
|
202 } |
|
203 // else: no <ServiceID> child element will be added |
|
204 } |
|
205 |
|
206 ////////////////////////////////////////////////////////////////////////// |
|
207 |
|
208 |
|
209 EXPORT_C CSenIdentityProvider::~CSenIdentityProvider() |
|
210 { |
|
211 } |
|
212 |
|
213 EXPORT_C TPtrC8 CSenIdentityProvider::UserName() |
|
214 { |
|
215 TPtrC8 username = AuthzID(); |
|
216 if (username.Length()==0) |
|
217 { |
|
218 return AdvisoryAuthnID(); |
|
219 } |
|
220 return username; |
|
221 } |
|
222 |
|
223 EXPORT_C TPtrC8 CSenIdentityProvider::AuthzID() |
|
224 { |
|
225 return ContentOf( KSenIdpAuthzIDLocalname() ); |
|
226 } |
|
227 |
|
228 EXPORT_C TPtrC8 CSenIdentityProvider::AdvisoryAuthnID() |
|
229 { |
|
230 return ContentOf( KSenIdpAdvisoryAuthnIdLocalname() ); |
|
231 } |
|
232 |
|
233 EXPORT_C TPtrC8 CSenIdentityProvider::ProviderID() |
|
234 { |
|
235 return ContentOf( KSenIdpProviderIdLocalname() ); |
|
236 } |
|
237 |
|
238 EXPORT_C TPtrC8 CSenIdentityProvider::Password() |
|
239 { |
|
240 return ContentOf( KSenIdpPasswordLocalname() ); |
|
241 } |
|
242 |
|
243 EXPORT_C const TDesC8& CSenIdentityProvider::IMEI() |
|
244 { |
|
245 return KFakeIMEI8(); |
|
246 } |
|
247 |
|
248 EXPORT_C TBool CSenIdentityProvider::IsDefault() |
|
249 { |
|
250 TBool ret = EFalse; |
|
251 if ( AsElement().AttrValue( KDefaultIdentityAttributeName ) ) |
|
252 { |
|
253 ret = ETrue; |
|
254 } |
|
255 |
|
256 return ret; |
|
257 } |
|
258 //EXPORT_C TInt CSenIdentityProvider::SetUserInfo(const TDesC8& aAuthzID, |
|
259 // const TDesC8& aAdvisoryAuthnID, |
|
260 // const TDesC8& aPassword ) |
|
261 // { |
|
262 // TInt leaveCode(KErrNone); |
|
263 // TRAP(leaveCode, SetUserInfoL(aAuthzID, aAdvisoryAuthnID, aPassword)); |
|
264 // return leaveCode; |
|
265 // } |
|
266 |
|
267 EXPORT_C TInt CSenIdentityProvider::SetUserInfoL(const TDesC8& aAuthzID, |
|
268 const TDesC8& aAdvisoryAuthnID, |
|
269 const TDesC8& aPassword ) |
|
270 { |
|
271 // For MS this function sud be commented as WLM already send xml encoded password |
|
272 //HBufC8* encPassword = SenXmlUtils::EncodeHttpCharactersLC(aPassword); |
|
273 if(aAuthzID.Length()>0) |
|
274 { |
|
275 SetContentOfL(KSenIdpAuthzIDLocalname, aAuthzID); |
|
276 } |
|
277 if(aAdvisoryAuthnID.Length()>0) |
|
278 { |
|
279 SetContentOfL(KSenIdpAdvisoryAuthnIdLocalname, aAdvisoryAuthnID); |
|
280 } |
|
281 //if(aPassword.Length()>0) // in order to clean password, when listing accounts |
|
282 { |
|
283 SetContentOfL(KSenIdpPasswordLocalname, aPassword ); |
|
284 } |
|
285 //CleanupStack::PopAndDestroy(encPassword); |
|
286 return KErrNone; |
|
287 } |
|
288 |
|
289 EXPORT_C TInt CSenIdentityProvider::SetAccountExtensionsL(const TDesC8& aDetail) |
|
290 { |
|
291 SetContentOfL(KSenAccountExtensions, aDetail); |
|
292 //CSenElement* elem = NULL; |
|
293 //AddElementL(elem); |
|
294 return KErrNone; |
|
295 } |
|
296 |
|
297 EXPORT_C TPtrC8 CSenIdentityProvider::AccountExtensions(CSenElement*& aAccExt) |
|
298 { |
|
299 aAccExt = this->AsElement().Element(KSenAccountExtensions()); |
|
300 return ContentOf( KSenAccountExtensions() ); |
|
301 } |
|
302 |
|
303 EXPORT_C TBool CSenIdentityProvider::IsTrustedByL( |
|
304 MSenServiceDescription& aServiceDescription ) |
|
305 { |
|
306 TBool retVal(EFalse); |
|
307 TPtrC8 endpoint = aServiceDescription.Endpoint(); |
|
308 TPtrC8 contract = aServiceDescription.Contract(); |
|
309 |
|
310 TPtrC8 providerID = ProviderID(); |
|
311 if(providerID.Length()>0) |
|
312 { |
|
313 if((endpoint.Length() > 0) && (providerID.Length() > 0) |
|
314 && endpoint == providerID) |
|
315 { |
|
316 retVal = ETrue; |
|
317 } |
|
318 } |
|
319 |
|
320 if(!retVal) // no need to allocate new array etc if we already have a trust |
|
321 { |
|
322 // owned elsewhere: |
|
323 RPointerArray<CSenElement> services = AsElement().ElementsL(); |
|
324 TInt serviceCount = services.Count(); |
|
325 TInt i(0); |
|
326 while (!retVal && i < serviceCount) |
|
327 { |
|
328 if(services[i]->LocalName() == KServiceID) |
|
329 { |
|
330 TPtrC8 serviceID = services[i]->Content(); |
|
331 |
|
332 if(serviceID.Length()>0 && |
|
333 ( (endpoint.Length() > 0 && serviceID == endpoint) |
|
334 || |
|
335 (contract.Length() > 0 && serviceID == contract)) |
|
336 ) |
|
337 { |
|
338 retVal = ETrue; |
|
339 } |
|
340 } |
|
341 i++; |
|
342 } |
|
343 } |
|
344 |
|
345 return retVal; |
|
346 } |
|
347 |
|
348 EXPORT_C TBool CSenIdentityProvider::IsTrustedByL( const TDesC8& aProviderIdOrServiceId ) |
|
349 { |
|
350 //SENDEBUG_L("CSenIdentityProvider::IsTrustedByL"); |
|
351 TBool trusted(EFalse); |
|
352 TPtrC8 providerID = ProviderID(); |
|
353 if(providerID.Length()>0) |
|
354 { |
|
355 if(aProviderIdOrServiceId == providerID) |
|
356 { |
|
357 //SENDEBUG_L(" The ProviderID's are equal."); |
|
358 trusted = ETrue; |
|
359 } |
|
360 } |
|
361 |
|
362 if(!trusted) // no need for new array etc if we already have a trust |
|
363 { |
|
364 RPointerArray<CSenElement> services = AsElement().ElementsL(); |
|
365 TInt serviceCount = services.Count(); |
|
366 TInt i(0); |
|
367 while (!trusted && i < serviceCount) |
|
368 { |
|
369 if (services[i]->LocalName() == KServiceID ) |
|
370 { |
|
371 TPtrC8 serviceID = services[i]->Content(); |
|
372 if (serviceID.Length()>0 && serviceID == aProviderIdOrServiceId) |
|
373 { |
|
374 trusted = ETrue; |
|
375 } |
|
376 } |
|
377 i++; |
|
378 } |
|
379 } |
|
380 return trusted; |
|
381 } |
|
382 |
|
383 EXPORT_C TInt CSenIdentityProvider::SetProviderID( const TDesC8& aProviderID ) |
|
384 { |
|
385 TInt retVal(KErrNone); |
|
386 TInt leaveCode(KErrNone); |
|
387 TRAP( leaveCode, retVal = SetProviderIdL( aProviderID ); ) |
|
388 if ( leaveCode ) |
|
389 { |
|
390 retVal = leaveCode; |
|
391 } |
|
392 return retVal; |
|
393 } |
|
394 |
|
395 EXPORT_C TInt CSenIdentityProvider::SetProviderIdL( const TDesC8& aProviderID ) |
|
396 { |
|
397 if ( aProviderID.Length() == 0 ) |
|
398 { |
|
399 return KErrArgument; // zero-length provider ID |
|
400 } |
|
401 else |
|
402 { |
|
403 SetContentOfL( KSenIdpProviderIdLocalname, aProviderID ); |
|
404 return KErrNone; |
|
405 } |
|
406 } |
|
407 |
|
408 EXPORT_C TInt CSenIdentityProvider::SetServiceID( const TDesC8& aServiceID ) |
|
409 { |
|
410 TInt retVal(KErrNone); |
|
411 if(aServiceID.Length()>0) |
|
412 { |
|
413 TRAP(retVal, SetContentOfL(KServiceID, aServiceID);) |
|
414 } |
|
415 return retVal; |
|
416 } |
|
417 |
|
418 // @deprecated. This method is no longer in use. Kept only to keep BC with 3.0 |
|
419 EXPORT_C HBufC8* CSenIdentityProvider::HttpCredentialsL( MSenIdentityManager& /* aMgr */ ) |
|
420 { |
|
421 return NULL; |
|
422 } |
|
423 |
|
424 // End of File |
|
425 |