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