|
1 /* |
|
2 * Copyright (c) 2007 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: Extracted VPN bundle file handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_VPNBUNDLEHANDLER_H |
|
22 #define C_VPNBUNDLEHANDLER_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 /** |
|
28 * Basic handler for VPN bundle (i.e. the extracted .VPN file contents) |
|
29 * |
|
30 * Can be used to verify .vpn / .p12 file existence, and to |
|
31 * extract raw .vpn / .p12 file data into buffers. |
|
32 */ |
|
33 class CVpnBundleHandler : public CBase |
|
34 { |
|
35 public: |
|
36 /** |
|
37 * Standard twophased constructor. |
|
38 * |
|
39 * @param aBundleDir Reference to the directory where the |
|
40 * extracted bundle is located. |
|
41 * |
|
42 */ |
|
43 static CVpnBundleHandler* NewL(const TDesC& aBundleDir); |
|
44 /** |
|
45 * Standard twophased constructor that leaves CleanupStack |
|
46 * residuals. |
|
47 * |
|
48 * @param aBundleDir Reference to the directory where the |
|
49 * extracted bundle is located. |
|
50 * |
|
51 */ |
|
52 static CVpnBundleHandler* NewLC(const TDesC& aBundleDir); |
|
53 ~CVpnBundleHandler(); |
|
54 |
|
55 private: |
|
56 CVpnBundleHandler(const TDesC& aBundleDir); |
|
57 |
|
58 protected: |
|
59 void ConstructL(); |
|
60 |
|
61 public: |
|
62 |
|
63 /** |
|
64 * Gather information about the bundle contents: |
|
65 * Extract filenames for PKCS12 package and |
|
66 * VPN command file (if those exist) to local variables. |
|
67 * |
|
68 * |
|
69 * @leave Leaves if there are more than 1 cmd files / p12 packages |
|
70 */ |
|
71 void AnalyzeBundleContentsL(); |
|
72 |
|
73 /** |
|
74 * Returns ETrue iff a command file was found in bundle analysis |
|
75 * |
|
76 * @return ETrue iff a command file was found in bundle analysis |
|
77 * |
|
78 */ |
|
79 TBool CommandFileExists() const; |
|
80 |
|
81 /** |
|
82 * Returns ETrue iff a PKCS#12 file was found in bundle analysis |
|
83 * |
|
84 * @return ETrue iff a PKSC#12 file was found in bundle analysis |
|
85 */ |
|
86 TBool PKCS12FileExists() const; |
|
87 |
|
88 /** |
|
89 * Extracts PKCS12 data from the PKCS#12 file into a 8bit buffer. |
|
90 * |
|
91 * @return HBufC8* buffer containing the raw PKCS#12 data. |
|
92 * Control of the object transferred to caller. |
|
93 * |
|
94 * @leave Leaves if OOM, or if file operations fail. |
|
95 */ |
|
96 HBufC8* ExtractPKCS12DataL(); |
|
97 |
|
98 /** |
|
99 * Extracts VPN command file XML data from the command file |
|
100 * into a 8bit buffer. |
|
101 * |
|
102 * @return HBufC8* buffer containing the raw command file |
|
103 * XML data. Control of the object transferred to caller. |
|
104 * |
|
105 * @leave Leaves if OOM, or if file operations fail. |
|
106 */ |
|
107 HBufC8* ExtractCommandFileDataL(); |
|
108 |
|
109 private: |
|
110 |
|
111 /** |
|
112 * Extracts the command file name to iCommandFileName. |
|
113 * Command file name is decided by searching the temp directory |
|
114 * into which the VPN file was extracted. If more than one command |
|
115 * file is found, or OOM, the function may leave. |
|
116 * Command file search is based on file extension pattern (".vpc") |
|
117 * |
|
118 * @leave Leaves if OOM or more than one command files found |
|
119 */ |
|
120 void LocateCommandFileL(); |
|
121 |
|
122 /** |
|
123 * Extracts the PKCS#12 file name to iPKCS12FileName. |
|
124 * PKCS#12 file name is decided by searching the temp directory |
|
125 * into which the VPN file was extracted. If more than one PKCS#12 |
|
126 * file is found, or OOM, the function may leave. |
|
127 * Command file search is based on file extension pattern |
|
128 * (".p12") |
|
129 * |
|
130 * @leave Leaves if OOM or more than one command files found |
|
131 */ |
|
132 void LocatePKCS12FileL(); |
|
133 |
|
134 private: |
|
135 // Full filename (path included) to PKCS#12 file in .VPN bundle |
|
136 HBufC* iPKCS12FileName; |
|
137 |
|
138 // Full filename (path included) to command file in .VPN bundle |
|
139 HBufC* iCommandFileName; |
|
140 |
|
141 // Reference to the location of extracted .VPN bundle |
|
142 |
|
143 TPtrC iBundleFileDir; // ref |
|
144 RFs iFileServer; |
|
145 }; |
|
146 |
|
147 #endif // C_VPNPOLICYINSTALLER_H |
|
148 |