|
26 | 26 | import javax.xml.parsers.ParserConfigurationException; |
27 | 27 |
|
28 | 28 | import org.apache.logging.log4j.Logger; |
| 29 | +import org.apache.cloudstack.utils.security.ParserUtils; |
29 | 30 | import org.apache.logging.log4j.LogManager; |
30 | 31 | import org.w3c.dom.DOMException; |
31 | 32 | import org.w3c.dom.DOMImplementation; |
@@ -67,7 +68,7 @@ public enum OperationType { |
67 | 68 | public static String getAddPortProfile(String name, PortProfileType type, BindingType binding, SwitchPortMode mode, int vlanid, String vdc, String espName) { |
68 | 69 | try { |
69 | 70 | // Create the document and root element. |
70 | | - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
| 71 | + DocumentBuilderFactory docFactory = ParserUtils.getSaferDocumentBuilderFactory(); |
71 | 72 | DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
72 | 73 | DOMImplementation domImpl = docBuilder.getDOMImplementation(); |
73 | 74 | Document doc = createDocument(domImpl); |
@@ -100,7 +101,7 @@ public static String getAddPortProfile(String name, PortProfileType type, Bindin |
100 | 101 | public static String getAddPortProfile(String name, PortProfileType type, BindingType binding, SwitchPortMode mode, int vlanid) { |
101 | 102 | try { |
102 | 103 | // Create the document and root element. |
103 | | - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
| 104 | + DocumentBuilderFactory docFactory = ParserUtils.getSaferDocumentBuilderFactory(); |
104 | 105 | DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
105 | 106 | DOMImplementation domImpl = docBuilder.getDOMImplementation(); |
106 | 107 | Document doc = createDocument(domImpl); |
@@ -133,7 +134,7 @@ public static String getAddPortProfile(String name, PortProfileType type, Bindin |
133 | 134 | public static String getUpdatePortProfile(String name, SwitchPortMode mode, List<Pair<VsmCommand.OperationType, String>> params) { |
134 | 135 | try { |
135 | 136 | // Create the document and root element. |
136 | | - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
| 137 | + DocumentBuilderFactory docFactory = ParserUtils.getSaferDocumentBuilderFactory(); |
137 | 138 | DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
138 | 139 | DOMImplementation domImpl = docBuilder.getDOMImplementation(); |
139 | 140 | Document doc = createDocument(domImpl); |
@@ -166,7 +167,7 @@ public static String getUpdatePortProfile(String name, SwitchPortMode mode, List |
166 | 167 | public static String getDeletePortProfile(String portName) { |
167 | 168 | try { |
168 | 169 | // Create the document and root element. |
169 | | - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
| 170 | + DocumentBuilderFactory docFactory = ParserUtils.getSaferDocumentBuilderFactory(); |
170 | 171 | DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
171 | 172 | DOMImplementation domImpl = docBuilder.getDOMImplementation(); |
172 | 173 | Document doc = createDocument(domImpl); |
@@ -199,7 +200,7 @@ public static String getDeletePortProfile(String portName) { |
199 | 200 | public static String getAddPolicyMap(String name, int averageRate, int maxRate, int burstRate) { |
200 | 201 | try { |
201 | 202 | // Create the document and root element. |
202 | | - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
| 203 | + DocumentBuilderFactory docFactory = ParserUtils.getSaferDocumentBuilderFactory(); |
203 | 204 | DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
204 | 205 | DOMImplementation domImpl = docBuilder.getDOMImplementation(); |
205 | 206 | Document doc = createDocument(domImpl); |
@@ -232,7 +233,7 @@ public static String getAddPolicyMap(String name, int averageRate, int maxRate, |
232 | 233 | public static String getDeletePolicyMap(String name) { |
233 | 234 | try { |
234 | 235 | // Create the document and root element. |
235 | | - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
| 236 | + DocumentBuilderFactory docFactory = ParserUtils.getSaferDocumentBuilderFactory(); |
236 | 237 | DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
237 | 238 | DOMImplementation domImpl = docBuilder.getDOMImplementation(); |
238 | 239 | Document doc = createDocument(domImpl); |
@@ -265,7 +266,7 @@ public static String getDeletePolicyMap(String name) { |
265 | 266 | public static String getServicePolicy(String policyMap, String portProfile, boolean attach) { |
266 | 267 | try { |
267 | 268 | // Create the document and root element. |
268 | | - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
| 269 | + DocumentBuilderFactory docFactory = ParserUtils.getSaferDocumentBuilderFactory(); |
269 | 270 | DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
270 | 271 | DOMImplementation domImpl = docBuilder.getDOMImplementation(); |
271 | 272 | Document doc = createDocument(domImpl); |
@@ -297,7 +298,7 @@ public static String getServicePolicy(String policyMap, String portProfile, bool |
297 | 298 |
|
298 | 299 | public static String getPortProfile(String name) { |
299 | 300 | try { |
300 | | - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
| 301 | + DocumentBuilderFactory docFactory = ParserUtils.getSaferDocumentBuilderFactory(); |
301 | 302 | DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
302 | 303 | DOMImplementation domImpl = docBuilder.getDOMImplementation(); |
303 | 304 | Document doc = createDocument(domImpl); |
@@ -334,7 +335,7 @@ public static String getPortProfile(String name) { |
334 | 335 |
|
335 | 336 | public static String getPolicyMap(String name) { |
336 | 337 | try { |
337 | | - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
| 338 | + DocumentBuilderFactory docFactory = ParserUtils.getSaferDocumentBuilderFactory(); |
338 | 339 | DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
339 | 340 | DOMImplementation domImpl = docBuilder.getDOMImplementation(); |
340 | 341 | Document doc = createDocument(domImpl); |
@@ -367,7 +368,7 @@ public static String getPolicyMap(String name) { |
367 | 368 |
|
368 | 369 | public static String getHello() { |
369 | 370 | try { |
370 | | - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
| 371 | + DocumentBuilderFactory docFactory = ParserUtils.getSaferDocumentBuilderFactory(); |
371 | 372 | DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
372 | 373 | DOMImplementation domImpl = docBuilder.getDOMImplementation(); |
373 | 374 |
|
@@ -395,7 +396,7 @@ public static String getHello() { |
395 | 396 | public static String getVServiceNode(String vlanId, String ipAddr) { |
396 | 397 | try { |
397 | 398 | // Create the document and root element. |
398 | | - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
| 399 | + DocumentBuilderFactory docFactory = ParserUtils.getSaferDocumentBuilderFactory(); |
399 | 400 | DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
400 | 401 | DOMImplementation domImpl = docBuilder.getDOMImplementation(); |
401 | 402 | Document doc = createDocument(domImpl); |
|
0 commit comments