|
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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/implementationproxy.h> |
|
20 #include <e32base.h> |
|
21 |
|
22 #include "authserver/authplugininterface.h" |
|
23 #include "authserver/authtypes.h" |
|
24 #include "authserver/auth_srv_errs.h" |
|
25 |
|
26 |
|
27 |
|
28 namespace AuthServer |
|
29 { |
|
30 class CTestPlugin1 : public CAuthPluginInterface |
|
31 { |
|
32 public: |
|
33 static CTestPlugin1* NewL() |
|
34 { return new (ELeave) CTestPlugin1(); } |
|
35 |
|
36 CTestPlugin1(); |
|
37 virtual ~CTestPlugin1() {} |
|
38 virtual TPluginId Id() const { return 0x10274104; } |
|
39 virtual void Train(TIdentityId aId, HBufC8*& aResult, |
|
40 TRequestStatus& aRequest); |
|
41 virtual void Cancel() {}; |
|
42 |
|
43 virtual void Identify(TIdentityId& aId, const TDesC& aClientMessage, |
|
44 HBufC8*& aResult, TRequestStatus& aRequest); |
|
45 |
|
46 virtual TBool IsActive() const; |
|
47 virtual TInt Forget(TIdentityId aId); |
|
48 virtual TInt DefaultData(TIdentityId aId, HBufC8*& aOutputBuf); |
|
49 virtual TInt Reset(TIdentityId aId, const TDesC& aRegistrationData, HBufC8*& aResult); |
|
50 virtual const TPtrC& Name() const; |
|
51 virtual const TPtrC& Description() const; |
|
52 virtual AuthServer::TEntropy MinEntropy() const; |
|
53 virtual AuthServer::TPercentage FalsePositiveRate() const; |
|
54 virtual AuthServer::TPercentage FalseNegativeRate() const; |
|
55 virtual AuthServer::TAuthPluginType Type() const; |
|
56 |
|
57 protected: |
|
58 /// The name of the plugin. Derived classes should set this member. |
|
59 TPtrC iName; |
|
60 /// The plugin's description. Derived classes should set this member. |
|
61 TPtrC iDescription; |
|
62 /// The minumum entropy provided by the plugin. Derived classes should set |
|
63 /// this member. |
|
64 AuthServer::TEntropy iMinEntropy; |
|
65 /// The false positive rate of the plugin. Derived classes should set this |
|
66 /// member. |
|
67 AuthServer::TPercentage iFalsePositiveRate; |
|
68 /// The false negative rate of the plugin. Derived classes should set this |
|
69 /// member. |
|
70 AuthServer::TPercentage iFalseNegativeRate; |
|
71 /// The type of the plugin. Derived classes should set this member. |
|
72 AuthServer::TAuthPluginType iType; |
|
73 /// the state of the plugin. |
|
74 TBool iActive; |
|
75 |
|
76 }; |
|
77 |
|
78 class CInactivePlugin : public CTestPlugin1 |
|
79 { |
|
80 public: |
|
81 static CInactivePlugin* NewL() |
|
82 { return new (ELeave) CInactivePlugin(); } |
|
83 |
|
84 CInactivePlugin() {} |
|
85 virtual ~CInactivePlugin() {} |
|
86 virtual TPluginId Id() const { return 0x10274106; } |
|
87 |
|
88 virtual TBool IsActive() const { return EFalse; } |
|
89 virtual const TPtrC& Name() const; |
|
90 virtual const TPtrC& Description() const; |
|
91 virtual AuthServer::TEntropy MinEntropy() const; |
|
92 virtual AuthServer::TPercentage FalsePositiveRate() const; |
|
93 virtual AuthServer::TPercentage FalseNegativeRate() const; |
|
94 virtual AuthServer::TAuthPluginType Type() const; |
|
95 }; |
|
96 |
|
97 |
|
98 class CUnknownPlugin : public CTestPlugin1 |
|
99 { |
|
100 public: |
|
101 static CUnknownPlugin* NewL() |
|
102 { return new (ELeave) CUnknownPlugin(); } |
|
103 |
|
104 CUnknownPlugin() {} |
|
105 virtual ~CUnknownPlugin() {} |
|
106 virtual TPluginId Id() const { return 0x10274107; } |
|
107 virtual void Identify(TIdentityId& aId, const TDesC& aClientMessage, |
|
108 HBufC8*& aResult, TRequestStatus& aRequest); |
|
109 |
|
110 virtual void Train(TIdentityId aId, HBufC8*& aResult, |
|
111 TRequestStatus& aRequest); |
|
112 virtual TBool IsActive() const { return ETrue; } |
|
113 const TPtrC& Name() const; |
|
114 const TPtrC& Description() const; |
|
115 virtual AuthServer::TEntropy MinEntropy() const; |
|
116 virtual AuthServer::TPercentage FalsePositiveRate() const; |
|
117 virtual AuthServer::TPercentage FalseNegativeRate() const; |
|
118 virtual AuthServer::TAuthPluginType Type() const; |
|
119 }; |
|
120 |
|
121 class CWaitToComplete : public CTimer |
|
122 { |
|
123 public: |
|
124 CWaitToComplete() : CTimer(EPriorityNormal) |
|
125 { CTimer::ConstructL(); } |
|
126 |
|
127 void RunL() |
|
128 { |
|
129 RDebug::Printf("TestPlugin waittocomplete RUNL() : %d", iStatus.Int()); |
|
130 if (iStatus != KErrNone) |
|
131 { |
|
132 iReturn = iStatus.Int(); |
|
133 } |
|
134 User::RequestComplete(iCliReq, iReturn); |
|
135 } |
|
136 |
|
137 |
|
138 void SetCliStatus(TRequestStatus& aResult, TInt aReturn) |
|
139 { iCliReq = &aResult; iReturn = aReturn; } |
|
140 |
|
141 TRequestStatus* iCliReq; |
|
142 TInt iReturn; |
|
143 }; |
|
144 |
|
145 class CBlockPlugin : public CTestPlugin1 |
|
146 { |
|
147 public: |
|
148 static CBlockPlugin* NewL() |
|
149 { return new (ELeave) CBlockPlugin(); } |
|
150 |
|
151 CBlockPlugin() |
|
152 { |
|
153 } |
|
154 virtual ~CBlockPlugin() {} |
|
155 |
|
156 virtual TPluginId Id() const { return 0x10274105; } |
|
157 |
|
158 virtual void Train(TIdentityId /*aId*/, HBufC8*& aResult, |
|
159 TRequestStatus& aRequest) |
|
160 { |
|
161 if (!iTimer.IsAdded()) |
|
162 { |
|
163 CActiveScheduler::Add(&iTimer); |
|
164 } |
|
165 iClientStatus = &aRequest; |
|
166 aRequest = KRequestPending; |
|
167 iTimer.SetCliStatus(aRequest, KErrAuthServPluginCancelled); |
|
168 iTimer.After(5000000); |
|
169 aResult = 0; |
|
170 } |
|
171 |
|
172 virtual void Cancel() |
|
173 { |
|
174 iTimer.Cancel(); |
|
175 User::RequestComplete(iClientStatus, KErrCancel); |
|
176 } |
|
177 |
|
178 virtual void Identify(TIdentityId& aId, const TDesC& /*aClientMessage*/, |
|
179 HBufC8*& aResult, TRequestStatus& aRequest) |
|
180 { |
|
181 if (!iTimer.IsAdded()) |
|
182 { |
|
183 CActiveScheduler::Add(&iTimer); |
|
184 } |
|
185 iClientStatus = &aRequest; |
|
186 aRequest = KRequestPending; |
|
187 iTimer.SetCliStatus(aRequest, KErrNone); |
|
188 iTimer.After(5000000); |
|
189 aId = KUnknownIdentity; |
|
190 aResult = 0; |
|
191 } |
|
192 virtual const TPtrC& Name() const |
|
193 { |
|
194 return iName; |
|
195 } |
|
196 virtual const TPtrC& Description() const |
|
197 { |
|
198 return iDescription; |
|
199 } |
|
200 virtual TAuthPluginType Type() const |
|
201 { |
|
202 return iType; |
|
203 } |
|
204 |
|
205 virtual TEntropy MinEntropy() const |
|
206 { |
|
207 return iMinEntropy; |
|
208 } |
|
209 |
|
210 virtual TPercentage FalsePositiveRate() const |
|
211 { |
|
212 return iFalsePositiveRate; |
|
213 } |
|
214 |
|
215 virtual TPercentage FalseNegativeRate() const |
|
216 { |
|
217 return iFalseNegativeRate; |
|
218 } |
|
219 |
|
220 private: |
|
221 |
|
222 TRequestStatus iStatus; |
|
223 TRequestStatus* iClientStatus; |
|
224 CWaitToComplete iTimer; |
|
225 |
|
226 }; |
|
227 |
|
228 } |
|
229 |
|
230 IMPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount); |
|
231 |