sync with master
[platform/framework/native/appfw.git] / inc / FSecPkcsPkcs08Attribute.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2013 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                FSecPkcsPkcs08Attribute.h
20  * @brief               This is the header file for the %Pkcs08Attribute class.
21  *
22  * This header file contains the declarations of the %Pkcs08Attribute class.
23  */
24
25 #ifndef _FSEC_PKCS_PKCS_08_ATTRIBUTE_H_
26 #define _FSEC_PKCS_PKCS_08_ATTRIBUTE_H_
27
28 #include <FBaseByteBuffer.h>
29 #include <FBaseResult.h>
30 #include <FSecPkcsPkcs08AttributeValue.h>
31
32 namespace Tizen { namespace Security { namespace Pkcs
33 {
34
35 /**
36  * @class               Pkcs08Attribute
37  * @brief               This class implements the functionalities specified by the Pkcs08Attribute class. An Attribute object consists
38  *                                      of an attribute type (specified by an object identifier) and one or more attribute values. It acts as a
39  *                                      container for adding, inserting, removing, encoding X.509 AttributeValue.
40  * @since               2.1
41  *
42  */
43
44 class _OSP_EXPORT_ Pkcs08Attribute
45         : public Tizen::Base::Object
46 {
47 public:
48         /**
49          * The object is not fully constructed after this constructor is called. @n
50          * For full construction, the Construct() method must be called right after calling this constructor.
51          *
52          * @since       2.1
53          */
54         Pkcs08Attribute(void);
55
56         /**
57          * This destructor overrides Tizen::Base::Object::~Object().
58          *
59          * @since       2.1
60          */
61         virtual ~Pkcs08Attribute(void);
62
63         /**
64          * Intializes this instance of %Pkcs08Attribute with the Bytebuffer which contain X.509 Attribute @n
65          * structure in ASN.1 DER format. @n
66          *
67          * @since               2.1
68          *
69          * @return              An error code
70          * @param[in]   encodedData                             DER encoded Bytebuffer of X.509 Attribute structure.
71          * @exception   E_SUCCESS                                       The method is successful.
72          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
73          */
74         result Construct(const Tizen::Base::ByteBuffer& encodedData);
75
76         /**
77          * Intializes this instance of %Pkcs08Attribute with specified attribute type.
78          *
79          * @since               2.1
80          *
81          * @return              An error code
82          * @param[in]   attributeType                   This parameter specifies object Identifier of particular x.509 attribute type. Object IDs @n
83          *                                                                                                                      (e.g. oid for name is 2.5.4.41)are defined by standard bodies for attribute.
84          * @exception   E_SUCCESS                                       The method is successful.
85          * @exception   E_INVALID_ARG                   The specified input parameter is invalid.
86          */
87         result Construct(const Tizen::Base::String& attributeType);
88
89         /**
90          * Get the attribute type.
91          * This function implements GetAttributeType API which returns the Attribute type of this attribute instance.
92          *
93          * @since               2.1
94          *
95          * @return              Containing the Object ID of Attribute Type in string format like 2.5.4.41
96          *
97          */
98         Tizen::Base::String GetAttributeType(void) const;
99
100         /**
101          * This function adds attribute value in the attribute value list.
102          *
103          * @since               2.1
104          *
105          * @return              An error code
106          * @param[in]   attributeValue                  An instance of Pkcs08AttributeValue to add an attribute in the list.
107          */
108         result AddAttributeValue(const Pkcs08AttributeValue& attributeValue);
109
110         /**
111          * This function remove attribute value in the attribute value list.
112          *
113          * @since               2.1
114          *
115          * @return              An error code
116          * @param[in]   attributeValue                  An instance of Pkcs08AttributeValue to remove an attribute in the list.
117          */
118         result RemoveAttributeValue(const Pkcs08AttributeValue& attributeValue);
119
120         /**
121          * This function returns the array list containing the attribute values of type Pkcs08AttributeValue.
122          *
123          * @since               2.1
124          *
125          * @return              A reference to an ArrayList containing the list of Attribute values.
126          */
127         const Tizen::Base::Collection::ArrayList& GetAttributeValues(void) const;
128
129         /**
130          * Gets the encoded form of the Pkcs08Attribute.
131          * It is assumed that each Pkcs08Attribute will have only a single form of encoding example ASN.1 DER.
132          *
133          * @since               2.1
134          *
135          * @return              A pointer to the ByteBuffer class that contains the output, @n
136          *                                              else @c null if an error occurs
137          *
138          * @exception   E_SUCCESS                                               The method is successful.
139          * @exception   E_SYSTEM                                                The method cannot proceed due to a severe system error.
140          * @remarks             The specific error code can be accessed using the GetLastResult() method.
141          */
142         Tizen::Base::ByteBuffer* GetEncodedDataN(void) const;
143
144 private:
145         // This copy constructor is intentionally declared as private to prohibit @n
146         // copying of objects by users.
147         //
148         // @since               2.1
149         Pkcs08Attribute(const Pkcs08Attribute& rhs);
150
151         // The implementation of this copy assignment operator is intentionally blank and @n
152         // declared as private to prohibit copying of objects.
153         //
154         // @since               2.1
155         Pkcs08Attribute& operator =(const Pkcs08Attribute& rhs);
156
157 private:
158         class _Pkcs08AttributeImpl* __pPkcs08AttributeImpl;
159         friend class _Pkcs08AttributeImpl;
160
161 }; //Pkcs08Attribute
162
163 }}} // Tizen::Security::Pkcs
164
165 #endif // _FSEC_PKCS_PKCS_08_ATTRIBUTE_H_