|
1 /* |
|
2 * Copyright (c) 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "testplugins.h" |
|
20 #include <ecom/ecom.h> |
|
21 #include <f32file.h> |
|
22 #include "consts.h" |
|
23 |
|
24 using namespace AuthServer; |
|
25 |
|
26 _LIT(KTestPluginsUpgradeNamePin, "Test Plugin #1 - Upgrade"); |
|
27 |
|
28 TBool E32Dll() |
|
29 { |
|
30 return (ETrue); |
|
31 } |
|
32 |
|
33 CTestPlugin1::CTestPlugin1() : iActive(false) |
|
34 { |
|
35 iName.Set(KTestPluginsUpgradeNamePin); |
|
36 iDescription.Set(KPluginDescription); |
|
37 iType = EAuthKnowledge; |
|
38 iMinEntropy = KEntropy; |
|
39 iFalsePositiveRate = KFalsePos; |
|
40 iFalseNegativeRate = KFalseNeg; |
|
41 |
|
42 RFs fs; |
|
43 fs.Connect(); |
|
44 TEntry file; |
|
45 |
|
46 _LIT(KActiveFile, "\\testplugin_active\\"); |
|
47 TDriveUnit sysDrive (fs.GetSystemDrive()); |
|
48 TBuf<128> activeFile (sysDrive.Name()); |
|
49 activeFile.Append(KActiveFile); |
|
50 iActive = fs.Entry(activeFile, file);; |
|
51 fs.Close(); |
|
52 //RDebug::Printf("Plugin started, active = %d", iActive); |
|
53 iActive = iActive != KErrNotFound; |
|
54 //RDebug::Printf("Plugin started, active = %d", iActive); |
|
55 } |
|
56 |
|
57 void CTestPlugin1::Identify(TIdentityId& aId, const TDesC& /*aClientMessage*/, |
|
58 HBufC8*& aResult, TRequestStatus& aRequest) |
|
59 { |
|
60 aId = 22; |
|
61 aResult = HBufC8::New(20); |
|
62 |
|
63 TRequestStatus *stat = &aRequest; |
|
64 |
|
65 if(aResult == NULL) |
|
66 { |
|
67 User::RequestComplete(stat, KErrNoMemory); |
|
68 return; |
|
69 } |
|
70 |
|
71 *aResult = KIdentifyData; |
|
72 User::RequestComplete(stat, KErrNone); |
|
73 } |
|
74 |
|
75 void CTestPlugin1::Train(TIdentityId /*aId*/, HBufC8*& aResult, |
|
76 TRequestStatus& aRequest) |
|
77 { |
|
78 aResult = HBufC8::New(20); |
|
79 |
|
80 TRequestStatus* status = &aRequest; |
|
81 |
|
82 if(aResult == NULL) |
|
83 { |
|
84 User::RequestComplete(status, KErrNoMemory); |
|
85 return; |
|
86 } |
|
87 |
|
88 *aResult = KTrainData; |
|
89 User::RequestComplete(status, KErrNone); |
|
90 |
|
91 } |
|
92 |
|
93 |
|
94 void CUnknownPlugin::Identify(TIdentityId& aId, const TDesC& /*aClientMessage*/, |
|
95 HBufC8*& aResult, TRequestStatus& aRequest) |
|
96 { |
|
97 aId = KUnknownIdentity; |
|
98 aResult = HBufC8::New(0); |
|
99 |
|
100 TRequestStatus *stat = &aRequest; |
|
101 |
|
102 if(aResult == NULL) |
|
103 { |
|
104 User::RequestComplete(stat, KErrNoMemory); |
|
105 return; |
|
106 } |
|
107 |
|
108 User::RequestComplete(stat, KErrNone); |
|
109 } |
|
110 |
|
111 void CUnknownPlugin::Train(TIdentityId /*aId*/, HBufC8*& aResult, |
|
112 TRequestStatus& aRequest) |
|
113 { |
|
114 aResult = HBufC8::New(0); |
|
115 TRequestStatus* status = &aRequest; |
|
116 |
|
117 if(aResult == NULL) |
|
118 { |
|
119 User::RequestComplete(status, KErrNoMemory); |
|
120 return; |
|
121 } |
|
122 |
|
123 User::RequestComplete(status, KErrAuthServPluginCancelled); |
|
124 } |
|
125 |
|
126 TBool CTestPlugin1::IsActive() const |
|
127 { |
|
128 return iActive; |
|
129 } |
|
130 |
|
131 |
|
132 TInt CTestPlugin1::Forget(TIdentityId /*aId*/) |
|
133 { |
|
134 return KErrNone; |
|
135 } |
|
136 TInt CTestPlugin1::DefaultData(TIdentityId /*aId*/, HBufC8*& /*aOutputBuf*/) |
|
137 { |
|
138 return KErrNotSupported; |
|
139 } |
|
140 |
|
141 TInt CTestPlugin1::Reset(TIdentityId /*aId*/, const TDesC& /*aRegistrationData*/, HBufC8*& /*aResult*/) |
|
142 { |
|
143 return KErrNotSupported; |
|
144 } |
|
145 |
|
146 const TImplementationProxy ImplementationTable[] = |
|
147 { |
|
148 IMPLEMENTATION_PROXY_ENTRY(0x10274104, CTestPlugin1::NewL), |
|
149 IMPLEMENTATION_PROXY_ENTRY(0x10274105, CBlockPlugin::NewL), |
|
150 IMPLEMENTATION_PROXY_ENTRY(0x10274106, CInactivePlugin::NewL), |
|
151 IMPLEMENTATION_PROXY_ENTRY(0x10274107, CUnknownPlugin::NewL) |
|
152 }; |
|
153 |
|
154 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
155 { |
|
156 aTableCount = sizeof(ImplementationTable) / |
|
157 sizeof(TImplementationProxy); |
|
158 return ImplementationTable; |
|
159 } |
|
160 |
|
161 const TPtrC& CTestPlugin1::Name() const |
|
162 { |
|
163 return iName; |
|
164 } |
|
165 const TPtrC& CTestPlugin1::Description() const |
|
166 { |
|
167 return iDescription; |
|
168 } |
|
169 TAuthPluginType CTestPlugin1::Type() const |
|
170 { |
|
171 return iType; |
|
172 } |
|
173 |
|
174 TEntropy CTestPlugin1::MinEntropy() const |
|
175 { |
|
176 return iMinEntropy; |
|
177 } |
|
178 |
|
179 TPercentage CTestPlugin1::FalsePositiveRate() const |
|
180 { |
|
181 return iFalsePositiveRate; |
|
182 } |
|
183 |
|
184 TPercentage CTestPlugin1::FalseNegativeRate() const |
|
185 { |
|
186 return iFalseNegativeRate; |
|
187 } |
|
188 |
|
189 |
|
190 //Unknown Plugin |
|
191 |
|
192 const TPtrC& CUnknownPlugin::Name() const |
|
193 { |
|
194 return iName; |
|
195 } |
|
196 const TPtrC& CUnknownPlugin::Description() const |
|
197 { |
|
198 return iDescription; |
|
199 } |
|
200 AuthServer::TAuthPluginType CUnknownPlugin::Type() const |
|
201 { |
|
202 return iType; |
|
203 } |
|
204 |
|
205 AuthServer::TEntropy CUnknownPlugin::MinEntropy() const |
|
206 { |
|
207 return iMinEntropy; |
|
208 } |
|
209 |
|
210 AuthServer::TPercentage CUnknownPlugin::FalsePositiveRate() const |
|
211 { |
|
212 return iFalsePositiveRate; |
|
213 } |
|
214 |
|
215 AuthServer::TPercentage CUnknownPlugin::FalseNegativeRate() const |
|
216 { |
|
217 return iFalseNegativeRate; |
|
218 } |
|
219 |
|
220 |
|
221 |
|
222 //Inactive Plugin |
|
223 |
|
224 const TPtrC& CInactivePlugin::Name() const |
|
225 { |
|
226 return iName; |
|
227 } |
|
228 const TPtrC& CInactivePlugin::Description() const |
|
229 { |
|
230 return iDescription; |
|
231 } |
|
232 AuthServer::TAuthPluginType CInactivePlugin::Type() const |
|
233 { |
|
234 return iType; |
|
235 } |
|
236 |
|
237 AuthServer::TEntropy CInactivePlugin::MinEntropy() const |
|
238 { |
|
239 return iMinEntropy; |
|
240 } |
|
241 |
|
242 AuthServer::TPercentage CInactivePlugin::FalsePositiveRate() const |
|
243 { |
|
244 return iFalsePositiveRate; |
|
245 } |
|
246 |
|
247 AuthServer::TPercentage CInactivePlugin::FalseNegativeRate() const |
|
248 { |
|
249 return iFalseNegativeRate; |
|
250 } |
|
251 |