diff -r 000000000000 -r 33413c0669b9 vpnengine/vpnmanager/inc/policypatcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vpnengine/vpnmanager/inc/policypatcher.h Thu Dec 17 09:14:51 2009 +0200 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2003-2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Policy importer +* +*/ + + + +#ifndef __POLICYPATCHER_H__ +#define __POLICYPATCHER_H__ + +#include + +_LIT8(KDataField, " DATA:"); // Two preceding spaces just for indentation +_LIT8(KSpace, " "); +_LIT8(KNewLine, "\n"); +_LIT8(KName, "NAME"); +_LIT8(KKeyLenField, "PRIVATE_KEY_LENGTH: "); +_LIT8(KDNField, " SUBJECT_DN_SUFFIX: "); + + +const TChar KBinChar = 'B'; +const TChar KFormatChar = 'F'; + +const TInt KUndefinedOffset = -1; + +class TPatchKeyArrayPtr : public TKeyArrayFix +{ +public: + inline TPatchKeyArrayPtr(TInt aOffset, TKeyCmpText aType) + :TKeyArrayFix(aOffset, aType) {} + inline TPatchKeyArrayPtr(TInt aOffset, TKeyCmpText aType, TInt aLength) + :TKeyArrayFix(aOffset, aType, aLength) {} + inline TPatchKeyArrayPtr(TInt aOffset, TKeyCmpNumeric aType) + :TKeyArrayFix(aOffset, aType) {} + virtual TAny* At(TInt aIndex) const; +}; + + +class CPolicyPatchInfo : public CBase + { +public: + CPolicyPatchInfo(); + ~CPolicyPatchInfo(); + + const TDesC8& CertSubjectName() const; + void SetCertSubjectNameL(const TDesC8& aCertSubjectName); + + /** + * Sets key length (in bits) of user cert. + */ + void SetUserCertKeyLen( TInt aKeyLen ); + + /** + * Gets key length (in bits) of user cert. + */ + TInt UserCertKeyLen() const; + + /** + * Verifies, that subjectname does not include not closed commas inside attributes + */ + HBufC8* CheckSubjectNameSyntaxL(const TDesC8& aSubj); + +public: + TBuf8 iCertFileName; + TInt iPatchOffset; + TInt iReminderOffset; + +private: + HBufC8* iCertSubjectName; + + /** + * Key length (in bits) of user cert. + */ + TInt iUserCertKeyLen; + }; + +class CPolicyPatchInfoList : public CArrayPtrFlat + { +public: + CPolicyPatchInfoList(TInt aGranularity); + ~CPolicyPatchInfoList(); + }; + +class CPatchData : public CBase + { +public: + ~CPatchData(); + +public: + TInt iPatchOffset; + TInt iReminderOffset; + HBufC8* iData; + }; + +class CPatchDataList : public CArrayPtrFlat + { +public: + CPatchDataList(TInt aGranularity); + ~CPatchDataList(); + }; + +class CPolicyPatcher : public CBase + { +public: + static CPolicyPatcher* NewL(); + + HBufC8* PatchPolicyL(const TDesC8& aPolicyData, + CPolicyPatchInfoList* aPatchInfoList); + +private: + CPolicyPatcher(); + void ConstructL(); + ~CPolicyPatcher(); + + void FindOffsetsL(); + HBufC8* CreateOutputL(); + HBufC8* CreatePatchDataL(const CPolicyPatchInfo* aPatchInfo); + +private: + TPtrC8 iInput; + CPolicyPatchInfoList* iPatchInfoList; + TBool iUserCertPatched; + }; + +#endif // __POLICYPATCHER_H__