Revert "Delete checking if strlen() is 0 in ConvertWcsToMbsN()"
[platform/framework/native/appfw.git] / inc / FSecCertX509CertificatePath.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                        FSecCertX509CertificatePath.h
20  * @brief               This is the header file for the %X509CertificatePath class.
21  *
22  * This header file contains the declarations of the %X509CertificatePath class.
23  */
24 #ifndef _FSEC_CERT_X509_CERTIFICATE_PATH_H_
25 #define _FSEC_CERT_X509_CERTIFICATE_PATH_H_
26
27 #include <FBaseObject.h>
28 #include <FSecCertICertificatePath.h>
29 #include <FSecCertX509Certificate.h>
30
31
32 namespace Tizen { namespace Security { namespace Cert
33 {
34
35 class _CertMgrSvcProxy;
36
37 /**
38  *      @class          X509CertificatePath
39  *      @brief          This class provides the certificate path.
40  *
41  *      @since          2.0
42  *
43  * The %X509CertificatePath class provides the certificate path. @n
44  *
45  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/security/certificate_namespace.htm">Certificates</a>.
46  */
47 class _OSP_EXPORT_ X509CertificatePath
48         : public virtual ICertificatePath
49         , public Tizen::Base::Object
50 {
51
52 public:
53         /**
54          *      This is the default constructor for this class.
55          *
56          *      @since          2.0
57          */
58         X509CertificatePath(void);
59
60         /**
61          *      This is the destructor for this class.
62          *
63          *      @since          2.0
64          */
65         virtual ~X509CertificatePath(void);
66
67         /**
68          *      Gets the format name for the certificate path.
69          *
70          *      @since          2.0
71          *
72          *      @return         The format of the certificate
73          */
74         virtual Tizen::Base::String GetFormat(void) const;
75
76         /**
77          *      Adds a certificate to the certificate chain.
78          *
79          *      @since          2.0
80          *
81          *      @return         An error code
82          *      @param[in]      certificate                             A reference to a certificate
83          *      @exception      E_SUCCESS                               The method is successful.
84          *      @exception      E_INVALID_ARG                   The specified @c certificate or the certificate data is invalid.
85          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
86          *      @exception      E_SYSTEM                                A system error has occurred. @n
87          *                                                                              The certificate link list operation has failed.
88          */
89         virtual result AddCertificate(const Tizen::Security::Cert::ICertificate& certificate);
90
91         /**
92          *      Validates the specified certificate path.
93          *
94          *      @since          2.0
95          *
96          *      @return         The result of the certificate path validation
97          *      @exception      E_SUCCESS                               The method is successful.
98          *      @exception      E_SYSTEM                                A system error has occurred.
99          *                                                                              The certificate link list operation has failed.
100          * @remarks        The specific error code can be accessed using the GetLastResult() method.
101          */
102         virtual Tizen::Security::Cert::ValidationResult Validate(void);
103
104         /**
105          *      Validates the specified certificate path.
106          *
107          *      @since          2.0
108          *
109          *      @return         The result of the certificate path validation
110          *      @param[in]      trustAnchor                             The most trusted Certificate Authority (CA)
111          *      @exception      E_SUCCESS                               The method is successful.
112          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
113          *      @exception      E_INVALID_ARG                   The specified input parameter is invalid.
114          *      @exception      E_SYSTEM                                A system error has occurred. @n
115          *                                                                              The certificate link list operation has failed.
116          * @remarks        The specific error code can be accessed using the GetLastResult() method.
117          */
118         virtual Tizen::Security::Cert::ValidationResult Validate(const Tizen::Security::Cert::ICertificate& trustAnchor);
119
120         /**
121          *      Gets the length of the certificate path.
122          *
123          *      @since          2.0
124          *
125          *      @return         The length of the certificate path, @n
126          *                              else @c -1 if an error occurs
127          *      @exception      E_SUCCESS                               The method is successful.
128          *      @exception      E_SYSTEM                                A system error has occurred. @n
129          *                                                                              The certificate link list operation has failed.
130          */
131         virtual int GetLength(void) const;
132
133         /**
134          *      Gets the list of the certificates in this certificate path.
135          *
136          *      @since          2.0
137          *
138          *      @return         A pointer to the ICertificate interface, @n
139          *                              else @c null if an error occurs
140          *  @param[in]  nth                                             The nth certificate in the certificate path (starts from @c 0)
141          *      @exception      E_SUCCESS                               The method is successful.
142          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
143          *      @exception      E_INVALID_ARG                   The value of the specified @c nth is out of the valid range. @n
144          *                                                                              It must be less than GetLength().
145          *      @exception      E_OBJ_NOT_FOUND                 The certificate is not found.
146          *      @exception      E_SYSTEM                                A system error has occurred. @n
147          *                                                                              The certificate link list operation has failed.
148          * @remarks        The specific error code can be accessed using the GetLastResult() method.
149          */
150         virtual Tizen::Security::Cert::ICertificate* GetCertificateN(int nth) const;
151
152         /**
153          *      Gets the trust anchor for the certificate path.
154          *
155          *      @since                  2.0
156          *
157          *      @return         The root certificate, @n
158          *                                      else @c null if an error occurs
159          *      @exception      E_SUCCESS                               The method is successful.
160          *      @exception      E_OUT_OF_MEMORY                 The memory is insufficient.
161          *      @exception      E_OBJ_NOT_FOUND                 The certificate is not found.
162          *      @exception      E_SYSTEM                                A system error has occurred. @n
163          *                                                                              The certificate link list operation or
164          *                                                                              the Tizen::Base::ByteBuffer operation has failed.
165          * @remarks        The specific error code can be accessed using the GetLastResult() method.
166          */
167         virtual Tizen::Security::Cert::ICertificate* GetTrustAnchorN(void) const;
168
169 private:
170         X509CertificatePath(const X509CertificatePath& rhs);
171         X509CertificatePath& operator =(const X509CertificatePath& rhs);
172
173 private:
174         void* __certCtx;
175         int __depth;
176         int __trustAnchorIndex;
177
178         class _X509CertificatePathImpl* __pX509CertificatePathImpl;
179         friend class _X509CertificatePathImpl;
180
181 }; //X509CertificatePath
182
183 } } } //Tizen::Security::Cert
184
185 #endif //_FSEC_CERT_X509_CERTIFICATE_PATH_H_