webservices/wsstar/wsstarplugin/src/wsstarpolicy.cpp
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:           
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 // INCLUDE FILES
       
    29 #include "wsstarpolicy.h"
       
    30 #include "wsstarpolicyhandler.h" 
       
    31 #include "wsstarcons.h"
       
    32 
       
    33 namespace
       
    34 {   
       
    35     _LIT8(KServicePolicyLocalName, "ServicePolicy");
       
    36     _LIT8(KClientServicePolicyLocalName, "ClientPolicy");
       
    37     _LIT8(KSenNsUri, "urn:com.nokia.Sen.config.1.0");
       
    38     
       
    39     _LIT8(KHeader, "Header");
       
    40     _LIT8(KBody, "Body");
       
    41     _LIT8(KNamespace, "Namespace");
       
    42 }
       
    43 /*
       
    44 
       
    45 CWSStarPolicy* CWSStarPolicy::NewL()
       
    46 {
       
    47     CWSStarPolicy* pSelf =
       
    48     CWSStarPolicy::NewLC();
       
    49     CleanupStack::Pop(pSelf);
       
    50     return pSelf;   
       
    51 }
       
    52 CWSStarPolicy* CWSStarPolicy::NewLC()
       
    53 {
       
    54     CWSStarPolicy* pSelf =
       
    55     new (ELeave) CWSStarPolicy();
       
    56     CleanupStack::PushL(pSelf);
       
    57     pSelf->ConstructL();
       
    58     return pSelf; 
       
    59 }
       
    60 CWSStarPolicy::~CWSStarPolicy()
       
    61 {
       
    62     
       
    63 }
       
    64 CWSStarPolicy::CWSStarPolicy()
       
    65 {
       
    66     
       
    67 }
       
    68 void CWSStarPolicy::ConstructL()
       
    69 {
       
    70 }
       
    71 
       
    72 
       
    73 void CWSStarPolicy::SetPolicy(CSenElement* aPolicy)
       
    74 {
       
    75 }
       
    76 
       
    77 */
       
    78 CSenElement* CWSStarPolicy::GetPolicyL(MSenHandlerContext& aCtx, MSenServiceDescription* aSD)	//codescannerwarnings
       
    79 {
       
    80 
       
    81     CWSStarPlugin* SIF = (CWSStarPlugin*)aCtx.GetAnyL(HandlerContextKey::KSIF());//codescannerwarnings
       
    82     if(SIF)
       
    83     {
       
    84         CSenSessionHandler* pPolicyHandler =  (CSenSessionHandler*)SIF->Handler(WSStarConfig::KPolicyValue);
       
    85         if(pPolicyHandler)
       
    86         {
       
    87             CWSStarPolicyHandler* pHandler = (CWSStarPolicyHandler*)pPolicyHandler;
       
    88             if( pHandler )
       
    89             {
       
    90                 TPtrC8 contract(KWSStarSTSContract());
       
    91                 return pHandler->PolicyL(aSD);	//codescannerwarnings
       
    92             }
       
    93         }
       
    94     }
       
    95     return NULL;
       
    96 }
       
    97 
       
    98 TPtrC8 CWSStarPolicy::GetAttributeValueL(const TDesC8& aAttribute, CSenElement* aElement)
       
    99 {
       
   100     RPointerArray<CSenBaseAttribute>& attrs = aElement->AttributesL();
       
   101     
       
   102     CSenBaseAttribute* bs = NULL;
       
   103     TInt ele_count = attrs.Count();
       
   104          
       
   105     for (TInt j=0; j < ele_count; j++)
       
   106         {
       
   107             
       
   108         bs = (attrs)[j];
       
   109         if(bs)
       
   110 
       
   111         if(bs->Name().Compare(aAttribute) == 0)
       
   112             {
       
   113              return bs->Value();
       
   114             }
       
   115          }
       
   116     return KNullDesC8();
       
   117 }
       
   118 
       
   119 TPtrC8 CWSStarPolicy::GetNSPrefixL(const TDesC8& aNamespaceUri, CSenElement* aElement)
       
   120 {
       
   121     RPointerArray<CSenNamespace> sourceNamespaces = aElement->NamespacesL();
       
   122     if (sourceNamespaces.Count() > 0)
       
   123     {
       
   124         for (TInt i=0;i<sourceNamespaces.Count(); i++)
       
   125         {
       
   126             CSenNamespace* pNamespace = sourceNamespaces[i];
       
   127             if(pNamespace->URI().Compare(aNamespaceUri) == 0)
       
   128             {
       
   129                 return pNamespace->Prefix();
       
   130             }
       
   131         }
       
   132     }
       
   133     
       
   134     return KNullDesC8();        
       
   135 }
       
   136 TInt CWSStarPolicy::ChildCountL(CSenElement* aTerm)	//codescannerwarnings
       
   137 {
       
   138     RPointerArray<CSenElement>& children = aTerm->ElementsL();
       
   139     
       
   140     TInt childCount = children.Count();
       
   141     return childCount;
       
   142     
       
   143 }
       
   144 TBool CWSStarPolicy::CheckPolicyValueL(const TDesC8& aKey, MSenServiceDescription* aSD)
       
   145     {
       
   146 
       
   147     CSenWSDescription* pSD = (CSenWSDescription*)aSD;
       
   148 //    CSenElement* pServicePolicy = pSD->AsElement().Element(KServicePolicyLocalName);
       
   149     MSenServicePolicy* pServicePolicy = pSD->ServicePolicy(); 
       
   150     // Cant be possible :p
       
   151     if(!pServicePolicy)
       
   152         return EFalse;
       
   153    
       
   154 //    CSenElement* pClientPolicy = pServicePolicy->Element(KClientServicePolicyLocalName);
       
   155     CSenElement* pClientPolicy = pServicePolicy->ClientPolicy();
       
   156 /*    
       
   157     if(!pClientPolicy)
       
   158         {
       
   159         pClientPolicy = pServicePolicy->Element(KSenNsUri, KClientServicePolicyLocalName);
       
   160         }
       
   161   */	
       
   162     //now start worrying
       
   163     if(!pClientPolicy)
       
   164     return EFalse;
       
   165     
       
   166     if(pClientPolicy)
       
   167     {
       
   168         CSenElement* result = NULL;
       
   169         result = pClientPolicy->Element(aKey);
       
   170         if(result)
       
   171             return ETrue;
       
   172         else
       
   173             return EFalse;
       
   174     }                    
       
   175 
       
   176     return EFalse;
       
   177     }
       
   178 HBufC8* CWSStarPolicy::GetPolicyValueL(const TDesC8& aKey, MSenServiceDescription* aSD)
       
   179     {
       
   180 
       
   181     CSenWSDescription* pSD = (CSenWSDescription*)aSD;
       
   182     CSenElement* pServicePolicy = pSD->AsElement().Element(KServicePolicyLocalName);
       
   183     HBufC8* value = NULL;
       
   184     // Cant be possible :p
       
   185     if(!pServicePolicy)
       
   186         return value;
       
   187     CSenElement* pClientPolicy = pServicePolicy->Element(KClientServicePolicyLocalName);
       
   188     if(!pClientPolicy)
       
   189         {
       
   190         pClientPolicy = pServicePolicy->Element(KSenNsUri, KClientServicePolicyLocalName);
       
   191         }
       
   192     //now start worrying
       
   193     if(!pClientPolicy)
       
   194         return value;
       
   195     
       
   196     if(pClientPolicy)
       
   197     {
       
   198         CSenElement* result = NULL;
       
   199         result = pClientPolicy->Element(aKey);
       
   200         if(result && result->HasContent())
       
   201         {
       
   202             value = result->Content().AllocL();
       
   203         }
       
   204     }
       
   205       return value;
       
   206     }
       
   207 TInt CWSStarPolicy::SearchForElementsL(CSenElement* aPolicy, TPtrC8 aKey, RPointerArray<CSenElement>& aElements)
       
   208 {
       
   209     RPointerArray<CSenElement>& children = aPolicy->ElementsL();
       
   210     TInt count(children.Count());
       
   211     CSenElement* req = NULL;
       
   212     CSenElement* result = NULL;
       
   213     for (TInt i = 0; i < count; i++)
       
   214      {
       
   215         req = children[i];
       
   216         TPtrC8 nimi = req->LocalName();
       
   217         if(nimi.Compare(aKey) == 0)
       
   218         {
       
   219                 result =  req;
       
   220                 aElements.Append(result);
       
   221         }
       
   222 
       
   223         if(!result)
       
   224             SearchForElementsL(req, aKey, aElements);
       
   225 //        if (result)
       
   226 //           break;
       
   227      }
       
   228      
       
   229     return aElements.Count();
       
   230     
       
   231 }
       
   232 CSenElement* CWSStarPolicy::SearchForElementL(CSenElement* aPolicy, TPtrC8 aKey)	//codescannerwarnings
       
   233 {
       
   234 
       
   235     RPointerArray<CSenElement>& children = aPolicy->ElementsL();
       
   236     TInt count(children.Count());
       
   237     CSenElement* req = NULL;
       
   238     CSenElement* result = NULL;
       
   239     for (TInt i = 0; i < count; i++)
       
   240      {
       
   241         req = children[i];
       
   242         TPtrC8 nimi = req->LocalName();
       
   243         if(nimi.Compare(aKey) == 0)
       
   244         {
       
   245                 result =  req;
       
   246         }
       
   247         if(!result)
       
   248             result = SearchForElementL(req, aKey);	//codescannerwarnings
       
   249         if (result)
       
   250            break;
       
   251      }
       
   252      
       
   253     return result;
       
   254 }
       
   255 
       
   256 HBufC8* CWSStarPolicy::GetPolicyValueL(const TDesC8& aKey, const TDesC8& aSubKey, CWSStarPlugin& aWSStarPlugin, MSenServiceDescription* aSD)
       
   257     {
       
   258     HBufC8* result = NULL;
       
   259     CSenElement* policy = NULL;
       
   260     
       
   261     CSenSessionHandler* pPolicyHandler =  (CSenSessionHandler*)(aWSStarPlugin.Handler(WSStarConfig::KPolicyValue()));
       
   262     if(pPolicyHandler)
       
   263     {
       
   264         CWSStarPolicyHandler* phand = (CWSStarPolicyHandler*)pPolicyHandler;
       
   265         if(phand)
       
   266         {
       
   267                 TPtrC8 contract(KWSStarSTSContract());
       
   268                 policy =  phand->PolicyL(aSD); //Policy(aSD);	//codescannerwarnings
       
   269   
       
   270         }
       
   271            
       
   272     }
       
   273     if(policy)
       
   274     {
       
   275         CSenElement* token = SearchForElementL(policy, aKey);	//codescannerwarnings
       
   276         CSenElement* subValue = NULL;
       
   277         if(token)                
       
   278         {
       
   279             if(aSubKey.Length() > 0)
       
   280                 subValue =  SearchForElementL(token, aSubKey);   	//codescannerwarnings
       
   281             else
       
   282                 subValue = token;
       
   283             
       
   284                 if(subValue)
       
   285                 {
       
   286                     if(ChildCountL(subValue) > 0)	//codescannerwarnings
       
   287                         {
       
   288                         //not supprted now
       
   289                         }
       
   290                     if(subValue->HasContent())
       
   291                         {
       
   292                         result = subValue->Content().AllocL();
       
   293                         }
       
   294                 }
       
   295             }
       
   296         }
       
   297     return result;
       
   298     }
       
   299 HBufC8* CWSStarPolicy::GetPolicyValueL(const TDesC8& aKey, const TDesC8& aSubKey, MSenHandlerContext& aCtx, MSenServiceDescription* aSD)
       
   300     {
       
   301     RPointerArray<CSenElement> aElements;
       
   302     return GetPolicyValueL(aKey, aSubKey, aCtx, aSD, aElements);
       
   303     }
       
   304 HBufC8* CWSStarPolicy::GetPolicyValueL(const TDesC8& aTokenType, const TDesC8& aKey, const TDesC8& aSubKey, MSenHandlerContext& aCtx, MSenServiceDescription* aSD)
       
   305     {
       
   306     RPointerArray<CSenElement> aElements;
       
   307     return GetPolicyValueL(aTokenType, aKey, aSubKey, aCtx, aSD, aElements);
       
   308     }
       
   309 HBufC8* CWSStarPolicy::GetPolicyValueL(const TDesC8& aTokenType, const TDesC8& aKey, const TDesC8& aSubKey, MSenHandlerContext& aCtx, MSenServiceDescription* aSD, RPointerArray<CSenElement>& aElements)
       
   310 {
       
   311     HBufC8* result = NULL;
       
   312     CSenElement* policy = GetPolicyL(aCtx, aSD);	//codescannerwarnings
       
   313     if(policy)
       
   314     {
       
   315         RPointerArray<CSenElement> elements;
       
   316         CleanupClosePushL(elements);
       
   317         
       
   318         TInt count = SearchForElementsL(policy, aKey, elements);
       
   319 
       
   320         for (TInt i = 0; i< count; i++)
       
   321             {
       
   322             
       
   323             CSenElement* token = elements[i];
       
   324             CSenElement* ele = SearchForElementL(token, _L8("TokenType"));	//codescannerwarnings
       
   325             if(ele)            
       
   326             {
       
   327                 if(ele->HasContent())
       
   328                 {
       
   329                     TPtrC8 contents = ele->Content();
       
   330                     if(contents == aTokenType)
       
   331                         {
       
   332                         CSenElement* subValue = NULL;
       
   333                         if(token)
       
   334                             {
       
   335                                 if(aSubKey.Length() > 0)
       
   336                                     subValue =  SearchForElementL(token, aSubKey);   	//codescannerwarnings
       
   337                                 else
       
   338                                     subValue = token;
       
   339                                 
       
   340                                     if(subValue)
       
   341                                     {
       
   342                                         if(ChildCountL(subValue) > 0)	//codescannerwarnings
       
   343                                         {
       
   344                                             //                    All of the elements
       
   345                                             aElements =  subValue->ElementsL();
       
   346                                             //OuterXML
       
   347                                             HBufC8* data = subValue->AsXmlL();
       
   348                                             if(data && data->Length() > 0)
       
   349                                             {//parse the tag name and return the child tags only
       
   350                                                 TInt start = data->Locate('>');
       
   351                                                 TInt end = data->LocateReverse('<');
       
   352                                                 if(start+1 < end-1 && start != KErrNotFound && end != KErrNotFound)
       
   353                                                 {
       
   354                                                     TInt length = end-1-start;
       
   355                                                     TPtrC8 dataq(data->Mid(start+1,length));
       
   356                                                     result = HBufC8::NewL(dataq.Length());
       
   357                                                     TPtr8 id16 = result->Des();
       
   358                                                     id16.Copy(dataq); 
       
   359                                                 }
       
   360                                                 
       
   361                                             }
       
   362                                             delete data;
       
   363                                         }
       
   364                                         else if(subValue->HasContent())
       
   365                                         {
       
   366                                             result = subValue->Content().AllocL();
       
   367                                         }
       
   368                                         
       
   369                                     }
       
   370                             }
       
   371                         
       
   372                         
       
   373                         
       
   374                         }
       
   375                 }
       
   376             }
       
   377             
       
   378             }
       
   379         CleanupStack::Pop(&elements);
       
   380         elements.Close();
       
   381     }   
       
   382             
       
   383     return result;
       
   384     
       
   385 }
       
   386 HBufC8* CWSStarPolicy::GetPolicyValueL(const TDesC8& aKey, const TDesC8& aSubKey, MSenHandlerContext& aCtx, MSenServiceDescription* aSD, RPointerArray<CSenElement>& aElements)
       
   387 {
       
   388     HBufC8* result = NULL;
       
   389     CSenElement* policy = GetPolicyL(aCtx, aSD);	//codescannerwarnings
       
   390     if(policy)
       
   391     {
       
   392         CSenElement* token = SearchForElementL(policy, aKey);	//codescannerwarnings
       
   393         CSenElement* subValue = NULL;
       
   394         if(token)                
       
   395         {
       
   396             if(aSubKey.Length() > 0)
       
   397                 subValue =  SearchForElementL(token, aSubKey);   	//codescannerwarnings
       
   398             else
       
   399                 subValue = token;
       
   400             
       
   401                 if(subValue)
       
   402                 {
       
   403                     if(ChildCountL(subValue) > 0)	//codescannerwarnings
       
   404                     {
       
   405                         //                    All of the elements
       
   406                         aElements =  subValue->ElementsL();
       
   407                         //OuterXML
       
   408                         HBufC8* data = subValue->AsXmlL();
       
   409                         if(data && data->Length() > 0)
       
   410                         {//parse the tag name and return the child tags only
       
   411                             TInt start = data->Locate('>');
       
   412                             TInt end = data->LocateReverse('<');
       
   413                             if(start+1 < end-1 && start != KErrNotFound && end != KErrNotFound)
       
   414                             {
       
   415                                 TInt length = end-1-start;
       
   416                                 TPtrC8 dataq(data->Mid(start+1,length));
       
   417                                 result = HBufC8::NewL(dataq.Length());
       
   418                                 TPtr8 id16 = result->Des();
       
   419                                 id16.Copy(dataq); 
       
   420                             }
       
   421                             
       
   422                         }
       
   423                         delete data;
       
   424                     }
       
   425                     else if(subValue->HasContent())
       
   426                     {
       
   427                         result = subValue->Content().AllocL();
       
   428                     }
       
   429                     
       
   430                 }
       
   431         }
       
   432         
       
   433     }   
       
   434             
       
   435     return result;
       
   436 }
       
   437 
       
   438 void CWSStarPolicy::GetPolicyValueL(const TDesC8& aKey, const TDesC8& aSubKey,MSenServiceDescription* aSD,RPointerArray<CSenElement>& aElements)
       
   439     {
       
   440 
       
   441     CSenWSDescription* pSD = (CSenWSDescription*)aSD;
       
   442     CSenElement* pServicePolicy = pSD->AsElement().Element(KServicePolicyLocalName);
       
   443 
       
   444     // Cant be possible :p
       
   445     if(!pServicePolicy)
       
   446         return;
       
   447     CSenElement* pClientPolicy = pServicePolicy->Element(KClientServicePolicyLocalName);
       
   448     if(!pClientPolicy)
       
   449         {
       
   450         pClientPolicy = pServicePolicy->Element(KSenNsUri, KClientServicePolicyLocalName);
       
   451         }
       
   452     //now start worrying
       
   453     if(!pClientPolicy)
       
   454         return;
       
   455     
       
   456     if(pClientPolicy)
       
   457         {
       
   458         CSenElement* resultKey = NULL;
       
   459         resultKey = pClientPolicy->Element(aKey);
       
   460         if(resultKey)
       
   461             {
       
   462             CSenElement* resultSubKey = NULL;
       
   463             resultSubKey = resultKey->Element(aSubKey);
       
   464             
       
   465             if(resultSubKey)
       
   466                 {
       
   467                  aElements = resultSubKey->ElementsL();
       
   468                 
       
   469                      }
       
   470             
       
   471                  } 
       
   472          
       
   473             }
       
   474       return;
       
   475     }
       
   476 void CWSStarPolicy::GetPolicyValueL(const TDesC8& aKey, const TDesC8& aSubKey, MSenHandlerContext& aCtx, MSenServiceDescription* aSD, RPointerArray<HBufC8>& aList)
       
   477     {
       
   478     CSenElement* policy = GetPolicyL(aCtx, aSD);	//codescannerwarnings
       
   479     if (policy)
       
   480         {
       
   481         GetValueL(aKey, aSubKey, policy, aList);
       
   482         }
       
   483     }
       
   484 void CWSStarPolicy::GetPolicyValueL(const TDesC8& aKey, const TDesC8& aSubKey, CWSStarPolicyHandler* aPolicyHandler, MSenServiceDescription* aSD, RPointerArray<HBufC8>& aList)
       
   485     {
       
   486     CSenElement* policy = aPolicyHandler->PolicyL(aSD);	//codescannerwarnings
       
   487     if (policy)
       
   488         {
       
   489         GetValueL(aKey, aSubKey, policy, aList);
       
   490         }
       
   491     /*if (aList.Count() == 0 && aKey == WSPolicy::KSignedParts)
       
   492         {
       
   493         aList.ResetAndDestroy();
       
   494         aList.Append(_L8("MessageID").AllocL());
       
   495         aList.Append(_L8("http://schemas.xmlsoap.org/ws/2004/08/addressing").AllocL());
       
   496         aList.Append(_L8("ReplyTo").AllocL());
       
   497         aList.Append(_L8("http://schemas.xmlsoap.org/ws/2004/08/addressing").AllocL());
       
   498         aList.Append(_L8("To").AllocL());
       
   499         aList.Append(_L8("http://schemas.xmlsoap.org/ws/2004/08/addressing").AllocL());
       
   500         aList.Append(_L8("Action").AllocL());
       
   501         aList.Append(_L8("http://schemas.xmlsoap.org/ws/2004/08/addressing").AllocL());
       
   502         aList.Append(_L8("Timestamp").AllocL());
       
   503         aList.Append(_L8("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd").AllocL());
       
   504         }*/
       
   505     }
       
   506 
       
   507 void CWSStarPolicy::GetValueL(const TDesC8& aKey, const TDesC8& aSubKey, CSenElement* aPolicy, RPointerArray<HBufC8>& aList)
       
   508     {
       
   509     CSenElement* token = SearchForElementL(aPolicy, aKey);	//codescannerwarnings
       
   510     CSenElement* subValue = NULL;
       
   511     if(token)
       
   512     {
       
   513         if(aSubKey.Length() > 0)
       
   514             subValue =  SearchForElementL(token, aSubKey);   	//codescannerwarnings
       
   515         else
       
   516             subValue = token;
       
   517         
       
   518         if(subValue)
       
   519         {
       
   520             if(aKey == WSPolicy::KSignedParts || aSubKey == WSPolicy::KSignedParts)
       
   521             {
       
   522                 CEncryptedSignedPartsI* signedParts = CEncryptedSignedPartsI::NewL(subValue);    
       
   523                 if(signedParts->Header() || signedParts->Body())
       
   524                 {
       
   525                 //return the list of elements to be signed or Enrypted
       
   526                 //If Body element is found in list then whole body should be signed/encrypted
       
   527                 //If Header Element is found then All headers should be signed/encrypted
       
   528                 //If individual elements are found then only those elements 
       
   529                 // in Header should be signed/encrypted
       
   530                     signedParts->ElementsL(aList);	//codescannerwarnings
       
   531                     
       
   532                 }
       
   533                 delete  signedParts;                   
       
   534             }
       
   535         }
       
   536     }
       
   537     }
       
   538 CSenElement* CWSStarPolicy::GetElementL(const TDesC8& aKey, const TDesC8& aSubKey, MSenHandlerContext& aCtx, MSenServiceDescription* aSD)
       
   539 {
       
   540     CSenElement* policy = GetPolicyL(aCtx, aSD);	//codescannerwarnings
       
   541     if(policy)
       
   542     {
       
   543         CSenElement* token = SearchForElementL(policy, aKey);	//codescannerwarnings
       
   544         CSenElement* subValue = NULL;
       
   545         if(token)
       
   546         {
       
   547             if(aSubKey.Length() > 0)
       
   548                 subValue =  SearchForElementL(token, aSubKey);   	//codescannerwarnings
       
   549             else
       
   550                 subValue = token;
       
   551             
       
   552             if(subValue)
       
   553             {
       
   554                 if(aKey == WSPolicy::KDictionaries || aSubKey == WSPolicy::KDictionary)
       
   555                 {
       
   556                 return subValue;
       
   557                 }
       
   558             }
       
   559         }
       
   560         
       
   561     }   
       
   562     return NULL;
       
   563 }
       
   564 
       
   565     
       
   566 ///////////////////////////////////////////////////////////////////////
       
   567 //////    CEncryptedSignedPartsI                                              
       
   568 ///////////////////////////////////////////////////////////////////////
       
   569 CEncryptedSignedPartsI* CEncryptedSignedPartsI::NewL(CSenElement* aAssertion)
       
   570 {
       
   571      CEncryptedSignedPartsI* pSelf = CEncryptedSignedPartsI::NewLC(aAssertion);
       
   572     CleanupStack::Pop(pSelf);
       
   573     return pSelf;  
       
   574 }  
       
   575 
       
   576 CEncryptedSignedPartsI* CEncryptedSignedPartsI::NewLC(CSenElement* aAssertion)
       
   577 {
       
   578   
       
   579     CEncryptedSignedPartsI* pSelf = new (ELeave) CEncryptedSignedPartsI();
       
   580     CleanupStack::PushL(pSelf);
       
   581     pSelf->ConstructL(aAssertion);
       
   582     return pSelf;  
       
   583 }
       
   584 CEncryptedSignedPartsI::~CEncryptedSignedPartsI()
       
   585 {
       
   586     iHeaders.Close();
       
   587 }
       
   588 
       
   589 TBool CEncryptedSignedPartsI::IsEqualEncryptedSignedParts(CEncryptedSignedPartsI* aAssertion)
       
   590 {
       
   591     if(Body() == aAssertion->Body() && Header() == aAssertion->Header())
       
   592     {
       
   593         return ETrue;    
       
   594     }
       
   595     
       
   596     return EFalse;
       
   597 }
       
   598 
       
   599 TBool CEncryptedSignedPartsI::Header()
       
   600 {
       
   601     return iHeader;    
       
   602 }
       
   603 TBool CEncryptedSignedPartsI::Body()
       
   604 {
       
   605     return iBody;
       
   606 }
       
   607 void CEncryptedSignedPartsI::ElementsL(RPointerArray<HBufC8>& aElements)	//codescannerwarnings
       
   608 {
       
   609     if(iBody)
       
   610         {
       
   611         aElements.Append(KBody().AllocL());
       
   612         aElements.Append(KNullDesC8().AllocL());
       
   613         }
       
   614         
       
   615     if(iHeader && iHeaders.Count() == 0)
       
   616     {
       
   617         aElements.Append(KHeader().AllocL());
       
   618     }
       
   619     else if(iHeader && iHeaders.Count() > 0)
       
   620     {
       
   621         for(TInt i = 0; i< iHeaders.Count(); i++)
       
   622         {
       
   623             SoapHeader header(iHeaders[i]);
       
   624             TPtrC8 name(header.iName);
       
   625             if(name != KNullDesC8())
       
   626             {
       
   627                aElements.Append(name.AllocL());
       
   628                aElements.Append(header.iNsUri.AllocL());
       
   629             }
       
   630             
       
   631         }
       
   632     }
       
   633 }
       
   634 void CEncryptedSignedPartsI::ConstructL(CSenElement* aAssertion)
       
   635 {
       
   636 //No need to rip off caz there wont be any policy elements here
       
   637 
       
   638     RPointerArray<CSenElement>& tokenChildren = aAssertion->ElementsL(); //find the policy element
       
   639     
       
   640     if(tokenChildren.Count() < 0)
       
   641     {
       
   642         iHeader = ETrue;
       
   643         iBody = ETrue;
       
   644         return;
       
   645     }
       
   646    
       
   647     CSenElement* child = NULL;
       
   648     SoapHeader header;
       
   649     for (TInt i = 0; i< tokenChildren.Count(); i++) //while (tokenChildren.HasNext()) // Get all the elements
       
   650     { 
       
   651         child = tokenChildren[i];
       
   652 
       
   653         TPtrC8 localName = child->LocalName();
       
   654                 
       
   655         if(localName.Compare(KBody) == 0)
       
   656         {
       
   657            iBody = ETrue;
       
   658         }
       
   659         else if(localName.Compare(KHeader) == 0)
       
   660         {
       
   661             iHeader = ETrue;
       
   662             //get header attributes
       
   663             
       
   664            TPtrC8 headerName = CWSStarPolicy::GetAttributeValueL(WSPolicy::KName, child);            
       
   665            if(headerName != KNullDesC8())
       
   666            {
       
   667 
       
   668                header.iName.Set(headerName);
       
   669            }
       
   670            
       
   671            TPtrC8 nsUri = CWSStarPolicy::GetAttributeValueL(KNamespace, child);            
       
   672            //if(nsUri != KNullDesC8())
       
   673            //{
       
   674            header.iNsUri.Set(nsUri);             
       
   675            //               header.iNsPrefix.Set(CWSStarPolicy::GetNSPrefixL(nsUri, child));
       
   676            //}           
       
   677            iHeaders.Append(header);
       
   678 
       
   679         }
       
   680     }
       
   681 }
       
   682 CEncryptedSignedPartsI::CEncryptedSignedPartsI()
       
   683 :
       
   684     iHeader(EFalse),
       
   685     iBody(EFalse)
       
   686 {
       
   687     
       
   688 }
       
   689 // End of file