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 is used 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 A 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 A system error has occurred. @n
93 * The IPC operation has failed.
94 * @exception E_INVALID_ARG The specified @c selector is invalid.
95 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
97 virtual result SetCertificateSelector(const Tizen::Security::Cert::ICertificateSelector& selector);
100 * Gets a count of certificates that match the specified selector.
105 * @privilege %http://tizen.org/privilege/certificate.read
107 * @return An error code
108 * @param[out] count The count of certificates
109 * @exception E_SUCCESS The method is successful.
110 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
112 virtual result GetCertificateCount(int& count) const;
115 * Gets each certificate that matches the specified selector.
120 * @privilege %http://tizen.org/privilege/certificate.read
122 * @return The certificates that matches the specified selector
123 * @exception E_SUCCESS The method is successful.
124 * @exception E_OUT_OF_MEMORY The memory is insufficient.
125 * @exception E_OBJ_NOT_FOUND The certificate is not found.
126 * @exception E_SYSTEM A system error has occurred. @n
127 * The Tizen::Base::ByteBuffer operation has failed.
128 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
130 virtual Tizen::Security::Cert::ICertificate* GetNextCertificateN(void) const;
133 * Inserts the certificate into the certificate store.
138 * @privilege %http://tizen.org/privilege/certificate.write
140 * @return An error code
141 * @param[in] certificateType The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
142 * @param[in] certificate A reference to the certificate to insert
143 * @exception E_SUCCESS The method is successful.
144 * @exception E_OUT_OF_MEMORY The memory is insufficient.
145 * @exception E_INVALID_ARG The specified @c certificate or the certificate data is invalid, or
146 * the specified @c certificateType is invalid.
147 * @exception E_SYSTEM A system error has occurred. @n
148 * Either the IPC operation or the file operation or the DB operation has failed.
149 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
151 virtual result Insert(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
154 * Updates the certificate in the certificate store.
159 * @privilege %http://tizen.org/privilege/certificate.write
161 * @return An error code
162 * @param[in] certificateType The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
163 * @param[in] oldCert A reference to the old certificate
164 * @param[in] newCert A reference to the new certificate
165 * @exception E_SUCCESS The method is successful.
166 * @exception E_OUT_OF_MEMORY The memory is insufficient.
167 * @exception E_INVALID_ARG The specified @c certificate or the certificate data is invalid, or
168 * the specified @c certificateType is invalid.
169 * @exception E_OBJ_NOT_FOUND The certificate is not found.
170 * @exception E_SYSTEM A system error has occurred. @n
171 * Either the IPC operation or the file operation or the DB operation has failed.
172 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
174 virtual result Update(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& oldCert, const Tizen::Security::Cert::ICertificate& newCert);
177 * Removes the certificate from the certificate store.
182 * @privilege %http://tizen.org/privilege/certificate.write
184 * @return An error code
185 * @param[in] certificateType The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, TRUSTED_THIRD_PARTY_DOMAIN)
186 * @param[in] certificate A reference to the certificate to remove
187 * @exception E_SUCCESS The method is successful.
188 * @exception E_OUT_OF_MEMORY The memory is insufficient.
189 * @exception E_INVALID_ARG The specified @c certificate or the certificate data is invalid, or
190 * the specified @c certificateType is invalid.
191 * @exception E_OBJ_NOT_FOUND The certificate is not found.
192 * @exception E_SYSTEM A system error has occurred. @n
193 * Either the IPC operation or the file operation or the DB operation has failed.
194 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
196 virtual result Remove(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
199 * Inserts the user certificate of PKCS 12 format into the certificate store.
204 * @privilege %http://tizen.org/privilege/certificate.write
206 * @return An error code
207 * @param[in] filePath The file path of PKCS 12 certificate to insert
208 * @param[in] password The password string to decrypt PKCS 12 certificate
209 * @exception E_SUCCESS The method is successful.
210 * @exception E_INVALID_ARG The specified @c certificate or the certificate data is invalid.
211 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
212 * @exception E_DATA_NOT_FOUND A root CA certificate does not exist.
213 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
215 result InsertPkcs12(const Tizen::Base::String& filePath, const Tizen::Base::String& password);
218 X509CertificateStore(const X509CertificateStore& rhs);
219 X509CertificateStore& operator =(const X509CertificateStore& rhs);
222 class _X509CertificateStoreImpl* __pX509CertificateStoreImpl;
223 friend class _X509CertificateStoreImpl;
225 }; //X509CertificateStore
227 } } } //Tizen::Security::Cert
229 #endif //_FSEC_CERT_X509_CERTIFICATE_STORE_H_