|
1 /* |
|
2 * Copyright (c) 2005-2009 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 the License "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: |
|
15 * CAuthDb Authentication server data store declaration |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @released |
|
23 @internalComponent |
|
24 */ |
|
25 |
|
26 #ifndef AUTHDB_H |
|
27 #define AUTHDB_H |
|
28 |
|
29 #include <d32dbms.h> |
|
30 #include "authserver/authtypes.h" |
|
31 #include "authserver/idandstring.h" |
|
32 |
|
33 namespace AuthServer |
|
34 { |
|
35 |
|
36 class CTransientKeyInfo; |
|
37 |
|
38 NONSHARABLE_CLASS(CAuthDb2) : public CBase |
|
39 { |
|
40 public: |
|
41 static CAuthDb2* NewL(RFs& aFs); |
|
42 static CAuthDb2* NewLC(RFs& aFs); |
|
43 virtual ~CAuthDb2(); |
|
44 |
|
45 // identities |
|
46 TInt NumIdentitiesL(); |
|
47 void AddIdentityWithTrainedPluginL( |
|
48 TIdentityId aIdentityId, const TDesC& aDesc, |
|
49 const CTransientKeyInfo& aTransKeyInfo); |
|
50 void AddIdentityL(TIdentityId aIdentityId, const TDesC& aDesc); |
|
51 void RemoveIdentityL(TIdentityId aIdentityId); |
|
52 void IdentitiesL(RArray<TIdentityId>& aResults); |
|
53 HBufC* DescriptionL(TIdentityId aIdentityId); |
|
54 void SetDescriptionL(TIdentityId aIdentityId, const TDesC& aDesc); |
|
55 void IdentitiesWithDescriptionL(RIdAndStringArray& aList); |
|
56 TIdentityId DefaultIdentityL(); |
|
57 // plugins |
|
58 TInt NumPluginsL(); |
|
59 TInt NumTrainedPluginsL(TIdentityId aId); |
|
60 // Returns list of plugins that are trained for the given identity |
|
61 void TrainedPluginsListL(TIdentityId aIdentityId, RArray<TPluginId>& aTrainedPlugins); |
|
62 TAuthTrainingStatus PluginStatusL(TPluginId aPluginId); |
|
63 |
|
64 // preferences |
|
65 void SetPreferredPluginL(TAuthPluginType aPluginType, TPluginId aPluginId); |
|
66 void ClearPreferredPluginL(TAuthPluginType aPluginType); |
|
67 TPluginId PreferredPluginL(TAuthPluginType aPluginType); |
|
68 |
|
69 // trained plugins |
|
70 void SetTrainedPluginL( |
|
71 TIdentityId aIdentityId, TPluginId aPluginId, const CTransientKeyInfo& aTransKeyInfo); |
|
72 void RemoveTrainedPluginL(TIdentityId aIdentityId, TPluginId aPluginId); |
|
73 CTransientKeyInfo* KeyInfoL(TIdentityId aIdentity, TPluginId aPluginId); |
|
74 |
|
75 void CompactIfRequired(); |
|
76 void CloseDbFile(); |
|
77 TInt OpenDbFileL(RFs& aFs, const TFileName& aDbName); |
|
78 |
|
79 private: |
|
80 void ConstructL(RFs& aFs); |
|
81 |
|
82 void FindExistingIdentityLC(RDbTable& aTable, RDbRowSet::TAccess aAccess, TIdentityId aIdentityId); |
|
83 TBool FindIdentityLC(RDbTable& aTable, RDbRowSet::TAccess aAccess, TIdentityId aIdentityId); |
|
84 |
|
85 TBool FindPrefLC(RDbTable& aTable, RDbRowSet::TAccess aAccess, TAuthPluginType aPluginType); |
|
86 |
|
87 TBool FindTrainedPluginLC( |
|
88 RDbTable& aTable, RDbRowSet::TAccess aAccess, |
|
89 TIdentityId aIdentityId, TPluginId aPluginId); |
|
90 |
|
91 TBool OpenTableAndNavigateLC( |
|
92 RDbTable& aTable, const TDesC& aTableName, RDbRowSet::TAccess aAccess, |
|
93 const TDesC& aIndexName, TUint aKey); |
|
94 void OpenTableLC( |
|
95 RDbTable& aTable, const TDesC& aTableName, |
|
96 RDbRowSet::TAccess aAccess, const TDesC& aIndexName); |
|
97 void CheckIdentityRegisteredL(TUint aIdentityId); |
|
98 |
|
99 void CheckItemRegisteredL( |
|
100 const TDesC& aTableName, const TDesC& aIndexName, |
|
101 TUint aValue, TInt aNotFoundError); |
|
102 |
|
103 |
|
104 |
|
105 private: |
|
106 /** |
|
107 * The database file itself, used to persist identities |
|
108 * when the server is not in use. |
|
109 */ |
|
110 RDbNamedDatabase iAuthDbFile; |
|
111 |
|
112 /** |
|
113 * Keep track of whether the database is open or not. |
|
114 */ |
|
115 TBool iIsDbOpen; |
|
116 |
|
117 }; |
|
118 |
|
119 |
|
120 // databases structure |
|
121 |
|
122 _LIT(KDbName, "!:\\private\\102740FC\\auth.db"); |
|
123 |
|
124 /** Identities table name. */ |
|
125 _LIT(KIdentitiesTableName, "Identities"); |
|
126 /** Identities index number */ |
|
127 _LIT(KIdentitiesIndex, "identityIdx"); |
|
128 /** Identities index number.- Based on order of insertion */ |
|
129 _LIT(KIdIndexNum, "idIndex"); |
|
130 /** Identity column number in Identities table. */ |
|
131 const TInt KIdentitiesIdentityIdCol = 2; |
|
132 /** Description column number in Identities table. */ |
|
133 const TInt KIdentitiesDescCol = 3; |
|
134 |
|
135 /** Prefs table name. */ |
|
136 _LIT(KPrefsTableName, "Prefs"); |
|
137 /** Prefs index name. */ |
|
138 _LIT(KPrefsTypeIndex, "typeIdx"); |
|
139 |
|
140 /** Type column number in Prefs table. */ |
|
141 const TInt KPrefsTypeCol = 1; |
|
142 /** PluginId column number is Prefs table. */ |
|
143 const TInt KPrefsIdCol = 2; |
|
144 |
|
145 /** TrainedPlugins table name. */ |
|
146 _LIT(KTpTableName, "TrainedPlugins"); |
|
147 /** TrainedPlugins index name. */ |
|
148 _LIT(KTpIndex, "identityPluginIdx"); |
|
149 |
|
150 /** IdentityId column number in TrainedPlugins table. */ |
|
151 const TInt KTpIdentityIdCol = 1; |
|
152 /** PluginId column number in TrainedPlugins table. */ |
|
153 const TInt KTpPluginIdCol = 2; |
|
154 /** TransientKey column number in TrainedPlugins table. */ |
|
155 const TInt KTpTransientKeyCol = 3; |
|
156 |
|
157 } // namespace AuthServer |
|
158 |
|
159 #endif // AUTHDB_H |