2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FSecCertX509CertificateStore.h
19 * @brief This is the header file for the %X509CertificateStore class.
21 * This header file contains the declarations of the %X509CertificateStore class.
23 #ifndef _FSEC_CERT_X509_CERTIFICATE_STORE_H_
24 #define _FSEC_CERT_X509_CERTIFICATE_STORE_H_
26 #include <FBaseString.h>
27 #include <FBaseByteBuffer.h>
28 #include <FSecIPrivateKey.h>
29 #include <FSecCertICertificateStore.h>
30 #include <FSecCertICertificateSelector.h>
32 namespace Tizen { namespace Security { namespace Cert
35 class _CertMgrSvcProxy;
38 * @class X509CertificateStore
39 * @brief This class provides methods for retrieving and managing certificates from a repository.
43 * The %X509CertificateStore class is used for retrieving and managing certificates from a repository.
45 class _OSP_EXPORT_ X509CertificateStore
46 : public virtual ICertificateStore
47 , public Tizen::Base::Object
52 * This is the default constructor for this class.
56 X509CertificateStore(void);
59 * This is the destructor for this class.
63 virtual ~X509CertificateStore(void);
66 * Gets the name of the current certificate store.
71 * @privilege %http://tizen.org/privilege/certificate.read
73 * @return An error code
74 * @param[out] name The name of the certificate store
75 * @exception E_SUCCESS The method is successful.
76 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
78 virtual result GetName(Tizen::Base::String& name) const;
81 * Sets a list of certificates that match the specified @c selector.
86 * @privilege %http://tizen.org/privilege/certificate.read
88 * @return An error code
89 * @param[in] selector The selector that defines a set of criterion for selecting certificates
90 * @exception E_SUCCESS The method is successful.
91 * @exception E_OUT_OF_MEMORY The memory is insufficient.
92 * @exception E_SYSTEM Either of the following conditions has occurred:
93 * - A system error has occurred.
94 * - The IPC operation has failed.
95 * @exception E_INVALID_ARG The specified @c selector is invalid.
96 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
98 virtual result SetCertificateSelector(const Tizen::Security::Cert::ICertificateSelector& selector);
101 * Gets the count of certificates that match the specified selector.
106 * @privilege %http://tizen.org/privilege/certificate.read
108 * @return An error code
109 * @param[out] count The count of certificates
110 * @exception E_SUCCESS The method is successful.
111 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
113 virtual result GetCertificateCount(int& count) const;
116 * Gets the certificate that matches the specified selector.
121 * @privilege %http://tizen.org/privilege/certificate.read
123 * @return The certificate that matches the specified selector
124 * @exception E_SUCCESS The method is successful.
125 * @exception E_OUT_OF_MEMORY The memory is insufficient.
126 * @exception E_OBJ_NOT_FOUND The certificate is not found.
127 * @exception E_SYSTEM Either of the following conditions has occurred:
128 * - A system error has occurred.
129 * - The Tizen::Base::ByteBuffer operation has failed.
130 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
132 virtual Tizen::Security::Cert::ICertificate* GetNextCertificateN(void) const;
135 * Inserts the certificate into the certificate store.
140 * @privilege %http://tizen.org/privilege/certificate.write
142 * @return An error code
143 * @param[in] certificateType The type of the Certificate (@c ROOT_CA, @c OPERATOR_DOMAIN, or @c TRUSTED_THIRD_PARTY_DOMAIN)
144 * @param[in] certificate A reference to the certificate to insert
145 * @exception E_SUCCESS The method is successful.
146 * @exception E_OUT_OF_MEMORY The memory is insufficient.
147 * @exception E_INVALID_ARG Either of the following conditions has occurred:
148 * - The specified @c certificate or the certificate data is invalid.
149 * - The specified @c certificateType is invalid.
150 * @exception E_SYSTEM Either of the following conditions has occurred:
151 * - A system error has occurred.
152 * - Either the IPC operation or the file operation or the DB operation has failed.
153 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
155 virtual result Insert(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
158 * Updates the certificate in the certificate store.
163 * @privilege %http://tizen.org/privilege/certificate.write
165 * @return An error code
166 * @param[in] certificateType The type of the Certificate (@c ROOT_CA, @c OPERATOR_DOMAIN, or @c TRUSTED_THIRD_PARTY_DOMAIN)
167 * @param[in] oldCert A reference to the old certificate
168 * @param[in] newCert A reference to the new certificate
169 * @exception E_SUCCESS The method is successful.
170 * @exception E_OUT_OF_MEMORY The memory is insufficient.
171 * @exception E_INVALID_ARG Either of the following conditions has occurred:
172 * - The specified @c certificate or the certificate data is invalid.
173 * - The specified @c certificateType is invalid.
174 * @exception E_OBJ_NOT_FOUND The certificate is not found.
175 * @exception E_SYSTEM Either of the following conditions has occurred:
176 * - A system error has occurred.
177 * - Either the IPC operation or the file operation or the DB operation has failed.
178 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
180 virtual result Update(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& oldCert, const Tizen::Security::Cert::ICertificate& newCert);
183 * Removes the certificate from the certificate store.
188 * @privilege %http://tizen.org/privilege/certificate.write
190 * @return An error code
191 * @param[in] certificateType The type of the Certificate (@c ROOT_CA, @c OPERATOR_DOMAIN, @c TRUSTED_THIRD_PARTY_DOMAIN)
192 * @param[in] certificate A reference to the certificate to remove
193 * @exception E_SUCCESS The method is successful.
194 * @exception E_OUT_OF_MEMORY The memory is insufficient.
195 * @exception E_INVALID_ARG Either of the following conditions has occurred:
196 * - The specified @c certificate or the certificate data is invalid.
197 * - The specified @c certificateType is invalid.
198 * @exception E_OBJ_NOT_FOUND The certificate is not found.
199 * @exception E_SYSTEM Either of the following conditions has occurred:
200 * - A system error has occurred.
201 * - Either the IPC operation or the file operation or the DB operation has failed.
202 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
204 virtual result Remove(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
207 * Inserts the user certificate of PKCS 12 format into the certificate store.
212 * @privilege %http://tizen.org/privilege/certificate.write
214 * @return An error code
215 * @param[in] filePath The file path of PKCS 12 certificate to insert
216 * @param[in] password The password string to decrypt PKCS 12 certificate
217 * @exception E_SUCCESS The method is successful.
218 * @exception E_INVALID_ARG The specified @c certificate or the certificate data is invalid.
219 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
220 * @exception E_DATA_NOT_FOUND A root CA certificate does not exist.
221 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
223 result InsertPkcs12(const Tizen::Base::String& filePath, const Tizen::Base::String& password);
226 X509CertificateStore(const X509CertificateStore& rhs);
227 X509CertificateStore& operator =(const X509CertificateStore& rhs);
230 class _X509CertificateStoreImpl* __pX509CertificateStoreImpl;
231 friend class _X509CertificateStoreImpl;
233 }; //X509CertificateStore
235 } } } //Tizen::Security::Cert
237 #endif //_FSEC_CERT_X509_CERTIFICATE_STORE_H_