1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 /*
21  * XSEC
22  *
23  * DSIGObject := Defines the container class used by dsig to hold objects
24  *				 inside a signture
25  *
26  * $Id: DSIGObject.hpp 1833341 2018-06-11 16:25:41Z scantor $
27  *
28  */
29 
30 #ifndef DSIGOBJECT_INCLUDE
31 #define DSIGOBJECT_INCLUDE
32 
33 // XSEC Includes
34 
35 #include <xsec/framework/XSECDefs.hpp>
36 
37 XSEC_DECLARE_XERCES_CLASS(DOMElement);
38 XSEC_DECLARE_XERCES_CLASS(DOMNode);
39 
40 class XSECEnv;
41 
42 /**
43  * @ingroup pubsig
44  */
45 
46 /**
47  * @brief Base class for \<Object\> nodes in a \<Signature\> element.
48  *
49  * The DSIG spec allows for enveloping signatures, in which the signature holds
50  * the information it is signing.  For these types of signatures, the data being
51  * signed can be held in an \<Object\> container.
52  *
53  * This class allows callers to and manipulate Object containers.
54  *
55  */
56 
57 
58 class XSEC_EXPORT DSIGObject {
59 
60 public:
61 
62 	/** @name Constructors and Destructors */
63 	//@{
64 
65 	/**
66 	 * \brief Construct from an owning signature
67 	 *
68 	 * Called by the library when an Object needs to be created from an Object
69 	 * in a DOM tree.
70 	 *
71 	 * @param env The environment that the Object is operating within
72 	 * @param dom The DOM node that will be loaded
73 	 */
74 
75 	DSIGObject(const XSECEnv * env, XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *dom);
76 
77 	/**
78 	 * \brief Construct a new object
79 	 *
80 	 * Called by the library to create an Object from scratch
81 	 *
82 	 * @param env The environment the Object is operating within
83 	 */
84 
85 	DSIGObject(const XSECEnv * env);
86 
87 
88 	/**
89 	 * \brief Destructor
90 	 */
91 
92 	~DSIGObject();
93 
94 	//@}
95 
96 	/** @name Library functions */
97 	//@{
98 
99 	/**
100 	 * \brief Load the object from DOM
101 	 *
102 	 * Called by the library to load a constructed object
103 	 */
104 
105 	void load(void);
106 
107 	/**
108 	 * \brief Create a new Object
109 	 *
110 	 * Create a new Object from scratch (will generate the DOM)
111 	 */
112 
113 	XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *
114 		createBlankObject(void);
115 
116 	//@}
117 
118 	/** @name Get functions */
119 	//@{
120 
121 	/**
122 	 * \brief Get the Id for this object
123 	 *
124 	 * @returns the URI attribute string for this object
125 	 */
126 
127 	const XMLCh * getId(void) const;
128 
129 	/**
130 	 * \brief Returns the MimeType string of this object
131 	 *
132 	 * @returns a pointer to the buffer containing the Mime Type string
133 	 */
134 
135 	const XMLCh * getMimeType(void) const;
136 
137 	/**
138 	 * \brief Returns the Encoding string of this object
139 	 *
140 	 * @returns a pointer to the buffer containing the Encoding string
141 	 */
142 
143 	const XMLCh * getEncoding(void) const;
144 
145 	/**
146 	 * \brief Returns the Element node for this object
147 	 *
148 	 * @returns the Element node at the head of this object
149 	 */
150 
151 	const XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void) const;
152 
153 	//@}
154 
155 	/** @name Setter functions */
156 	//@{
157 
158 	/**
159 	 * \brief Set the Id attribute for this Object
160 	 *
161 	 * @param id String to use for the Id attribute
162 	 */
163 
164 	void setId(const XMLCh * id);
165 
166 	/**
167 	 * \brief Set the Id attribute for this Object
168 	 *
169 	 * @param type String to use for the MimeType attribute
170 	 */
171 
172 	void setMimeType(const XMLCh * type);
173 
174 	/**
175 	 * \brief Set the Encoding attribute for this Object
176 	 *
177 	 * @param encoding String to use for the Encoding attribute
178 	 */
179 
180 	void setEncoding(const XMLCh * encoding);
181 
182 	/**
183 	 * \brief Add a child node to the Object
184 	 *
185 	 * This is a "ease of use" function to allow users to add a DOM structure
186 	 * that has been built previously into the Object element
187 	 */
188 
189 	void appendChild(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * child);
190 
191 	//@}
192 
193 
194 private:
195 
196 	const XSECEnv		* mp_env;
197 	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
198 						* mp_objectNode;
199 	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
200 						* mp_idAttr;
201 	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
202 						* mp_mimeTypeAttr;
203 	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
204 						* mp_encodingAttr;
205 
206 };
207 
208 #endif /* DSIGOBJECT_INCLUDE */
209 
210