6
|
1 |
/*
|
|
2 |
* reserved comment block
|
|
3 |
* DO NOT REMOVE OR ALTER!
|
|
4 |
*/
|
|
5 |
/*
|
|
6 |
* Copyright 2001-2005 The Apache Software Foundation.
|
|
7 |
*
|
|
8 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9 |
* you may not use this file except in compliance with the License.
|
|
10 |
* You may obtain a copy of the License at
|
|
11 |
*
|
|
12 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13 |
*
|
|
14 |
* Unless required by applicable law or agreed to in writing, software
|
|
15 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17 |
* See the License for the specific language governing permissions and
|
|
18 |
* limitations under the License.
|
|
19 |
*/
|
|
20 |
|
|
21 |
package com.sun.org.apache.xerces.internal.parsers;
|
|
22 |
|
|
23 |
import com.sun.org.apache.xerces.internal.impl.Constants;
|
|
24 |
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
|
|
25 |
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
|
|
26 |
import com.sun.org.apache.xerces.internal.util.SymbolTable;
|
20964
|
27 |
import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
|
6
|
28 |
|
|
29 |
/**
|
|
30 |
* This configuration allows Xerces to behave in a security-conscious manner; that is,
|
|
31 |
* it permits applications to instruct Xerces to limit certain
|
|
32 |
* operations that could be exploited by malicious document authors to cause a denail-of-service
|
|
33 |
* attack when the document is parsed.
|
|
34 |
*
|
|
35 |
* In addition to the features and properties recognized by the base
|
|
36 |
* parser configuration, this class recognizes these additional
|
|
37 |
* features and properties:
|
|
38 |
* <ul>
|
|
39 |
* <li>Properties
|
|
40 |
* <ul>
|
|
41 |
* <li>http://apache.org/xml/properties/security-manager</li>
|
|
42 |
* </ul>
|
|
43 |
* </ul>
|
|
44 |
*
|
|
45 |
* @author Neil Graham, IBM
|
|
46 |
*
|
|
47 |
*/
|
|
48 |
public class SecurityConfiguration extends XIncludeAwareParserConfiguration
|
|
49 |
{
|
|
50 |
|
|
51 |
//
|
|
52 |
// Constants
|
|
53 |
//
|
|
54 |
|
|
55 |
protected static final String SECURITY_MANAGER_PROPERTY =
|
|
56 |
Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
|
|
57 |
|
|
58 |
//
|
|
59 |
// Constructors
|
|
60 |
//
|
|
61 |
|
|
62 |
/** Default constructor. */
|
|
63 |
public SecurityConfiguration () {
|
|
64 |
this(null, null, null);
|
|
65 |
} // <init>()
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Constructs a parser configuration using the specified symbol table.
|
|
69 |
*
|
|
70 |
* @param symbolTable The symbol table to use.
|
|
71 |
*/
|
|
72 |
public SecurityConfiguration (SymbolTable symbolTable) {
|
|
73 |
this(symbolTable, null, null);
|
|
74 |
} // <init>(SymbolTable)
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Constructs a parser configuration using the specified symbol table and
|
|
78 |
* grammar pool.
|
|
79 |
* <p>
|
|
80 |
* <strong>REVISIT:</strong>
|
|
81 |
* Grammar pool will be updated when the new validation engine is
|
|
82 |
* implemented.
|
|
83 |
*
|
|
84 |
* @param symbolTable The symbol table to use.
|
|
85 |
* @param grammarPool The grammar pool to use.
|
|
86 |
*/
|
|
87 |
public SecurityConfiguration (SymbolTable symbolTable,
|
|
88 |
XMLGrammarPool grammarPool) {
|
|
89 |
this(symbolTable, grammarPool, null);
|
|
90 |
} // <init>(SymbolTable,XMLGrammarPool)
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Constructs a parser configuration using the specified symbol table,
|
|
94 |
* grammar pool, and parent settings.
|
|
95 |
* <p>
|
|
96 |
* <strong>REVISIT:</strong>
|
|
97 |
* Grammar pool will be updated when the new validation engine is
|
|
98 |
* implemented.
|
|
99 |
*
|
|
100 |
* @param symbolTable The symbol table to use.
|
|
101 |
* @param grammarPool The grammar pool to use.
|
|
102 |
* @param parentSettings The parent settings.
|
|
103 |
*/
|
|
104 |
public SecurityConfiguration (SymbolTable symbolTable,
|
|
105 |
XMLGrammarPool grammarPool,
|
|
106 |
XMLComponentManager parentSettings) {
|
|
107 |
super(symbolTable, grammarPool, parentSettings);
|
|
108 |
|
20968
|
109 |
// create the SecurityManager property:
|
|
110 |
setProperty(SECURITY_MANAGER_PROPERTY, new XMLSecurityManager(true));
|
6
|
111 |
} // <init>(SymbolTable,XMLGrammarPool)
|
|
112 |
|
|
113 |
} // class SecurityConfiguration
|