sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "CSWICertStoreEntry.h"
|
sl@0
|
20 |
#include <cctcertinfo.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
CSWICertStoreEntry* CSWICertStoreEntry::NewLC(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex, TInt aStoreIndex)
|
sl@0
|
23 |
{
|
sl@0
|
24 |
CSWICertStoreEntry* self = new(ELeave) CSWICertStoreEntry(aStoreIndex);
|
sl@0
|
25 |
CleanupStack::PushL(self);
|
sl@0
|
26 |
|
sl@0
|
27 |
self->InternalizeL(aStream, aToken, aCertIndex);
|
sl@0
|
28 |
return self;
|
sl@0
|
29 |
}
|
sl@0
|
30 |
|
sl@0
|
31 |
CSWICertStoreEntry* CSWICertStoreEntry::NewL(const CCTCertInfo& aCertInfo,const RArray<TUid>& aCertificateApps,TBool aTrusted,TStreamId aDataStreamId,const TCertMetaInfo& aCertMetaInfo, TInt aStoreIndex)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
CSWICertStoreEntry* self = new(ELeave) CSWICertStoreEntry(aStoreIndex);
|
sl@0
|
34 |
CleanupStack::PushL(self);
|
sl@0
|
35 |
self->ConstructL(aCertInfo, aCertificateApps, aTrusted, aDataStreamId, aCertMetaInfo);
|
sl@0
|
36 |
CleanupStack::Pop(self);
|
sl@0
|
37 |
return self;
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
void CSWICertStoreEntry::ConstructL(const CCTCertInfo& aCertInfo,const RArray<TUid>& aCertificateApps,TBool aTrusted,TStreamId aDataStreamId, const TCertMetaInfo& aCertMetaInfo)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
iCertInfo = CCTCertInfo::NewL(aCertInfo);
|
sl@0
|
43 |
|
sl@0
|
44 |
for (TInt i = 0 ; i < aCertificateApps.Count() ; ++i)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
iCertificateApps.AppendL(aCertificateApps[i]);
|
sl@0
|
47 |
}
|
sl@0
|
48 |
|
sl@0
|
49 |
iTrusted = aTrusted;
|
sl@0
|
50 |
iDataStreamId = aDataStreamId;
|
sl@0
|
51 |
iCertMetaInfo = aCertMetaInfo;
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
TInt CSWICertStoreEntry::StoreIndex() const
|
sl@0
|
55 |
{
|
sl@0
|
56 |
return iStoreIndex;
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
CSWICertStoreEntry::CSWICertStoreEntry(TInt aStoreIndex):iStoreIndex(aStoreIndex)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
CSWICertStoreEntry::~CSWICertStoreEntry()
|
sl@0
|
64 |
{
|
sl@0
|
65 |
if (iCertInfo)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
iCertInfo->Release();
|
sl@0
|
68 |
}
|
sl@0
|
69 |
iCertificateApps.Close();
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
void CSWICertStoreEntry::InternalizeL(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
ASSERT(!iCertInfo);
|
sl@0
|
75 |
iCertInfo = CCTCertInfo::NewL(aStream, aToken);
|
sl@0
|
76 |
iCertInfo->SetCertificateId(aCertIndex);
|
sl@0
|
77 |
|
sl@0
|
78 |
TInt count = aStream.ReadInt32L();
|
sl@0
|
79 |
for (TInt i = 0 ; i < count ; ++i)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
TUid id;
|
sl@0
|
82 |
aStream >> id;
|
sl@0
|
83 |
User::LeaveIfError(iCertificateApps.Append(id));
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
iTrusted = !!aStream.ReadUint8L(); // !! converts TUint8 to TBool
|
sl@0
|
87 |
aStream >> iDataStreamId;
|
sl@0
|
88 |
TPckg<TCapabilitySet> capsPckg(iCertMetaInfo.iCapabilities);
|
sl@0
|
89 |
aStream >> capsPckg;
|
sl@0
|
90 |
TUint8 value = aStream.ReadUint8L();
|
sl@0
|
91 |
iCertMetaInfo.iIsMandatory = !!(value & (1 << KMandatory)); // !! converts TUint8 to TBool
|
sl@0
|
92 |
iCertMetaInfo.iIsSystemUpgrade = !!(value & (1 << KSystemUpgrade));
|
sl@0
|
93 |
}
|
sl@0
|
94 |
|
sl@0
|
95 |
const CCTCertInfo& CSWICertStoreEntry::CertInfo() const
|
sl@0
|
96 |
{
|
sl@0
|
97 |
return *iCertInfo;
|
sl@0
|
98 |
}
|
sl@0
|
99 |
|
sl@0
|
100 |
const RArray<TUid>& CSWICertStoreEntry::CertificateApps() const
|
sl@0
|
101 |
{
|
sl@0
|
102 |
return iCertificateApps;
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|
sl@0
|
105 |
TBool CSWICertStoreEntry::IsApplicable(const TUid& aApplication) const
|
sl@0
|
106 |
{
|
sl@0
|
107 |
for (TInt i = 0 ; i < iCertificateApps.Count() ; ++i)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
if (iCertificateApps[i] == aApplication)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
return ETrue;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
}
|
sl@0
|
114 |
return EFalse;
|
sl@0
|
115 |
}
|
sl@0
|
116 |
|
sl@0
|
117 |
TBool CSWICertStoreEntry::Trusted() const
|
sl@0
|
118 |
{
|
sl@0
|
119 |
return iTrusted;
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
TStreamId CSWICertStoreEntry::DataStreamId() const
|
sl@0
|
123 |
{
|
sl@0
|
124 |
return iDataStreamId;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
const TCertMetaInfo& CSWICertStoreEntry::CertMetaInfo() const
|
sl@0
|
128 |
{
|
sl@0
|
129 |
return iCertMetaInfo;
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
|