|
1 /* |
|
2 * Copyright (c) 2009 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 "wsdlpolicyattachment.h" |
|
22 #include "wspolicyreader.h" |
|
23 #include "wspolicywriter.h" |
|
24 #include "policyassertion.h" |
|
25 #include "wspolicy.h" |
|
26 using namespace WsdlPolicyAttachment; |
|
27 |
|
28 EXPORT_C CWsdlPolicyAttachment* CWsdlPolicyAttachment::NewL(const TDesC8& aWsdlFileName) |
|
29 { |
|
30 CWsdlPolicyAttachment* pSelf = CWsdlPolicyAttachment::NewLC(aWsdlFileName); |
|
31 CleanupStack::Pop(pSelf); |
|
32 return pSelf; |
|
33 } |
|
34 |
|
35 EXPORT_C CWsdlPolicyAttachment* CWsdlPolicyAttachment::NewLC(const TDesC8& aWsdlFileName) |
|
36 { |
|
37 CWsdlPolicyAttachment* pSelf = new (ELeave) CWsdlPolicyAttachment(); |
|
38 CleanupStack::PushL(pSelf); |
|
39 pSelf->ConstructL(aWsdlFileName); |
|
40 return pSelf; |
|
41 } |
|
42 |
|
43 CWsdlPolicyAttachment::~CWsdlPolicyAttachment() |
|
44 { |
|
45 iOriginalPolicies.Reset(); |
|
46 iNormalizedPolicies.Reset(); |
|
47 if( iRegistry ) |
|
48 { |
|
49 iRegistry->ResetRegistry(); |
|
50 } |
|
51 delete iRegistry; |
|
52 } |
|
53 |
|
54 void CWsdlPolicyAttachment::ConstructL(const TDesC8& aWsdlFileName) |
|
55 { |
|
56 iRegistry = CPolicyRegistry::NewL(); |
|
57 CreateWsdlPolicyL( aWsdlFileName ); |
|
58 } |
|
59 |
|
60 CWsdlPolicyAttachment::CWsdlPolicyAttachment() : |
|
61 iOriginalPolicies(ETrue,ETrue), |
|
62 iNormalizedPolicies(ETrue, ETrue), |
|
63 iParsed(EFalse) |
|
64 { |
|
65 } |
|
66 |
|
67 void CWsdlPolicyAttachment::CreateWsdlPolicyL( const TDesC8& aWsdlContent ) |
|
68 { |
|
69 TInt size = aWsdlContent.Length(); |
|
70 if(size > 0) |
|
71 { |
|
72 iXmlReader = CSenXmlReader::NewL( KXmlParserMimeType ); // use libxml2 sax parser + CodeScannerWarnings |
|
73 TRAPD (err, ParseL( aWsdlContent )); |
|
74 delete iXmlReader; |
|
75 iXmlReader = NULL; |
|
76 |
|
77 if(err == KErrNone) |
|
78 { |
|
79 iParsed = ETrue; |
|
80 iPolicy = &AsElement(); |
|
81 iRegistry->PopulateRegistryL(iPolicy); |
|
82 } |
|
83 } |
|
84 } |
|
85 |
|
86 TPtrC8 CWsdlPolicyAttachment::GetAttributeValueL(const TDesC8& aAttribute, CSenElement* aElement) |
|
87 { |
|
88 RPointerArray<CSenBaseAttribute>& attrs = aElement->AttributesL(); |
|
89 |
|
90 CSenBaseAttribute* bs = NULL; |
|
91 TInt ele_count = attrs.Count(); |
|
92 |
|
93 for (TInt j=0; j < ele_count; j++) |
|
94 { |
|
95 |
|
96 bs = (attrs)[j]; |
|
97 if(bs) |
|
98 |
|
99 if(bs->Name().Compare(aAttribute) == 0) |
|
100 { |
|
101 return bs->Value(); |
|
102 } |
|
103 } |
|
104 return KNullDesC8(); |
|
105 } |
|
106 |
|
107 EXPORT_C CSenElement* CWsdlPolicyAttachment::GetEffectiveServicePolicyL( const TDesC8& aService ) |
|
108 { |
|
109 //wsdl:service |
|
110 CSenElement* pServicePolicy = GetServicePolicyL( aService ); |
|
111 RPointerArray<CSenElement> array; |
|
112 CleanupClosePushL( array ); |
|
113 if( pServicePolicy ) |
|
114 { |
|
115 array.Append( pServicePolicy ); |
|
116 } |
|
117 CWSPolicy* pol = GetEffectivePolicyL( array, iRegistry ); |
|
118 CleanupStack::PopAndDestroy( &array ); //array.Close(); |
|
119 //CSenElement* policy = NULL; |
|
120 //return policy; |
|
121 return NULL; |
|
122 } |
|
123 |
|
124 |
|
125 EXPORT_C CSenElement* CWsdlPolicyAttachment::GetEffectiveEndpointPolicyL( |
|
126 const TDesC8& aService, |
|
127 const TDesC8& aPort ) |
|
128 { |
|
129 //wsdl:port |
|
130 //wsdl:portType |
|
131 //wsdl:binding |
|
132 CSenElement* portPolicy = GetPortPolicyL(aService, aPort); |
|
133 RPointerArray<CSenElement> array; |
|
134 CleanupClosePushL( array ); |
|
135 if( portPolicy ) |
|
136 { |
|
137 array.Append(portPolicy); |
|
138 } |
|
139 CSenElement* portTypePolicy = GetPortTypePolicyL(aService, aPort); |
|
140 if(portTypePolicy) |
|
141 { |
|
142 array.Append(portTypePolicy); |
|
143 } |
|
144 |
|
145 CSenElement* bindingPolicy = GetBindingPolicyL(aService, aPort); |
|
146 if(bindingPolicy) |
|
147 { |
|
148 array.Append(bindingPolicy); |
|
149 } |
|
150 |
|
151 // (!) Merge these policies to get effective one: |
|
152 CWSPolicy* pol = GetEffectivePolicyL(array, iRegistry); //merge these policies to get effective one |
|
153 if( pol ) |
|
154 { |
|
155 // Serialize into file: |
|
156 RFs fss; |
|
157 User::LeaveIfError(fss.Connect()); |
|
158 CleanupClosePushL(fss); |
|
159 |
|
160 CSenElement* poli = pol->PolicyL(); |
|
161 _LIT( KFileNameOut, "c:\\logs\\WsSecurity10Sign.svc.xml"); |
|
162 HBufC8* temp = poli->AsXmlL(); |
|
163 CleanupStack::PushL(temp); |
|
164 TFileName iFileName12(KFileNameOut); |
|
165 RFile xmlFilew; |
|
166 xmlFilew.Replace(fss , iFileName12, EFileWrite ); |
|
167 xmlFilew.Write(temp->Des()); |
|
168 xmlFilew.Close(); |
|
169 CleanupStack::PopAndDestroy(temp); |
|
170 CleanupStack::PopAndDestroy(&fss); |
|
171 } |
|
172 CleanupStack::PopAndDestroy( &array ); // array.Close(); |
|
173 return NULL; |
|
174 } |
|
175 |
|
176 EXPORT_C CSenElement* CWsdlPolicyAttachment::GetEffectiveOperationPolicyL( const TDesC8& aService, |
|
177 const TDesC8& aPortName, |
|
178 const TDesC8& aOpName ) |
|
179 { |
|
180 // wsdl:portType/wsdl:operation |
|
181 // wsdl:binding/wsdl:operation |
|
182 CSenElement* portTypePolicy = GetPortTypeOperationPolicyL(aService, aPortName, aOpName); |
|
183 RPointerArray<CSenElement> array; |
|
184 CleanupClosePushL( array ); |
|
185 if(portTypePolicy) |
|
186 { |
|
187 array.Append(portTypePolicy); |
|
188 } |
|
189 CSenElement* bindingPolicy = GetBindingOperationPolicyL(aService, aPortName, aOpName); |
|
190 if(bindingPolicy) |
|
191 { |
|
192 array.Append(bindingPolicy); |
|
193 } |
|
194 // (!) Merge these policies to get effective one: |
|
195 GetEffectivePolicyL(array, iRegistry); |
|
196 CleanupStack::PopAndDestroy( &array ); // array.Close(); |
|
197 // CSenElement* policy = NULL; |
|
198 // return policy; |
|
199 return NULL; |
|
200 } |
|
201 |
|
202 EXPORT_C CSenElement* CWsdlPolicyAttachment::GetEffectiveInputPolicyL(const TDesC8& aService, const TDesC8& aPortName, const TDesC8& aOpName) |
|
203 { |
|
204 // wsdl:message |
|
205 // wsdl:portType/wsdl:operation/wsdl:input |
|
206 // wsdl:binding/wsdl:operation/wsdl:input |
|
207 CSenElement* messagePolicy = GetMessagePolicyL(aService, aPortName, aOpName, ETrue); |
|
208 RPointerArray<CSenElement> array; |
|
209 CleanupClosePushL( array ); |
|
210 if( messagePolicy ) |
|
211 { |
|
212 array.Append(messagePolicy); |
|
213 } |
|
214 CSenElement* portTypePolicy = GetPortTypeOperationInputOutputPolicyL(aService, aPortName, aOpName, ETrue); |
|
215 if( portTypePolicy ) |
|
216 { |
|
217 array.Append(portTypePolicy); |
|
218 } |
|
219 CSenElement* bindingPolicy = GetBindingOperationInputOutputPolicyL(aService, aPortName, aOpName, ETrue); |
|
220 if( bindingPolicy ) |
|
221 { |
|
222 array.Append(bindingPolicy); |
|
223 } |
|
224 // (!) Merge these policies to get effective one: |
|
225 GetEffectivePolicyL(array, iRegistry); |
|
226 CleanupStack::PopAndDestroy( &array ); // array.Close(); |
|
227 //CSenElement* policy = NULL; |
|
228 //return policy; |
|
229 return NULL; |
|
230 } |
|
231 |
|
232 EXPORT_C CSenElement* CWsdlPolicyAttachment::GetEffectiveOutputPolicyL(const TDesC8& aService, const TDesC8& aPortName, const TDesC8& aOpName) |
|
233 { |
|
234 // wsdl:message |
|
235 // wsdl:portType/wsdl:operation/wsdl:output |
|
236 // wsdl:binding/wsdl:operation/wsdl:output |
|
237 CSenElement* messagePolicy = GetMessagePolicyL(aService, aPortName, aOpName, EFalse); |
|
238 RPointerArray<CSenElement> array; |
|
239 if( messagePolicy ) |
|
240 { |
|
241 array.Append(messagePolicy); |
|
242 } |
|
243 CSenElement* portTypePolicy = GetPortTypeOperationInputOutputPolicyL(aService, aPortName, aOpName, EFalse); |
|
244 if( portTypePolicy ) |
|
245 { |
|
246 array.Append(portTypePolicy); |
|
247 } |
|
248 CSenElement* bindingPolicy = GetBindingOperationInputOutputPolicyL(aService, aPortName, aOpName, EFalse); |
|
249 if( bindingPolicy ) |
|
250 { |
|
251 array.Append(bindingPolicy); |
|
252 } |
|
253 // (!) Merge these policies to get effective one: |
|
254 GetEffectivePolicyL( array, iRegistry ); |
|
255 CleanupStack::PopAndDestroy( &array ); // array.Close(); |
|
256 // CSenElement* policy = NULL; |
|
257 // return policy; |
|
258 return NULL; |
|
259 } |
|
260 |
|
261 EXPORT_C CSenElement* CWsdlPolicyAttachment::GetEffectiveFaultPolicyL( /*QName aService, */ |
|
262 const TDesC8& /*aPortName*/, |
|
263 const TDesC8& /*aOpName*/ ) |
|
264 { |
|
265 |
|
266 // wsdl:message |
|
267 // wsdl:portType/wsdl:operation/wsdl:fault |
|
268 // wsdl:binding/wsdl:operation/wsdl:fault |
|
269 return NULL; |
|
270 } |
|
271 |
|
272 //////////////////////////////////////////////////////////////////////// |
|
273 //PRIVATE FUNCTIONS |
|
274 //////////////////////////////////////////////////////////////////////// |
|
275 //////////////////////////////////////////////////////////////////////// |
|
276 CSenElement* CWsdlPolicyAttachment::GetServicePolicyL( const TDesC8& aServiceName ) |
|
277 { |
|
278 // RPointerArray<CSenElement>& list = iPolicy->ElementsL(); //get the definitions elements |
|
279 // TInt count = list.Count(); |
|
280 // for(TInt i = 0; i< count; i++) |
|
281 // { |
|
282 // CSenElement* definitions = list[i]; |
|
283 // TPtrC8 localName = definitions->LocalName(); |
|
284 |
|
285 RPointerArray<CSenElement> serviceList; // get the wsdl:service |
|
286 iPolicy->ElementsL(serviceList, KService); //KWsdlNsUri, KService); |
|
287 CleanupClosePushL( serviceList ); |
|
288 TInt count2 = serviceList.Count(); |
|
289 for( TInt j = 0; j< count2; j++ ) |
|
290 { |
|
291 CSenElement* service = serviceList[j]; |
|
292 |
|
293 TPtrC8 localServiceName = service->LocalName(); |
|
294 |
|
295 TPtrC8 serviceName = GetAttributeValueL(KName, service); |
|
296 if(serviceName != KNullDesC8()) |
|
297 { |
|
298 if (serviceName.Compare(aServiceName) == 0) |
|
299 { //we have right service tag, search its children for PolicyReference |
|
300 serviceList.Close(); |
|
301 return GetPolicyReferenceL(service); |
|
302 } |
|
303 } |
|
304 } |
|
305 CleanupStack::PopAndDestroy( &serviceList ); // serviceList.Close(); |
|
306 return NULL; |
|
307 } |
|
308 |
|
309 CSenElement* CWsdlPolicyAttachment::GetPortPolicyL(const TDesC8& aServiceName, const TDesC8& aPort) |
|
310 { |
|
311 CSenElement* result = GetServiceElementL(aServiceName); |
|
312 if (result) |
|
313 { |
|
314 result = GetPortElementL(aPort, result); |
|
315 if (result) |
|
316 { |
|
317 return GetPolicyReferenceL(result); |
|
318 } |
|
319 |
|
320 } |
|
321 return NULL; |
|
322 } |
|
323 |
|
324 CSenElement* CWsdlPolicyAttachment::GetPortTypePolicyL( const TDesC8& aServiceName, |
|
325 const TDesC8& aPort ) |
|
326 { |
|
327 //from service get port |
|
328 //from port get binding |
|
329 //from binding get porttype |
|
330 CSenElement* result = GetServiceElementL(aServiceName); |
|
331 if (result) |
|
332 { |
|
333 result = GetPortElementL(aPort, result); |
|
334 if (result) |
|
335 { |
|
336 // get binding from port |
|
337 TPtrC8 bindingQName = GetAttributeValueL(KBinding, result); |
|
338 |
|
339 TPtrC8 bindingPrefix = bindingQName.Left(bindingQName.Find(KColon)); |
|
340 TPtrC8 bindingName = bindingQName.Right(bindingQName.Length() - bindingPrefix.Length()-1); |
|
341 |
|
342 result = GetBindingElementL(bindingName); |
|
343 if(result) |
|
344 { |
|
345 //we got the right binding, now get the portType |
|
346 TPtrC8 portTypeQName = GetAttributeValueL(KType, result); |
|
347 //actually this is buinding type |
|
348 TPtrC8 portTypePrefix = portTypeQName.Left(portTypeQName.Find(KColon)); |
|
349 TPtrC8 portTypeName = portTypeQName.Right(portTypeQName.Length() - portTypePrefix.Length()-1); |
|
350 //here we have port Name |
|
351 //now look for this port type in wsdl |
|
352 result = GetPortTypeElementL(portTypeName); |
|
353 if(result) |
|
354 { |
|
355 return GetPolicyReferenceL(result); |
|
356 } |
|
357 else |
|
358 { |
|
359 return NULL; |
|
360 } |
|
361 } |
|
362 } |
|
363 } |
|
364 return NULL; |
|
365 } |
|
366 |
|
367 CSenElement* CWsdlPolicyAttachment::GetBindingPolicyL( const TDesC8& aServiceName, |
|
368 const TDesC8& aPort ) |
|
369 { |
|
370 //the aBindingName is obtained from the port operation. |
|
371 //so Use that Name and then jsut search for that particualr binding |
|
372 CSenElement* result = GetServiceElementL(aServiceName); |
|
373 if (result) |
|
374 { |
|
375 result = GetPortElementL(aPort, result); |
|
376 if (result) |
|
377 { |
|
378 // get binding from port and |
|
379 TPtrC8 bindingQName = GetAttributeValueL(KBinding, result); |
|
380 |
|
381 TPtrC8 bindingPrefix = bindingQName.Left(bindingQName.Find(KColon)); |
|
382 TPtrC8 bindingName = bindingQName.Right(bindingQName.Length() - bindingPrefix.Length()-1); |
|
383 result = GetBindingElementL(bindingName); |
|
384 if( result ) |
|
385 { |
|
386 //we got the right binding, now get the policy |
|
387 result = GetPolicyReferenceL( result ); |
|
388 //if ( result ) |
|
389 // //we got a policy TAG for the binding |
|
390 // { |
|
391 return result; |
|
392 } |
|
393 } |
|
394 } |
|
395 return NULL; |
|
396 } |
|
397 |
|
398 CSenElement* CWsdlPolicyAttachment::GetPortTypeOperationPolicyL( const TDesC8& aServiceName, const TDesC8& aPort, const TDesC8& aOpName ) |
|
399 { |
|
400 CSenElement* result = GetServiceElementL(aServiceName); |
|
401 if ( result ) |
|
402 { |
|
403 result = GetPortElementL(aPort, result); |
|
404 if ( result ) |
|
405 { |
|
406 // get binding from port and |
|
407 TPtrC8 bindingQName = GetAttributeValueL(KBinding, result); |
|
408 TPtrC8 bindingPrefix = bindingQName.Left(bindingQName.Find(KColon)); |
|
409 TPtrC8 bindingName = bindingQName.Right(bindingQName.Length() - bindingPrefix.Length()-1); |
|
410 result = GetBindingElementL(bindingName); |
|
411 if( result ) |
|
412 { |
|
413 // we got the right binding, now get the portType |
|
414 TPtrC8 portTypeQName = GetAttributeValueL(KType, result); |
|
415 //actually this is buinding type |
|
416 TPtrC8 portTypePrefix = portTypeQName.Left(portTypeQName.Find(KColon)); |
|
417 TPtrC8 portTypeName = portTypeQName.Right(portTypeQName.Length() - portTypePrefix.Length()-1); |
|
418 // here we have port Name |
|
419 // now look for this port type in wsdl |
|
420 result = GetPortTypeElementL( portTypeName ); |
|
421 if( result ) //we got the portType |
|
422 { |
|
423 // now get the operation in this element |
|
424 result = GetOperationPolicyL( aOpName, result ); |
|
425 return result; |
|
426 } |
|
427 } |
|
428 } |
|
429 } |
|
430 return NULL; |
|
431 } |
|
432 |
|
433 CSenElement* CWsdlPolicyAttachment::GetBindingOperationPolicyL( const TDesC8& aServiceName, const TDesC8& aPort, const TDesC8& aOpName ) |
|
434 { |
|
435 CSenElement* result = GetServiceElementL(aServiceName); |
|
436 if ( result ) |
|
437 { |
|
438 result = GetPortElementL(aPort, result); |
|
439 if ( result ) |
|
440 { |
|
441 //get binding from port and |
|
442 TPtrC8 bindingQName = GetAttributeValueL(KBinding, result); |
|
443 TPtrC8 bindingPrefix = bindingQName.Left(bindingQName.Find(KColon)); |
|
444 TPtrC8 bindingName = bindingQName.Right(bindingQName.Length() - bindingPrefix.Length()-1); |
|
445 result = GetBindingElementL(bindingName); |
|
446 if(result) //we got the right binding, |
|
447 // now get the OperationPolicy from this binding |
|
448 { |
|
449 result = GetOperationPolicyL(aOpName, result); |
|
450 return result; |
|
451 } |
|
452 } |
|
453 } |
|
454 return NULL; |
|
455 } |
|
456 |
|
457 CSenElement* CWsdlPolicyAttachment::GetOperationPolicyL( const TDesC8& aOpName, |
|
458 CSenElement* aElement ) |
|
459 { |
|
460 RPointerArray<CSenElement> operationList; |
|
461 aElement->ElementsL(operationList, KWsdlNsUri, KOperation); |
|
462 CleanupClosePushL( operationList ); |
|
463 TInt count = operationList.Count(); |
|
464 CSenElement* result = NULL; |
|
465 for(TInt i = 0; i< count; i++) |
|
466 { |
|
467 CSenElement* operation = operationList[i]; |
|
468 TPtrC8 operationName = GetAttributeValueL(KName, operation); |
|
469 if(operationName.Compare(aOpName) == 0) |
|
470 { |
|
471 //we got the rigth operation element |
|
472 //now retrieve policy from this element |
|
473 result = GetPolicyReferenceL(operation); |
|
474 //if( result ) |
|
475 // { |
|
476 // //we got a policy TAG for the binding |
|
477 // |
|
478 // } |
|
479 } |
|
480 } |
|
481 CleanupStack::PopAndDestroy( &operationList ); // operationList.Close(); |
|
482 return result; |
|
483 } |
|
484 |
|
485 CSenElement* CWsdlPolicyAttachment::GetMessagePolicyL( const TDesC8& aServiceName, |
|
486 const TDesC8& aPort, |
|
487 const TDesC8& aOpName, TBool aInput ) |
|
488 { |
|
489 CSenElement* result = GetServiceElementL(aServiceName); |
|
490 if ( result ) |
|
491 { |
|
492 result = GetPortElementL(aPort, result); |
|
493 if ( result ) |
|
494 { |
|
495 //get binding from port and |
|
496 TPtrC8 bindingQName = GetAttributeValueL(KBinding, result); |
|
497 TPtrC8 bindingPrefix = bindingQName.Left(bindingQName.Find(KColon)); |
|
498 TPtrC8 bindingName = bindingQName.Right(bindingQName.Length() - bindingPrefix.Length()-1); |
|
499 result = GetBindingElementL(bindingName); |
|
500 if( result ) |
|
501 { |
|
502 // we got the right binding, now get the Operation from this binding |
|
503 // if aInput == ETrue then its Input policy else its output policy |
|
504 // we get binding now find the input/output for that aOpName |
|
505 RPointerArray<CSenElement> operationList; |
|
506 result->ElementsL(operationList, KWsdlNsUri, KOperation); |
|
507 CleanupClosePushL(operationList); |
|
508 TInt count = operationList.Count(); |
|
509 for(TInt i = 0; i< count; i++) |
|
510 { |
|
511 CSenElement* operation = operationList[i]; |
|
512 TPtrC8 operationName = GetAttributeValueL(KName, operation); |
|
513 if(operationName.Compare(aOpName) == 0) |
|
514 { |
|
515 //we got the rigth operation element |
|
516 //now retrieve input/output element |
|
517 RPointerArray<CSenElement> operationInOutList; |
|
518 CleanupClosePushL(operationInOutList); |
|
519 if(aInput) |
|
520 { |
|
521 operation->ElementsL(operationInOutList, KWsdlNsUri, KInput); |
|
522 } |
|
523 else |
|
524 { |
|
525 operation->ElementsL(operationInOutList, KWsdlNsUri, KOutput); |
|
526 } |
|
527 TInt operationListCount = operationInOutList.Count(); |
|
528 for( TInt j = 0; j< operationListCount; j++ ) |
|
529 { |
|
530 //should be only one, no more then one input. |
|
531 //if there are more, then weired but the fucntion |
|
532 //will return on first instance of input/output |
|
533 |
|
534 CSenElement* inputoutput = operationInOutList[j]; |
|
535 //get the message attribute of this input/output operation |
|
536 if(inputoutput) |
|
537 { |
|
538 TPtrC8 messageName = GetAttributeValueL(KMessage, inputoutput); |
|
539 if(messageName != KNullDesC8()) |
|
540 { |
|
541 |
|
542 // if Qname then retrieve the name from Qname |
|
543 |
|
544 CSenElement* result = GetMessageElementL(messageName); |
|
545 if( result ) |
|
546 { |
|
547 result = GetPolicyReferenceL(result); |
|
548 CleanupStack::PopAndDestroy(&operationInOutList); |
|
549 CleanupStack::PopAndDestroy(&operationList); |
|
550 return result; |
|
551 } |
|
552 else |
|
553 { |
|
554 CleanupStack::PopAndDestroy(&operationInOutList); |
|
555 CleanupStack::PopAndDestroy(&operationList); |
|
556 return NULL; |
|
557 } |
|
558 } |
|
559 } |
|
560 } |
|
561 CleanupStack::PopAndDestroy(&operationInOutList); |
|
562 } |
|
563 } |
|
564 CleanupStack::PopAndDestroy(&operationList); |
|
565 } |
|
566 } |
|
567 } |
|
568 return NULL; |
|
569 } |
|
570 |
|
571 |
|
572 CSenElement* CWsdlPolicyAttachment::GetPortTypeOperationInputOutputPolicyL(const TDesC8& aServiceName, const TDesC8& aPort, const TDesC8& aOpName, TBool aInput) |
|
573 { |
|
574 CSenElement* result = GetServiceElementL(aServiceName); |
|
575 if (result) |
|
576 { |
|
577 result = GetPortElementL(aPort, result); |
|
578 if (result) |
|
579 { |
|
580 // get binding from port and |
|
581 TPtrC8 bindingQName = GetAttributeValueL(KBinding, result); |
|
582 TPtrC8 bindingPrefix = bindingQName.Left(bindingQName.Find(KColon)); |
|
583 TPtrC8 bindingName = bindingQName.Right(bindingQName.Length() - bindingPrefix.Length()-1); |
|
584 result = GetBindingElementL( bindingName ); |
|
585 if( result ) |
|
586 { |
|
587 // we got the right binding, now get the portType |
|
588 TPtrC8 portTypeQName = GetAttributeValueL(KType, result); |
|
589 // actually this is buinding type |
|
590 TPtrC8 portTypePrefix = portTypeQName.Left(portTypeQName.Find(KColon)); |
|
591 TPtrC8 portTypeName = portTypeQName.Right(portTypeQName.Length() - portTypePrefix.Length()-1); |
|
592 //here we have port Name |
|
593 //now look for this port type in wsdl |
|
594 result = GetPortTypeElementL(portTypeName); |
|
595 if( result ) //we got the portType |
|
596 { |
|
597 // now get the operation input output policy from this element |
|
598 return GetOperationInputOutputPolicyL(aOpName, result, aInput); |
|
599 } |
|
600 else |
|
601 { |
|
602 return NULL; |
|
603 } |
|
604 } |
|
605 } |
|
606 } |
|
607 return NULL; |
|
608 } |
|
609 |
|
610 CSenElement* CWsdlPolicyAttachment::GetBindingOperationInputOutputPolicyL(const TDesC8& aServiceName, const TDesC8& aPort, const TDesC8& aOpName, TBool aInput) |
|
611 { |
|
612 CSenElement* result = GetServiceElementL(aServiceName); |
|
613 if (result) |
|
614 { |
|
615 result = GetPortElementL(aPort, result); |
|
616 if (result) |
|
617 { |
|
618 // get binding from port and |
|
619 TPtrC8 bindingQName = GetAttributeValueL(KBinding, result); |
|
620 |
|
621 TPtrC8 bindingPrefix = bindingQName.Left(bindingQName.Find(KColon)); |
|
622 TPtrC8 bindingName = bindingQName.Right(bindingQName.Length() - bindingPrefix.Length()-1); |
|
623 |
|
624 result = GetBindingElementL(bindingName); |
|
625 if(result) //we got the right binding, |
|
626 |
|
627 { |
|
628 // now get the Operation from this binding |
|
629 // if aInput == ETrue then its Input policy else its output policy |
|
630 |
|
631 result = GetOperationInputOutputPolicyL(aOpName, result, aInput); |
|
632 if(result) |
|
633 { |
|
634 return result; |
|
635 } |
|
636 else |
|
637 { |
|
638 return NULL; |
|
639 } |
|
640 } |
|
641 } |
|
642 } |
|
643 return NULL; |
|
644 } |
|
645 |
|
646 CSenElement* CWsdlPolicyAttachment::GetOperationInputOutputPolicyL(const TDesC8& aOpName, CSenElement* aElement, TBool aInput) |
|
647 { |
|
648 RPointerArray<CSenElement> operationList; |
|
649 aElement->ElementsL( operationList, KWsdlNsUri, KOperation ); |
|
650 CleanupClosePushL( operationList ); |
|
651 TInt count = operationList.Count(); |
|
652 for( TInt i = 0; i< count; i++ ) |
|
653 { |
|
654 CSenElement* operation = operationList[i]; |
|
655 TPtrC8 operationName = GetAttributeValueL(KName, operation); |
|
656 if(operationName.Compare(aOpName) == 0) |
|
657 { |
|
658 // we got the rigth operation element |
|
659 // now retrieve input/output element |
|
660 RPointerArray<CSenElement> operationInOutList; |
|
661 if(aInput) |
|
662 operation->ElementsL(operationInOutList, KWsdlNsUri, KInput); |
|
663 else |
|
664 operation->ElementsL(operationInOutList, KWsdlNsUri, KOutput); |
|
665 |
|
666 CleanupClosePushL(operationInOutList); |
|
667 TInt operationInOutListCount = operationInOutList.Count(); |
|
668 for(TInt j = 0; j< operationInOutListCount; j++) |
|
669 { |
|
670 //should be only one, no more then one input. |
|
671 //if there are then weired but the fucntion will return on first instance of input/output |
|
672 CSenElement* inputoutput = operationInOutList[j]; |
|
673 if(inputoutput) |
|
674 { |
|
675 CleanupStack::PopAndDestroy(&operationInOutList); |
|
676 CleanupStack::PopAndDestroy(&operationList); |
|
677 return GetPolicyReferenceL(inputoutput); |
|
678 } |
|
679 else |
|
680 { |
|
681 CleanupStack::PopAndDestroy(&operationInOutList); |
|
682 CleanupStack::PopAndDestroy(&operationList); |
|
683 return NULL; |
|
684 } |
|
685 } |
|
686 CleanupStack::PopAndDestroy(&operationInOutList); |
|
687 } |
|
688 } |
|
689 CleanupStack::PopAndDestroy(&operationList); |
|
690 return NULL; |
|
691 } |
|
692 |
|
693 CSenElement* CWsdlPolicyAttachment::GetPolicyReferenceL(CSenElement* aElement) |
|
694 { |
|
695 RPointerArray<CSenElement> policyRef; //find the policyReference from input child aElement |
|
696 aElement->ElementsL(policyRef, KWspNsUri, KWspPolicyReference); |
|
697 //now we have PolicyReference tag in our PolicyRef List |
|
698 //get its URI and get teh hell out of here |
|
699 CleanupClosePushL(policyRef); |
|
700 //there shud be only ONE count here otherwise seems to me a problem |
|
701 TInt count = policyRef.Count(); |
|
702 for(TInt i = 0; i< count; i++) |
|
703 { |
|
704 CSenElement* policyReference = policyRef[i]; |
|
705 TPtrC8 policyUri = GetAttributeValueL(KUri, policyReference); |
|
706 //may be only uri is enough at the moment. |
|
707 CSenElement* resultPolicy = GetPolicyL(policyUri); |
|
708 if(resultPolicy) //it should exist |
|
709 { |
|
710 CleanupStack::PopAndDestroy(&policyRef); |
|
711 return resultPolicy; |
|
712 } |
|
713 } |
|
714 CleanupStack::PopAndDestroy(&policyRef); |
|
715 return NULL; |
|
716 } |
|
717 |
|
718 CSenElement* CWsdlPolicyAttachment::GetPolicyL(const TDesC8& aUri) |
|
719 { |
|
720 //only take an input URI and return corresponding policy Element from wsdl file |
|
721 if(aUri.Length() < 1) |
|
722 return NULL; |
|
723 |
|
724 TPtrC8 reqPolicy = aUri.Right(aUri.Length()-1); |
|
725 |
|
726 RPointerArray<CSenElement> policyList; //get the wsp:policy elements |
|
727 iPolicy->ElementsL(policyList, KWspNsUri, KPolicy); |
|
728 CleanupClosePushL(policyList); |
|
729 TInt policyListcount = policyList.Count(); |
|
730 |
|
731 CSenElement* requiredPolicy; |
|
732 for (TInt j = 0; j< policyListcount; j++) |
|
733 { |
|
734 requiredPolicy = policyList[j]; |
|
735 if(requiredPolicy) |
|
736 { |
|
737 TPtrC8 policyId = GetAttributeValueL(KWsuId, requiredPolicy); |
|
738 if(policyId.Compare(reqPolicy) == 0) |
|
739 { |
|
740 CleanupStack::PopAndDestroy(&policyList); |
|
741 return requiredPolicy; |
|
742 } |
|
743 } |
|
744 } |
|
745 CleanupStack::PopAndDestroy(&policyList); |
|
746 return NULL; |
|
747 } |
|
748 |
|
749 CSenElement* CWsdlPolicyAttachment::GetServiceElementL(const TDesC8& aServiceName) |
|
750 { |
|
751 return GetElementL(aServiceName, KService); |
|
752 } |
|
753 |
|
754 CSenElement* CWsdlPolicyAttachment::GetPortElementL(const TDesC8& aPortName, CSenElement* aElement) |
|
755 { |
|
756 return GetElementL(aPortName, KPort, aElement); |
|
757 } |
|
758 |
|
759 CSenElement* CWsdlPolicyAttachment::GetPortTypeElementL(const TDesC8& aPortTypeName) |
|
760 { |
|
761 return GetElementL(aPortTypeName, KPortType); |
|
762 } |
|
763 |
|
764 CSenElement* CWsdlPolicyAttachment::GetBindingElementL(const TDesC8& aBindingName) |
|
765 { |
|
766 return GetElementL(aBindingName, KBinding); |
|
767 } |
|
768 |
|
769 CSenElement* CWsdlPolicyAttachment::GetMessageElementL(const TDesC8& aMessageName) |
|
770 { |
|
771 return GetElementL(aMessageName, KMessage); |
|
772 } |
|
773 |
|
774 CSenElement* CWsdlPolicyAttachment::GetElementL(const TDesC8& aName, const TDesC8& aType) |
|
775 { |
|
776 RPointerArray<CSenElement> list; |
|
777 //get the wsdl:definitions child elements with aType name |
|
778 iPolicy->ElementsL(list, KWsdlNsUri, aType); |
|
779 CleanupClosePushL(list); |
|
780 TInt count = list.Count(); |
|
781 CSenElement* ele = NULL; |
|
782 for (TInt j = 0; j< count; j++) |
|
783 { |
|
784 ele = list[j]; |
|
785 TPtrC8 localName = ele->LocalName(); |
|
786 TPtrC8 name = GetAttributeValueL(KName, ele); |
|
787 if(name.Compare(aName) == 0) //We got the right name |
|
788 { |
|
789 CleanupStack::PopAndDestroy(&list); |
|
790 return ele; |
|
791 } |
|
792 ele = NULL; |
|
793 } |
|
794 CleanupStack::PopAndDestroy(&list); |
|
795 return NULL; |
|
796 } |
|
797 |
|
798 CSenElement* CWsdlPolicyAttachment::GetElementL(const TDesC8& aName, const TDesC8& aType, CSenElement* aElement) |
|
799 { |
|
800 RPointerArray<CSenElement> list; //get the wsdl:definitions child elements with aType name |
|
801 aElement->ElementsL(list, KWsdlNsUri, aType); |
|
802 CleanupClosePushL(list); |
|
803 |
|
804 TInt count = list.Count(); |
|
805 CSenElement* ele = NULL; |
|
806 for (TInt j = 0; j< count; j++) |
|
807 { |
|
808 ele = list[j]; |
|
809 TPtrC8 localName = ele->LocalName(); |
|
810 |
|
811 TPtrC8 name = GetAttributeValueL(KName, ele); |
|
812 if(name.Compare(aName) == 0) //We got the right name |
|
813 { |
|
814 CleanupStack::PopAndDestroy(&list); |
|
815 return ele; |
|
816 } |
|
817 ele = NULL; |
|
818 } |
|
819 CleanupStack::PopAndDestroy(&list); |
|
820 return NULL; |
|
821 } |
|
822 |
|
823 CWSPolicy* CWsdlPolicyAttachment::GetPolicyToSenL(CPolicyAssertion* aPolicy) |
|
824 { |
|
825 _LIT8(KN, "name"); |
|
826 TPtrC8 nimi(KN); |
|
827 CWSPolicyWriter* iWriter = CWSPolicyWriter::NewLC(); |
|
828 CWSPolicy* policy = NULL; |
|
829 if(aPolicy) |
|
830 { |
|
831 CBufFlat *pBuf = CBufFlat::NewL(128); |
|
832 CleanupStack::PushL(pBuf); |
|
833 TPtrC8 p = iWriter->WriteToBufL(*pBuf, aPolicy); |
|
834 policy = CWSPolicy::NewL(nimi, p); |
|
835 if(policy) |
|
836 policy->NormalizePolicyL(NULL); |
|
837 |
|
838 CleanupStack::PopAndDestroy(pBuf); |
|
839 } |
|
840 CleanupStack::PopAndDestroy(iWriter); |
|
841 return policy; |
|
842 } |
|
843 |
|
844 CPolicyAssertion* CWsdlPolicyAttachment::GetSenToPolicyL(CSenElement* aPolicy, CPolicyRegistry* aReg) |
|
845 { |
|
846 CWSPolicyReader* iReader = CWSPolicyReader::NewLC(); |
|
847 CPolicyAssertion* policyTerm = iReader->GetPolicyL(aPolicy); |
|
848 CPolicyAssertion* policy = NULL; |
|
849 if(policyTerm) |
|
850 { |
|
851 CleanupStack::PushL(policyTerm); |
|
852 policy = (CPolicyAssertion*)policyTerm->NormalizeL(aReg); |
|
853 CleanupStack::PopAndDestroy(policyTerm); |
|
854 } |
|
855 CleanupStack::PopAndDestroy(iReader); |
|
856 return policy; |
|
857 } |
|
858 |
|
859 CWSPolicy* CWsdlPolicyAttachment::GetEffectivePolicyL(RPointerArray<CSenElement>& aPolicyArray, CPolicyRegistry* aReg) |
|
860 { |
|
861 TInt count = aPolicyArray.Count(); |
|
862 |
|
863 |
|
864 CPolicyAssertion* policyTerm = NULL; |
|
865 CPolicyAssertion* policyTerm2 = NULL; |
|
866 CSenElement* policy = NULL; |
|
867 |
|
868 for(TInt i = 0; i< count; i++) |
|
869 { |
|
870 policy = aPolicyArray[i]; |
|
871 if(policy && policy->LocalName().Compare(WSPolicy::KWsPolicy) == 0) |
|
872 { |
|
873 policyTerm2 = GetSenToPolicyL(policy, aReg); |
|
874 |
|
875 if(policyTerm == NULL) |
|
876 { |
|
877 policyTerm = policyTerm2; |
|
878 } |
|
879 else |
|
880 { |
|
881 CleanupStack::PushL(policyTerm); |
|
882 CleanupStack::PushL(policyTerm2); |
|
883 CPolicyAssertion* temp = (CPolicyAssertion*)policyTerm->MergeL(policyTerm2, NULL); |
|
884 CleanupStack::PopAndDestroy(policyTerm2); |
|
885 CleanupStack::PopAndDestroy(policyTerm); |
|
886 policyTerm = temp; |
|
887 } |
|
888 } |
|
889 } |
|
890 |
|
891 if (policyTerm && !policyTerm->IsNormalized()) |
|
892 { |
|
893 CleanupStack::PushL(policyTerm); |
|
894 CPolicyAssertion* temp = (CPolicyAssertion*) policyTerm->NormalizeL(); |
|
895 CleanupStack::PopAndDestroy(policyTerm); |
|
896 policyTerm = temp; |
|
897 } |
|
898 return GetPolicyToSenL(policyTerm); |
|
899 } |
|
900 |
|
901 CSenElement* CWsdlPolicyAttachment::GetEffectivePolicyL(const TDesC8& /*aUri*/) |
|
902 { |
|
903 // will be a merged from all policies |
|
904 // input should be array of URIs or array of CSenElement*::PolicyElements |
|
905 return NULL; |
|
906 } |
|
907 |
|
908 // END OF FILE |
|
909 |
|
910 |