os/security/cryptoservices/certificateandkeymgmt/tadditionalstores/test1certstore.h
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.
24 #ifndef __TEST1CERTSTORE_H__
25 #define __TEST1CERTSTORE_H__
30 #include <mctwritablecertstore.h>
31 #include <unifiedkeystore.h>
33 #include "test1certstoretoken.h"
37 class CFileCertStoreMapping;
38 class CFileCertStoreMappings;
41 * This class implements a certificate store which is stored on a file on the device.
43 * CTest1CertStore initialization.
44 * NewL and NewLC call the constructor and ConstructL. The constructor does nothing
45 * except initializing to 0. ConstructL connects to fs, then calls
46 * OpenStoreL, then RestoreL and then sets the values of iStoreInfo.
47 * OpenStoreL opens the store ad copies it from the ROM if necessary.
50 class CTest1CertStore : public CActive, public MCTWritableCertStore
53 static CTest1CertStore* NewL(RFs& aFs, CTest1CertStoreToken& aToken,
54 const TDesC& aFileName, TFileMode aMode);
56 public: // from MCTTokenInterface
57 virtual MCTToken& Token();
58 protected: // from MCTTokenInterface
59 virtual void DoRelease();
62 public: // from MCTCertStore
63 virtual void List(RMPointerArray<CCTCertInfo>& aCerts,
64 const CCertAttributeFilter& aFilter, TRequestStatus& aStatus);
65 virtual void CancelList();
66 virtual void GetCert(CCTCertInfo*& aCertInfo, const TCTTokenObjectHandle& aHandle,
67 TRequestStatus& aStatus);
68 virtual void CancelGetCert();
69 virtual void Applications(const CCTCertInfo& aCertInfo, RArray<TUid>& aApplications,
70 TRequestStatus& aStatus);
71 virtual void CancelApplications();
72 virtual void IsApplicable(const CCTCertInfo& aCertInfo, TUid aApplication,
73 TBool& aIsApplicable, TRequestStatus& aStatus);
74 virtual void CancelIsApplicable();
75 virtual void Trusted(const CCTCertInfo& aCertInfo, TBool& aTrusted,
76 TRequestStatus& aStatus);
77 virtual void CancelTrusted();
79 // this could be asynch or sync depending on state of compile flag CERTSTORE_SOFTWARE_ASYNCH
80 virtual void Retrieve(const CCTCertInfo& aCertInfo, TDes8& aEncodedCert,
81 TRequestStatus& aStatus);
82 virtual void CancelRetrieve();
83 virtual void Capabilities(const CCTCertInfo& aCertInfo, TCapabilitySet& aCapbilitiesOut,
84 TRequestStatus& aStatus);
85 virtual void CancelCapabilities();
86 virtual void IsMandatory(const CCTCertInfo& aCertInfo, TBool& aMandatoryOut,
87 TRequestStatus& aStatus);
88 virtual void CancelIsMandatory();
90 public: // from MCTWritableCertStore
91 virtual void Add(const TDesC& aLabel, TCertificateFormat aFormat,
92 TCertificateOwnerType aCertificateOwnerType,
93 const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
94 const TDesC8& aCert, TRequestStatus& aStatus);
95 virtual void CancelAdd();
96 virtual void Remove(const CCTCertInfo& aCertInfo, TRequestStatus& aStatus);
97 virtual void CancelRemove();
98 virtual void SetApplicability(const CCTCertInfo& aCertInfo,
99 const RArray<TUid>& aApplications, TRequestStatus &aStatus);
100 virtual void CancelSetApplicability();
101 virtual void SetTrust(const CCTCertInfo& aCertInfo, TBool aTrusted,
102 TRequestStatus& aStatus);
103 virtual void CancelSetTrust();
104 virtual void SetCapabilities(const CCTCertInfo& aCertInfo, const TCapabilitySet& aCapabilities,
105 TRequestStatus& aStatus);
106 virtual void CancelSetCapabilities();
107 virtual void SetMandatory(const CCTCertInfo& aCertInfo, TBool aMandatory,
108 TRequestStatus& aStatus);
109 virtual void CancelSetMandatory();
112 virtual ~CTest1CertStore();
113 void DoSetApplicabilityL(const CCTCertInfo& aCertInfo,
114 const RArray<TUid>& aApplications);
115 void DoSetTrustL(const CCTCertInfo& aCertInfo,
117 CTest1CertStore(CTest1CertStoreToken& aToken, RFs& aFs);
118 void ConstructL(const TDesC& aFileName, TFileMode aMode);
119 static void RevertStore(TAny* aStore);
120 static void DeleteFile(TAny* aThis);
122 CPermanentFileStore* OpenStoreL(const TDesC& aFileName, TFileMode aMode);
123 CPermanentFileStore* OpenStoreLC(const TDesC& aFileName, TFileMode aMode);
127 // void AddCACertL(const CCertificate& aCert, const TDesC& aLabel, TCertificateFormat aFormat);
128 // void AddUserCertL(const CCertificate& aCert, const TDesC& aLabel, TCertificateFormat aFormat,
129 // const TKeyIdentifier& aIssuerKeyHash, const TKeyIdentifier& aSubjectKeyHash);
130 void AddUserCertURLL(const TDesC8& aCert, const TDesC& aLabel,
131 const TKeyIdentifier& aIssuerKeyHash, const TKeyIdentifier& aSubjectKeyHash);
132 // void AddCertL(CCTCertInfo* aCertInfo, const CCertificate& aCert, CFileCertStoreMappings& aMappings);
133 void AddCertL(CCTCertInfo* aCertInfo, const TDesC8& aCert, CFileCertStoreMappings& aMappings);
134 void DoRemoveL(const CCTCertInfo& aCertInfo);
135 void DoLoadL(TDes8& aCertificate, CFileCertStoreMapping& aMapping) const;
136 void DoGetUserCertsL(RPointerArray<CCTCertInfo>& aCertInfos,
137 const CCertAttributeFilter& aFilter) const;
139 void DoAddL(const TDesC& aLabel, TCertificateFormat aFormat,
140 TCertificateOwnerType aCertificateOwnerType, const TKeyIdentifier* aSubjectKeyId,
141 const TKeyIdentifier* aIssuerKeyId,const TDesC8& aCert);
143 // perform the retrieval synchronously
144 void RetrieveNow(const CCTCertInfo& aCertInfo,TDes8& aCertificate,TRequestStatus& aStatus);
160 CTest1CertStoreToken& iToken;
164 CPermanentFileStore* iStore;
167 * The list of certificates contained in the store.
169 CFileCertStoreMappings* iCerts;
172 TRequestStatus* iOriginalRequestStatus;
173 RPointerArray<CCTCertInfo>* iCertInfos;
174 const CCertAttributeFilter* iFilter;
175 TCTKeyAttributeFilter iKeyFilter;
176 RMPointerArray<CCTKeyInfo> iKeyInfos;
177 CUnifiedKeyStore* iUnifiedKeyStore;
179 // used for asynchronous certificate retrieval
180 const CCTCertInfo* iAsynchCertInfo;
181 TDes8* iAsynchCertificate;