|
1 /* |
|
2 * Copyright (c) 2003-2008 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: Policy importer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __POLICYPATCHER_H__ |
|
21 #define __POLICYPATCHER_H__ |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 _LIT8(KDataField, " DATA:"); // Two preceding spaces just for indentation |
|
26 _LIT8(KSpace, " "); |
|
27 _LIT8(KNewLine, "\n"); |
|
28 _LIT8(KName, "NAME"); |
|
29 _LIT8(KKeyLenField, "PRIVATE_KEY_LENGTH: "); |
|
30 _LIT8(KDNField, " SUBJECT_DN_SUFFIX: "); |
|
31 |
|
32 |
|
33 const TChar KBinChar = 'B'; |
|
34 const TChar KFormatChar = 'F'; |
|
35 |
|
36 const TInt KUndefinedOffset = -1; |
|
37 |
|
38 class TPatchKeyArrayPtr : public TKeyArrayFix |
|
39 { |
|
40 public: |
|
41 inline TPatchKeyArrayPtr(TInt aOffset, TKeyCmpText aType) |
|
42 :TKeyArrayFix(aOffset, aType) {} |
|
43 inline TPatchKeyArrayPtr(TInt aOffset, TKeyCmpText aType, TInt aLength) |
|
44 :TKeyArrayFix(aOffset, aType, aLength) {} |
|
45 inline TPatchKeyArrayPtr(TInt aOffset, TKeyCmpNumeric aType) |
|
46 :TKeyArrayFix(aOffset, aType) {} |
|
47 virtual TAny* At(TInt aIndex) const; |
|
48 }; |
|
49 |
|
50 |
|
51 class CPolicyPatchInfo : public CBase |
|
52 { |
|
53 public: |
|
54 CPolicyPatchInfo(); |
|
55 ~CPolicyPatchInfo(); |
|
56 |
|
57 const TDesC8& CertSubjectName() const; |
|
58 void SetCertSubjectNameL(const TDesC8& aCertSubjectName); |
|
59 |
|
60 /** |
|
61 * Sets key length (in bits) of user cert. |
|
62 */ |
|
63 void SetUserCertKeyLen( TInt aKeyLen ); |
|
64 |
|
65 /** |
|
66 * Gets key length (in bits) of user cert. |
|
67 */ |
|
68 TInt UserCertKeyLen() const; |
|
69 |
|
70 /** |
|
71 * Verifies, that subjectname does not include not closed commas inside attributes |
|
72 */ |
|
73 HBufC8* CheckSubjectNameSyntaxL(const TDesC8& aSubj); |
|
74 |
|
75 public: |
|
76 TBuf8<KMaxFileName> iCertFileName; |
|
77 TInt iPatchOffset; |
|
78 TInt iReminderOffset; |
|
79 |
|
80 private: |
|
81 HBufC8* iCertSubjectName; |
|
82 |
|
83 /** |
|
84 * Key length (in bits) of user cert. |
|
85 */ |
|
86 TInt iUserCertKeyLen; |
|
87 }; |
|
88 |
|
89 class CPolicyPatchInfoList : public CArrayPtrFlat<CPolicyPatchInfo> |
|
90 { |
|
91 public: |
|
92 CPolicyPatchInfoList(TInt aGranularity); |
|
93 ~CPolicyPatchInfoList(); |
|
94 }; |
|
95 |
|
96 class CPatchData : public CBase |
|
97 { |
|
98 public: |
|
99 ~CPatchData(); |
|
100 |
|
101 public: |
|
102 TInt iPatchOffset; |
|
103 TInt iReminderOffset; |
|
104 HBufC8* iData; |
|
105 }; |
|
106 |
|
107 class CPatchDataList : public CArrayPtrFlat<CPatchData> |
|
108 { |
|
109 public: |
|
110 CPatchDataList(TInt aGranularity); |
|
111 ~CPatchDataList(); |
|
112 }; |
|
113 |
|
114 class CPolicyPatcher : public CBase |
|
115 { |
|
116 public: |
|
117 static CPolicyPatcher* NewL(); |
|
118 |
|
119 HBufC8* PatchPolicyL(const TDesC8& aPolicyData, |
|
120 CPolicyPatchInfoList* aPatchInfoList); |
|
121 |
|
122 private: |
|
123 CPolicyPatcher(); |
|
124 void ConstructL(); |
|
125 ~CPolicyPatcher(); |
|
126 |
|
127 void FindOffsetsL(); |
|
128 HBufC8* CreateOutputL(); |
|
129 HBufC8* CreatePatchDataL(const CPolicyPatchInfo* aPatchInfo); |
|
130 |
|
131 private: |
|
132 TPtrC8 iInput; |
|
133 CPolicyPatchInfoList* iPatchInfoList; |
|
134 TBool iUserCertPatched; |
|
135 }; |
|
136 |
|
137 #endif // __POLICYPATCHER_H__ |