os/security/cryptoservices/certificateandkeymgmt/swicertstore/CSWICertStoreEntry.cpp
First public contribution.
2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "CSWICertStoreEntry.h"
20 #include <cctcertinfo.h>
22 CSWICertStoreEntry* CSWICertStoreEntry::NewLC(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex, TInt aStoreIndex)
24 CSWICertStoreEntry* self = new(ELeave) CSWICertStoreEntry(aStoreIndex);
25 CleanupStack::PushL(self);
27 self->InternalizeL(aStream, aToken, aCertIndex);
31 CSWICertStoreEntry* CSWICertStoreEntry::NewL(const CCTCertInfo& aCertInfo,const RArray<TUid>& aCertificateApps,TBool aTrusted,TStreamId aDataStreamId,const TCertMetaInfo& aCertMetaInfo, TInt aStoreIndex)
33 CSWICertStoreEntry* self = new(ELeave) CSWICertStoreEntry(aStoreIndex);
34 CleanupStack::PushL(self);
35 self->ConstructL(aCertInfo, aCertificateApps, aTrusted, aDataStreamId, aCertMetaInfo);
36 CleanupStack::Pop(self);
40 void CSWICertStoreEntry::ConstructL(const CCTCertInfo& aCertInfo,const RArray<TUid>& aCertificateApps,TBool aTrusted,TStreamId aDataStreamId, const TCertMetaInfo& aCertMetaInfo)
42 iCertInfo = CCTCertInfo::NewL(aCertInfo);
44 for (TInt i = 0 ; i < aCertificateApps.Count() ; ++i)
46 iCertificateApps.AppendL(aCertificateApps[i]);
50 iDataStreamId = aDataStreamId;
51 iCertMetaInfo = aCertMetaInfo;
54 TInt CSWICertStoreEntry::StoreIndex() const
59 CSWICertStoreEntry::CSWICertStoreEntry(TInt aStoreIndex):iStoreIndex(aStoreIndex)
63 CSWICertStoreEntry::~CSWICertStoreEntry()
69 iCertificateApps.Close();
72 void CSWICertStoreEntry::InternalizeL(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex)
75 iCertInfo = CCTCertInfo::NewL(aStream, aToken);
76 iCertInfo->SetCertificateId(aCertIndex);
78 TInt count = aStream.ReadInt32L();
79 for (TInt i = 0 ; i < count ; ++i)
83 User::LeaveIfError(iCertificateApps.Append(id));
86 iTrusted = !!aStream.ReadUint8L(); // !! converts TUint8 to TBool
87 aStream >> iDataStreamId;
88 TPckg<TCapabilitySet> capsPckg(iCertMetaInfo.iCapabilities);
90 TUint8 value = aStream.ReadUint8L();
91 iCertMetaInfo.iIsMandatory = !!(value & (1 << KMandatory)); // !! converts TUint8 to TBool
92 iCertMetaInfo.iIsSystemUpgrade = !!(value & (1 << KSystemUpgrade));
95 const CCTCertInfo& CSWICertStoreEntry::CertInfo() const
100 const RArray<TUid>& CSWICertStoreEntry::CertificateApps() const
102 return iCertificateApps;
105 TBool CSWICertStoreEntry::IsApplicable(const TUid& aApplication) const
107 for (TInt i = 0 ; i < iCertificateApps.Count() ; ++i)
109 if (iCertificateApps[i] == aApplication)
117 TBool CSWICertStoreEntry::Trusted() const
122 TStreamId CSWICertStoreEntry::DataStreamId() const
124 return iDataStreamId;
127 const TCertMetaInfo& CSWICertStoreEntry::CertMetaInfo() const
129 return iCertMetaInfo;