src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/PropertyManager.java
author joehw
Wed, 04 Oct 2017 10:54:18 -0700
changeset 47312 d4f959806fe9
parent 47216 71c04702a3d5
child 48412 d4412e380f6b
permissions -rw-r--r--
8187593: Cleanup: removing SecuritySupport files Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     1
/*
47312
d4f959806fe9 8187593: Cleanup: removing SecuritySupport files
joehw
parents: 47216
diff changeset
     2
 * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     4
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    10
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    15
 * accompanied this code).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    16
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    20
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    23
 * questions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    24
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    25
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    26
package com.sun.org.apache.xerces.internal.impl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    27
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
    28
import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
    29
import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
    30
import com.sun.xml.internal.stream.StaxEntityResolverWrapper;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    31
import java.util.HashMap;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
    32
import javax.xml.XMLConstants;
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
    33
import javax.xml.catalog.CatalogFeatures;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    34
import javax.xml.stream.XMLInputFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    35
import javax.xml.stream.XMLOutputFactory;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    36
import javax.xml.stream.XMLResolver;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
    37
import jdk.xml.internal.JdkXmlUtils;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    38
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    39
/**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    40
 *  This class manages different properties related to Stax specification and its implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    41
 * This class constructor also takes itself (PropertyManager object) as parameter and initializes the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    42
 * object with the property taken from the object passed.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    43
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    44
 * @author  Neeraj Bajaj, neeraj.bajaj@sun.com
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    45
 * @author K.Venugopal@sun.com
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    46
 * @author Sunitha Reddy, sunitha.reddy@sun.com
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    47
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    48
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    49
public class PropertyManager {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    50
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    51
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    52
    public static final String STAX_NOTATIONS = "javax.xml.stream.notations";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    53
    public static final String STAX_ENTITIES = "javax.xml.stream.entities";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    54
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    55
    private static final String STRING_INTERNING = "http://xml.org/sax/features/string-interning";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    56
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
    57
    /** Property identifier: Security manager. */
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
    58
    private static final String SECURITY_MANAGER = Constants.SECURITY_MANAGER;
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
    59
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
    60
    /** Property identifier: Security property manager. */
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
    61
    private static final String XML_SECURITY_PROPERTY_MANAGER =
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
    62
            Constants.XML_SECURITY_PROPERTY_MANAGER;
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
    63
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
    64
    HashMap<String, Object> supportedProps = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    65
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
    66
    private XMLSecurityManager fSecurityManager;
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
    67
    private XMLSecurityPropertyManager fSecurityPropertyMgr;
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
    68
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    69
    public static final int CONTEXT_READER = 1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    70
    public static final int CONTEXT_WRITER = 2;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    71
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    72
    /** Creates a new instance of PropertyManager */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    73
    public PropertyManager(int context) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    74
        switch(context){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    75
            case CONTEXT_READER:{
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    76
                initConfigurableReaderProperties();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    77
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    78
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    79
            case CONTEXT_WRITER:{
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    80
                initWriterProps();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    81
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    82
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    83
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    84
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    85
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    86
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    87
     * Initialize this object with the properties taken from passed PropertyManager object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    88
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    89
    public PropertyManager(PropertyManager propertyManager){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    90
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
    91
        HashMap<String, Object> properties = propertyManager.getProperties();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    92
        supportedProps.putAll(properties);
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
    93
        fSecurityManager = (XMLSecurityManager)getProperty(SECURITY_MANAGER);
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
    94
        fSecurityPropertyMgr = (XMLSecurityPropertyManager)getProperty(XML_SECURITY_PROPERTY_MANAGER);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    95
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    96
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
    97
    private HashMap<String, Object> getProperties(){
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    98
        return supportedProps ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    99
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   100
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   101
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   102
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   103
     * Important point:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   104
     * 1. We are not exposing Xerces namespace property. Application should configure namespace through
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   105
     * Stax specific property.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   106
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   107
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   108
    private void initConfigurableReaderProperties(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   109
        //spec default values
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   110
        supportedProps.put(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   111
        supportedProps.put(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   112
        supportedProps.put(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   113
        supportedProps.put(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.TRUE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   114
        supportedProps.put(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   115
        supportedProps.put(XMLInputFactory.SUPPORT_DTD, Boolean.TRUE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   116
        supportedProps.put(XMLInputFactory.REPORTER, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   117
        supportedProps.put(XMLInputFactory.RESOLVER, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   118
        supportedProps.put(XMLInputFactory.ALLOCATOR, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   119
        supportedProps.put(STAX_NOTATIONS,null );
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   120
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   121
        //zephyr (implementation) specific properties which can be set by the application.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   122
        //interning is always done
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   123
        supportedProps.put(Constants.SAX_FEATURE_PREFIX + Constants.STRING_INTERNING_FEATURE , true);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   124
        //recognizing java encoding names by default
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   125
        supportedProps.put(Constants.XERCES_FEATURE_PREFIX + Constants.ALLOW_JAVA_ENCODINGS_FEATURE, true) ;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   126
        //in stax mode, namespace declarations are not added as attributes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   127
        supportedProps.put(Constants.ADD_NAMESPACE_DECL_AS_ATTRIBUTE ,  Boolean.FALSE) ;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   128
        supportedProps.put(Constants.READER_IN_DEFINED_STATE, true);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   129
        supportedProps.put(Constants.REUSE_INSTANCE, true);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   130
        supportedProps.put(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.STAX_REPORT_CDATA_EVENT , false);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   131
        supportedProps.put(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.IGNORE_EXTERNAL_DTD, Boolean.FALSE);
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   132
        supportedProps.put(Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE, false);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   133
        supportedProps.put(Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ENTITYDEF_FEATURE, false);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   134
        supportedProps.put(Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_UNDECLARED_ELEMDEF_FEATURE, false);
17534
21dc0b2762da 8011653: Upgrade JDK8 to JAXP 1.5
joehw
parents: 12457
diff changeset
   135
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   136
        fSecurityManager = new XMLSecurityManager(true);
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   137
        supportedProps.put(SECURITY_MANAGER, fSecurityManager);
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
   138
        fSecurityPropertyMgr = new XMLSecurityPropertyManager();
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
   139
        supportedProps.put(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   140
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   141
        // Initialize Catalog features
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   142
        supportedProps.put(XMLConstants.USE_CATALOG, JdkXmlUtils.USE_CATALOG_DEFAULT);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   143
        for( CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   144
            supportedProps.put(f.getPropertyName(), null);
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   145
        }
42247
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
   146
52fafb950d5a 8158619: Very large CDATA section in XML document causes OOME
joehw
parents: 39907
diff changeset
   147
        supportedProps.put(JdkXmlUtils.CDATA_CHUNK_SIZE, JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   148
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   149
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   150
    private void initWriterProps(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   151
        supportedProps.put(XMLOutputFactory.IS_REPAIRING_NAMESPACES , Boolean.FALSE);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   152
        //default value of escaping characters is 'true'
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   153
        supportedProps.put(Constants.ESCAPE_CHARACTERS , Boolean.TRUE);
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   154
        supportedProps.put(Constants.REUSE_INSTANCE, true);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   155
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   156
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   157
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   158
     * public void reset(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   159
     * supportedProps.clear() ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   160
     * }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   161
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   162
    public boolean containsProperty(String property){
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
   163
        return supportedProps.containsKey(property) ||
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   164
                (fSecurityManager != null && fSecurityManager.getIndex(property) > -1) ||
18891
be38bcc1d0f3 8020430: NullPointerException in xml sqe nightly result on 2013-07-12
joehw
parents: 18890
diff changeset
   165
                (fSecurityPropertyMgr!=null && fSecurityPropertyMgr.getIndex(property) > -1) ;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   166
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   167
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   168
    public Object getProperty(String property){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   169
        return supportedProps.get(property);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   170
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   171
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   172
    public void setProperty(String property, Object value){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   173
        String equivalentProperty = null ;
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   174
        if(property.equals(XMLInputFactory.IS_NAMESPACE_AWARE)){
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   175
            equivalentProperty = Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   176
        }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   177
        else if(property.equals(XMLInputFactory.IS_VALIDATING)){
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   178
            if( (value instanceof Boolean) && ((Boolean)value).booleanValue()){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   179
                throw new java.lang.IllegalArgumentException("true value of isValidating not supported") ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   180
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   181
        }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   182
        else if(property.equals(STRING_INTERNING)){
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   183
            if( (value instanceof Boolean) && !((Boolean)value).booleanValue()){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   184
                throw new java.lang.IllegalArgumentException("false value of " + STRING_INTERNING + "feature is not supported") ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   185
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   186
        }
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 25868
diff changeset
   187
        else if(property.equals(XMLInputFactory.RESOLVER)){
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   188
            //add internal stax property
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   189
            supportedProps.put( Constants.XERCES_PROPERTY_PREFIX + Constants.STAX_ENTITY_RESOLVER_PROPERTY , new StaxEntityResolverWrapper((XMLResolver)value)) ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   190
        }
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
   191
20973
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   192
        /**
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   193
         * It's possible for users to set a security manager through the interface.
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   194
         * If it's the old SecurityManager, convert it to the new XMLSecurityManager
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   195
         */
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   196
        if (property.equals(Constants.SECURITY_MANAGER)) {
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   197
            fSecurityManager = XMLSecurityManager.convert(value, fSecurityManager);
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   198
            supportedProps.put(Constants.SECURITY_MANAGER, fSecurityManager);
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   199
            return;
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   200
        }
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   201
        if (property.equals(Constants.XML_SECURITY_PROPERTY_MANAGER)) {
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   202
            if (value == null) {
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   203
                fSecurityPropertyMgr = new XMLSecurityPropertyManager();
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   204
            } else {
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   205
                fSecurityPropertyMgr = (XMLSecurityPropertyManager)value;
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   206
            }
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   207
            supportedProps.put(Constants.XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   208
            return;
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   209
        }
cc1cc8eb501b 8022682: Supporting XOM
joehw
parents: 20968
diff changeset
   210
20968
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   211
        //check if the property is managed by security manager
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   212
        if (fSecurityManager == null ||
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   213
                !fSecurityManager.setLimit(property, XMLSecurityManager.State.APIPROPERTY, value)) {
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   214
            //check if the property is managed by security property manager
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   215
            if (fSecurityPropertyMgr == null ||
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   216
                    !fSecurityPropertyMgr.setValue(property, XMLSecurityPropertyManager.State.APIPROPERTY, value)) {
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   217
                //fall back to the existing property manager
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   218
                supportedProps.put(property, value);
dde41f8b7b96 8014530: Better digital signature processing
joehw
parents: 18891
diff changeset
   219
            }
18890
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
   220
        }
25bdeca3173b 8016648: FEATURE_SECURE_PROCESSING set to true or false causes SAXParseException to be thrown
joehw
parents: 17534
diff changeset
   221
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   222
        if(equivalentProperty != null){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   223
            supportedProps.put(equivalentProperty, value ) ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   224
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   225
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   226
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   227
    public String toString(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   228
        return supportedProps.toString();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   229
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   230
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   231
}//PropertyManager