|
1 /* |
|
2 * Copyright (c) 2006 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: Implementation of DevandTruSrvCertStoreEntry |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "DevandTruSrvCertStoreEntry.h" |
|
21 #include "DevTokenDataTypes.h" |
|
22 #include "DevTokenUtil.h" |
|
23 |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 //CDevandTruSrvCertStoreEntry |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CDevandTruSrvCertStoreEntry::NewL() |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CDevandTruSrvCertStoreEntry* CDevandTruSrvCertStoreEntry::NewL(const CDevTokenCertInfo& aCertInfo, |
|
34 RArray<TUid> aCertificateApps, |
|
35 TBool aTrusted, |
|
36 TStreamId aDataStreamId) |
|
37 { |
|
38 CDevandTruSrvCertStoreEntry* self = new(ELeave) CDevandTruSrvCertStoreEntry(); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(aCertInfo, aCertificateApps, aTrusted, aDataStreamId); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CDevandTruSrvCertStoreEntry::NewLC() |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CDevandTruSrvCertStoreEntry* CDevandTruSrvCertStoreEntry::NewLC(RReadStream& aStream) |
|
51 { |
|
52 CDevandTruSrvCertStoreEntry* self = new(ELeave) CDevandTruSrvCertStoreEntry(); |
|
53 CleanupStack::PushL(self); |
|
54 self->InternalizeL(aStream); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CDevandTruSrvCertStoreEntry::CDevandTruSrvCertStoreEntry() |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CDevandTruSrvCertStoreEntry::CDevandTruSrvCertStoreEntry() |
|
64 { |
|
65 } |
|
66 |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CDevandTruSrvCertStoreEntry::ConstructL() |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 void CDevandTruSrvCertStoreEntry::ConstructL(const CDevTokenCertInfo& aCertInfo, |
|
73 RArray<TUid> aCertificateApps, |
|
74 TBool aTrusted, |
|
75 TStreamId aDataStreamId) |
|
76 { |
|
77 assert(aDataStreamId != KNullStreamId, EPanicCertStoreEntryConstructArguments); |
|
78 |
|
79 iCertInfo = CDevTokenCertInfo::NewL(aCertInfo); |
|
80 |
|
81 for (TInt i = 0 ; i < aCertificateApps.Count() ; ++i) |
|
82 { |
|
83 User::LeaveIfError(iCertificateApps.Append(aCertificateApps[i])); |
|
84 } |
|
85 |
|
86 iTrusted = aTrusted; |
|
87 iDataStreamId = aDataStreamId; |
|
88 } |
|
89 |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CDevandTruSrvCertStoreEntry::~CDevandTruSrvCertStoreEntry() |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 CDevandTruSrvCertStoreEntry::~CDevandTruSrvCertStoreEntry() |
|
96 { |
|
97 delete iCertInfo; |
|
98 iCertificateApps.Close(); |
|
99 } |
|
100 |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // CDevandTruSrvCertStoreEntry::ExternalizeL() |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CDevandTruSrvCertStoreEntry::ExternalizeL(RWriteStream& aStream) const |
|
107 { |
|
108 aStream << *iCertInfo; |
|
109 TInt count = iCertificateApps.Count(); |
|
110 aStream.WriteInt32L(count); |
|
111 for (TInt i = 0 ; i < count ; ++i) |
|
112 { |
|
113 aStream << iCertificateApps[i]; |
|
114 } |
|
115 aStream.WriteUint8L(iTrusted); |
|
116 aStream << iDataStreamId; |
|
117 } |
|
118 |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CDevandTruSrvCertStoreEntry::InternalizeL() |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 void CDevandTruSrvCertStoreEntry::InternalizeL(RReadStream& aStream) |
|
125 { |
|
126 assert(!iCertInfo, EPanicCertStoreEntryInternalizeState); |
|
127 iCertInfo = CDevTokenCertInfo::NewL(aStream); |
|
128 |
|
129 TInt count = aStream.ReadInt32L(); |
|
130 for (TInt i = 0 ; i < count ; ++i) |
|
131 { |
|
132 TUid id; |
|
133 aStream >> id; |
|
134 User::LeaveIfError(iCertificateApps.Append(id)); |
|
135 } |
|
136 |
|
137 iTrusted = !!aStream.ReadUint8L(); |
|
138 aStream >> iDataStreamId; |
|
139 } |
|
140 |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CDevandTruSrvCertStoreEntry::CertInfo() |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 const CDevTokenCertInfo& CDevandTruSrvCertStoreEntry::CertInfo() const |
|
147 { |
|
148 return *iCertInfo; |
|
149 } |
|
150 |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CDevandTruSrvCertStoreEntry::CertificateApps() |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 const RArray<TUid>& CDevandTruSrvCertStoreEntry::CertificateApps() const |
|
157 { |
|
158 return iCertificateApps; |
|
159 } |
|
160 |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // CDevandTruSrvCertStoreEntry::IsApplicable() |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 TBool CDevandTruSrvCertStoreEntry::IsApplicable(const TUid& aApplication) const |
|
167 { |
|
168 for (TInt i = 0 ; i < iCertificateApps.Count() ; ++i) |
|
169 { |
|
170 if (iCertificateApps[i] == aApplication) |
|
171 { |
|
172 return ETrue; |
|
173 } |
|
174 } |
|
175 return EFalse; |
|
176 } |
|
177 |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // CDevandTruSrvCertStoreEntry::Trusted() |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 TBool CDevandTruSrvCertStoreEntry::Trusted() const |
|
184 { |
|
185 return iTrusted; |
|
186 } |
|
187 |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CDevandTruSrvCertStoreEntry::DataStreamId() |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 TStreamId CDevandTruSrvCertStoreEntry::DataStreamId() const |
|
194 { |
|
195 return iDataStreamId; |
|
196 } |
|
197 |
|
198 //EOF |
|
199 |