|
1 // Copyright (c) 2006-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 /** |
|
17 @file |
|
18 */ |
|
19 |
|
20 #ifndef __CSIMSMARTCARDEAP_H__ |
|
21 #define __CSIMSMARTCARDEAP_H__ |
|
22 |
|
23 #include <et_phone.h> |
|
24 #include "etelmm.h" |
|
25 #include "CSimPhone.h" |
|
26 |
|
27 class CSimSmartCardEap; |
|
28 |
|
29 /** |
|
30 Class to hold one challenge and its response ptrs, as read from |
|
31 the config.txt file. |
|
32 */ |
|
33 class TEapChngResp |
|
34 { |
|
35 public: |
|
36 TEapChngResp(); |
|
37 |
|
38 public: |
|
39 /** Challenge request data parsed from the config.txt. */ |
|
40 HBufC8* iChallenge; |
|
41 /** Challenge response data parsed from the config.txt. */ |
|
42 HBufC8* iResp; |
|
43 /** |
|
44 The authentication status after this challenge has completed. |
|
45 */ |
|
46 RMobileSmartCardEap::TEapAuthStatus iAuthStatus; |
|
47 }; |
|
48 |
|
49 /** |
|
50 class to hold the parsed data of an EAP procedure from the |
|
51 config.txt file. |
|
52 */ |
|
53 class TEapProcedureData |
|
54 { |
|
55 public: |
|
56 TEapProcedureData(); |
|
57 |
|
58 public: |
|
59 /** |
|
60 holds Application's ID, on which the authentication is to be |
|
61 carried out. Note, there is no checking for this AID's |
|
62 existence, config file must simply match client's request data. |
|
63 */ |
|
64 TBuf8<RMobilePhone::KAIDSize*4> iAID; |
|
65 /** holds the Eap method type to be used with this procedure */ |
|
66 RMobileSmartCardEap::TEapType iEapType; |
|
67 /** holds the Eap key to be returned at end of this procedure */ |
|
68 HBufC8* iEapKey; // MSK |
|
69 HBufC8* iEapExtKey; // EMSK |
|
70 /** holds the Eap identity to be returned at beginning of this procedure */ |
|
71 HBufC8* iEapId; // Permanent |
|
72 HBufC8* iEapPsId; // Pseudonym |
|
73 /** holds a list of challenge requests and responses */ |
|
74 RArray<TEapChngResp> iChResp; |
|
75 }; |
|
76 |
|
77 /** |
|
78 Holds data to help manage access to the smart card applications with |
|
79 EAP capability. |
|
80 */ |
|
81 class CSimSmartCardEapManager : public CBase |
|
82 { |
|
83 public: |
|
84 static CSimSmartCardEapManager* NewL(CSimPhone *aPhone); |
|
85 CSimSmartCardEapManager(CSimPhone *aPhone); |
|
86 void ConstructL(); |
|
87 ~CSimSmartCardEapManager(); |
|
88 |
|
89 CTelObject* CreateScEapSubSessionL(RMobilePhone::TAID& aAID, RMobileSmartCardEap::TEapType& aEapType); |
|
90 TEapProcedureData* ProcData(const RMobilePhone::TAID& aAID, const RMobileSmartCardEap::TEapType& aEapType); |
|
91 void ProcDataUseCompleted(const TEapProcedureData* aProcData); |
|
92 |
|
93 void RegisterSubSessionL(CSimSmartCardEap* aToRegister); |
|
94 TInt DeRegisterSubSession(const CSimSmartCardEap* aToRegister); |
|
95 |
|
96 private: |
|
97 const CTestConfigSection* CfgFile(); |
|
98 void ParseEapInfoL(); |
|
99 void ClearParsedData(); |
|
100 void AID_EapType_ExistsInConfigL(const RMobilePhone::TAID& aAID, const RMobileSmartCardEap::TEapType& aEapType); |
|
101 |
|
102 private: |
|
103 CSimPhone *iPhone; |
|
104 |
|
105 /** |
|
106 holds the data parsed from the config file on the EAP procedures |
|
107 configured. |
|
108 */ |
|
109 RArray<TEapProcedureData> iEapProcData; |
|
110 /** |
|
111 We must use an array of flags to specify which of the procedures in |
|
112 iEapProcData has been used up. The reason is that we cannot delete |
|
113 from iEapProcData, doing so will cause a mismatch of pointers |
|
114 between the iEapProcData items and the pointers held by the |
|
115 CSimSmartCardEap objects. |
|
116 */ |
|
117 RArray<TBool> iDiscardedProcedure; |
|
118 /** |
|
119 Holds a record of all EAP sub-session (CSimSmartCardEap) objects. |
|
120 */ |
|
121 RPointerArray<CSimSmartCardEap> iSubSessionObjs; |
|
122 }; |
|
123 |
|
124 |
|
125 class CSimSmartCardEap : public CSubSessionExtBase |
|
126 { |
|
127 class CThreadTerminationListener; |
|
128 friend class CThreadTerminationListener; |
|
129 |
|
130 public: |
|
131 static CSimSmartCardEap* NewL(CSimPhone *aPhone, CSimSmartCardEapManager* aEapMan, RMobilePhone::TAID& aAID, RMobileSmartCardEap::TEapType& aEapType); |
|
132 CSimSmartCardEap(CSimPhone *aPhone, RMobilePhone::TAID& aAID, RMobileSmartCardEap::TEapType& aEapType); |
|
133 void ConstructL(CSimSmartCardEapManager* aEapMan); |
|
134 ~CSimSmartCardEap(); |
|
135 |
|
136 virtual TInt ExtFunc(const TTsyReqHandle aTsyReqHandle,const TInt aIpc,const TDataPackage& aPackage); |
|
137 virtual CTelObject::TReqMode ReqModeL(const TInt aIPC); |
|
138 virtual CTelObject* OpenNewObjectByNameL(const TDesC& aName); |
|
139 virtual CTelObject* OpenNewObjectL(TDes& aNewName); |
|
140 virtual TInt CancelService(const TInt aIpc, const TTsyReqHandle aTsyReqHandle); |
|
141 virtual TInt RegisterNotification(const TInt aIpc); |
|
142 virtual TInt DeregisterNotification(const TInt aIpc); |
|
143 virtual TInt NumberOfSlotsL(const TInt aIpc); |
|
144 virtual void Init(); |
|
145 |
|
146 private: |
|
147 TInt SimInitialiseEapMethod(const TTsyReqHandle aTsyReqHandle, TThreadId* aThreadId); |
|
148 TInt SimInitialiseEapMethodCancel(const TTsyReqHandle aTsyReqHandle); |
|
149 TInt SimGetUserIdentity(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapUserIdType* aEapIdType, TDes8* aUserId); |
|
150 TInt SimGetUserIdentityCancel(const TTsyReqHandle aTsyReqHandle); |
|
151 TInt SimGetAuthenticationStatus(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapAuthStatus* aAuthStatus); |
|
152 TInt SimGetAuthenticationStatusCancel(const TTsyReqHandle aTsyReqHandle); |
|
153 TInt SimGetEapKey(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapKeyTag* aEapKeyTag, TDes8* aKey); |
|
154 TInt SimGetEapKeyCancel(const TTsyReqHandle aTsyReqHandle); |
|
155 TInt SimSetAuthenticateDataForPhase1(const TTsyReqHandle aTsyReqHandle, TDes8* aEapAuthData, TInt* aPhase1Size); |
|
156 TInt SimGetAuthenticateDataForPhase2(const TTsyReqHandle aTsyReqHandle, TDes8* aEapAuthData, TDes8* aPhase2Resp); |
|
157 TInt SimSmartCardEapAuthenticationCancel(const TTsyReqHandle aTsyReqHandle); |
|
158 TInt SimReleaseEapMethod(const TTsyReqHandle aTsyReqHandle); |
|
159 TInt SimGetEapMethodAccessStatus(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapMethodAccessStatus* aEapState); |
|
160 TInt SimNotifyEapMethodAccessStatusChange(const TTsyReqHandle aTsyReqHandle, RMobileSmartCardEap::TEapMethodAccessStatus* aEapState); |
|
161 TInt SimNotifyEapMethodAccessStatusChangeCancel(const TTsyReqHandle aTsyReqHandle); |
|
162 void SimCompleteNotifyEapMethodAccessStatusChange(); |
|
163 virtual RHandleBase* GlobalKernelObjectHandle(); |
|
164 void ClientHasTerminated(TInt aExitReason); |
|
165 |
|
166 private: |
|
167 /** |
|
168 Listener class for client thread termination. Used to ensure |
|
169 iSemaphr is signalled in the event that a client dies unnaturally. |
|
170 */ |
|
171 class CThreadTerminationListener : public CActive |
|
172 { |
|
173 public: |
|
174 static CThreadTerminationListener* NewL(CSimSmartCardEap* aSubSess, const TThreadId& aId); |
|
175 void Start(); |
|
176 ~CThreadTerminationListener(); |
|
177 |
|
178 private: |
|
179 CThreadTerminationListener(CSimSmartCardEap* aPhone); |
|
180 void ConstructL(const TThreadId& aId); |
|
181 void DoCancel(); |
|
182 void RunL(); |
|
183 |
|
184 private: |
|
185 /** The owner sub-session object. */ |
|
186 CSimSmartCardEap* iSubSess; |
|
187 RThread iCliThread; |
|
188 }; |
|
189 |
|
190 /** |
|
191 Basic structure for holding the notification information for a |
|
192 SimCompleteNotifyEapMethodAccessStatusChange() call. |
|
193 |
|
194 @see CSimSmartCardEap::iEapAccessNotifyData |
|
195 */ |
|
196 struct TNotifyData |
|
197 { |
|
198 TBool iNotifyPending; |
|
199 TTsyReqHandle iNotifyHandle; |
|
200 TAny* iNotifyData; |
|
201 }; |
|
202 |
|
203 private: |
|
204 /** Simtsy's RMobilePhone server object. */ |
|
205 CSimPhone *iPhone; |
|
206 RMobilePhone::TAID iAID; |
|
207 RMobileSmartCardEap::TEapType iEapType; |
|
208 /** |
|
209 The procedure data for this sub-session, which is parsed by iEapMan |
|
210 and retieved by this object during SimInitialiseEapMethod(). |
|
211 */ |
|
212 TEapProcedureData* iProcedureData; |
|
213 /** |
|
214 Flag indicating whether the sub-session has already been |
|
215 intialised. |
|
216 */ |
|
217 TBool iSSInitialised; |
|
218 /** |
|
219 The semaphore used by the client side RMobileSmartCardEap code to |
|
220 ensure single access to this sub-session. |
|
221 */ |
|
222 RSemaphore iSemaphr; |
|
223 /** The access of this sub-session. */ |
|
224 RMobileSmartCardEap::TEapMethodAccessStatus iAccessStatus; |
|
225 /** |
|
226 The authentication status of the EAP procedure running within this |
|
227 sub-session. |
|
228 */ |
|
229 RMobileSmartCardEap::TEapAuthStatus iAuthStatus; |
|
230 /** Used in the SimNotifyEapMethodAccessStatusChange() request. */ |
|
231 TNotifyData iEapAccessNotifyData; |
|
232 /** |
|
233 This object calls back into ClientHasTerminated() when the client |
|
234 thread dies. |
|
235 */ |
|
236 CThreadTerminationListener* iCliTerminationListener; |
|
237 /** |
|
238 The EAP manager object to which this sub-session is linked. This |
|
239 manager object should be one in simtsy and it is the object that |
|
240 created this sub-session CSimSmartCardEap object (for CSimPhone). |
|
241 */ |
|
242 CSimSmartCardEapManager* iEapMan; |
|
243 /** |
|
244 iProcedureData contains an RArray of EAP challenge/response data, |
|
245 parsed from the config.txt. This integer keeps track of which |
|
246 challenge should be used in the next call to |
|
247 SimSetAuthenticateDataForPhase1(). |
|
248 */ |
|
249 TInt iCurrentChallenge; |
|
250 }; |
|
251 |
|
252 #endif // __CSIMSMARTCARDEAP_H__ |