|
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 "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 #ifndef JAVACERTSTOREIMPL_H |
|
19 #define JAVACERTSTOREIMPL_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <mctwritablecertstore.h> |
|
23 #include "commslistener.h" |
|
24 #include "commsclientendpoint.h" |
|
25 #include "commsmessage.h" |
|
26 |
|
27 class CAknGlobalConfirmationQuery; |
|
28 |
|
29 namespace java |
|
30 { |
|
31 namespace security |
|
32 { |
|
33 |
|
34 class CJavaCertStoreToken; |
|
35 |
|
36 class CJavaCertData: public CBase |
|
37 { |
|
38 public: |
|
39 |
|
40 /** |
|
41 * @param aEncodedState First bit indicates whether cert is already disabled. |
|
42 * Second bit indicates whether cert can be disabled. |
|
43 * Third bit indicates whether cert can be deleted. |
|
44 */ |
|
45 CJavaCertData(const std::string& aCertContent, const long long aCertSize, |
|
46 const std::string& aId,TInt aEncodedState); |
|
47 |
|
48 virtual ~CJavaCertData(); |
|
49 |
|
50 std::string mCertContent; |
|
51 std::string mId; |
|
52 //This flag is used to indicate that cert has been deleted from cert store. |
|
53 //I.e. Remove() operation has been called in this session. |
|
54 TBool mDeleted; |
|
55 //These three boolean values has been read from aEncodeState argument. |
|
56 TBool mIsDisabled; |
|
57 TBool mCanDisable; |
|
58 TBool mCanDelete; |
|
59 //This datamember tells size of the certificate. |
|
60 long long mSizeOfCert; |
|
61 |
|
62 private: |
|
63 |
|
64 //Not implemented. |
|
65 CJavaCertData(const CJavaCertData &x); |
|
66 CJavaCertData &operator=(const CJavaCertData &x); |
|
67 |
|
68 }; |
|
69 |
|
70 class CJavaCertStoreImpl: public CActive, public MCTWritableCertStore, |
|
71 public java::comms::CommsListener, |
|
72 public java::comms::CommsClientEndpoint |
|
73 { |
|
74 public: |
|
75 |
|
76 static CJavaCertStoreImpl* NewL(CJavaCertStoreToken& aToken); |
|
77 |
|
78 virtual ~CJavaCertStoreImpl(); |
|
79 |
|
80 virtual MCTToken& Token(); |
|
81 |
|
82 //CommsListener |
|
83 virtual void processMessage(java::comms::CommsMessage& aMessage); |
|
84 |
|
85 //CActive |
|
86 virtual void RunL(); |
|
87 virtual void DoCancel(); |
|
88 virtual TInt RunError(TInt aError); |
|
89 |
|
90 //MCTWritableCertStore |
|
91 virtual void Add(const TDesC& aLabel, TCertificateFormat aFormat, |
|
92 TCertificateOwnerType aCertificateOwnerType, |
|
93 const TKeyIdentifier* aSubjectKeyId, |
|
94 const TKeyIdentifier* aIssuerKeyId, |
|
95 const TDesC8& aCert, TRequestStatus& aStatus); |
|
96 virtual void CancelAdd(); |
|
97 virtual void Remove(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus); |
|
98 virtual void CancelRemove(); |
|
99 virtual void SetApplicability(const CCTCertInfo& aCertInfo, |
|
100 const RArray<TUid>& aApplications, |
|
101 TRequestStatus &aStatus); |
|
102 virtual void CancelSetApplicability(); |
|
103 virtual void SetTrust(const CCTCertInfo& aCertInfo, TBool aTrusted, |
|
104 TRequestStatus& aStatus); |
|
105 virtual void CancelSetTrust(); |
|
106 virtual void List(RMPointerArray<CCTCertInfo>& aCerts, |
|
107 const CCertAttributeFilter& aFilter, TRequestStatus& aStatus); |
|
108 virtual void CancelList(); |
|
109 virtual void GetCert(CCTCertInfo*& aCertInfo, const TCTTokenObjectHandle& aHandle, |
|
110 TRequestStatus& aStatus); |
|
111 virtual void CancelGetCert(); |
|
112 virtual void Applications(const CCTCertInfo& aCertInfo, RArray<TUid>& aApplications, |
|
113 TRequestStatus& aStatus); |
|
114 virtual void CancelApplications(); |
|
115 virtual void IsApplicable(const CCTCertInfo& aCertInfo, TUid aApplication, |
|
116 TBool& aIsApplicable, TRequestStatus& aStatus); |
|
117 virtual void CancelIsApplicable(); |
|
118 virtual void Trusted(const CCTCertInfo& aCertInfo, TBool& aTrusted, |
|
119 TRequestStatus& aStatus); |
|
120 virtual void CancelTrusted(); |
|
121 virtual void Retrieve(const CCTCertInfo& aCertInfo, TDes8& aEncodedCert, |
|
122 TRequestStatus& aStatus); |
|
123 virtual void CancelRetrieve(); |
|
124 |
|
125 private: |
|
126 |
|
127 enum TState |
|
128 { |
|
129 EInitial, |
|
130 EListing, |
|
131 EPreDisabling, |
|
132 EPreEnabling |
|
133 }; |
|
134 |
|
135 //Datamembers. |
|
136 CJavaCertStoreToken& mToken; |
|
137 java::comms::CommsClientEndpoint mComms; |
|
138 TRequestStatus* mClientStatus; |
|
139 //This class does not have ownership into this object. |
|
140 RMPointerArray<CCTCertInfo>* mClientList; |
|
141 java::comms::CommsMessage mReceivedCommsMsg; |
|
142 RPointerArray<CJavaCertData> mCertsData; |
|
143 TState mState; |
|
144 RThread mUiThread; |
|
145 std::auto_ptr<CAknGlobalConfirmationQuery> mQuery; |
|
146 //This class does not have ownership into this object. |
|
147 CJavaCertData* mTempCertData; |
|
148 |
|
149 //Internal operations. |
|
150 CJavaCertStoreImpl(CJavaCertStoreToken& aToken); |
|
151 void ConstructL(); |
|
152 TBool validateCertAttrFilter(const CCertAttributeFilter& aFilter) const; |
|
153 void FillCertificateInfos(RMPointerArray<CCTCertInfo>& aInfoArray); |
|
154 void FillCertInfoFromCacheL(RMPointerArray<CCTCertInfo>& aInfoArray); |
|
155 TInt GetIndexToCertData(const TCTTokenObjectHandle& aCertInfo); |
|
156 TBool GetCertDataObj(const CCTCertInfo& aCertInfo, |
|
157 TRequestStatus* aRequestStatus, |
|
158 CJavaCertData*& aOutCertDataObj); |
|
159 TBool SendDisableEnableCommsMsg(const std::string& aId, |
|
160 TState aState, |
|
161 TRequestStatus* aRequestStatus); |
|
162 TBool CheckCapability(const TCapability& aCapability,TRequestStatus* aRequestStatus); |
|
163 void HandleDisableQuery(TRequestStatus &aRequestStatus); |
|
164 void ShowQueryL(); |
|
165 void SendDisableMsg(TInt aStatus); |
|
166 void HandleSendingEnableDisableMsg(TRequestStatus* aRequestStatus, |
|
167 TState aState,CJavaCertData& aCertDataObj); |
|
168 |
|
169 //Not implemented. |
|
170 CJavaCertStoreImpl(const CJavaCertStoreImpl &x); |
|
171 CJavaCertStoreImpl &operator=(const CJavaCertStoreImpl &x); |
|
172 |
|
173 }; |
|
174 |
|
175 |
|
176 } // end namespace security |
|
177 } // end namespace java |
|
178 |
|
179 #endif // JAVACERTSTOREIMPL_H |