|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "ocsppolicy.h" |
|
17 |
|
18 #include <f32file.h> |
|
19 #include <s32file.h> |
|
20 |
|
21 |
|
22 // OCSP policy repository UID |
|
23 static const TUid KUidOCSPRepository = { 0x2002B28B }; |
|
24 |
|
25 // Default values for the settings |
|
26 const TBool KDefaultGenerateResponseForMissingUri = ETrue; |
|
27 const TBool KDefaultEnableHttpGETMethod = EFalse; |
|
28 |
|
29 EXPORT_C COcspPolicy* COcspPolicy::NewL() |
|
30 { |
|
31 COcspPolicy* self = new(ELeave)COcspPolicy(); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 EXPORT_C TBool COcspPolicy::IsGenerateResponseForMissingUriEnabled() const |
|
39 { |
|
40 return iGenerateResponseForMissingUri; |
|
41 } |
|
42 |
|
43 EXPORT_C TBool COcspPolicy::IsHttpGETMethodEnabled() const |
|
44 { |
|
45 return iEnableHttpGETMethod; |
|
46 } |
|
47 |
|
48 COcspPolicy::COcspPolicy() |
|
49 : iGenerateResponseForMissingUri(KDefaultGenerateResponseForMissingUri), |
|
50 iEnableHttpGETMethod(KDefaultEnableHttpGETMethod) |
|
51 { |
|
52 } |
|
53 |
|
54 /* |
|
55 * Leaves with KErrNotFound if the OCSP repository is not found and |
|
56 * default values for the settings are retained if the settings are missing |
|
57 * in the repository. |
|
58 * Otherwise, the settings are set to the read values from the repository. |
|
59 */ |
|
60 void COcspPolicy::ConstructL() |
|
61 { |
|
62 // Session to access OCSP Central Repository Server. |
|
63 SecuritySettingsServer::RSecSettingsSession SecSettingsSession; |
|
64 |
|
65 // Connect to the Central Repository server. |
|
66 User::LeaveIfError(SecSettingsSession.Connect()); |
|
67 |
|
68 CleanupClosePushL(SecSettingsSession); |
|
69 |
|
70 // Read-in the values of the settings - GenerateResponseForMissingUri and |
|
71 // EnableHttpGETMethod from the OCSP Central Repository. |
|
72 // These will retain the default values if any error occurs. |
|
73 |
|
74 TInt value = 1; |
|
75 |
|
76 TRAPD(err, (value = SecSettingsSession.SettingValueL(KUidOCSPRepository, KGenerateResponseForMissingUri))); |
|
77 |
|
78 if( err == KErrNone ) |
|
79 { |
|
80 iGenerateResponseForMissingUri = value; |
|
81 } |
|
82 else if( err != KErrSettingNotFound ) |
|
83 { |
|
84 User::Leave(err); |
|
85 } |
|
86 |
|
87 TRAP(err, (value = SecSettingsSession.SettingValueL(KUidOCSPRepository, KEnableHttpGetMethod))); |
|
88 |
|
89 if ( err == KErrNone ) |
|
90 { |
|
91 iEnableHttpGETMethod = value; |
|
92 } |
|
93 else if( err != KErrSettingNotFound ) |
|
94 { |
|
95 User::Leave(err); |
|
96 } |
|
97 |
|
98 CleanupStack::PopAndDestroy(&SecSettingsSession); |
|
99 } |
|
100 |