1 /* |
|
2 * Copyright (c) 2006-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 * CPinPluginDB pin plugin data store declaration |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 */ |
|
23 |
|
24 #ifndef PIN_PLUGINDB_H |
|
25 #define PIN_PLUGINDB_H |
|
26 |
|
27 #include <s32file.h> |
|
28 #include <authserver/authtypes.h> |
|
29 |
|
30 // PinPlugin DB |
|
31 class CPinPluginDB : public CBase |
|
32 { |
|
33 public: |
|
34 /** static methods to constuct the object of the CPinPluginDB */ |
|
35 static CPinPluginDB* NewL(); |
|
36 static CPinPluginDB* NewLC(); |
|
37 |
|
38 /** Destructor */ |
|
39 virtual ~CPinPluginDB(); |
|
40 |
|
41 /** |
|
42 Add Id and KeyHash to the store if the id is not exist in the |
|
43 store and pin is not used by any other id. |
|
44 |
|
45 @param aId The Id to be Trained |
|
46 @param aIdentityKeyHash The pin used to Train the Id |
|
47 @leave It leaves with KErrAlreadyExists if the id is |
|
48 already exist or pin is used by other identity. |
|
49 */ |
|
50 void AddPinL(const AuthServer::TIdentityId& aId, const TDesC8& aIdentityKeyHash); |
|
51 |
|
52 /** |
|
53 Update the Id and Pin in the store With the new Pin, if the id exists. |
|
54 |
|
55 @param aId The Id to be ReTrained |
|
56 @param aIdentityKeyHash The pin used to ReTrain the Id |
|
57 @leave It leaves with KErrNotFound if the id is |
|
58 not exist. |
|
59 */ |
|
60 void UpdatePinL(const AuthServer::TIdentityId& aId, const TDesC8& aIdentityKeyHash); |
|
61 |
|
62 /** |
|
63 Remove the Id from the store, if the Id exists |
|
64 |
|
65 @param aId The Id to be ReTrained |
|
66 @leave It leaves with KErrNotFound if the id is |
|
67 not exist. |
|
68 */ |
|
69 void RemovePinL(const AuthServer::TIdentityId& aId); |
|
70 |
|
71 /** |
|
72 Searches the pinvalue in the store |
|
73 |
|
74 @param aIdentityKeyHash The pinvalue to be search for |
|
75 @return It return the IdentityId for the pin, if search |
|
76 is success else return KUnknownIdentity. |
|
77 */ |
|
78 AuthServer::TIdentityId IdFromPin(const TDesC8& aIdentityKeyHash) const; |
|
79 |
|
80 /** |
|
81 Searches the Id in the store. |
|
82 |
|
83 @param aId The Id to be search for. |
|
84 @return It return the index of the Id if the search |
|
85 is success else return KErrNotFound. |
|
86 */ |
|
87 TInt IdIndex(const AuthServer::TIdentityId& aId) const ; |
|
88 |
|
89 /** |
|
90 Verifies the pin is unique. |
|
91 |
|
92 @param aIdentityKeyHash The pinvalue to be search for |
|
93 @return return ETrue if the pin is not used by any of |
|
94 the identity else EFalse. |
|
95 */ |
|
96 TBool IsUniquePin(const TDesC8& aIdentityKeyHash) const; |
|
97 |
|
98 private: |
|
99 CPinPluginDB(); |
|
100 void ConstructL(); |
|
101 |
|
102 private: |
|
103 /** |
|
104 Create and open a New Store If it is first time |
|
105 else Open the existing store. |
|
106 */ |
|
107 void OpenStoreL(); |
|
108 |
|
109 /** |
|
110 Open the existing store |
|
111 @param aFile The name of the file to open |
|
112 */ |
|
113 void OpenStoreInFileL(const TDesC& aFile); |
|
114 |
|
115 /** |
|
116 Create the new store |
|
117 @param aFile The name of the file to create |
|
118 */ |
|
119 void CreateStoreInFileL(const TDesC& aFile); |
|
120 |
|
121 /** |
|
122 Write the In memory represtation to the store. |
|
123 */ |
|
124 void WriteIdKeysToStoreL(); |
|
125 |
|
126 /** |
|
127 Read the Id and keys from the store |
|
128 */ |
|
129 void ReadIdKeysFromStoreL(); |
|
130 |
|
131 private: |
|
132 /** |
|
133 Methods dealing with atomic updates to key data file |
|
134 cleanup item that reverts the store. |
|
135 */ |
|
136 static void RevertStore(TAny* aStore); |
|
137 /** |
|
138 Attempt to compact the store - it doesn't matter if these calls leave, it |
|
139 will only mean that the store takes up more space than necessary. |
|
140 */ |
|
141 void CompactStore(); |
|
142 private: |
|
143 RFile iFile; |
|
144 RFs iFs; |
|
145 /** FileStore Object */ |
|
146 CPermanentFileStore* iFileStore; |
|
147 /** Root Stream that constains identityStreamId */ |
|
148 TStreamId iRootStreamId; |
|
149 /** Identity Stream that contains dataStreamId and count of idHashes stored in the DB */ |
|
150 TStreamId iIdentityStreamId; |
|
151 /** DB file Name */ |
|
152 TFileName iPluginDBName; |
|
153 private: |
|
154 /** In memory representation of id in the store */ |
|
155 RArray<AuthServer::TIdentityId> iId; |
|
156 /** In memory representation of hash in the store */ |
|
157 RPointerArray<HBufC8> iIdKeyHash; |
|
158 }; |
|
159 |
|
160 #endif /* PIN_PLUGINDB_H */ |
|