1 /* |
1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.xml.internal.bind.v2.util; |
26 package com.sun.xml.internal.bind.v2.util; |
27 |
27 |
28 import com.sun.xml.internal.bind.Util; |
|
29 import com.sun.xml.internal.bind.v2.Messages; |
28 import com.sun.xml.internal.bind.v2.Messages; |
|
29 |
|
30 import java.security.AccessController; |
|
31 import java.security.PrivilegedAction; |
30 import java.util.logging.Level; |
32 import java.util.logging.Level; |
31 import java.util.logging.Logger; |
33 import java.util.logging.Logger; |
32 import javax.xml.XMLConstants; |
34 import javax.xml.XMLConstants; |
33 import javax.xml.parsers.DocumentBuilderFactory; |
35 import javax.xml.parsers.DocumentBuilderFactory; |
34 import javax.xml.parsers.ParserConfigurationException; |
36 import javax.xml.parsers.ParserConfigurationException; |
41 |
43 |
42 import org.xml.sax.SAXException; |
44 import org.xml.sax.SAXException; |
43 import org.xml.sax.SAXNotRecognizedException; |
45 import org.xml.sax.SAXNotRecognizedException; |
44 import org.xml.sax.SAXNotSupportedException; |
46 import org.xml.sax.SAXNotSupportedException; |
45 |
47 |
46 import static com.sun.xml.internal.bind.Util.getSystemProperty; |
|
47 |
|
48 /** |
48 /** |
49 * Provides helper methods for creating properly configured XML parser |
49 * Provides helper methods for creating properly configured XML parser |
50 * factory instances with namespace support turned on and configured for |
50 * factory instances with namespace support turned on and configured for |
51 * security. |
51 * security. |
52 * @author snajper |
52 * @author snajper |
66 * Boolean |
66 * Boolean |
67 * @since 2.2.6 |
67 * @since 2.2.6 |
68 */ |
68 */ |
69 private static final String DISABLE_XML_SECURITY = "com.sun.xml.internal.bind.disableXmlSecurity"; |
69 private static final String DISABLE_XML_SECURITY = "com.sun.xml.internal.bind.disableXmlSecurity"; |
70 |
70 |
71 public static final boolean XML_SECURITY_DISABLED = Boolean.parseBoolean(getSystemProperty(DISABLE_XML_SECURITY)); |
71 private static final boolean XML_SECURITY_DISABLED = AccessController.doPrivileged( |
|
72 new PrivilegedAction<Boolean>() { |
|
73 @Override |
|
74 public Boolean run() { |
|
75 return Boolean.getBoolean(DISABLE_XML_SECURITY); |
|
76 } |
|
77 } |
|
78 ); |
72 |
79 |
73 private static boolean isXMLSecurityDisabled(boolean runtimeSetting) { |
80 private static boolean isXMLSecurityDisabled(boolean runtimeSetting) { |
74 return XML_SECURITY_DISABLED || runtimeSetting; |
81 return XML_SECURITY_DISABLED || runtimeSetting; |
75 } |
82 } |
76 |
83 |