|
1 /* |
|
2 * Copyright (c) 2007-2007 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 "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 #ifndef SMARTCARDCRYPTOTOKENREADER_H |
|
20 #define SMARTCARDCRYPTOTOKENREADER_H |
|
21 |
|
22 #include "javaosheaders.h" |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 #include <ct.h> |
|
27 #include <mctcertstore.h> |
|
28 #include <mctwritablecertstore.h> |
|
29 |
|
30 namespace java |
|
31 { |
|
32 namespace security |
|
33 { |
|
34 |
|
35 OS_NONSHARABLE_CLASS(SmartCardCryptoTokenReader) : public CActive |
|
36 { |
|
37 |
|
38 enum State |
|
39 { |
|
40 EStart, |
|
41 EListTokenTypes, |
|
42 EOpenTokenType, |
|
43 EOpenToken, |
|
44 EGetTokenInterface, |
|
45 EListCertificates, |
|
46 EFilterCertificates, |
|
47 ERetrieveCertificates, |
|
48 EReleaseToken, |
|
49 EFinish |
|
50 }; |
|
51 |
|
52 public: |
|
53 static SmartCardCryptoTokenReader* NewL(); |
|
54 virtual ~SmartCardCryptoTokenReader(); |
|
55 void RetrieveCerts(RArray<HBufC8*>& aSmartCardCerts); |
|
56 // CActive |
|
57 virtual void RunL(); |
|
58 virtual void DoCancel(); |
|
59 virtual TInt RunError(TInt aError); |
|
60 private: |
|
61 SmartCardCryptoTokenReader(); |
|
62 void ConstructL(); |
|
63 bool Initialize(); |
|
64 bool ListTokenTypes(); |
|
65 bool OpenTokenType(); |
|
66 bool OpenToken(); |
|
67 bool GetTokenInterface(); |
|
68 bool ListCertificates(); |
|
69 bool FilterCertificates(); |
|
70 bool RetrieveCertificates(); |
|
71 bool ReleaseToken(); |
|
72 void CancelOpenTokenType(); |
|
73 void CancelOpenToken(); |
|
74 void CancelGetTokenInterface(); |
|
75 void CompleteRequest(TInt aCompletionCode); |
|
76 void NextState(bool aCurrentOperationSucceeded); |
|
77 void DoReleaseToken(); |
|
78 |
|
79 private: |
|
80 // file handler |
|
81 RFs iFs; |
|
82 // the state machine's state (see State for values) |
|
83 State iState; |
|
84 // smart card token attributes |
|
85 RArray<TUid> iSmartCardTokensInterfaces; |
|
86 RArray <TCTTokenTypeAttribute> iSmartCardTokensAttributes; |
|
87 // smart card token types |
|
88 RCPointerArray <CCTTokenTypeInfo> iSmartCardTokenTypes; |
|
89 // smart card tokens from the list are handled one by one |
|
90 // -> this is the index of the token type being currently handled |
|
91 int iCurrentTokenType; |
|
92 // smart card token type & info |
|
93 MCTToken* iSmartCardToken; |
|
94 CCTTokenType* iSmartCardTokenType; |
|
95 RCPointerArray<HBufC> iSmartCardTokenInfo; |
|
96 // smart card token interface |
|
97 MCTTokenInterface* iSmartCardTokenInterface; |
|
98 MCTCertStore* iSmartCardStore; |
|
99 // smart card certificate filters |
|
100 CCertAttributeFilter* iSmartCardCertsFilter; |
|
101 // smart card certificate infos |
|
102 RMPointerArray<CCTCertInfo> iSmartCardCertInfos; |
|
103 // smart card certificates contents are retrieved one by one by the state machine |
|
104 // -> this is the index of the smart card cert content being currently retrieved |
|
105 int iCurrentRetrievedSmartCardCert; |
|
106 // smart card certs |
|
107 RArray<HBufC8*>* iSmartCardCerts; |
|
108 // flag identifying if the currently retrieved cert is trusted |
|
109 TBool iCurrentSmartCardCertIsTrusted; |
|
110 // temporary buffer (and pointer to it) via which a single certificate |
|
111 // content is retrieved |
|
112 HBufC8* iTmpBuf; |
|
113 TPtr8 iTmpBufPtr; |
|
114 CActiveScheduler* iActiveScheduler; |
|
115 }; |
|
116 |
|
117 } //end namespace security |
|
118 } //end namespace java |
|
119 |
|
120 #endif // SMARTCARDCRYPTOTOKENREADER_H |