Revert "Revert "Fix intApp TC failure""
[platform/framework/native/appfw.git] / inc / FSecCertX509CertificateStore.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16
17 /**
18  * @file                FSecCertX509CertificateStore.h
19  * @brief               This is the header file for the %X509CertificateStore class.
20  *
21  * This header file contains the declarations of the %X509CertificateStore class.
22  */
23 #ifndef _FSEC_CERT_X509_CERTIFICATE_STORE_H_
24 #define _FSEC_CERT_X509_CERTIFICATE_STORE_H_
25
26 #include <FBaseString.h>
27 #include <FBaseByteBuffer.h>
28 #include <FSecIPrivateKey.h>
29 #include <FSecCertICertificateStore.h>
30 #include <FSecCertICertificateSelector.h>
31
32 namespace Tizen { namespace Security { namespace Cert
33 {
34
35 class _CertMgrSvcProxy;
36
37 /**
38  *      @class  X509CertificateStore
39  *      @brief  This class provides methods for retrieving and managing certificates from a repository.
40  *
41  *      @since  2.0
42  *
43  *      The %X509CertificateStore class is used for retrieving and managing certificates from a repository.
44  */
45 class _OSP_EXPORT_ X509CertificateStore
46         : public virtual ICertificateStore
47         , public Tizen::Base::Object
48 {
49
50 public:
51         /**
52          *      This is the default constructor for this class.
53          *
54          *      @since          2.0
55          */
56         X509CertificateStore(void);
57
58         /**
59          *      This is the destructor for this class.
60          *
61          *      @since          2.0
62          */
63         virtual ~X509CertificateStore(void);
64
65         /**
66          *      Gets the name of the current certificate store.
67          *
68          *      @since                  2.0
69          *
70          *      @privlevel              partner
71          *      @privilege              %http://tizen.org/privilege/certificate.read
72          *
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.
77          */
78         virtual result GetName(Tizen::Base::String& name) const;
79
80         /**
81          *      Sets a list of certificates that match the specified @c selector.
82          *
83          *      @since                  2.0
84          *
85          *      @privlevel              partner
86          *      @privilege              %http://tizen.org/privilege/certificate.read
87          *
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.
97          */
98         virtual result SetCertificateSelector(const Tizen::Security::Cert::ICertificateSelector& selector);
99
100         /**
101          *      Gets the count of certificates that match the specified selector.
102          *
103          *      @since                  2.0
104          *
105          *      @privlevel              partner
106          *      @privilege              %http://tizen.org/privilege/certificate.read
107          *
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.
112          */
113         virtual result GetCertificateCount(int& count) const;
114
115         /**
116          *      Gets the certificate that matches the specified selector.
117          *
118          *      @since                  2.0
119          *
120          *      @privlevel              partner
121          *      @privilege              %http://tizen.org/privilege/certificate.read
122          *
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.
131          */
132         virtual Tizen::Security::Cert::ICertificate* GetNextCertificateN(void) const;
133
134         /**
135          *      Inserts the certificate into the certificate store.
136          *
137          *      @since                  2.0
138          *
139          *      @privlevel              partner
140          *      @privilege              %http://tizen.org/privilege/certificate.write
141          *
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.
154          */
155         virtual result Insert(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
156
157         /**
158          *      Updates the certificate in the certificate store.
159          *
160          *      @since                  2.0
161          *
162          *      @privlevel              partner
163          *      @privilege              %http://tizen.org/privilege/certificate.write
164          *
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.
179          */
180         virtual result Update(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& oldCert, const Tizen::Security::Cert::ICertificate& newCert);
181
182         /**
183          *      Removes the certificate from the certificate store.
184          *
185          *      @since                  2.0
186          *
187          *      @privlevel              partner
188          *      @privilege              %http://tizen.org/privilege/certificate.write
189          *
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.
203          */
204         virtual result Remove(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
205
206         /**
207          *  Inserts the user certificate of PKCS 12 format into the certificate store.
208          *
209          *      @since 2.0
210          *
211          *      @privlevel              partner
212          *      @privilege              %http://tizen.org/privilege/certificate.write
213          *
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.
222          */
223         result InsertPkcs12(const Tizen::Base::String& filePath, const Tizen::Base::String& password);
224
225 private:
226         X509CertificateStore(const X509CertificateStore& rhs);
227         X509CertificateStore& operator =(const X509CertificateStore& rhs);
228
229 private:
230         class _X509CertificateStoreImpl* __pX509CertificateStoreImpl;
231         friend class _X509CertificateStoreImpl;
232
233 }; //X509CertificateStore
234
235 } } } //Tizen::Security::Cert
236
237 #endif //_FSEC_CERT_X509_CERTIFICATE_STORE_H_