Merge "Apply millisecond of DateTime for Calendar" into tizen_2.1
[platform/framework/native/appfw.git] / inc / FSecCertX509CertificateStore.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file                FSecCertX509CertificateStore.h
20  * @brief               This is the header file for the %X509CertificateStore class.
21  *
22  * This header file contains the declarations of the %X509CertificateStore class.
23  */
24 #ifndef _FSEC_CERT_X509_CERTIFICATE_STORE_H_
25 #define _FSEC_CERT_X509_CERTIFICATE_STORE_H_
26
27 #include <FBaseString.h>
28 #include <FBaseByteBuffer.h>
29 #include <FSecIPrivateKey.h>
30 #include <FSecCertICertificateStore.h>
31 #include <FSecCertICertificateSelector.h>
32
33 namespace Tizen { namespace Security { namespace Cert
34 {
35
36 class _CertMgrSvcProxy;
37
38 /**
39  *      @class  X509CertificateStore
40  *      @brief  This class is used for retrieving and managing certificates from a repository.
41  *
42  *      @since  2.0
43  *
44  *      The %X509CertificateStore class is used for retrieving and managing certificates from a repository.
45  */
46 class _OSP_EXPORT_ X509CertificateStore
47         : public virtual ICertificateStore
48         , public Tizen::Base::Object
49 {
50
51 public:
52         /**
53          *      This is the default constructor for this class.
54          *
55          *      @since          2.0
56          */
57         X509CertificateStore(void);
58
59         /**
60          *      This is the destructor for this class.
61          *
62          *      @since          2.0
63          */
64         virtual ~X509CertificateStore(void);
65
66         /**
67          *      Gets the name of the current certificate store.
68          *
69          *      @since                  2.0
70          *
71          *      @privlevel              partner
72          *      @privilege              %http://tizen.org/privilege/certificate.read
73          *
74          *      @return                 An error code
75          *      @param[out]             name                            The name of the certificate store
76          *      @exception              E_SUCCESS                       The method is successful.
77          *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
78          */
79         virtual result GetName(Tizen::Base::String& name) const;
80
81         /**
82          *      Sets a list of certificates that match the specified @c selector.
83          *
84          *      @since                  2.0
85          *
86          *      @privlevel              partner
87          *      @privilege              %http://tizen.org/privilege/certificate.read
88          *
89          *      @return                 An error code
90          *      @param[in]              selector                        A selector that defines a set of criterion for selecting certificates
91          *      @exception              E_SUCCESS                       The method is successful.
92          *      @exception              E_OUT_OF_MEMORY         The memory is insufficient.
93          *      @exception              E_SYSTEM                        A system error has occurred. @n
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 a 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 each 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 certificates 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                        A system error has occurred. @n
128          *                                                                              The Tizen::Base::ByteBuffer operation has failed.
129          *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
130          */
131         virtual Tizen::Security::Cert::ICertificate* GetNextCertificateN(void) const;
132
133         /**
134          *      Inserts the certificate into the certificate store.
135          *
136          *      @since                  2.0
137          *
138          *      @privlevel              partner
139          *      @privilege              %http://tizen.org/privilege/certificate.write
140          *
141          *      @return                 An error code
142          *      @param[in]              certificateType         The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
143          *      @param[in]              certificate                     A reference to the certificate to insert
144          *      @exception              E_SUCCESS                       The method is successful.
145          *      @exception              E_OUT_OF_MEMORY         The memory is insufficient.
146          *      @exception              E_INVALID_ARG           The specified @c certificate or the certificate data is invalid, or
147          *                                                                              the specified @c certificateType is invalid.
148          *      @exception              E_SYSTEM                        A system error has occurred. @n
149          *                                      Either the IPC operation or the file operation or the DB operation has failed.
150          *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
151          */
152         virtual result Insert(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
153
154         /**
155          *  Updates the certificate in the certificate store.
156          *
157          *      @since                  2.0
158          *
159          *      @privlevel              partner
160          *      @privilege              %http://tizen.org/privilege/certificate.write
161          *
162          *      @return                 An error code
163          *      @param[in]              certificateType         The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
164          *      @param[in]              oldCert                         A reference to the old certificate
165          *      @param[in]              newCert                         A reference to the new certificate
166          *      @exception              E_SUCCESS                       The method is successful.
167          *      @exception              E_OUT_OF_MEMORY         The memory is insufficient.
168          *      @exception              E_INVALID_ARG           The specified @c certificate or the certificate data is invalid, or
169          *                                                                              the specified @c certificateType is invalid.
170          *      @exception              E_OBJ_NOT_FOUND         The certificate is not found.
171          *      @exception              E_SYSTEM                        A system error has occurred. @n
172          *                                      Either the IPC operation or the file operation or the DB operation has failed.
173          *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
174          */
175         virtual result Update(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& oldCert, const Tizen::Security::Cert::ICertificate& newCert);
176
177         /**
178          *  Removes the certificate from the certificate store.
179          *
180          *      @since                  2.0
181          *
182          *      @privlevel              partner
183          *      @privilege              %http://tizen.org/privilege/certificate.write
184          *
185          *      @return                 An error code
186          *      @param[in]              certificateType         The type of the Certificate (ROOT_CA, OPERATOR_DOMAIN, TRUSTED_THIRD_PARTY_DOMAIN)
187          *      @param[in]              certificate                     A reference to the certificate to remove
188          *      @exception              E_SUCCESS                       The method is successful.
189          *      @exception              E_OUT_OF_MEMORY         The memory is insufficient.
190          *      @exception              E_INVALID_ARG           The specified @c certificate or the certificate data is invalid, or
191          *                                                                              the specified @c certificateType is invalid.
192          *      @exception              E_OBJ_NOT_FOUND         The certificate is not found.
193          *      @exception              E_SYSTEM                        A system error has occurred. @n
194          *                                      Either the IPC operation or the file operation or the DB operation has failed.
195          *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
196          */
197         virtual result Remove(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate);
198
199         /**
200          *  Inserts the user certificate of PKCS 12 format into the certificate store.
201          *
202          *      @since 2.0
203          *
204          *      @privlevel              partner
205          *      @privilege              %http://tizen.org/privilege/certificate.write
206          *
207          *      @return                 An error code
208          *  @param[in]          filePath                        The file path of PKCS 12 certificate to insert
209          *  @param[in]          password                        The password string to decrypt PKCS 12 certificate
210          *      @exception              E_SUCCESS                       The method is successful.
211          *      @exception              E_INVALID_ARG           The specified @c certificate or the certificate data is invalid.
212          *      @exception              E_SYSTEM                        The method cannot proceed due to a severe system error.
213          *      @exception              E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
214          */
215         result InsertPkcs12(const Tizen::Base::String& filePath, const Tizen::Base::String& password);
216
217 private:
218         X509CertificateStore(const X509CertificateStore& rhs);
219         X509CertificateStore& operator =(const X509CertificateStore& rhs);
220
221 private:
222         class _X509CertificateStoreImpl* __pX509CertificateStoreImpl;
223         friend class _X509CertificateStoreImpl;
224
225 }; //X509CertificateStore
226
227 } } } //Tizen::Security::Cert
228
229 #endif //_FSEC_CERT_X509_CERTIFICATE_STORE_H_