sync with tizen_2.0
[platform/framework/native/appfw.git] / inc / FSecCertICertificateStore.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  * @if VISPARTNER
20  * @file                        FSecCertICertificateStore.h
21  * @brief               This is the header file for the %ICertificateStore interface.
22  *
23  * This header file contains the declarations of the %ICertificateStore interface.
24  *
25  * @endif
26  */
27 #ifndef _FSEC_CERT_ICERTIFICATE_STORE_H_
28 #define _FSEC_CERT_ICERTIFICATE_STORE_H_
29
30 #include <FBaseString.h>
31 #include <FBaseByteBuffer.h>
32 #include <FSecIPrivateKey.h>
33 #include <FSecCertICertificate.h>
34 #include <FSecCertICertificateSelector.h>
35
36
37 namespace Tizen { namespace Security { namespace Cert
38 {
39
40 /**
41  *      @if VISPARTNER
42  *      @interface      ICertificateStore
43  *      @brief          This is the interface for retrieving and managing the certificates from a repository.
44  *
45  *      @since                  2.0
46  *
47  *      @visibility     partner
48  *
49  *      The %ICertificateStore interface is used for retrieving and managing the certificates from a repository.
50  *  @endif
51  */
52 class _OSP_EXPORT_ ICertificateStore
53 {
54
55 public:
56         /**
57          *      This is the destructor for this class.
58          *
59          *      @since          2.0
60          */
61         virtual ~ICertificateStore(void) {}
62
63         /**
64          *  Gets the @c name of the certificate store.
65          *
66          *      @since          2.0
67          *
68          *      @return         An error code
69          *      @param[out]     name                                    The name of the certificate store
70          *      @exception      E_SUCCESS                               The method is successful.
71          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
72          */
73         virtual result GetName(Tizen::Base::String& name) const = 0;
74
75         /**
76          *      Sets a list of certificates that match the specified selector.
77          *
78          *      @since          2.0
79          *
80          *      @return         An error code
81          *      @param[in]      selector                                A selector that defines a set of criterion for selecting certificates
82          *      @exception      E_SUCCESS                               The method is successful.
83          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
84          *      @exception      E_SYSTEM                                A system error has occurred. @n
85          *                                                                              The IPC operation has failed.
86          *      @exception      E_INVALID_ARG                   The specified @c selector is invalid.
87          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
88          */
89         virtual result SetCertificateSelector(const Tizen::Security::Cert::ICertificateSelector& selector) = 0;
90
91         /**
92          *      Gets the count of certificates that match the specified selector.
93          *
94          *      @since          2.0
95          *
96          *      @return         An error code
97          *      @param[out] count                                       The count of certificates
98          *      @exception      E_SUCCESS                               The method is successful.
99          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
100          */
101         virtual result GetCertificateCount(int& count) const = 0;
102
103         /**
104          *      Gets each certificate that matches the specified selector.
105          *
106          *      @since          2.0
107          *
108          *      @return         The certificates that match the specified selector
109          *      @exception      E_SUCCESS                               The method is successful.
110          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
111          *      @exception      E_OBJ_NOT_FOUND                 The certificate is not found.
112          *      @exception      E_SYSTEM                                A system error has occurred. @n
113          *                                                                              The Tizen::Base::ByteBuffer operation has failed.
114          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
115          *  @remarks        The specific error code can be accessed using the GetLastResult() method.
116          */
117         virtual Tizen::Security::Cert::ICertificate* GetNextCertificateN(void) const = 0;
118
119         /**
120          *  Inserts the certificate into the certificate store.
121          *
122          *      @since          2.0
123          *
124          *      @return         An error code
125          *      @param[in]      certificateType                 The type of the Certificate (that is, ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
126          *      @param[in]      certificate                             A reference to the certificate to insert
127          *      @exception      E_SUCCESS                               The method is successful.
128          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
129          *      @exception      E_INVALID_ARG                   The specified @c certificate or the certificate data is invalid, or
130          *                                                                              the specified @c certificateType is invalid.
131          *      @exception      E_SYSTEM                                A system error has occurred. @n
132          *                                      Either the IPC operation or the file operation or the DB operation has failed.
133          *      @exception      E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
134          */
135         virtual result Insert(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate) = 0;
136
137         /**
138          *  Updates the certificate in the certificate store.
139          *
140          *      @since          2.0
141          *
142          *      @return         An error code
143          *      @param[in]      certificateType                 The type of the Certificate (that is, ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
144          *      @param[in]      oldCert                                 A reference to the old certificate
145          *      @param[in]      newCert                                 A reference to the new certificate
146          *      @exception      E_SUCCESS                               The method is successful.
147          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
148          *      @exception      E_INVALID_ARG                   The specified @c certificate or the certificate data is invalid, or
149          *                                                                                      the specified @c certificateType is invalid.
150          *      @exception      E_OBJ_NOT_FOUND                 The certificate is not found.
151          *      @exception      E_SYSTEM                                A system error has occurred. @n
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 Update(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& oldCert, const Tizen::Security::Cert::ICertificate& newCert) = 0;
156
157         /**
158          *  Removes the certificate from the certificate store.
159          *
160          *      @since          2.0
161          *
162          *      @return         An error code
163          *      @param[in]      certificateType                 The type of the Certificate (that is, ROOT_CA, OPERATOR_DOMAIN, or TRUSTED_THIRD_PARTY_DOMAIN)
164          *      @param[in]      certificate                             A reference to the certificate to remove
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.
173          */
174         virtual result Remove(CertificateType certificateType, const Tizen::Security::Cert::ICertificate& certificate) = 0;
175
176 protected:
177         //
178         // This method is for internal use only. Using this method can cause behavioral, security-related,
179         // and consistency-related issues in the application.
180         //
181         // This method is reserved and may change its name at any time without prior notice.
182         //
183         // @since 2.0
184         //
185         virtual void ICertificateStore_Reserved1(void) {}
186
187         //
188         // This method is for internal use only. Using this method can cause behavioral, security-related,
189         // and consistency-related issues in the application.
190         //
191         // This method is reserved and may change its name at any time without prior notice.
192         //
193         // @since 2.0
194         //
195         virtual void ICertificateStore_Reserved2(void) {}
196
197         //
198         // This method is for internal use only. Using this method can cause behavioral, security-related,
199         // and consistency-related issues in the application.
200         //
201         // This method is reserved and may change its name at any time without prior notice.
202         //
203         // @since 2.0
204         //
205         virtual void ICertificateStore_Reserved3(void) {}
206
207 }; //ICertificateStore
208
209 } } } //Tizen::Security::Cert
210
211 #endif //_FSEC_CERT_ICERTIFICATE_STORE_H_