|
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 #include "wssecuritypolicy.h" |
|
22 #include "wspolicy.h" |
|
23 #include "wssecuritypolicyconstants.h" |
|
24 |
|
25 using namespace WsSecurityPolicy; |
|
26 |
|
27 CWsSecurityPolicy* CWsSecurityPolicy::NewL() |
|
28 { |
|
29 CWsSecurityPolicy* pSelf = |
|
30 CWsSecurityPolicy::NewLC(); |
|
31 CleanupStack::Pop(pSelf); |
|
32 return pSelf; |
|
33 } |
|
34 CWsSecurityPolicy* CWsSecurityPolicy::NewLC() |
|
35 { |
|
36 CWsSecurityPolicy* pSelf = new (ELeave) CWsSecurityPolicy(); |
|
37 CleanupStack::PushL(pSelf); |
|
38 pSelf->ConstructL(); |
|
39 return pSelf; |
|
40 } |
|
41 void CWsSecurityPolicy::ConstructL() |
|
42 { |
|
43 |
|
44 } |
|
45 CWsSecurityPolicy::~CWsSecurityPolicy() |
|
46 { |
|
47 |
|
48 } |
|
49 CWsSecurityPolicy::CWsSecurityPolicy() |
|
50 { |
|
51 |
|
52 } |
|
53 |
|
54 CSenElement* CWsSecurityPolicy::IntersectL(TDesC8& aKey, CSenElement* aFirst, CSenElement* aSecond) |
|
55 { |
|
56 TBool reply(EFalse); |
|
57 |
|
58 if(aKey.Compare(KAsymmetricBinding) == 0) |
|
59 { |
|
60 CAsymmetricBinding* firstBinding = CAsymmetricBinding::NewL(aFirst); |
|
61 CleanupStack::PushL( firstBinding ); |
|
62 CAsymmetricBinding* secondBinding = CAsymmetricBinding::NewL(aSecond); |
|
63 CleanupStack::PushL( secondBinding ); |
|
64 reply = firstBinding->IsEqualAsymmtericAssertion( secondBinding ); |
|
65 CleanupStack::PopAndDestroy( secondBinding ); // delete secondBinding; |
|
66 CleanupStack::PopAndDestroy( firstBinding ); // delete firstBinding; |
|
67 } |
|
68 else if(aKey.Compare(KSymmetricBinding) == 0) |
|
69 { |
|
70 CSymmetricBinding* firstBinding = CSymmetricBinding::NewL(aFirst); |
|
71 CleanupStack::PushL( firstBinding ); |
|
72 CSymmetricBinding* secondBinding = CSymmetricBinding::NewL(aSecond); |
|
73 CleanupStack::PushL( secondBinding ); |
|
74 reply = firstBinding->IsEqualSymmtericAssertion(secondBinding); |
|
75 CleanupStack::PopAndDestroy( secondBinding ); // delete secondBinding; |
|
76 CleanupStack::PopAndDestroy( firstBinding ); // delete firstBinding; |
|
77 } |
|
78 else if(aKey.Compare(KWss10) == 0) |
|
79 { |
|
80 CWss10* pFirstAssertion = CWss10::NewL(aFirst); |
|
81 CleanupStack::PushL( pFirstAssertion ); |
|
82 CWss10* pSecondAssertion = CWss10::NewL(aSecond); |
|
83 CleanupStack::PushL( pSecondAssertion ); |
|
84 reply = pFirstAssertion->IsEqualWss10Assertion(pSecondAssertion); |
|
85 CleanupStack::PopAndDestroy( pSecondAssertion ); // delete pSecondAssertion; |
|
86 CleanupStack::PopAndDestroy( pFirstAssertion ); // delete pFirstAssertion; |
|
87 } |
|
88 else if(aKey.Compare(KWss11) == 0) |
|
89 { |
|
90 CWss11* pFirstAssertion = CWss11::NewL(aFirst); |
|
91 CleanupStack::PushL( pFirstAssertion ); |
|
92 CWss11* pSecondAssertion = CWss11::NewL(aSecond); |
|
93 CleanupStack::PushL( pSecondAssertion ); |
|
94 reply = pFirstAssertion->IsEqualWss11Assertion(pSecondAssertion); |
|
95 CleanupStack::PopAndDestroy( pSecondAssertion ); // delete pSecondAssertion; |
|
96 CleanupStack::PopAndDestroy( pFirstAssertion ); // delete pFirstAssertion; |
|
97 } |
|
98 else if(aKey.Compare(KTrust10) == 0) |
|
99 { |
|
100 CWsTrust10* pFirstAssertion = CWsTrust10::NewL(aFirst); |
|
101 CleanupStack::PushL( pFirstAssertion ); |
|
102 CWsTrust10* pSecondAssertion = CWsTrust10::NewL(aSecond); |
|
103 CleanupStack::PushL( pSecondAssertion ); |
|
104 reply = pFirstAssertion->IsEqualWsTrust10Assertion(pSecondAssertion); |
|
105 CleanupStack::PopAndDestroy( pSecondAssertion ); // delete pSecondAssertion; |
|
106 CleanupStack::PopAndDestroy( pFirstAssertion ); // delete pFirstAssertion; |
|
107 } |
|
108 else if(aKey.Compare(KSignedParts) == 0 || aKey.Compare(KEncryptedParts) == 0 ) |
|
109 { |
|
110 CEncryptedSignedParts* pFirstAssertion = CEncryptedSignedParts::NewL(aFirst); |
|
111 CleanupStack::PushL( pFirstAssertion ); |
|
112 CEncryptedSignedParts* pSecondAssertion = CEncryptedSignedParts::NewL(aSecond); |
|
113 CleanupStack::PushL( pSecondAssertion ); |
|
114 reply = pFirstAssertion->IsEqualEncryptedSignedParts(pSecondAssertion); |
|
115 CleanupStack::PopAndDestroy( pSecondAssertion ); // delete pSecondAssertion; |
|
116 CleanupStack::PopAndDestroy( pFirstAssertion ); // delete pFirstAssertion; |
|
117 } |
|
118 else if(aKey.Compare(KSignedElements) == 0 || aKey.Compare(KEncryptedElements) == 0 ) |
|
119 { |
|
120 CEncryptedSignedElements* pFirstAssertion = CEncryptedSignedElements::NewL(aFirst); |
|
121 CleanupStack::PushL( pFirstAssertion ); |
|
122 CEncryptedSignedElements* pSecondAssertion = CEncryptedSignedElements::NewL(aSecond); |
|
123 CleanupStack::PushL( pSecondAssertion ); |
|
124 reply = pFirstAssertion->IsEqualEncryptedSignedElements(pSecondAssertion); |
|
125 CleanupStack::PopAndDestroy( pSecondAssertion ); // delete pSecondAssertion; |
|
126 CleanupStack::PopAndDestroy( pFirstAssertion ); // delete pFirstAssertion; |
|
127 } |
|
128 |
|
129 // return the first, if comparison equals |
|
130 if (reply) |
|
131 { |
|
132 return aFirst; |
|
133 } |
|
134 else |
|
135 { |
|
136 return NULL; |
|
137 } |
|
138 } |
|
139 |
|
140 CSenElement* CWsSecurityPolicy::MergeL(TDesC8& aKey, CSenElement* aFirst, CSenElement* aSecond) |
|
141 { |
|
142 TBool reply(EFalse); |
|
143 if(aKey.Compare(KAsymmetricBinding) == 0) |
|
144 { |
|
145 CAsymmetricBinding* firstBinding = CAsymmetricBinding::NewL(aFirst); |
|
146 CleanupStack::PushL( firstBinding ); |
|
147 CAsymmetricBinding* secondBinding = CAsymmetricBinding::NewL(aSecond); |
|
148 CleanupStack::PushL( secondBinding ); |
|
149 reply = firstBinding->IsEqualAsymmtericAssertion(secondBinding); |
|
150 CleanupStack::PopAndDestroy( secondBinding ); // delete secondBinding; |
|
151 CleanupStack::PopAndDestroy( firstBinding ); // delete firstBinding; |
|
152 } |
|
153 else if(aKey.Compare(KSymmetricBinding) == 0) |
|
154 { |
|
155 CSymmetricBinding* firstBinding = CSymmetricBinding::NewL(aFirst); |
|
156 CleanupStack::PushL( firstBinding ); |
|
157 CSymmetricBinding* secondBinding = CSymmetricBinding::NewL(aSecond); |
|
158 CleanupStack::PushL( secondBinding ); |
|
159 reply = firstBinding->IsEqualSymmtericAssertion(secondBinding); |
|
160 CleanupStack::PopAndDestroy( secondBinding ); // delete secondBinding; |
|
161 CleanupStack::PopAndDestroy( firstBinding ); // delete firstBinding; |
|
162 } |
|
163 else if(aKey.Compare(KWss10) == 0) |
|
164 { |
|
165 CWss10* pFirstAssertion = CWss10::NewL(aFirst); |
|
166 CleanupStack::PushL( pFirstAssertion ); |
|
167 CWss10* pSecondAssertion = CWss10::NewL(aSecond); |
|
168 CleanupStack::PushL( pSecondAssertion ); |
|
169 reply = pFirstAssertion->IsEqualWss10Assertion(pFirstAssertion); |
|
170 CleanupStack::PopAndDestroy( pSecondAssertion ); // delete pSecondAssertion; |
|
171 CleanupStack::PopAndDestroy( pFirstAssertion ); // delete pFirstAssertion; |
|
172 } |
|
173 else if(aKey.Compare(KWss11) == 0) |
|
174 { |
|
175 CWss11* pFirstAssertion = CWss11::NewL(aFirst); |
|
176 CleanupStack::PushL( pFirstAssertion ); |
|
177 CWss11* pSecondAssertion = CWss11::NewL(aSecond); |
|
178 CleanupStack::PushL( pSecondAssertion ); |
|
179 reply = pFirstAssertion->IsEqualWss11Assertion(pSecondAssertion); |
|
180 CleanupStack::PopAndDestroy( pSecondAssertion ); // delete pSecondAssertion; |
|
181 CleanupStack::PopAndDestroy( pFirstAssertion ); // delete pFirstAssertion; |
|
182 } |
|
183 else if(aKey.Compare(KTrust10) == 0) |
|
184 { |
|
185 CWsTrust10* pFirstAssertion = CWsTrust10::NewL(aFirst); |
|
186 CleanupStack::PushL( pFirstAssertion ); |
|
187 CWsTrust10* pSecondAssertion = CWsTrust10::NewL(aSecond); |
|
188 CleanupStack::PushL( pSecondAssertion ); |
|
189 reply = pFirstAssertion->IsEqualWsTrust10Assertion(pSecondAssertion); |
|
190 CleanupStack::PopAndDestroy( pSecondAssertion ); // delete pSecondAssertion; |
|
191 CleanupStack::PopAndDestroy( pFirstAssertion ); // delete pFirstAssertion; |
|
192 } |
|
193 else if(aKey.Compare(KSignedParts) == 0 || aKey.Compare(KEncryptedParts) == 0 ) |
|
194 { |
|
195 CEncryptedSignedParts* pFirstAssertion = CEncryptedSignedParts::NewL(aFirst); |
|
196 CleanupStack::PushL( pFirstAssertion ); |
|
197 CEncryptedSignedParts* pSecondAssertion = CEncryptedSignedParts::NewL(aSecond); |
|
198 CleanupStack::PushL( pSecondAssertion ); |
|
199 reply = pFirstAssertion->IsEqualEncryptedSignedParts(pSecondAssertion); |
|
200 CleanupStack::PopAndDestroy( pSecondAssertion ); // delete pSecondAssertion; |
|
201 CleanupStack::PopAndDestroy( pFirstAssertion ); // delete pFirstAssertion; |
|
202 } |
|
203 else if(aKey.Compare(KSignedElements) == 0 || aKey.Compare(KEncryptedElements) == 0 ) |
|
204 { |
|
205 CEncryptedSignedElements* pFirstAssertion = CEncryptedSignedElements::NewL(aFirst); |
|
206 CleanupStack::PushL( pFirstAssertion ); |
|
207 CEncryptedSignedElements* pSecondAssertion = CEncryptedSignedElements::NewL(aSecond); |
|
208 CleanupStack::PushL( pSecondAssertion ); |
|
209 reply = pFirstAssertion->IsEqualEncryptedSignedElements(pSecondAssertion); |
|
210 CleanupStack::PopAndDestroy( pSecondAssertion ); // delete pSecondAssertion; |
|
211 CleanupStack::PopAndDestroy( pFirstAssertion ); // delete pFirstAssertion; |
|
212 |
|
213 // RArray<TPtrC8> result; |
|
214 // TBool signAll = firstAssertion->MergedElements(SecondAssertion, result); |
|
215 // CSenElement* mergedEelement = aFirst.CopyL(); |
|
216 // mergedEelement.RemoveChildren(); |
|
217 // |
|
218 // if(!signAll) |
|
219 // { |
|
220 // |
|
221 // //reply value depends on it |
|
222 // if(//reply && |
|
223 // result.Count() > 0) |
|
224 // { |
|
225 //// TString argument; |
|
226 //// argument.SetL(KXPath); |
|
227 // for(TInt i = 0; i< result.Count(); i++) |
|
228 // {//Copy original element, delete all children and add new children |
|
229 // |
|
230 // TPtrC8 te= result[i]; |
|
231 //// TString content; |
|
232 //// content.SetL(te); |
|
233 // CSenElement* xpath = mergedEelement.AddNewElementSameNsL(KXPath); |
|
234 // xpath.AddTextL(te); |
|
235 //// content.Close(); |
|
236 // } |
|
237 //// argument.Close(); |
|
238 // |
|
239 // } |
|
240 // |
|
241 // } |
|
242 // |
|
243 } |
|
244 if (reply) |
|
245 { |
|
246 return aFirst; |
|
247 } |
|
248 else |
|
249 { |
|
250 return NULL; |
|
251 } |
|
252 } |
|
253 |
|
254 |
|
255 /////////////////////////////////////////////////////////////////// |
|
256 |
|
257 /////////////////////////////////////////////////////////////////// |
|
258 |
|
259 CToken::~CToken() |
|
260 { |
|
261 } |
|
262 |
|
263 CToken::CToken(): |
|
264 iTokenInclusion(KIncludeAlways), |
|
265 iDerivedKeys(EFalse) |
|
266 { |
|
267 } |
|
268 |
|
269 void CToken::ConstructL(CSenElement* aToken) |
|
270 { |
|
271 const TDesC8* attr = aToken->AttrValue(KIncludeToken); |
|
272 if(attr) |
|
273 { |
|
274 HBufC8* attrib = attr->AllocL(); |
|
275 TPtrC8 includeToken = attrib->Des(); |
|
276 if(includeToken.Compare(KIncludeNever) == 0) |
|
277 iTokenInclusion.Set(KIncludeNever); |
|
278 else if(includeToken.Compare(KIncludeOnce) == 0) |
|
279 iTokenInclusion.Set(KIncludeOnce); |
|
280 else if(includeToken.Compare(KIncludeAlwaysToReceipent) == 0) |
|
281 iTokenInclusion.Set(KIncludeAlwaysToReceipent); |
|
282 else if(includeToken.Compare(KIncludeAlways) == 0) |
|
283 iTokenInclusion.Set(KIncludeAlways); |
|
284 delete attrib; |
|
285 } |
|
286 } |
|
287 |
|
288 void CToken::BaseConstructL(CSenElement* aToken) |
|
289 { |
|
290 ConstructL(aToken); |
|
291 } |
|
292 |
|
293 |
|
294 CHttpsToken* CHttpsToken::NewL(CSenElement* aToken) |
|
295 { |
|
296 CHttpsToken* pSelf = CHttpsToken::NewLC(aToken); |
|
297 CleanupStack::Pop(pSelf); |
|
298 return pSelf; |
|
299 } |
|
300 |
|
301 CHttpsToken* CHttpsToken::NewLC(CSenElement* aToken) |
|
302 { |
|
303 CHttpsToken* pSelf = new (ELeave) CHttpsToken(); |
|
304 CleanupStack::PushL(pSelf); |
|
305 pSelf->ConstructL(aToken); |
|
306 return pSelf; |
|
307 } |
|
308 |
|
309 CHttpsToken::~CHttpsToken() |
|
310 { |
|
311 } |
|
312 |
|
313 CHttpsToken::CHttpsToken(): |
|
314 iRequireClientCertificate(ETrue) |
|
315 { |
|
316 |
|
317 } |
|
318 |
|
319 void CHttpsToken::ConstructL(CSenElement* aToken) |
|
320 { |
|
321 const TDesC8* attr = aToken->AttrValue(KRequireClientCertificate); |
|
322 if(attr) |
|
323 { |
|
324 HBufC8* attrib = attr->AllocL(); |
|
325 TPtrC8 requireCertificateToken = attrib->Des(); |
|
326 if(requireCertificateToken.Compare(KTrue) == 0) |
|
327 iRequireClientCertificate = ETrue; |
|
328 else if(requireCertificateToken.Compare(KFalse) == 0) |
|
329 iRequireClientCertificate = EFalse; |
|
330 } |
|
331 RPointerArray<CSenElement>& tokenChildren = aToken->ElementsL(); |
|
332 CSenElement* child = NULL; |
|
333 for (TInt i = 0; i < tokenChildren.Count(); i++) |
|
334 { |
|
335 //There should be only one element here the TokenType |
|
336 child = tokenChildren[i]; |
|
337 TPtrC8 localName = child->LocalName(); |
|
338 if(localName.Compare(WSPolicy::KWsPolicy) == 0) |
|
339 { |
|
340 iPolicy = child; |
|
341 } |
|
342 } |
|
343 } |
|
344 |
|
345 CSamlToken* CSamlToken::NewL(CSenElement* aToken) |
|
346 { |
|
347 CSamlToken* pSelf = CSamlToken::NewLC(aToken); |
|
348 CleanupStack::Pop(pSelf); |
|
349 return pSelf; |
|
350 |
|
351 } |
|
352 CSamlToken* CSamlToken::NewLC(CSenElement* aToken) |
|
353 { |
|
354 CSamlToken* pSelf = new (ELeave) CSamlToken(); |
|
355 CleanupStack::PushL(pSelf); |
|
356 pSelf->ConstructL(aToken); |
|
357 return pSelf; |
|
358 |
|
359 } |
|
360 CSamlToken::~CSamlToken() |
|
361 { |
|
362 |
|
363 } |
|
364 CSamlToken::CSamlToken() |
|
365 { |
|
366 |
|
367 } |
|
368 void CSamlToken::ConstructL(CSenElement* aToken) |
|
369 { |
|
370 BaseConstructL(aToken); |
|
371 |
|
372 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aToken); |
|
373 |
|
374 RPointerArray<CSenElement>& tokenChildren = AND->ElementsL(); |
|
375 |
|
376 CSenElement* child; |
|
377 |
|
378 for (TInt i = 0; i < tokenChildren.Count(); i++) |
|
379 { //There should be only one element here the TokenType |
|
380 child = tokenChildren[i]; |
|
381 |
|
382 TPtrC8 localName = child->LocalName(); |
|
383 |
|
384 if(localName.Compare(KRequireKeyIdentifierReference) == 0) |
|
385 { |
|
386 iRequireKeyIdentifierReference = ETrue; |
|
387 } |
|
388 else if(localName.Compare(KWssSamlV10Token10) == 0) |
|
389 { |
|
390 iSamlTokenProfile.Set(KWssSamlV10Token10); |
|
391 } |
|
392 else if(localName.Compare(KWssSamlV11Token10) == 0) |
|
393 { |
|
394 iSamlTokenProfile.Set(KWssSamlV11Token10); |
|
395 } |
|
396 |
|
397 else if(localName.Compare(KWssSamlV10Token11) == 0) |
|
398 { |
|
399 iSamlTokenProfile.Set(KWssSamlV10Token11); |
|
400 } |
|
401 else if(localName.Compare(KWssSamlV11Token11) == 0) |
|
402 { |
|
403 iSamlTokenProfile.Set(KWssSamlV11Token11); |
|
404 } |
|
405 else if(localName.Compare(KWssSamlV20Token11) == 0) |
|
406 { |
|
407 iSamlTokenProfile.Set(KWssSamlV20Token11); |
|
408 } |
|
409 } |
|
410 |
|
411 } |
|
412 |
|
413 CUsernameToken* CUsernameToken::NewL(CSenElement* aToken) |
|
414 { |
|
415 CUsernameToken* pSelf = CUsernameToken::NewLC(aToken); |
|
416 CleanupStack::Pop(pSelf); |
|
417 return pSelf; |
|
418 } |
|
419 CUsernameToken* CUsernameToken::NewLC(CSenElement* aToken) |
|
420 { |
|
421 CUsernameToken* pSelf = new (ELeave) CUsernameToken(); |
|
422 CleanupStack::PushL(pSelf); |
|
423 pSelf->ConstructL(aToken); |
|
424 return pSelf; |
|
425 } |
|
426 CUsernameToken::~CUsernameToken() |
|
427 { |
|
428 |
|
429 } |
|
430 |
|
431 CUsernameToken::CUsernameToken() |
|
432 :iUsernameTokenProfile(KWssUsernameToken10) |
|
433 { |
|
434 |
|
435 } |
|
436 void CUsernameToken::ConstructL(CSenElement* aToken) |
|
437 { |
|
438 BaseConstructL(aToken); |
|
439 |
|
440 |
|
441 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aToken); |
|
442 |
|
443 |
|
444 RPointerArray<CSenElement>& tokenChildren = AND->ElementsL(); |
|
445 |
|
446 CSenElement* child; |
|
447 |
|
448 for (TInt i = 0; i < tokenChildren.Count(); i++) |
|
449 { //There should be only one element here the TokenType |
|
450 child = tokenChildren[i]; |
|
451 |
|
452 TPtrC8 localName = child->LocalName(); |
|
453 |
|
454 if(localName.Compare(KWssUsernameToken10) == 0) |
|
455 { |
|
456 iUsernameTokenProfile.Set(KWssUsernameToken10); |
|
457 } |
|
458 else if(localName.Compare(KWssUsernameToken11) == 0) |
|
459 { |
|
460 iUsernameTokenProfile.Set(KWssUsernameToken11); |
|
461 } |
|
462 } |
|
463 |
|
464 } |
|
465 |
|
466 |
|
467 CRequestSecurityTokenTemplate* CRequestSecurityTokenTemplate::NewL(CSenElement* aToken) |
|
468 { |
|
469 CRequestSecurityTokenTemplate* pSelf = CRequestSecurityTokenTemplate::NewLC(aToken); |
|
470 CleanupStack::Pop(pSelf); |
|
471 return pSelf; |
|
472 |
|
473 } |
|
474 CRequestSecurityTokenTemplate* CRequestSecurityTokenTemplate::NewLC(CSenElement* aToken) |
|
475 { |
|
476 CRequestSecurityTokenTemplate* pSelf = new (ELeave) CRequestSecurityTokenTemplate(); |
|
477 CleanupStack::PushL(pSelf); |
|
478 pSelf->ConstructL(aToken); |
|
479 return pSelf; |
|
480 |
|
481 } |
|
482 CRequestSecurityTokenTemplate::~CRequestSecurityTokenTemplate() |
|
483 { |
|
484 delete iToken; |
|
485 delete iTrustVersion; |
|
486 } |
|
487 CRequestSecurityTokenTemplate::CRequestSecurityTokenTemplate() |
|
488 :iToken(KNullDesC8().AllocL()), |
|
489 iTrustVersion(KNullDesC8().AllocL()) |
|
490 { |
|
491 |
|
492 } |
|
493 void CRequestSecurityTokenTemplate::ConstructL(CSenElement* aToken) |
|
494 { //parse the token and then save it as HBufC8 |
|
495 |
|
496 const TDesC8* attr = aToken->AttrValue(KTrustVersion); |
|
497 if(attr) |
|
498 { |
|
499 iTrustVersion = attr->AllocL(); |
|
500 } |
|
501 |
|
502 RPointerArray<CSenElement>& tokenChildren = aToken->ElementsL(); |
|
503 |
|
504 CSenElement* child = NULL; |
|
505 RBuf8 buffer; |
|
506 CleanupClosePushL(buffer); |
|
507 RBuf8 request; |
|
508 CleanupClosePushL(request); |
|
509 |
|
510 for (TInt i = 0; i < tokenChildren.Count(); i++) |
|
511 { |
|
512 child = tokenChildren[i]; |
|
513 |
|
514 TPtrC8 localName = child->LocalName(); |
|
515 |
|
516 // child.OuterXmlL(buffer); |
|
517 request.Append(buffer); |
|
518 } |
|
519 |
|
520 iToken = request.AllocL(); |
|
521 |
|
522 CleanupStack::PopAndDestroy(&request); |
|
523 CleanupStack::PopAndDestroy(&buffer); |
|
524 |
|
525 } |
|
526 |
|
527 |
|
528 |
|
529 CIssuedToken* CIssuedToken::NewL(CSenElement* aToken) |
|
530 { |
|
531 CIssuedToken* pSelf = CIssuedToken::NewLC(aToken); |
|
532 CleanupStack::Pop(pSelf); |
|
533 return pSelf; |
|
534 |
|
535 } |
|
536 CIssuedToken* CIssuedToken::NewLC(CSenElement* aToken) |
|
537 { |
|
538 CIssuedToken* pSelf = new (ELeave) CIssuedToken(); |
|
539 CleanupStack::PushL(pSelf); |
|
540 pSelf->ConstructL(aToken); |
|
541 return pSelf; |
|
542 |
|
543 } |
|
544 CIssuedToken::~CIssuedToken() |
|
545 { |
|
546 } |
|
547 |
|
548 CIssuedToken::CIssuedToken() |
|
549 : |
|
550 iIssuer(NULL), |
|
551 iRequireDerivedKeys(EFalse), |
|
552 iRequestSecurityTokenTemplate(NULL), |
|
553 iRequireExternalReference(EFalse), |
|
554 iRequireInternalReference(EFalse) |
|
555 { |
|
556 } |
|
557 void CIssuedToken::ConstructL(CSenElement* aToken) |
|
558 { //can have multiple child elements including poliy and assertions |
|
559 //loop for multiple children |
|
560 |
|
561 BaseConstructL(aToken); |
|
562 |
|
563 RPointerArray<CSenElement>& tokenChildren = aToken->ElementsL(); |
|
564 |
|
565 CSenElement* child; |
|
566 for (TInt i = 0; i < tokenChildren.Count(); i++) |
|
567 { |
|
568 child = tokenChildren[i]; |
|
569 |
|
570 TPtrC8 localName = child->LocalName(); |
|
571 |
|
572 if(localName.Compare(KIssuer) == 0) |
|
573 { //get the issuer element and save it, this is endpoint of STS |
|
574 iIssuer = child; //request.AllocL(); |
|
575 } |
|
576 else if(localName.Compare(KRequestSecurityTokenTemplate) == 0) |
|
577 { |
|
578 //we are just using the origianl element o get all the |
|
579 //information from RequestSecurityTokenTemplate |
|
580 iRequestSecurityTokenTemplate = child; |
|
581 // CRequestSecurityTokenTemplate::NewL(child); |
|
582 } |
|
583 else if(localName.Compare(WSPolicy::KWsPolicy) == 0) |
|
584 { |
|
585 |
|
586 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aToken); |
|
587 |
|
588 |
|
589 RPointerArray<CSenElement>& children = AND->ElementsL(); |
|
590 |
|
591 CSenElement* child2; |
|
592 for (TInt j = 0; j < children.Count(); j++) |
|
593 { |
|
594 child2 = children[j]; |
|
595 |
|
596 TPtrC8 localName = child2->LocalName(); |
|
597 |
|
598 if(localName.Compare(KRequireDerivedKeys) == 0) |
|
599 { |
|
600 iRequireDerivedKeys = ETrue; |
|
601 } |
|
602 if(localName.Compare(KRequireExternalReference) == 0) |
|
603 { |
|
604 iRequireExternalReference = ETrue; |
|
605 } |
|
606 else if(localName.Compare(KRequireInternalReference) == 0) |
|
607 { |
|
608 iRequireInternalReference = ETrue; |
|
609 } |
|
610 |
|
611 } |
|
612 |
|
613 } |
|
614 |
|
615 } |
|
616 |
|
617 } |
|
618 |
|
619 |
|
620 CSecureConversationToken* CSecureConversationToken::NewL(CSenElement* aToken) |
|
621 { |
|
622 CSecureConversationToken* pSelf = CSecureConversationToken::NewLC(aToken); |
|
623 CleanupStack::Pop(pSelf); |
|
624 return pSelf; |
|
625 |
|
626 } |
|
627 CSecureConversationToken* CSecureConversationToken::NewLC(CSenElement* aToken) |
|
628 { |
|
629 CSecureConversationToken* pSelf = new (ELeave) CSecureConversationToken(); |
|
630 CleanupStack::PushL(pSelf); |
|
631 pSelf->ConstructL(aToken); |
|
632 return pSelf; |
|
633 |
|
634 } |
|
635 CSecureConversationToken::~CSecureConversationToken() |
|
636 { |
|
637 delete iIssuer; |
|
638 } |
|
639 |
|
640 TPtrC8 CSecureConversationToken::Issuer() |
|
641 { |
|
642 return iIssuer->Des(); |
|
643 } |
|
644 TBool CSecureConversationToken::RequireExternalUriReference() |
|
645 { |
|
646 return iRequireExternalUriReference; |
|
647 } |
|
648 TBool CSecureConversationToken::SC10SecurityContextToken() |
|
649 { |
|
650 return iSC10SecurityContextToken; |
|
651 } |
|
652 TBool CSecureConversationToken::IsBootstrapPolicy() |
|
653 { |
|
654 return iBootstrap; |
|
655 } |
|
656 CSenElement* CSecureConversationToken::BootstrapPolicy() |
|
657 { |
|
658 return iBootstrapPolicy; |
|
659 } |
|
660 CSecureConversationToken::CSecureConversationToken() |
|
661 : |
|
662 iIssuer(KNullDesC8().AllocL()), |
|
663 iRequireExternalUriReference(EFalse), |
|
664 iSC10SecurityContextToken(EFalse), |
|
665 iRequireDerivedKeys(EFalse), |
|
666 iBootstrap(EFalse) |
|
667 { |
|
668 |
|
669 } |
|
670 void CSecureConversationToken::ConstructL(CSenElement* aToken) |
|
671 { |
|
672 BaseConstructL(aToken); |
|
673 |
|
674 TPtrC8 localName = aToken->LocalName(); |
|
675 |
|
676 RPointerArray<CSenElement>& tokenChildren = aToken->ElementsL(); |
|
677 CSenElement* child; |
|
678 |
|
679 for (TInt j = 0; j < tokenChildren.Count(); j++) |
|
680 { |
|
681 child = tokenChildren[j]; |
|
682 |
|
683 TPtrC8 childName = child->LocalName(); |
|
684 |
|
685 if(childName.Compare(KIssuer) == 0) |
|
686 { //get the issuer element and save it, this is endpoint of STS |
|
687 RBuf8 buffer; |
|
688 CleanupClosePushL(buffer); |
|
689 // child.OuterXmlL(buffer); |
|
690 iIssuer = buffer.AllocL(); |
|
691 CleanupStack::PopAndDestroy(&buffer); |
|
692 } |
|
693 else if(childName.Compare(WSPolicy::KWsPolicy) == 0) |
|
694 { |
|
695 |
|
696 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aToken); |
|
697 |
|
698 |
|
699 RPointerArray<CSenElement>& ANDChildren = AND->ElementsL(); |
|
700 TPtrC8 policyChildName = child->LocalName(); |
|
701 |
|
702 CSenElement* child2; |
|
703 |
|
704 for (TInt i = 0; i < ANDChildren.Count(); i++) |
|
705 { |
|
706 child2 = ANDChildren[i]; |
|
707 |
|
708 TPtrC8 localName = child2->LocalName(); |
|
709 |
|
710 if(localName.Compare(KRequireDerivedKeys) == 0) |
|
711 { |
|
712 iRequireDerivedKeys = ETrue; |
|
713 } |
|
714 else if(localName.Compare(KRequireExternalUriReference) == 0) |
|
715 { |
|
716 iRequireExternalUriReference = ETrue; |
|
717 } |
|
718 else if(localName.Compare(KSC10SecurityContextToken) == 0) |
|
719 { |
|
720 iSC10SecurityContextToken = ETrue; |
|
721 } |
|
722 else if(localName.Compare(KBootstrapPolicy) == 0) |
|
723 { |
|
724 iBootstrap = ETrue; |
|
725 iBootstrapPolicy = child2; |
|
726 } |
|
727 |
|
728 } |
|
729 } |
|
730 |
|
731 } |
|
732 } |
|
733 |
|
734 |
|
735 //TOKEN HOLDERS |
|
736 //////////////////////////////////////////////////////// |
|
737 |
|
738 CTokenHolder* CTokenHolder::NewL(CSenElement* aToken) |
|
739 { |
|
740 CTokenHolder* pSelf = CTokenHolder::NewLC(aToken); |
|
741 CleanupStack::Pop(pSelf); |
|
742 return pSelf; |
|
743 } |
|
744 CTokenHolder* CTokenHolder::NewLC(CSenElement* aToken) |
|
745 { |
|
746 CTokenHolder* pSelf = new (ELeave) CTokenHolder(); |
|
747 CleanupStack::PushL(pSelf); |
|
748 pSelf->ConstructL(aToken); |
|
749 return pSelf; |
|
750 } |
|
751 CTokenHolder::~CTokenHolder() |
|
752 { |
|
753 if(iToken) |
|
754 delete iToken; |
|
755 } |
|
756 |
|
757 //check here what kind of token the element have and then |
|
758 //instantiate that TokenType |
|
759 CTokenHolder::CTokenHolder() |
|
760 :iToken(NULL) |
|
761 { |
|
762 |
|
763 } |
|
764 void CTokenHolder::ConstructL(CSenElement* aToken) |
|
765 { |
|
766 |
|
767 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aToken); |
|
768 |
|
769 |
|
770 RPointerArray<CSenElement>& tokenChildren = AND->ElementsL(); |
|
771 |
|
772 CSenElement* child; |
|
773 for (TInt i = 0; i < tokenChildren.Count(); i++) |
|
774 { //There should be only one element here the TokenType |
|
775 child = tokenChildren[i]; |
|
776 |
|
777 TPtrC8 localName = child->LocalName(); |
|
778 |
|
779 if(localName.Compare(KUsernameToken) == 0) |
|
780 { |
|
781 iTokenType.Set(KUsernameToken); |
|
782 iToken = CUsernameToken::NewL(child); |
|
783 } |
|
784 else if(localName.Compare(KIssuedToken) == 0) |
|
785 { |
|
786 iTokenType.Set(KIssuedToken); |
|
787 iToken = CIssuedToken::NewL(child); |
|
788 } |
|
789 else if(localName.Compare(KSecureConversationToken) == 0) |
|
790 { |
|
791 iTokenType.Set(KSecureConversationToken); |
|
792 iToken = CSecureConversationToken::NewL(child); |
|
793 } |
|
794 else if(localName.Compare(KSamlToken) == 0) |
|
795 { |
|
796 iTokenType.Set(KSamlToken); |
|
797 iToken = CSamlToken::NewL(child); |
|
798 } |
|
799 else if(localName.Compare(KHttpsToken) == 0) |
|
800 { |
|
801 iTokenType.Set(KHttpsToken); |
|
802 iToken = CHttpsToken::NewL(child); |
|
803 } |
|
804 else |
|
805 { |
|
806 //errror here |
|
807 } |
|
808 |
|
809 } |
|
810 } |
|
811 |
|
812 CWss10* CWss10::NewL(CSenElement* aAssertion) |
|
813 { |
|
814 CWss10* pSelf = CWss10::NewLC(aAssertion); |
|
815 CleanupStack::Pop(pSelf); |
|
816 return pSelf; |
|
817 |
|
818 } |
|
819 CWss10* CWss10::NewLC(CSenElement* aAssertion) |
|
820 { |
|
821 CWss10* pSelf = new (ELeave) CWss10(); |
|
822 CleanupStack::PushL(pSelf); |
|
823 pSelf->ConstructL(aAssertion); |
|
824 return pSelf; |
|
825 } |
|
826 CWss10::~CWss10() |
|
827 { |
|
828 |
|
829 } |
|
830 void CWss10::ConstructL(CSenElement* aAssertion) |
|
831 { |
|
832 |
|
833 BaseConstructL(aAssertion); |
|
834 } |
|
835 |
|
836 CWss10::CWss10() |
|
837 :iMustSupportRefKeyIdentifier(EFalse), |
|
838 iMustSupportRefIssuerSerial(EFalse), |
|
839 iMustSupportRefExternalURI(EFalse), |
|
840 iMustSupportRefEmbeddedToken(EFalse) |
|
841 { |
|
842 |
|
843 } |
|
844 |
|
845 TBool CWss10::IsEqualWss10Assertion(CWss10* aAssertion) |
|
846 { |
|
847 if |
|
848 ( |
|
849 (MustSupportRefKeyIdentifier() == aAssertion->MustSupportRefKeyIdentifier()) && |
|
850 (MustSupportRefIssuerSerial() == aAssertion->MustSupportRefIssuerSerial()) && |
|
851 (MustSupportRefExternalURI() == aAssertion->MustSupportRefExternalURI()) && |
|
852 (MustSupportRefEmbeddedToken() == aAssertion->MustSupportRefEmbeddedToken()) |
|
853 ) |
|
854 return ETrue; |
|
855 else |
|
856 return EFalse; |
|
857 |
|
858 } |
|
859 |
|
860 TBool CWss10::MustSupportRefKeyIdentifier() |
|
861 { |
|
862 return iMustSupportRefKeyIdentifier; |
|
863 } |
|
864 TBool CWss10::MustSupportRefIssuerSerial() |
|
865 { |
|
866 return iMustSupportRefIssuerSerial; |
|
867 } |
|
868 TBool CWss10::MustSupportRefExternalURI() |
|
869 { |
|
870 return iMustSupportRefExternalURI; |
|
871 } |
|
872 TBool CWss10::MustSupportRefEmbeddedToken() |
|
873 { |
|
874 return iMustSupportRefEmbeddedToken; |
|
875 } |
|
876 |
|
877 void CWss10::BaseConstructL(CSenElement* aAssertion) |
|
878 { |
|
879 |
|
880 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aAssertion); |
|
881 |
|
882 |
|
883 RPointerArray<CSenElement>& wss10Children = AND->ElementsL(); |
|
884 CSenElement* child = NULL; |
|
885 |
|
886 for (TInt i = 0; i<wss10Children.Count(); i++) |
|
887 { |
|
888 child = wss10Children[i]; |
|
889 |
|
890 TPtrC8 localName = child->LocalName(); |
|
891 |
|
892 if(localName.Compare(KMustSupportRefKeyIdentifier) == 0) |
|
893 { |
|
894 iMustSupportRefKeyIdentifier = ETrue; |
|
895 } |
|
896 else if(localName.Compare(KMustSupportRefIssuerSerial) == 0) |
|
897 { |
|
898 iMustSupportRefIssuerSerial = ETrue; |
|
899 } |
|
900 else if(localName.Compare(KMustSupportRefExternalURI) == 0) |
|
901 { |
|
902 iMustSupportRefExternalURI = ETrue; |
|
903 } |
|
904 else if(localName.Compare(KMustSupportRefEmbeddedToken) == 0) |
|
905 { |
|
906 iMustSupportRefEmbeddedToken = ETrue; |
|
907 } |
|
908 else |
|
909 { |
|
910 //do something |
|
911 } |
|
912 } |
|
913 } |
|
914 |
|
915 |
|
916 CWss11* CWss11::NewL(CSenElement* aAssertion) |
|
917 { |
|
918 CWss11* pSelf = CWss11::NewLC(aAssertion); |
|
919 CleanupStack::Pop(pSelf); |
|
920 return pSelf; |
|
921 |
|
922 } |
|
923 CWss11* CWss11::NewLC(CSenElement* aAssertion) |
|
924 { |
|
925 CWss11* pSelf = new (ELeave) CWss11(); |
|
926 CleanupStack::PushL(pSelf); |
|
927 pSelf->ConstructL(aAssertion); |
|
928 return pSelf; |
|
929 |
|
930 } |
|
931 CWss11::~CWss11() |
|
932 { |
|
933 |
|
934 } |
|
935 |
|
936 TBool CWss11::IsEqualWss11Assertion(CWss11* aAssertion) |
|
937 { |
|
938 if |
|
939 ((MustSupportRefThumbprint() == aAssertion->MustSupportRefThumbprint()) && |
|
940 (MustSupportRefEncryptedKey() == aAssertion->MustSupportRefEncryptedKey()) && |
|
941 (RequireSignatureConfirmation() == aAssertion->RequireSignatureConfirmation()) && |
|
942 (MustSupportRefKeyIdentifier() == aAssertion->MustSupportRefKeyIdentifier()) && |
|
943 (MustSupportRefIssuerSerial() == aAssertion->MustSupportRefIssuerSerial()) && |
|
944 (MustSupportRefExternalURI() == aAssertion->MustSupportRefExternalURI()) && |
|
945 (MustSupportRefEmbeddedToken() == aAssertion->MustSupportRefEmbeddedToken()) |
|
946 |
|
947 ) |
|
948 return ETrue; |
|
949 else |
|
950 return EFalse; |
|
951 |
|
952 } |
|
953 |
|
954 TBool CWss11::MustSupportRefThumbprint() |
|
955 { |
|
956 return iMustSupportRefThumbprint; |
|
957 } |
|
958 TBool CWss11::MustSupportRefEncryptedKey() |
|
959 { |
|
960 return iMustSupportRefEncryptedKey; |
|
961 } |
|
962 TBool CWss11::RequireSignatureConfirmation() |
|
963 { |
|
964 return iRequireSignatureConfirmation; |
|
965 } |
|
966 void CWss11::ConstructL(CSenElement* aAssertion) |
|
967 { |
|
968 BaseConstructL(aAssertion); |
|
969 |
|
970 |
|
971 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aAssertion); |
|
972 |
|
973 |
|
974 RPointerArray<CSenElement>& wss11Children = AND->ElementsL(); |
|
975 CSenElement* child; |
|
976 TInt count = wss11Children.Count(); |
|
977 |
|
978 for (TInt i = 0; i<count; i++) |
|
979 { |
|
980 child = wss11Children[i]; |
|
981 |
|
982 TPtrC8 localName = child->LocalName(); |
|
983 |
|
984 if(localName.Compare(KMustSupportRefThumbprint) == 0) |
|
985 { |
|
986 iMustSupportRefThumbprint = ETrue; |
|
987 } |
|
988 else if(localName.Compare(KMustSupportRefEncryptedKey) == 0) |
|
989 { |
|
990 iMustSupportRefEncryptedKey = ETrue; |
|
991 } |
|
992 else if(localName.Compare(KRequireSignatureConfirmation) == 0) |
|
993 { |
|
994 iRequireSignatureConfirmation = ETrue; |
|
995 } |
|
996 else |
|
997 { |
|
998 //do something |
|
999 } |
|
1000 } |
|
1001 } |
|
1002 CWss11::CWss11() |
|
1003 :iMustSupportRefThumbprint(EFalse), |
|
1004 iMustSupportRefEncryptedKey(EFalse), |
|
1005 iRequireSignatureConfirmation(EFalse) |
|
1006 { |
|
1007 |
|
1008 } |
|
1009 |
|
1010 |
|
1011 |
|
1012 CWsTrust10* CWsTrust10::NewL(CSenElement* aAssertion) |
|
1013 { |
|
1014 CWsTrust10* pSelf = CWsTrust10::NewLC(aAssertion); |
|
1015 CleanupStack::Pop(pSelf); |
|
1016 return pSelf; |
|
1017 |
|
1018 } |
|
1019 CWsTrust10* CWsTrust10::NewLC(CSenElement* aAssertion) |
|
1020 { |
|
1021 CWsTrust10* pSelf = new (ELeave) CWsTrust10(); |
|
1022 CleanupStack::PushL(pSelf); |
|
1023 pSelf->ConstructL(aAssertion); |
|
1024 return pSelf; |
|
1025 } |
|
1026 CWsTrust10::~CWsTrust10() |
|
1027 { |
|
1028 |
|
1029 } |
|
1030 |
|
1031 TBool CWsTrust10::IsEqualWsTrust10Assertion(CWsTrust10* aAssertion) |
|
1032 { |
|
1033 if ( |
|
1034 (MustSupportClientChallenge() == aAssertion->MustSupportClientChallenge()) && |
|
1035 (MustSupportServerChallenge() == aAssertion->MustSupportServerChallenge()) && |
|
1036 (RequireClientEntropy() == aAssertion->RequireClientEntropy()) && |
|
1037 (RequireServerEntropy() == aAssertion->RequireServerEntropy()) && |
|
1038 (MustSupportIssuedTokens() == aAssertion->MustSupportIssuedTokens()) |
|
1039 ) |
|
1040 return ETrue; |
|
1041 else |
|
1042 return EFalse; |
|
1043 } |
|
1044 /* |
|
1045 _LIT8(KTrust10, "Trust10"); |
|
1046 */ |
|
1047 TBool CWsTrust10::MustSupportClientChallenge() |
|
1048 { |
|
1049 return iMustSupportClientChallenge; |
|
1050 } |
|
1051 TBool CWsTrust10::MustSupportServerChallenge() |
|
1052 { |
|
1053 return iMustSupportServerChallenge; |
|
1054 } |
|
1055 TBool CWsTrust10::RequireClientEntropy() |
|
1056 { |
|
1057 return iRequireClientEntropy; |
|
1058 } |
|
1059 TBool CWsTrust10::RequireServerEntropy() |
|
1060 { |
|
1061 return iRequireServerEntropy; |
|
1062 } |
|
1063 TBool CWsTrust10::MustSupportIssuedTokens() |
|
1064 { |
|
1065 return iMustSupportIssuedTokens; |
|
1066 } |
|
1067 |
|
1068 |
|
1069 |
|
1070 void CWsTrust10::ConstructL(CSenElement* aAssertion) |
|
1071 { |
|
1072 |
|
1073 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aAssertion); |
|
1074 |
|
1075 |
|
1076 RPointerArray<CSenElement>& wsTrustChildren = AND->ElementsL(); |
|
1077 |
|
1078 CSenElement* child; |
|
1079 TInt count = wsTrustChildren.Count(); |
|
1080 |
|
1081 for (TInt i = 0; i<count; i++) |
|
1082 { |
|
1083 child = wsTrustChildren[i]; |
|
1084 |
|
1085 TPtrC8 localName = child->LocalName(); |
|
1086 |
|
1087 if(localName.Compare(KMustSupportClientChallenge) == 0) |
|
1088 { |
|
1089 iMustSupportClientChallenge = ETrue; |
|
1090 } |
|
1091 else if(localName.Compare(KMustSupportServerChallenge) == 0) |
|
1092 { |
|
1093 iMustSupportServerChallenge = ETrue; |
|
1094 } |
|
1095 else if(localName.Compare(KRequireClientEntropy) == 0) |
|
1096 { |
|
1097 iRequireClientEntropy = ETrue; |
|
1098 } |
|
1099 else if(localName.Compare(KRequireServerEntropy) == 0) |
|
1100 { |
|
1101 iRequireServerEntropy = ETrue; |
|
1102 } |
|
1103 else if(localName.Compare(KMustSupportIssuedTokens) == 0) |
|
1104 { |
|
1105 iMustSupportIssuedTokens = ETrue; |
|
1106 } |
|
1107 else |
|
1108 { |
|
1109 //errror here |
|
1110 } |
|
1111 } |
|
1112 } |
|
1113 CWsTrust10::CWsTrust10() |
|
1114 :iMustSupportClientChallenge(EFalse), |
|
1115 iMustSupportServerChallenge(EFalse), |
|
1116 iRequireClientEntropy(EFalse), |
|
1117 iRequireServerEntropy(EFalse), |
|
1118 iMustSupportIssuedTokens(EFalse) |
|
1119 { |
|
1120 |
|
1121 } |
|
1122 |
|
1123 |
|
1124 /////////////////////////////////////////////////////////////////// |
|
1125 |
|
1126 /////////////////////////////////////////////////////////////////// |
|
1127 /* |
|
1128 CXmlHelper::CXmlHelper() |
|
1129 { |
|
1130 } |
|
1131 |
|
1132 CXmlHelper::~CXmlHelper() |
|
1133 { |
|
1134 } |
|
1135 */ |
|
1136 |
|
1137 TPtrC8 CXmlHelper::AttributeValueL(CSenElement* aAssertion, const TDesC8& aAttribName) |
|
1138 { |
|
1139 if(aAssertion == NULL) { User::Leave(KErrArgument); } |
|
1140 |
|
1141 RPointerArray<CSenBaseAttribute>& attrs = aAssertion->AttributesL(); |
|
1142 |
|
1143 CSenBaseAttribute* bs = NULL; |
|
1144 TInt ele_count = attrs.Count(); |
|
1145 |
|
1146 for (TInt j=0; j < ele_count; j++) |
|
1147 { |
|
1148 |
|
1149 bs = (attrs)[j]; |
|
1150 if(bs) |
|
1151 { |
|
1152 if(bs->Name().Compare(aAttribName) == 0) |
|
1153 { |
|
1154 return bs->Value(); |
|
1155 } |
|
1156 } |
|
1157 |
|
1158 |
|
1159 } |
|
1160 return KNullDesC8(); |
|
1161 |
|
1162 } |
|
1163 TBool CXmlHelper::HasAttributeL(CSenElement* aAssertion, const TDesC8& aAttribName) |
|
1164 { |
|
1165 if(aAssertion == NULL) { User::Leave(KErrArgument); } |
|
1166 |
|
1167 RPointerArray<CSenBaseAttribute>& attrs = aAssertion->AttributesL(); |
|
1168 |
|
1169 CSenBaseAttribute* bs = NULL; |
|
1170 TInt ele_count = attrs.Count(); |
|
1171 |
|
1172 for (TInt j=0; j < ele_count; j++) |
|
1173 { |
|
1174 |
|
1175 bs = (attrs)[j]; |
|
1176 if(bs) |
|
1177 { |
|
1178 if(bs->Name().Compare(aAttribName) == 0) |
|
1179 { |
|
1180 return ETrue; |
|
1181 } |
|
1182 } |
|
1183 |
|
1184 |
|
1185 } |
|
1186 return EFalse; |
|
1187 |
|
1188 } |
|
1189 CSenElement* CXmlHelper::RipPolicyXORElementL(CSenElement* aElement) |
|
1190 { |
|
1191 |
|
1192 RPointerArray<CSenElement>& pPolicyList = aElement->ElementsL(); |
|
1193 |
|
1194 CSenElement* XOR = NULL; |
|
1195 CSenElement* AND = NULL; |
|
1196 if(pPolicyList.Count() > 0) |
|
1197 { |
|
1198 CSenElement* policy = pPolicyList[0]; |
|
1199 TPtrC8 policyName = policy->LocalName(); |
|
1200 |
|
1201 RPointerArray<CSenElement>& policyXORChild = policy->ElementsL(); //find the policy/XOR element |
|
1202 |
|
1203 if(policyXORChild.Count() > 0) |
|
1204 { |
|
1205 XOR = policyXORChild[0]; |
|
1206 |
|
1207 TPtrC8 xorName = XOR->LocalName(); |
|
1208 |
|
1209 RPointerArray<CSenElement>& policyANDChild = XOR->ElementsL(); //find the policy/XOR/AND element |
|
1210 |
|
1211 if(policyANDChild.Count() > 0) |
|
1212 { |
|
1213 AND = policyANDChild[0]; |
|
1214 TPtrC8 andName = AND->LocalName(); |
|
1215 return AND; |
|
1216 |
|
1217 } |
|
1218 } |
|
1219 |
|
1220 } |
|
1221 |
|
1222 return NULL; |
|
1223 } |
|
1224 |
|
1225 |
|
1226 /////////////////////////////////////////////////////////////////// |
|
1227 // CLayout |
|
1228 /////////////////////////////////////////////////////////////////// |
|
1229 |
|
1230 CLayout* CLayout::NewL(CSenElement* aLayout) |
|
1231 { |
|
1232 CLayout* pSelf = CLayout::NewLC(aLayout); |
|
1233 CleanupStack::Pop(pSelf); |
|
1234 return pSelf; |
|
1235 } |
|
1236 CLayout* CLayout::NewLC(CSenElement* aLayout) |
|
1237 { |
|
1238 CLayout* pSelf = new (ELeave) CLayout(); |
|
1239 CleanupStack::PushL(pSelf); |
|
1240 pSelf->ConstructL(aLayout); |
|
1241 return pSelf; |
|
1242 } |
|
1243 CLayout::~CLayout() |
|
1244 { |
|
1245 |
|
1246 } |
|
1247 void CLayout::ConstructL(CSenElement* aLayout) |
|
1248 { |
|
1249 |
|
1250 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aLayout); |
|
1251 |
|
1252 |
|
1253 RPointerArray<CSenElement>& layoutChildren = AND->ElementsL(); |
|
1254 CleanupClosePushL(layoutChildren); |
|
1255 CSenElement* child; |
|
1256 TInt count = layoutChildren.Count(); |
|
1257 for (TInt i = 0; i<count; i++) |
|
1258 { |
|
1259 child = layoutChildren[i]; |
|
1260 |
|
1261 TPtrC8 localName = child->LocalName(); |
|
1262 |
|
1263 if(localName.Compare(KStrict) == 0) |
|
1264 { |
|
1265 iLayout.Set(KStrict); |
|
1266 } |
|
1267 else if(localName.Compare(KLax) == 0) |
|
1268 { |
|
1269 iLayout.Set(KLax); |
|
1270 } |
|
1271 else if(localName.Compare(KLaxTsFirst) == 0) |
|
1272 { |
|
1273 iLayout.Set(KLaxTsFirst); |
|
1274 } |
|
1275 else if(localName.Compare(KLaxTsLast) == 0) |
|
1276 { |
|
1277 iLayout.Set(KLaxTsLast); |
|
1278 } |
|
1279 else |
|
1280 { |
|
1281 //errror here |
|
1282 } |
|
1283 } |
|
1284 CleanupStack::PopAndDestroy(&layoutChildren); |
|
1285 } |
|
1286 |
|
1287 CLayout::CLayout() |
|
1288 :iLayout(KLax) |
|
1289 { |
|
1290 |
|
1291 } |
|
1292 |
|
1293 TBool CLayout::IsEqualLayout(CLayout* aLayout) |
|
1294 { |
|
1295 if (iLayout.Compare(aLayout->Layout()) == 0) |
|
1296 return ETrue; |
|
1297 else |
|
1298 return EFalse; |
|
1299 } |
|
1300 /////////////////////////////////////////////////////////////////// |
|
1301 //BINDING, SYMASYMMBINDING, ASYMMETRICBINDING, SYMMETRICBINDING |
|
1302 /////////////////////////////////////////////////////////////////// |
|
1303 |
|
1304 CBinding* CBinding::NewL(CSenElement* aBinding) |
|
1305 { |
|
1306 CBinding* pSelf = CBinding::NewLC(aBinding); |
|
1307 CleanupStack::Pop(pSelf); |
|
1308 return pSelf; |
|
1309 } |
|
1310 CBinding* CBinding::NewLC(CSenElement* aBinding) |
|
1311 { |
|
1312 CBinding* pSelf = new (ELeave) CBinding(); |
|
1313 CleanupStack::PushL(pSelf); |
|
1314 pSelf->ConstructL(aBinding); |
|
1315 return pSelf; |
|
1316 } |
|
1317 CBinding::~CBinding() |
|
1318 { |
|
1319 delete iAlgorithmSuite; |
|
1320 delete iLayout; |
|
1321 } |
|
1322 |
|
1323 void CBinding::SetbaseElementL(CSenElement* aBinding) |
|
1324 { |
|
1325 RPointerArray<CSenElement>& symmBindingChildren = aBinding->ElementsL(); |
|
1326 TInt count = symmBindingChildren.Count(); |
|
1327 CSenElement* child = NULL; |
|
1328 for (TInt i = 0; i<count; i++) |
|
1329 { |
|
1330 child = symmBindingChildren[i]; |
|
1331 |
|
1332 TPtrC8 localName = child->LocalName(); |
|
1333 |
|
1334 if(localName.Compare(KAlgorithmSuite) == 0) |
|
1335 { |
|
1336 iAlgorithmSuite = CAlgorithmSuite::NewL(child); |
|
1337 } |
|
1338 else if(localName.Compare(KLayout) == 0) |
|
1339 { |
|
1340 iLayout = CLayout::NewL(child); |
|
1341 } |
|
1342 else if(localName.Compare(KIncludeTimestamp) == 0) |
|
1343 { |
|
1344 iIncludeTimestamp = ETrue; |
|
1345 } |
|
1346 else |
|
1347 { |
|
1348 //do something |
|
1349 } |
|
1350 } |
|
1351 } |
|
1352 |
|
1353 CBinding::CBinding(): |
|
1354 iAlgorithmSuite(NULL), |
|
1355 iLayout(NULL), |
|
1356 iIncludeTimestamp(EFalse) |
|
1357 { |
|
1358 |
|
1359 } |
|
1360 void CBinding::ConstructL(CSenElement* /*aBinding*/) |
|
1361 { |
|
1362 |
|
1363 } |
|
1364 ///////////////////////////////////////////////////////////// |
|
1365 CSymmAsymmBinding* CSymmAsymmBinding::NewL(CSenElement* aBinding) |
|
1366 { |
|
1367 CSymmAsymmBinding* pSelf = CSymmAsymmBinding::NewLC(aBinding); |
|
1368 CleanupStack::Pop(pSelf); |
|
1369 return pSelf; |
|
1370 |
|
1371 } |
|
1372 CSymmAsymmBinding* CSymmAsymmBinding::NewLC(CSenElement* aBinding) |
|
1373 { |
|
1374 CSymmAsymmBinding* pSelf = new (ELeave) CSymmAsymmBinding(); |
|
1375 CleanupStack::PushL(pSelf); |
|
1376 pSelf->ConstructL(aBinding); |
|
1377 return pSelf; |
|
1378 |
|
1379 } |
|
1380 |
|
1381 CSymmAsymmBinding::~CSymmAsymmBinding() |
|
1382 { |
|
1383 |
|
1384 } |
|
1385 void CSymmAsymmBinding::BaseConstructL(CSenElement* aBinding) |
|
1386 { |
|
1387 |
|
1388 SetbaseElementL(aBinding); |
|
1389 |
|
1390 RPointerArray<CSenElement>& symmBindingChildren = aBinding->ElementsL(); |
|
1391 |
|
1392 CSenElement* child = NULL; |
|
1393 |
|
1394 for (TInt i = 0; i < symmBindingChildren.Count(); i++) |
|
1395 { |
|
1396 child = symmBindingChildren[i]; |
|
1397 |
|
1398 TPtrC8 localName = child->LocalName(); |
|
1399 |
|
1400 if(localName.Compare(KEncryptBeforeSigning) == 0) |
|
1401 { |
|
1402 iProtectionOrder.Set(KEncryptBeforeSigning); |
|
1403 } |
|
1404 else if(localName.Compare(KSignBeforeEncrypting) == 0 ) |
|
1405 { |
|
1406 iProtectionOrder.Set(KSignBeforeEncrypting); |
|
1407 } |
|
1408 else if(localName.Compare(KEncryptSignature) == 0) |
|
1409 { |
|
1410 iEncryptSignature = ETrue; |
|
1411 } |
|
1412 else if(localName.Compare(KProtectTokens) == 0) |
|
1413 { |
|
1414 iProtectTokens = ETrue; |
|
1415 } |
|
1416 else if (localName.Compare(KOnlySignEntireHeadersAndBody) == 0) |
|
1417 { |
|
1418 iOnlySignEntireHeadersAndBody = ETrue; |
|
1419 } |
|
1420 else |
|
1421 { |
|
1422 //do something |
|
1423 } |
|
1424 } |
|
1425 |
|
1426 } |
|
1427 |
|
1428 CSymmAsymmBinding::CSymmAsymmBinding() |
|
1429 : |
|
1430 iProtectionOrder(KSignBeforeEncrypting), |
|
1431 iEncryptSignature(EFalse), |
|
1432 iProtectTokens(EFalse), |
|
1433 iOnlySignEntireHeadersAndBody(EFalse) |
|
1434 |
|
1435 { |
|
1436 |
|
1437 } |
|
1438 void CSymmAsymmBinding::ConstructL(CSenElement* /*aBinding*/) |
|
1439 { |
|
1440 |
|
1441 } |
|
1442 /////////////////////////////////////////////////////////// |
|
1443 //CAsymmetricBinding |
|
1444 /////////////////////////////////////////////////////////// |
|
1445 CAsymmetricBinding* CAsymmetricBinding::NewL(CSenElement* aAsymmBinding) |
|
1446 { |
|
1447 CAsymmetricBinding* pSelf = CAsymmetricBinding::NewLC(aAsymmBinding); |
|
1448 CleanupStack::Pop(pSelf); |
|
1449 return pSelf; |
|
1450 } |
|
1451 CAsymmetricBinding* CAsymmetricBinding::NewLC(CSenElement* aAsymmBinding) |
|
1452 { |
|
1453 CAsymmetricBinding* pSelf = new (ELeave) CAsymmetricBinding(); |
|
1454 CleanupStack::PushL(pSelf); |
|
1455 pSelf->ConstructL(aAsymmBinding); |
|
1456 return pSelf; |
|
1457 } |
|
1458 CAsymmetricBinding::~CAsymmetricBinding() |
|
1459 { |
|
1460 delete iInitiatorToken; |
|
1461 delete iRecipientToken; |
|
1462 } |
|
1463 void CAsymmetricBinding::ConstructL(CSenElement* aAsymmBinding) |
|
1464 {//parse AsymmBinding and get AlgoSuite Element |
|
1465 |
|
1466 TPtrC8 localName = aAsymmBinding->LocalName(); |
|
1467 |
|
1468 |
|
1469 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aAsymmBinding); |
|
1470 |
|
1471 |
|
1472 BaseConstructL(AND); |
|
1473 RPointerArray<CSenElement>& symmBindingChildren = AND->ElementsL(); |
|
1474 |
|
1475 CSenElement* child = NULL; |
|
1476 |
|
1477 for (TInt i = 0; i < symmBindingChildren.Count(); i++) |
|
1478 { |
|
1479 child = symmBindingChildren[i]; |
|
1480 |
|
1481 TPtrC8 localName = child->LocalName(); |
|
1482 |
|
1483 if(localName.Compare(KInitiatorToken) == 0) |
|
1484 { |
|
1485 iInitiatorToken = CTokenHolder::NewL(child); |
|
1486 |
|
1487 } |
|
1488 else if(localName.Compare(KRecipientToken) == 0) |
|
1489 { |
|
1490 iRecipientToken = CTokenHolder::NewL(child); |
|
1491 } |
|
1492 else |
|
1493 { |
|
1494 //do something |
|
1495 } |
|
1496 } |
|
1497 CleanupStack::PopAndDestroy(&symmBindingChildren); |
|
1498 |
|
1499 } |
|
1500 |
|
1501 CAsymmetricBinding::CAsymmetricBinding() |
|
1502 { |
|
1503 /* |
|
1504 <sp:InitiatorToken> </sp:InitiatorToken> |
|
1505 <sp:RecipientToken> </sp:RecipientToken> |
|
1506 <sp:AlgorithmSuite ... > ... </sp:AlgorithmSuite> |
|
1507 <sp:Layout ... > ... </sp:Layout> ? |
|
1508 <sp:IncludeTimestamp ... /> ? |
|
1509 <sp:EncryptBeforeSigning ... /> ? |
|
1510 <sp:EncryptSignature ... /> ? |
|
1511 <sp:ProtectTokens ... /> ? |
|
1512 <sp:OnlySignEntireHeadersAndBody ... /> ? |
|
1513 */ |
|
1514 } |
|
1515 |
|
1516 TBool CAsymmetricBinding::IsEqualAsymmtericAssertion(CAsymmetricBinding* aAsymmetricBinding) |
|
1517 { |
|
1518 |
|
1519 if( |
|
1520 (GetAlgoSuite()->IsEqualAlgoSuite(aAsymmetricBinding->GetAlgoSuite())) && |
|
1521 (GetLayout()->IsEqualLayout(aAsymmetricBinding->GetLayout())) && |
|
1522 (IncludetimeStamp() == aAsymmetricBinding->IncludetimeStamp()) && |
|
1523 (EncryptSignature() == aAsymmetricBinding->EncryptSignature()) && |
|
1524 (EncryptBeforeSigning().Compare(aAsymmetricBinding->EncryptBeforeSigning()) == 0) && |
|
1525 (ProtectTokens() == aAsymmetricBinding->ProtectTokens()) && |
|
1526 (OnlySignEntireHeadersAndBody() == aAsymmetricBinding->OnlySignEntireHeadersAndBody())) |
|
1527 { |
|
1528 return ETrue; |
|
1529 } |
|
1530 |
|
1531 return EFalse; |
|
1532 |
|
1533 } |
|
1534 |
|
1535 /////////////////////////////////////////////////////////// |
|
1536 //CSymmetricBinding |
|
1537 /////////////////////////////////////////////////////////// |
|
1538 CSymmetricBinding* CSymmetricBinding::NewL(CSenElement* aSymmBinding) |
|
1539 { |
|
1540 CSymmetricBinding* pSelf = CSymmetricBinding::NewLC(aSymmBinding); |
|
1541 CleanupStack::Pop(pSelf); |
|
1542 return pSelf; |
|
1543 } |
|
1544 CSymmetricBinding* CSymmetricBinding::NewLC(CSenElement* aSymmBinding) |
|
1545 { |
|
1546 CSymmetricBinding* pSelf = new (ELeave) CSymmetricBinding(); |
|
1547 CleanupStack::PushL(pSelf); |
|
1548 pSelf->ConstructL(aSymmBinding); |
|
1549 return pSelf; |
|
1550 } |
|
1551 CSymmetricBinding::~CSymmetricBinding() |
|
1552 { |
|
1553 |
|
1554 delete iEncriptionToken; |
|
1555 delete iSignatureToken; |
|
1556 delete iProtectionToken; |
|
1557 |
|
1558 } |
|
1559 void CSymmetricBinding::ConstructL(CSenElement* aAsymmBinding) |
|
1560 {//parse AsymmBinding and get AlgoSuite Element |
|
1561 |
|
1562 TPtrC8 localName = aAsymmBinding->LocalName(); |
|
1563 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aAsymmBinding); |
|
1564 RPointerArray<CSenElement>& symmBindingChildren = AND->ElementsL(); |
|
1565 BaseConstructL(AND); |
|
1566 CSenElement* child = NULL; |
|
1567 |
|
1568 for (TInt i = 0; i < symmBindingChildren.Count(); i++) |
|
1569 { |
|
1570 child = symmBindingChildren[i]; |
|
1571 |
|
1572 TPtrC8 localName = child->LocalName(); |
|
1573 |
|
1574 if(localName.Compare(KEncryptionToken) == 0) |
|
1575 { |
|
1576 iEncriptionToken = CTokenHolder::NewL(child); |
|
1577 } |
|
1578 else if(localName.Compare(KSignatureToken) == 0) |
|
1579 { |
|
1580 iSignatureToken = CTokenHolder::NewL(child); |
|
1581 } |
|
1582 else if(localName.Compare(KProtectionToken) == 0) |
|
1583 { |
|
1584 iProtectionToken = CTokenHolder::NewL(child); |
|
1585 } |
|
1586 else |
|
1587 { |
|
1588 //do something |
|
1589 } |
|
1590 } |
|
1591 |
|
1592 |
|
1593 } |
|
1594 |
|
1595 CSymmetricBinding::CSymmetricBinding() |
|
1596 { |
|
1597 /* |
|
1598 <sp:EncryptionToken> </sp:EncryptionToken> |
|
1599 <sp:SignatureToken> </sp:SignatureToken> |
|
1600 or |
|
1601 <sp:ProtectionToken> </sp:ProtectionToken> |
|
1602 |
|
1603 <sp:AlgorithmSuite ... > ... </sp:AlgorithmSuite> |
|
1604 <sp:Layout ... > ... </sp:Layout> ? |
|
1605 <sp:IncludeTimestamp ... /> ? |
|
1606 <sp:EncryptBeforeSigning ... /> ? |
|
1607 <sp:EncryptSignature ... /> ? |
|
1608 <sp:ProtectTokens ... /> ? |
|
1609 <sp:OnlySignEntireHeadersAndBody ... /> ? |
|
1610 */ |
|
1611 } |
|
1612 |
|
1613 TBool CSymmetricBinding::IsEqualSymmtericAssertion(CSymmetricBinding* aSymmetricBinding) |
|
1614 { |
|
1615 |
|
1616 if( |
|
1617 (GetAlgoSuite()->IsEqualAlgoSuite(aSymmetricBinding->GetAlgoSuite())) && |
|
1618 (GetLayout()->IsEqualLayout(aSymmetricBinding->GetLayout())) && |
|
1619 (IncludetimeStamp() == aSymmetricBinding->IncludetimeStamp()) && |
|
1620 (EncryptSignature() == aSymmetricBinding->EncryptSignature()) && |
|
1621 (EncryptBeforeSigning().Compare(aSymmetricBinding->EncryptBeforeSigning()) == 0) && |
|
1622 (ProtectTokens() == aSymmetricBinding->ProtectTokens()) && |
|
1623 (OnlySignEntireHeadersAndBody() == aSymmetricBinding->OnlySignEntireHeadersAndBody())) |
|
1624 { |
|
1625 return ETrue; |
|
1626 } |
|
1627 |
|
1628 return EFalse; |
|
1629 |
|
1630 } |
|
1631 |
|
1632 /////////////////////////////////////////////////////////// |
|
1633 //CTranportBinding |
|
1634 /////////////////////////////////////////////////////////// |
|
1635 |
|
1636 CTranportBinding* CTranportBinding::NewL(CSenElement* aTransportBinding) |
|
1637 { |
|
1638 CTranportBinding* pSelf = CTranportBinding::NewLC(aTransportBinding); |
|
1639 CleanupStack::Pop(pSelf); |
|
1640 return pSelf; |
|
1641 |
|
1642 } |
|
1643 CTranportBinding* CTranportBinding::NewLC(CSenElement* aTransportBinding) |
|
1644 { |
|
1645 CTranportBinding* pSelf = new (ELeave) CTranportBinding(); |
|
1646 CleanupStack::PushL(pSelf); |
|
1647 pSelf->ConstructL(aTransportBinding); |
|
1648 return pSelf; |
|
1649 |
|
1650 } |
|
1651 CTranportBinding::~CTranportBinding() |
|
1652 { |
|
1653 delete iTransportToken; |
|
1654 } |
|
1655 |
|
1656 TBool CTranportBinding::IsEqualTransportBindingAssertion(CTranportBinding* aTransportBinding) |
|
1657 { |
|
1658 if( |
|
1659 (GetAlgoSuite()->IsEqualAlgoSuite(aTransportBinding->GetAlgoSuite())) && |
|
1660 (GetLayout()->IsEqualLayout(aTransportBinding->GetLayout())) && |
|
1661 (IncludetimeStamp() == aTransportBinding->IncludetimeStamp())) |
|
1662 { |
|
1663 return ETrue; |
|
1664 } |
|
1665 |
|
1666 return EFalse; |
|
1667 |
|
1668 } |
|
1669 void CTranportBinding::ConstructL(CSenElement* aTransportBinding) |
|
1670 { |
|
1671 TPtrC8 localName = aTransportBinding->LocalName(); |
|
1672 |
|
1673 |
|
1674 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aTransportBinding); |
|
1675 |
|
1676 |
|
1677 SetbaseElementL(AND); |
|
1678 |
|
1679 RPointerArray<CSenElement>& bindingChildren = AND->ElementsL(); |
|
1680 |
|
1681 CSenElement* child = NULL; |
|
1682 |
|
1683 for (TInt i = 0; i < bindingChildren.Count(); i++) |
|
1684 { |
|
1685 child = bindingChildren[i]; |
|
1686 |
|
1687 TPtrC8 localName = child->LocalName(); |
|
1688 |
|
1689 if(localName.Compare(KTransportToken) == 0) |
|
1690 { |
|
1691 iTransportToken = CTokenHolder::NewL(child); |
|
1692 } |
|
1693 else |
|
1694 { |
|
1695 //do something |
|
1696 } |
|
1697 } |
|
1698 |
|
1699 } |
|
1700 CTranportBinding::CTranportBinding() |
|
1701 { |
|
1702 |
|
1703 } |
|
1704 |
|
1705 // CTokenHolder* iTransportToken; |
|
1706 |
|
1707 |
|
1708 /////////////////////////////////////////////////////////// |
|
1709 //CAlgorithmSuite |
|
1710 /////////////////////////////////////////////////////////// |
|
1711 |
|
1712 CAlgorithmSuite* CAlgorithmSuite::NewL(CSenElement* aAlgoSuite) |
|
1713 { |
|
1714 CAlgorithmSuite* pSelf = CAlgorithmSuite::NewLC(aAlgoSuite); |
|
1715 CleanupStack::Pop(pSelf); |
|
1716 return pSelf; |
|
1717 } |
|
1718 |
|
1719 CAlgorithmSuite* CAlgorithmSuite::NewLC(CSenElement* aAlgoSuite) |
|
1720 { |
|
1721 CAlgorithmSuite* pSelf = new (ELeave) CAlgorithmSuite(); |
|
1722 CleanupStack::PushL(pSelf); |
|
1723 pSelf->ConstructL(aAlgoSuite); |
|
1724 return pSelf; |
|
1725 } |
|
1726 |
|
1727 CAlgorithmSuite::~CAlgorithmSuite() |
|
1728 { |
|
1729 delete iAlgoSuite; |
|
1730 delete iSymmetricSignature; |
|
1731 delete iAsymmetricSignature; |
|
1732 delete iComputedKey; |
|
1733 delete iDigest; |
|
1734 delete iEncryption; |
|
1735 delete iSymmetricKeyWrap; |
|
1736 delete iAsymmetricKeyWrap; |
|
1737 delete iEncryptionKeyDerivation; |
|
1738 delete iSignatureKeyDerivation; |
|
1739 delete iC14n; |
|
1740 delete iSoapNormalization; |
|
1741 delete iStrTransform; |
|
1742 delete iXPath; |
|
1743 delete iXPathFilter20; |
|
1744 |
|
1745 } |
|
1746 void CAlgorithmSuite::ConstructL(CSenElement* aAlgoSuite) |
|
1747 { |
|
1748 |
|
1749 CSenElement* AND = CXmlHelper::RipPolicyXORElementL(aAlgoSuite); |
|
1750 |
|
1751 |
|
1752 RPointerArray<CSenElement>& algoChildren = AND->ElementsL();; //find the policy element |
|
1753 CSenElement* child = NULL; |
|
1754 for (TInt i = 0; i < algoChildren.Count(); i++) |
|
1755 { //should be only one element |
|
1756 child = algoChildren[i]; |
|
1757 |
|
1758 TPtrC8 localName = child->LocalName(); |
|
1759 iAlgoSuite = localName.AllocL(); |
|
1760 SetAlgoSuiteL(localName); |
|
1761 |
|
1762 } |
|
1763 |
|
1764 } |
|
1765 CAlgorithmSuite::CAlgorithmSuite() |
|
1766 : |
|
1767 iAlgoSuite(KNullDesC8().AllocL()), |
|
1768 iSymmetricSignature(KAlgoHMAC_SHA1().AllocL()), |
|
1769 iAsymmetricSignature(KAlgoRSA_SHA1().AllocL()), |
|
1770 iComputedKey(KAlgoP_SHA1().AllocL()), |
|
1771 iMaximumSymmetricKeyLength(256), |
|
1772 iMinimumAsymmetricKeyLength(1024), |
|
1773 iMaximumAsymmetricKeyLength(4096), |
|
1774 iDigest(KNullDesC8().AllocL()), |
|
1775 iEncryption(KNullDesC8().AllocL()), |
|
1776 iSymmetricKeyWrap(KNullDesC8().AllocL()), |
|
1777 iAsymmetricKeyWrap(KNullDesC8().AllocL()), |
|
1778 iEncryptionKeyDerivation(KNullDesC8().AllocL()), |
|
1779 iSignatureKeyDerivation(KNullDesC8().AllocL()), |
|
1780 iMinimumSymmetricKeyLength(0), |
|
1781 iC14n(KAlgoEX_C14N().AllocL()), |
|
1782 iSoapNormalization(KNullDesC8().AllocL()), |
|
1783 iStrTransform(KNullDesC8().AllocL()), |
|
1784 iXPath(KNullDesC8().AllocL()), |
|
1785 iXPathFilter20(KNullDesC8().AllocL()) |
|
1786 |
|
1787 { |
|
1788 |
|
1789 } |
|
1790 TBool CAlgorithmSuite::IsEqualAlgoSuite(CAlgorithmSuite* aAlgoSuite) |
|
1791 { |
|
1792 if (AlgoSuite().Compare(aAlgoSuite->AlgoSuite()) == 0) |
|
1793 return ETrue; |
|
1794 else |
|
1795 return EFalse; |
|
1796 } |
|
1797 |
|
1798 void CAlgorithmSuite::SetAlgoSuiteL(TDesC8& aSuiteName) |
|
1799 { |
|
1800 if(aSuiteName.Compare(KBasic256) == 0) |
|
1801 { |
|
1802 iDigest = KAlgoSHA1().AllocL(); |
|
1803 iEncryption = KAlgoAES256().AllocL(); |
|
1804 iSymmetricKeyWrap = KAlgoKW_AES256().AllocL(); |
|
1805 iAsymmetricKeyWrap = KAlgoKW_RSA_OAEP().AllocL(); |
|
1806 iEncryptionKeyDerivation = KAlgoP_SHA1_L256().AllocL(); |
|
1807 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1808 iMinimumSymmetricKeyLength = 256; |
|
1809 } |
|
1810 else if (aSuiteName.Compare(KBasic192) == 0) |
|
1811 { |
|
1812 iDigest = KAlgoSHA1().AllocL(); |
|
1813 iEncryption = KAlgoAES192().AllocL(); |
|
1814 iSymmetricKeyWrap = KAlgoKW_AES192().AllocL(); |
|
1815 iAsymmetricKeyWrap = KAlgoKW_RSA_OAEP().AllocL(); |
|
1816 iEncryptionKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1817 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1818 iMinimumSymmetricKeyLength = 192; |
|
1819 } |
|
1820 else if (aSuiteName.Compare(KBasic128) == 0) |
|
1821 { |
|
1822 iDigest = KAlgoSHA1().AllocL(); |
|
1823 iEncryption = KAlgoAES128().AllocL(); |
|
1824 iSymmetricKeyWrap = KAlgoKW_AES128().AllocL(); |
|
1825 iAsymmetricKeyWrap = KAlgoKW_RSA_OAEP().AllocL(); |
|
1826 iEncryptionKeyDerivation = KAlgoP_SHA1_L128().AllocL(); |
|
1827 iSignatureKeyDerivation = KAlgoP_SHA1_L128().AllocL(); |
|
1828 iMinimumSymmetricKeyLength = 128; |
|
1829 } |
|
1830 else if (aSuiteName.Compare(KTripleDes) == 0) |
|
1831 { |
|
1832 iDigest = KAlgoSHA1().AllocL(); |
|
1833 iEncryption = KAlgoTRIPLE_DES().AllocL(); |
|
1834 iSymmetricKeyWrap = KAlgoKW_TRIPLE_DES().AllocL(); |
|
1835 iAsymmetricKeyWrap = KAlgoKW_RSA_OAEP().AllocL(); |
|
1836 iEncryptionKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1837 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1838 iMinimumSymmetricKeyLength = 192; |
|
1839 } |
|
1840 else if (aSuiteName.Compare(KBasic256Rsa15) == 0) |
|
1841 { |
|
1842 iDigest = KAlgoSHA1().AllocL(); |
|
1843 iEncryption = KAlgoAES256().AllocL(); |
|
1844 iSymmetricKeyWrap = KAlgoKW_AES256().AllocL(); |
|
1845 iAsymmetricKeyWrap = KAlgoKW_RSA15().AllocL(); |
|
1846 iEncryptionKeyDerivation = KAlgoP_SHA1_L256().AllocL(); |
|
1847 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1848 iMinimumSymmetricKeyLength = 256; |
|
1849 } |
|
1850 else if (aSuiteName.Compare(KBasic192Rsa15) == 0) |
|
1851 { |
|
1852 iDigest = KAlgoSHA1().AllocL(); |
|
1853 iEncryption = KAlgoAES192().AllocL(); |
|
1854 iSymmetricKeyWrap = KAlgoKW_AES192().AllocL(); |
|
1855 iAsymmetricKeyWrap = KAlgoKW_RSA15().AllocL(); |
|
1856 iEncryptionKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1857 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1858 iMinimumSymmetricKeyLength = 192; |
|
1859 } |
|
1860 else if (aSuiteName.Compare(KBasic128Rsa15) == 0) |
|
1861 { |
|
1862 iDigest = KAlgoSHA1().AllocL(); |
|
1863 iEncryption = KAlgoAES128().AllocL(); |
|
1864 iSymmetricKeyWrap = KAlgoKW_AES128().AllocL(); |
|
1865 iAsymmetricKeyWrap = KAlgoKW_RSA15().AllocL(); |
|
1866 iEncryptionKeyDerivation = KAlgoP_SHA1_L128().AllocL(); |
|
1867 iSignatureKeyDerivation = KAlgoP_SHA1_L128().AllocL(); |
|
1868 iMinimumSymmetricKeyLength = 128; |
|
1869 } |
|
1870 else if (aSuiteName.Compare(KTripleDesRsa15) == 0) |
|
1871 { |
|
1872 iDigest = KAlgoSHA1().AllocL(); |
|
1873 iEncryption = KAlgoTRIPLE_DES().AllocL(); |
|
1874 iSymmetricKeyWrap = KAlgoKW_TRIPLE_DES().AllocL(); |
|
1875 iAsymmetricKeyWrap = KAlgoKW_RSA15().AllocL(); |
|
1876 iEncryptionKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1877 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1878 iMinimumSymmetricKeyLength = 192; |
|
1879 } |
|
1880 else if(aSuiteName.Compare(KBasic256Sha256) == 0) |
|
1881 { |
|
1882 iDigest = KAlgoSHA256().AllocL(); |
|
1883 iEncryption = KAlgoAES256().AllocL(); |
|
1884 iSymmetricKeyWrap = KAlgoKW_AES256().AllocL(); |
|
1885 iAsymmetricKeyWrap = KAlgoKW_RSA_OAEP().AllocL(); |
|
1886 iEncryptionKeyDerivation = KAlgoP_SHA1_L256().AllocL(); |
|
1887 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1888 iMinimumSymmetricKeyLength = 256; |
|
1889 } |
|
1890 else if (aSuiteName.Compare(KBasic192Sha256) == 0) |
|
1891 { |
|
1892 iDigest = KAlgoSHA256().AllocL(); |
|
1893 iEncryption = KAlgoAES192().AllocL(); |
|
1894 iSymmetricKeyWrap = KAlgoKW_AES192().AllocL(); |
|
1895 iAsymmetricKeyWrap = KAlgoKW_RSA_OAEP().AllocL(); |
|
1896 iEncryptionKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1897 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1898 iMinimumSymmetricKeyLength = 192; |
|
1899 } |
|
1900 else if (aSuiteName.Compare(KBasic128Sha256) == 0) |
|
1901 { |
|
1902 iDigest = KAlgoSHA256().AllocL(); |
|
1903 iEncryption = KAlgoAES128().AllocL(); |
|
1904 iSymmetricKeyWrap = KAlgoKW_AES128().AllocL(); |
|
1905 iAsymmetricKeyWrap = KAlgoKW_RSA_OAEP().AllocL(); |
|
1906 iEncryptionKeyDerivation = KAlgoP_SHA1_L128().AllocL(); |
|
1907 iSignatureKeyDerivation = KAlgoP_SHA1_L128().AllocL(); |
|
1908 iMinimumSymmetricKeyLength = 128; |
|
1909 } |
|
1910 else if(aSuiteName.Compare(KTripleDesSha256) == 0) |
|
1911 { |
|
1912 iDigest = KAlgoSHA256().AllocL(); |
|
1913 iEncryption = KAlgoTRIPLE_DES().AllocL(); |
|
1914 iSymmetricKeyWrap = KAlgoKW_TRIPLE_DES().AllocL(); |
|
1915 iAsymmetricKeyWrap = KAlgoKW_RSA_OAEP().AllocL(); |
|
1916 iEncryptionKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1917 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1918 iMinimumSymmetricKeyLength = 192; |
|
1919 } |
|
1920 else if (aSuiteName.Compare(KBasic256Sha256Rsa15) == 0) |
|
1921 { |
|
1922 iDigest = KAlgoSHA256().AllocL(); |
|
1923 iEncryption = KAlgoAES256().AllocL(); |
|
1924 iSymmetricKeyWrap = KAlgoKW_AES256().AllocL(); |
|
1925 iAsymmetricKeyWrap = KAlgoKW_RSA15().AllocL(); |
|
1926 iEncryptionKeyDerivation = KAlgoP_SHA1_L256().AllocL(); |
|
1927 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1928 iMinimumSymmetricKeyLength = 256; |
|
1929 } |
|
1930 else if (aSuiteName.Compare(KBasic192Sha256Rsa15) == 0) |
|
1931 { |
|
1932 iDigest = KAlgoSHA256().AllocL(); |
|
1933 iEncryption = KAlgoAES192().AllocL(); |
|
1934 iSymmetricKeyWrap = KAlgoKW_AES192().AllocL(); |
|
1935 iAsymmetricKeyWrap = KAlgoKW_RSA15().AllocL(); |
|
1936 iEncryptionKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1937 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1938 iMinimumSymmetricKeyLength = 192; |
|
1939 } |
|
1940 else if (aSuiteName.Compare(KBasic128Sha256Rsa15) == 0) |
|
1941 { |
|
1942 iDigest = KAlgoSHA256().AllocL(); |
|
1943 iEncryption = KAlgoAES128().AllocL(); |
|
1944 iSymmetricKeyWrap = KAlgoKW_AES128().AllocL(); |
|
1945 iAsymmetricKeyWrap = KAlgoKW_RSA15().AllocL(); |
|
1946 iEncryptionKeyDerivation = KAlgoP_SHA1_L128().AllocL(); |
|
1947 iSignatureKeyDerivation = KAlgoP_SHA1_L128().AllocL(); |
|
1948 iMinimumSymmetricKeyLength = 128; |
|
1949 } |
|
1950 else if (aSuiteName.Compare(KTripleDesSha256Rsa15) == 0) |
|
1951 { |
|
1952 iDigest = KAlgoSHA256().AllocL(); |
|
1953 iEncryption = KAlgoTRIPLE_DES().AllocL(); |
|
1954 iSymmetricKeyWrap = KAlgoKW_TRIPLE_DES().AllocL(); |
|
1955 iAsymmetricKeyWrap = KAlgoKW_RSA15().AllocL(); |
|
1956 iEncryptionKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1957 iSignatureKeyDerivation = KAlgoP_SHA1_L192().AllocL(); |
|
1958 iMinimumSymmetricKeyLength = 192; |
|
1959 } |
|
1960 //else {} |
|
1961 } |
|
1962 |
|
1963 TPtrC8 CAlgorithmSuite::AlgoSuite() |
|
1964 { |
|
1965 return iAlgoSuite->Des(); |
|
1966 } |
|
1967 |
|
1968 TPtrC8 CAlgorithmSuite::SymmetricSignature() |
|
1969 { |
|
1970 return iSymmetricSignature->Des(); |
|
1971 } |
|
1972 |
|
1973 TPtrC8 CAlgorithmSuite::AsymmetricSignature() |
|
1974 { |
|
1975 return iAsymmetricSignature->Des(); |
|
1976 } |
|
1977 |
|
1978 TPtrC8 CAlgorithmSuite::ComputedKey() |
|
1979 { |
|
1980 return iComputedKey->Des(); |
|
1981 } |
|
1982 |
|
1983 TInt CAlgorithmSuite::MaximumSymmetricKeyLength() |
|
1984 { |
|
1985 return iMaximumSymmetricKeyLength; |
|
1986 } |
|
1987 |
|
1988 TInt CAlgorithmSuite::MinimumAsymmetricKeyLength() |
|
1989 { |
|
1990 return iMinimumAsymmetricKeyLength; |
|
1991 } |
|
1992 |
|
1993 TInt CAlgorithmSuite::MaximumAsymmetricKeyLength() |
|
1994 { |
|
1995 return iMaximumAsymmetricKeyLength; |
|
1996 } |
|
1997 |
|
1998 TPtrC8 CAlgorithmSuite::Digest() |
|
1999 { |
|
2000 return iDigest->Des(); |
|
2001 } |
|
2002 |
|
2003 TPtrC8 CAlgorithmSuite::Encryption() |
|
2004 { |
|
2005 return iEncryption->Des(); |
|
2006 } |
|
2007 |
|
2008 TPtrC8 CAlgorithmSuite::SymmetricKeyWrap() |
|
2009 { |
|
2010 return iSymmetricKeyWrap->Des(); |
|
2011 } |
|
2012 |
|
2013 TPtrC8 CAlgorithmSuite::AsymmetricKeyWrap() |
|
2014 { |
|
2015 return iAsymmetricKeyWrap->Des(); |
|
2016 } |
|
2017 |
|
2018 TPtrC8 CAlgorithmSuite::EncryptionKeyDerivation() |
|
2019 { |
|
2020 return iEncryptionKeyDerivation->Des(); |
|
2021 } |
|
2022 |
|
2023 TPtrC8 CAlgorithmSuite::SignatureKeyDerivation() |
|
2024 { |
|
2025 return iSignatureKeyDerivation->Des(); |
|
2026 } |
|
2027 |
|
2028 TInt CAlgorithmSuite::MinimumSymmetricKeyLength() |
|
2029 { |
|
2030 return iMinimumSymmetricKeyLength; |
|
2031 } |
|
2032 |
|
2033 TPtrC8 CAlgorithmSuite::C14n() |
|
2034 { |
|
2035 return iC14n->Des(); |
|
2036 } |
|
2037 TPtrC8 CAlgorithmSuite::SoapNormalization() |
|
2038 { |
|
2039 return iSoapNormalization->Des(); |
|
2040 } |
|
2041 TPtrC8 CAlgorithmSuite::StrTransform() |
|
2042 { |
|
2043 return iStrTransform->Des(); |
|
2044 } |
|
2045 |
|
2046 TPtrC8 CAlgorithmSuite::XPath() |
|
2047 { |
|
2048 return iXPath->Des(); |
|
2049 } |
|
2050 |
|
2051 TPtrC8 CAlgorithmSuite::XPathFilter20() |
|
2052 { |
|
2053 return iXPathFilter20->Des(); |
|
2054 } |
|
2055 |
|
2056 void CAlgorithmSuite::SetC14nL(TDesC8& aValue) |
|
2057 { |
|
2058 if(iC14n) |
|
2059 { |
|
2060 delete iC14n; |
|
2061 iC14n = NULL; |
|
2062 } |
|
2063 iC14n = aValue.AllocL(); |
|
2064 } |
|
2065 |
|
2066 void CAlgorithmSuite::SetSoapNormalizationL(TDesC8& aValue) |
|
2067 { |
|
2068 if(iSoapNormalization) |
|
2069 delete iSoapNormalization; |
|
2070 iSoapNormalization = NULL; |
|
2071 iSoapNormalization = aValue.AllocL(); |
|
2072 } |
|
2073 |
|
2074 void CAlgorithmSuite::SetStrTransformL(TDesC8& aValue) |
|
2075 { |
|
2076 if(iStrTransform) |
|
2077 delete iStrTransform; |
|
2078 iStrTransform = NULL; |
|
2079 iStrTransform = aValue.AllocL(); |
|
2080 } |
|
2081 |
|
2082 void CAlgorithmSuite::SetXPathL(TDesC8& aValue) |
|
2083 { |
|
2084 if(iXPath) |
|
2085 delete iXPath; |
|
2086 iXPath = NULL; |
|
2087 iXPath = aValue.AllocL(); |
|
2088 } |
|
2089 |
|
2090 void CAlgorithmSuite::SetXPathFilter20L(TDesC8& aValue) |
|
2091 { |
|
2092 if(iXPathFilter20) |
|
2093 delete iXPathFilter20; |
|
2094 iXPathFilter20 = NULL; |
|
2095 iXPathFilter20 = aValue.AllocL(); |
|
2096 } |
|
2097 |
|
2098 /////////////////////////////////////////////////////////////////////// |
|
2099 ////// CEncryptedSignedParts |
|
2100 /////////////////////////////////////////////////////////////////////// |
|
2101 CEncryptedSignedParts* CEncryptedSignedParts::NewL(CSenElement* aAssertion) |
|
2102 { |
|
2103 CEncryptedSignedParts* pSelf = CEncryptedSignedParts::NewLC(aAssertion); |
|
2104 CleanupStack::Pop(pSelf); |
|
2105 return pSelf; |
|
2106 } |
|
2107 |
|
2108 CEncryptedSignedParts* CEncryptedSignedParts::NewLC(CSenElement* aAssertion) |
|
2109 { |
|
2110 CEncryptedSignedParts* pSelf = new (ELeave) CEncryptedSignedParts(); |
|
2111 CleanupStack::PushL(pSelf); |
|
2112 pSelf->ConstructL(aAssertion); |
|
2113 return pSelf; |
|
2114 } |
|
2115 |
|
2116 CEncryptedSignedParts::~CEncryptedSignedParts() |
|
2117 { |
|
2118 iHeaders.Close(); |
|
2119 } |
|
2120 |
|
2121 TBool CEncryptedSignedParts::IsEqualEncryptedSignedParts(CEncryptedSignedParts* aAssertion) |
|
2122 { |
|
2123 |
|
2124 if(Body() == aAssertion->Body() && Header() == aAssertion->Header()) |
|
2125 { |
|
2126 return ETrue; |
|
2127 } |
|
2128 return EFalse; |
|
2129 } |
|
2130 |
|
2131 TBool CEncryptedSignedParts::Header() |
|
2132 { |
|
2133 return iHeader; |
|
2134 } |
|
2135 |
|
2136 TBool CEncryptedSignedParts::Body() |
|
2137 { |
|
2138 return iBody; |
|
2139 } |
|
2140 |
|
2141 void CEncryptedSignedParts::ConstructL(CSenElement* aAssertion) |
|
2142 { |
|
2143 //No need to rip off caz there wont be any policy elements here |
|
2144 RPointerArray<CSenElement>& tokenChildren = aAssertion->ElementsL(); |
|
2145 if(tokenChildren.Count() < 0) |
|
2146 { |
|
2147 iHeader = ETrue; |
|
2148 iBody = ETrue; |
|
2149 return; |
|
2150 } |
|
2151 CSenElement* child; |
|
2152 for (TInt i = 0; i < tokenChildren.Count(); i++) |
|
2153 { |
|
2154 child = tokenChildren[i]; |
|
2155 |
|
2156 TPtrC8 localName = child->LocalName(); |
|
2157 |
|
2158 if(localName.Compare(KBody) == 0) |
|
2159 { |
|
2160 iBody = ETrue; |
|
2161 } |
|
2162 else if(localName.Compare(KHeader) == 0) |
|
2163 { |
|
2164 iHeader = ETrue; |
|
2165 //get header attributes |
|
2166 SoapHeader header; |
|
2167 if(CXmlHelper::HasAttributeL(aAssertion, KName())) |
|
2168 { |
|
2169 TPtrC8 headerName = CXmlHelper::AttributeValueL(aAssertion, KName); |
|
2170 header.iName.Set(headerName); |
|
2171 } |
|
2172 if(CXmlHelper::HasAttributeL(aAssertion, KNamespace())) |
|
2173 { |
|
2174 TPtrC8 nsUri = CXmlHelper::AttributeValueL(aAssertion, KNamespace()); |
|
2175 header.iNsUri.Set(nsUri); |
|
2176 } |
|
2177 iHeaders.Append(header); |
|
2178 } |
|
2179 } |
|
2180 } |
|
2181 |
|
2182 CEncryptedSignedParts::CEncryptedSignedParts() |
|
2183 : iHeader(EFalse), |
|
2184 iBody(EFalse) |
|
2185 { |
|
2186 } |
|
2187 |
|
2188 void CEncryptedSignedParts::ElementsL( RPointerArray<HBufC8>& aElements ) |
|
2189 { |
|
2190 if(iBody) |
|
2191 { |
|
2192 aElements.Append(KBody().AllocL()); |
|
2193 aElements.Append(KNullDesC8().AllocL()); |
|
2194 } |
|
2195 |
|
2196 if(iHeader && iHeaders.Count() == 0) |
|
2197 { |
|
2198 aElements.Append(KHeader().AllocL()); |
|
2199 } |
|
2200 else if(iHeader && iHeaders.Count() > 0) |
|
2201 { |
|
2202 for(TInt i = 0; i< iHeaders.Count(); i++) |
|
2203 { |
|
2204 SoapHeader header(iHeaders[i]); |
|
2205 TPtrC8 name(header.iName); |
|
2206 if(name != KNullDesC8()) |
|
2207 { |
|
2208 aElements.Append(name.AllocL()); |
|
2209 aElements.Append(header.iNsUri.AllocL()); |
|
2210 } |
|
2211 } |
|
2212 } |
|
2213 } |
|
2214 |
|
2215 /////////////////////////////////////////////////////////////////////// |
|
2216 ////// CEncryptedSignedElements |
|
2217 /////////////////////////////////////////////////////////////////////// |
|
2218 CEncryptedSignedElements* CEncryptedSignedElements::NewL(CSenElement* aAssertion) |
|
2219 { |
|
2220 CEncryptedSignedElements* pSelf = CEncryptedSignedElements::NewLC(aAssertion); |
|
2221 CleanupStack::Pop(pSelf); |
|
2222 return pSelf; |
|
2223 } |
|
2224 |
|
2225 CEncryptedSignedElements* CEncryptedSignedElements::NewLC(CSenElement* aAssertion) |
|
2226 { |
|
2227 CEncryptedSignedElements* pSelf = new (ELeave) CEncryptedSignedElements(); |
|
2228 CleanupStack::PushL(pSelf); |
|
2229 pSelf->ConstructL(aAssertion); |
|
2230 return pSelf; |
|
2231 } |
|
2232 |
|
2233 CEncryptedSignedElements::~CEncryptedSignedElements() |
|
2234 { |
|
2235 iXpaths.Close(); |
|
2236 delete iXPathVersion; |
|
2237 } |
|
2238 |
|
2239 TBool CEncryptedSignedElements::IsEqualEncryptedSignedElements(CEncryptedSignedElements* aAssertion) |
|
2240 { |
|
2241 |
|
2242 if( XPathVersion().Compare(aAssertion->XPathVersion()) == 0 ) |
|
2243 { |
|
2244 return ETrue; |
|
2245 } |
|
2246 return EFalse; |
|
2247 } |
|
2248 |
|
2249 void CEncryptedSignedElements::ConstructL(CSenElement* aAssertion) |
|
2250 { |
|
2251 //No need to rip off caz there wont be any policy elements here |
|
2252 if(CXmlHelper::HasAttributeL(aAssertion, KXPathVersion())) |
|
2253 { |
|
2254 TPtrC8 xpathVersion = CXmlHelper::AttributeValueL(aAssertion,KXPathVersion()); |
|
2255 iXPathVersion = xpathVersion.AllocL(); |
|
2256 } |
|
2257 RPointerArray<CSenElement> tokenChildren; |
|
2258 CleanupClosePushL(tokenChildren); |
|
2259 aAssertion->ElementsL(tokenChildren, KWsSecurityPolicyNsUri, KXPath); |
|
2260 CSenElement* child; |
|
2261 TInt count = tokenChildren.Count(); |
|
2262 for (TInt i = 0; i < count; i++) |
|
2263 { |
|
2264 child = tokenChildren[i]; |
|
2265 TPtrC8 localName = child->LocalName(); |
|
2266 if(child->HasContent()) |
|
2267 { |
|
2268 TPtrC8 content = child->Content(); |
|
2269 //check if xpath is ns qualified |
|
2270 TBool result = IfNsQualified(aAssertion, content); |
|
2271 |
|
2272 if(result) |
|
2273 { |
|
2274 iXpaths.Append(content); |
|
2275 } |
|
2276 } |
|
2277 } |
|
2278 CleanupStack::PopAndDestroy(&tokenChildren); |
|
2279 } |
|
2280 |
|
2281 CEncryptedSignedElements::CEncryptedSignedElements() |
|
2282 :iXPathVersion(KNullDesC8().AllocL()) |
|
2283 { |
|
2284 } |
|
2285 |
|
2286 TInt CEncryptedSignedElements::GetXPaths(RArray<TPtrC8>& aXpaths) |
|
2287 { |
|
2288 RArray<TPtrC8> xpaths(iXpaths); |
|
2289 aXpaths = xpaths; |
|
2290 return KErrNone; |
|
2291 } |
|
2292 |
|
2293 TBool CEncryptedSignedElements::MergedElements(CEncryptedSignedElements* aAssertion, RArray<TPtrC8>& aResult) |
|
2294 { |
|
2295 if( XPathVersion().Compare(aAssertion->XPathVersion()) == 0 ) |
|
2296 { |
|
2297 RArray<TPtrC8> xpath1; |
|
2298 GetXPaths(xpath1); |
|
2299 RArray<TPtrC8> xpath2; |
|
2300 aAssertion->GetXPaths(xpath2); |
|
2301 |
|
2302 TInt count = xpath1.Count(); |
|
2303 TInt count2 = xpath2.Count(); |
|
2304 |
|
2305 if(count == 0 || count2 == 0) //we have to sign/encrypt ALL Headers+Body |
|
2306 { |
|
2307 return ETrue; |
|
2308 } |
|
2309 |
|
2310 for (TInt i=0; i< count; i++) |
|
2311 { |
|
2312 aResult.Append(xpath1[i]); |
|
2313 } |
|
2314 |
|
2315 for ( TInt j=0; j< count2; j++ ) |
|
2316 { |
|
2317 if(aResult.Find(xpath2[j]) == KErrNotFound) |
|
2318 { |
|
2319 aResult.Append(xpath1[j]); |
|
2320 } |
|
2321 } |
|
2322 } |
|
2323 return EFalse; |
|
2324 } |
|
2325 |
|
2326 TBool CEncryptedSignedElements::IfNsQualified(CSenElement* aAssertion, TDesC8& aXpath) |
|
2327 { |
|
2328 // the xpath is /pp:nimi/qq:foo/rr:bah/ |
|
2329 //all the namespacce defined in Xpath should be in the Document namespaces |
|
2330 TPtrC8 xpath(aXpath); |
|
2331 while ( true ) |
|
2332 { |
|
2333 TInt slash = xpath.Find(_L8("/")); |
|
2334 xpath.Set(xpath.Right(xpath.Length()-slash-1)); |
|
2335 if( slash >= 0 ) |
|
2336 { |
|
2337 TInt position = xpath.Find(KColon); |
|
2338 if(position) |
|
2339 { |
|
2340 TPtrC8 nsString = xpath.Left(position); |
|
2341 const CSenNamespace* nameSpace = aAssertion->Namespace(nsString, ETrue); |
|
2342 if(nameSpace != NULL) |
|
2343 { |
|
2344 continue; |
|
2345 } |
|
2346 else |
|
2347 { |
|
2348 return EFalse; |
|
2349 } |
|
2350 } |
|
2351 else |
|
2352 break; |
|
2353 } |
|
2354 else |
|
2355 { |
|
2356 break; |
|
2357 } |
|
2358 } |
|
2359 return ETrue; |
|
2360 } |
|
2361 |
|
2362 // END OF FILE |
|
2363 |
|
2364 |