2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FSecCert_X509CertificateStoreImpl.h
20 * @brief This is the header file for the %_X509CertificateStoreImpl class.
22 * This header file contains the declarations of the %_X509CertificateStoreImpl class.
24 #ifndef _FSEC_CERT_INTERNAL_X509_CERTIFICATE_STORE_H_
25 #define _FSEC_CERT_INTERNAL_X509_CERTIFICATE_STORE_H_
27 #include <FBaseString.h>
28 #include <FBaseByteBuffer.h>
29 #include <FSecIPrivateKey.h>
30 #include <FSecCertICertificateStore.h>
31 #include <FSecCertICertificateSelector.h>
32 #include <FSecCertX509CertificateStore.h>
34 namespace Tizen { namespace Security { namespace Cert
37 class _CertServiceProxy;
39 * @brief This class is used for retrieving and managing certificates from a repository.
42 * The %_X509CertificateStoreImpl class is used for retrieving and managing certificates from a repository.
44 class _X509CertificateStoreImpl
49 * This is the default constructor for this class.
53 _X509CertificateStoreImpl(void);
56 * This is the destructor for this class.
60 virtual ~_X509CertificateStoreImpl(void);
63 * Gets the name of the current certificate store.
67 * @return An error code
68 * @param[out] name The name of the certificate store
69 * @exception E_SUCCESS The method is successful.
71 result GetName(Tizen::Base::String& name) const;
74 * Sets a list of certificates that match the specified selector.
78 * @return An error code
79 * @param[in] selector A selector that defines a set of criterion for selecting certificates
80 * @exception E_SUCCESS The method is successful.
81 * @exception E_OUT_OF_MEMORY The memory is insufficient.
82 * @exception E_SYSTEM A system error has occurred.
83 * - IPC operation failed.
84 * @exception E_INVALID_ARG The specified @c selector is invalid.
85 * @exception E_UNSUPPORTED_OPERATION The type of selector is invalid.
88 result SetCertificateSelector(const Tizen::Security::Cert::ICertificateSelector& selector);
91 * Gets a count of certificates that match the specified selector.
95 * @return An error code
96 * @param[out] count The count of certificates
97 * @exception E_SUCCESS The method is successful.
99 result GetCertificateCount(int& count) const;
102 * Gets each certificate that matches the specified selector.
106 * @return The certificates that matches the specified selector
107 * @exception E_SUCCESS The method is successful.
108 * @exception E_OUT_OF_MEMORY The memory is insufficient.
109 * @exception E_OBJ_NOT_FOUND The certificate is not found.
110 * @exception E_SYSTEM A system error has occurred.
111 * - ByteBuffer operation failed.
113 Tizen::Security::Cert::ICertificate* GetNextCertificateN(void) const;
116 * Inserts the certificate into the certificate store.
120 * @return An error code
121 * @param[in] certificateType The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
122 * @param[in] certificate A reference to the certificate to insert
123 * @exception E_SUCCESS The method is successful.
124 * @exception E_OUT_OF_MEMORY The memory is insufficient.
125 * @exception E_INVALID_ARG The specified @c certificate or the certificate data is invalid,
126 * or the specified @c certificateType is invalid.
127 * @exception E_SYSTEM A system error has occurred.
128 * - IPC operation failed.
129 * - File operation failed.
130 * - DB operation failed.
132 result Insert(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
135 * Inserts the user certificate of Pkcs 12 format into the certificate store.
139 * @return An error code
140 * @param[in] filePath The file path of pkcs 12 certificate to insert.
141 * @param[in] password Password string to decrypt pkcs 12 certificate.
142 * @exception E_SUCCESS The method is successful.
143 * @exception E_OUT_OF_MEMORY The memory is insufficient.
144 * @exception E_INVALID_ARG The specified @c certificate or the certificate data is invalid.
145 * @exception E_SYSTEM A system error has occurred.
146 * - IPC operation failed.
147 * - File operation failed.
148 * - DB operation failed.
150 result InsertPkcs12(const Tizen::Base::String& filePath, const Tizen::Base::String& password);
153 * Updates the certificate in the certificate store.
157 * @return An error code
158 * @param[in] certificateType The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
159 * @param[in] oldCert A reference to the old certificate
160 * @param[in] newCert A reference to the new certificate
161 * @exception E_SUCCESS The method is successful.
162 * @exception E_OUT_OF_MEMORY The memory is insufficient.
163 * @exception E_INVALID_ARG The specified @c certificate or the certificate data is invalid,
164 * or the specified @c certificateType is invalid.
165 * @exception E_OBJ_NOT_FOUND The certificate is not found.
166 * @exception E_SYSTEM A system error has occurred.
167 * - IPC operation failed.
168 * - File operation failed.
169 * - DB operation failed.
171 result Update(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& oldCert, const Tizen::Security::Cert::ICertificate& newCert);
174 * Removes the certificate from the certificate store.
178 * @return An error code
179 * @param[in] certificateType The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, TRUSTED_THIRD_PARTY_DOMAIN)
180 * @param[in] certificate A reference to the certificate to remove
181 * @exception E_SUCCESS The method is successful.
182 * @exception E_OUT_OF_MEMORY The memory is insufficient.
183 * @exception E_INVALID_ARG The specified @c certificate or the certificate data is invalid,
184 * or the specified @c certificateType is invalid.
185 * @exception E_OBJ_NOT_FOUND The certificate is not found.
186 * @exception E_SYSTEM A system error has occurred.
187 * - IPC operation failed.
188 * - File operation failed.
189 * - DB operation failed.
191 result Remove(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
193 static _X509CertificateStoreImpl* GetInstance(X509CertificateStore& x509CertificateStore);
194 static const _X509CertificateStoreImpl* GetInstance(const X509CertificateStore& x509CertificateStore);
197 result UpdateCertStoreContext(void);
198 _X509CertificateStoreImpl(const _X509CertificateStoreImpl& rhs);
199 _X509CertificateStoreImpl& operator =(const _X509CertificateStoreImpl& rhs);
203 int __certificateStoreCtx;
204 _CertServiceProxy* __pCertServiceProxy;
205 friend class X509CertificateStore;
206 }; //X509CertificateStoreImpl
208 } } } //Tizen::Security::Cert
210 #endif //_FSEC_CERT_INTERNAL_X509_CERTIFICATE_STORE_H_