vpnengine/vpnmanager/src/policypatcher.cpp
branchRCL_3
changeset 44 735de8341ce4
parent 2 ef893827b4d1
equal deleted inserted replaced
41:e06095241a65 44:735de8341ce4
     1 /*
     1 /*
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:   Policy importer
    14 * Description:  Policy importer
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
       
    19 
       
    20 #include "policypatcher.h"
    18 #include "policypatcher.h"
    21 #include "vpnapidefs.h"
    19 #include "vpnapidefs.h"
       
    20 #include "pkidefs.h"
    22 
    21 
    23 
    22 
    24 TAny* TPatchKeyArrayPtr::At(TInt aIndex) const
    23 TAny* TPatchKeyArrayPtr::At(TInt aIndex) const
    25     {
    24     {
    26     if (aIndex==KIndexPtr)
    25     if (aIndex==KIndexPtr)
   312 
   311 
   313 TInt CPolicyPatchInfo::UserCertKeyLen() const
   312 TInt CPolicyPatchInfo::UserCertKeyLen() const
   314     {
   313     {
   315     return iUserCertKeyLen;
   314     return iUserCertKeyLen;
   316     }
   315     }
   317     
   316 
   318 HBufC8* CPolicyPatchInfo::CheckSubjectNameSyntaxL(const TDesC8& aSubj)
   317 HBufC8* CPolicyPatchInfo::CheckSubjectNameSyntaxL(const TDesC8& aSubj)
   319     {
   318     {
   320     const TInt KMaxSubjectItems = 20;
   319     const TInt KMaxSubjectItems = 20;
   321     
   320     
   322     _LIT8(KEqualSign, "=");
   321     _LIT8(KEqualSign, "=");
   406             updateArr->AppendL(subjLth);
   405             updateArr->AppendL(subjLth);
   407             
   406             
   408             updateArrCount++;
   407             updateArrCount++;
   409             updateArrCount++;
   408             updateArrCount++;
   410             }
   409             }
   411        
   410 
   412        TBuf8<256> resultBuf;
   411        HBufC8* buf  = HBufC8::NewLC( KMaxX500DN );
   413        resultBuf.Copy(aSubj);
   412        TPtr8 bufPtr = buf->Des();
   414        
   413 
   415        i=0;       
   414        if ( KMaxX500DN >= aSubj.Length() )
   416        
   415            {
       
   416            bufPtr.Copy( aSubj );
       
   417            }
       
   418        else
       
   419            {
       
   420            User::Leave( KErrArgument );
       
   421            }
       
   422 
       
   423        i=0;
       
   424 
   417        //update subjectname acoording to updateArr array.
   425        //update subjectname acoording to updateArr array.
   418        if ( updateArr->Count()>0 )
   426        if ( updateArr->Count()>0 )
   419            {
   427            {
   420            while (i<updateArrCount)
   428            while (i<updateArrCount)
   421                {
   429                {
   422                if ( resultBuf.Length()<256 )
   430                if ( bufPtr.Length()<KMaxX500DN )
   423                    resultBuf.Insert(updateArr->At(i) + i, KReplacementChar);
   431                    bufPtr.Insert(updateArr->At(i) + i, KReplacementChar);
   424                else
   432                else
   425                    User::Leave(KErrNotSupported);
   433                    User::Leave(KErrNotSupported);
   426                i++;
   434                i++;
   427                }
   435                }
   428            }
   436            }
   429        
   437        
   430        CleanupStack::Pop(updateArr);
   438        CleanupStack::Pop( buf );
   431        CleanupStack::Pop(commaSignArr);
   439 
   432        CleanupStack::Pop(equalSignArr);
   440        CleanupStack::PopAndDestroy(updateArr);
       
   441        CleanupStack::PopAndDestroy(commaSignArr);
       
   442        CleanupStack::PopAndDestroy(equalSignArr);
   433        
   443        
   434        delete equalSignArr;
   444        return buf;
   435        equalSignArr=NULL;
       
   436        
       
   437        delete commaSignArr;
       
   438        commaSignArr=NULL;
       
   439        
       
   440        delete updateArr;
       
   441        updateArr=NULL;
       
   442        
       
   443        HBufC8* resultHeap = resultBuf.AllocL();
       
   444        
       
   445        return resultHeap;
       
   446     }
   445     }
   447 
   446 
   448 
   447 
   449 // CPolicyPatchInfoList
   448 // CPolicyPatchInfoList
   450 
   449