当前位置: 首页>>代码示例>>Java>>正文


Java Constants类代码示例

本文整理汇总了Java中org.apache.xerces.impl.Constants的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Constants类属于org.apache.xerces.impl包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSecuredDocumentBuilderFactory

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
/**
 * Create DocumentBuilderFactory with the XXE and XEE prevention measurements.
 *
 * @return DocumentBuilderFactory instance
 */
public static DocumentBuilderFactory getSecuredDocumentBuilderFactory() {

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setXIncludeAware(false);
    dbf.setExpandEntityReferences(false);
    try {
        dbf.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE, false);
        dbf.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE, false);
        dbf.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE, false);
        dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);

    } catch (ParserConfigurationException e) {
        log.error("Failed to load XML Processor Feature " + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE + " or " +
                Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE + " or " + Constants.LOAD_EXTERNAL_DTD_FEATURE +
                " or secure-processing.");
    }

    SecurityManager securityManager = new SecurityManager();
    securityManager.setEntityExpansionLimit(ENTITY_EXPANSION_LIMIT);
    dbf.setAttribute(Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY, securityManager);

    return dbf;

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:31,代码来源:IdentityUtil.java

示例2: getSecuredDocumentBuilder

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
/**
 * Get document builder factory instance.
 *
 * @return documentBuilderFactory
 */
private DocumentBuilderFactory getSecuredDocumentBuilder() {
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    documentBuilderFactory.setXIncludeAware(false);
    documentBuilderFactory.setExpandEntityReferences(false);
    try {
        documentBuilderFactory.setFeature(Constants.SAX_FEATURE_PREFIX +
                Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE, false);
        documentBuilderFactory.setFeature(Constants.SAX_FEATURE_PREFIX +
                Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE, false);
        documentBuilderFactory.setFeature(Constants.XERCES_FEATURE_PREFIX +
                Constants.LOAD_EXTERNAL_DTD_FEATURE, false);
        documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
    } catch (ParserConfigurationException e) {
        log.error("Failed to load XML Processor Feature " + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE + " or " +
                Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE + " or " + Constants.LOAD_EXTERNAL_DTD_FEATURE);
    }

    SecurityManager securityManager = new SecurityManager();
    securityManager.setEntityExpansionLimit(ENTITY_EXPANSION_LIMIT);
    documentBuilderFactory.setAttribute(Constants.XERCES_PROPERTY_PREFIX +
            Constants.SECURITY_MANAGER_PROPERTY, securityManager);
    return documentBuilderFactory;
}
 
开发者ID:wso2-extensions,项目名称:esb-connector-file,代码行数:30,代码来源:SplitFile.java

示例3: XSParser

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
public XSParser(LSResourceResolver entityResolver, DOMErrorHandler errorHandler){
    System.setProperty(DOMImplementationRegistry.PROPERTY, DOMXSImplementationSourceImpl.class.getName());
    DOMImplementationRegistry registry;
    try{
        registry = DOMImplementationRegistry.newInstance();
    }catch(Exception ex){
        throw new ImpossibleException(ex);
    }
    XSImplementationImpl xsImpl = (XSImplementationImpl)registry.getDOMImplementation("XS-Loader");

    xsLoader = xsImpl.createXSLoader(null);
    DOMConfiguration config = xsLoader.getConfig();
    config.setParameter(Constants.DOM_VALIDATE, Boolean.TRUE);

    if(entityResolver!=null)
        config.setParameter(Constants.DOM_RESOURCE_RESOLVER, entityResolver);

    if(errorHandler!=null)
        config.setParameter(Constants.DOM_ERROR_HANDLER, errorHandler);
}
 
开发者ID:santhosh-tekuri,项目名称:jlibs,代码行数:21,代码来源:XSParser.java

示例4: startGeneralEntity

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
/**
 * This method notifies of the start of an entity. The DTD has the
 * pseudo-name of "[dtd]" parameter entity names start with '%'; and
 * general entity names are just the entity name.
 * <p>
 * <strong>Note:</strong> Since the document is an entity, the handler
 * will be notified of the start of the document entity by calling the
 * startEntity method with the entity name "[xml]" <em>before</em> calling
 * the startDocument method. When exposing entity boundaries through the
 * SAX API, the document entity is never reported, however.
 * <p>
 * <strong>Note:</strong> This method is not called for entity references
 * appearing as part of attribute values.
 *
 * @param name     The name of the entity.
 * @param identifier The resource identifier.
 * @param encoding The auto-detected IANA encoding name of the entity
 *                 stream. This value will be null in those situations
 *                 where the entity encoding is not auto-detected (e.g.
 *                 internal parameter entities).
 * @param augs     Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startGeneralEntity(String name, XMLResourceIdentifier identifier, 
                               String encoding, Augmentations augs)
    throws XNIException {
    
    try {
        // Only report startEntity if this entity was actually read.
        if (augs != null && Boolean.TRUE.equals(augs.getItem(Constants.ENTITY_SKIPPED))) {
            // report skipped entity to content handler
            if (fContentHandler != null) {
                fContentHandler.skippedEntity(name);
            }
        }
        else {
            // SAX2 extension
            if (fLexicalHandler != null) {
                fLexicalHandler.startEntity(name);
            }
        }
    }
    catch (SAXException e) {
        throw new XNIException(e);
    }

}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:49,代码来源:AbstractSAXParserMMImpl.java

示例5: startParameterEntity

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
/**
 * This method notifies of the start of parameter entity. The DTD has the
 * pseudo-name of "[dtd]" parameter entity names start with '%'; and
 * general entity names are just the entity name.
 * <p>
 * <strong>Note:</strong> Since the document is an entity, the handler
 * will be notified of the start of the document entity by calling the
 * startEntity method with the entity name "[xml]" <em>before</em> calling
 * the startDocument method. When exposing entity boundaries through the
 * SAX API, the document entity is never reported, however.
 * <p>
 * <strong>Note:</strong> This method is not called for entity references
 * appearing as part of attribute values.
 *
 * @param name     The name of the parameter entity.
 * @param identifier The resource identifier.
 * @param encoding The auto-detected IANA encoding name of the entity
 *                 stream. This value will be null in those situations
 *                 where the entity encoding is not auto-detected (e.g.
 *                 internal parameter entities).
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startParameterEntity(String name, 
                                 XMLResourceIdentifier identifier,
                                 String encoding, Augmentations augs)
    throws XNIException {

    try {
        // Only report startEntity if this entity was actually read.
        if (augs != null && Boolean.TRUE.equals(augs.getItem(Constants.ENTITY_SKIPPED))) {
            // report skipped entity to content handler
            if (fContentHandler != null) {
                fContentHandler.skippedEntity(name);
            }
        }
        else {
            // SAX2 extension
            if (fLexicalHandler != null && fLexicalHandlerParameterEntities) {
                fLexicalHandler.startEntity(name);
            }
        }
    }
    catch (SAXException e) {
        throw new XNIException(e);
    }

}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:51,代码来源:AbstractSAXParserMMImpl.java

示例6: getSecuredDocumentBuilderFactory

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
/**
 * Create DocumentBuilderFactory with the XXE prevention measurements
 *
 * @return DocumentBuilderFactory instance
 */
public static DocumentBuilderFactory getSecuredDocumentBuilderFactory() {

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setXIncludeAware(false);
    dbf.setExpandEntityReferences(false);
    try {
        dbf.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE, false);
        dbf.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE, false);
        dbf.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE, false);
        dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
    } catch (ParserConfigurationException e) {
        logger.error(
                "Failed to load XML Processor Feature " + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE + " or " +
                        Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE + " or " + Constants.LOAD_EXTERNAL_DTD_FEATURE);
    }

    SecurityManager securityManager = new SecurityManager();
    securityManager.setEntityExpansionLimit(ENTITY_EXPANSION_LIMIT);
    dbf.setAttribute(Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY, securityManager);

    return dbf;
}
 
开发者ID:wso2,项目名称:balana,代码行数:29,代码来源:Utils.java

示例7: getSecuredDocumentBuilder

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
/**
 * Create DocumentBuilderFactory with the XXE and XEE prevention measurements.
 *
 * @return DocumentBuilderFactory instance
 */
public static DocumentBuilderFactory getSecuredDocumentBuilder() {

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setXIncludeAware(false);
    dbf.setExpandEntityReferences(false);
    try {
        dbf.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE, false);
        dbf.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE, false);
        dbf.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE, false);
        dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);

    } catch (ParserConfigurationException e) {
        log.error("Failed to load XML Processor Feature " + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE + " or " +
                Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE + " or " + Constants.LOAD_EXTERNAL_DTD_FEATURE +
                " or secure-processing.");
    }

    SecurityManager securityManager = new SecurityManager();
    securityManager.setEntityExpansionLimit(ENTITY_EXPANSION_LIMIT);
    dbf.setAttribute(Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY, securityManager);

    return dbf;

}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:31,代码来源:DOMUtils.java

示例8: getSecuredDocumentBuilder

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
private static DocumentBuilderFactory getSecuredDocumentBuilder() {
    final int ENTITY_EXPANSION_LIMIT = 0;
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setXIncludeAware(false);
    dbf.setExpandEntityReferences(false);

    try {
        dbf.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE, false);
        dbf.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE, false);
        dbf.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE, false);
        dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
    } catch (ParserConfigurationException e) {
        // Skip throwing the error as this exception doesn't break actual DocumentBuilderFactory creation
        log.error("Failed to load XML Processor Feature " + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE + " or "
                + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE + " or " + Constants.LOAD_EXTERNAL_DTD_FEATURE, e);
    }

    SecurityManager securityManager = new SecurityManager();
    securityManager.setEntityExpansionLimit(ENTITY_EXPANSION_LIMIT);
    dbf.setAttribute(Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY, securityManager);
    return dbf;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:24,代码来源:RxtUnboundedDataLoadUtils.java

示例9: checkProperty

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
/**
 * Check a property. If the property is know and supported, this method
 * simply returns. Otherwise, the appropriate exception is thrown.
 *
 * @param propertyId The unique identifier (URI) of the property
 *                   being set.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected void checkProperty(String propertyId)
    throws XMLConfigurationException {

    //
    // Xerces Properties
    //

    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();

        if (suffixLength == Constants.DTD_SCANNER_PROPERTY.length() && 
            propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) {
            return;
        }
    }

    //
    // Not recognized
    //

    super.checkProperty(propertyId);

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:37,代码来源:DTDConfiguration.java

示例10: startParameterEntity

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
/**
 * This method notifies of the start of a parameter entity. The parameter
 * entity name start with a '%' character.
 *
 * @param name     The name of the parameter entity.
 * @param identifier The resource identifier.
 * @param encoding The auto-detected IANA encoding name of the entity
 *                 stream. This value will be null in those situations
 *                 where the entity encoding is not auto-detected (e.g.
 *                 internal parameter entities).
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startParameterEntity (String name,
XMLResourceIdentifier identifier,
String encoding,
Augmentations augs) throws XNIException {
    if (DEBUG_EVENTS) {
        System.out.println ("==>startParameterEntity: "+name);
        if (DEBUG_BASEURI) {
            System.out.println ("   expandedSystemId: "+identifier.getExpandedSystemId ());
            System.out.println ("   baseURI:"+ identifier.getBaseSystemId ());
        }
    }
    if (augs != null && fInternalSubset != null && 
        !fInDTDExternalSubset && 
        Boolean.TRUE.equals(augs.getItem(Constants.ENTITY_SKIPPED))) {
        fInternalSubset.append(name).append(";\n");
    }
    fBaseURIStack.push (identifier.getExpandedSystemId ());
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:34,代码来源:AbstractDOMParser.java

示例11: checkFeature

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected void checkFeature(String featureId)
    throws XMLConfigurationException {

    //
    // Xerces Features
    //
    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // special performance feature: no one by component manager is allowed to set it
        //
        if (suffixLength == Constants.PARSER_SETTINGS.length() && 
            featureId.endsWith(Constants.PARSER_SETTINGS)) {
            short type = XMLConfigurationException.NOT_SUPPORTED;
            throw new XMLConfigurationException(type, featureId);
        }
    }

    super.checkFeature(featureId);

 }
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:35,代码来源:BasicParserConfiguration.java

示例12: reset

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
/**
 * Resets the parser state.
 *
 * @throws SAXException Thrown on initialization error.
 */
public void reset () {
    super.reset();
    
    // get state of namespace-declarations parameter.
    fNamespaceDeclarations = 
        fConfiguration.getFeature(Constants.DOM_NAMESPACE_DECLARATIONS);
            
    // DOM Filter
    if (fNullFilterInUse) {
        fDOMFilter = null;
        fNullFilterInUse = false;
    }
    if (fSkippedElemStack != null) {
        fSkippedElemStack.removeAllElements();
    }
    fRejectedElementDepth = 0;
    fFilterReject = false;
    fSchemaType = null;

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:26,代码来源:DOMParserImpl.java

示例13: endElement

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
public void endElement(QName element, Augmentations augs)
        throws XNIException {
    final Node currentElement = fDOMValidatorHelper.getCurrentElement();
    // Write type information to this element
    if (augs != null && fDocumentImpl != null) {
        ElementPSVI elementPSVI = (ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI);
        if (elementPSVI != null) {
            if (fStorePSVI) {
                ((PSVIElementNSImpl) currentElement).setPSVI(elementPSVI);
            }
            XSTypeDefinition type = elementPSVI.getMemberTypeDefinition();
            if (type == null) {
                type = elementPSVI.getTypeDefinition();
            }
            ((ElementNSImpl) currentElement).setType(type);
        }
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:19,代码来源:DOMResultAugmentor.java

示例14: endElement

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
public void endElement(QName element, Augmentations augs)
        throws XNIException {
    // write type information to this element
    if (augs != null && fDocumentImpl != null) {
        ElementPSVI elementPSVI = (ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI);
        if (elementPSVI != null) {
            if (fStorePSVI) {
                ((PSVIElementNSImpl)fCurrentNode).setPSVI(elementPSVI);
            }
            XSTypeDefinition type = elementPSVI.getMemberTypeDefinition();
            if (type == null) {
                type = elementPSVI.getTypeDefinition();
            }
            ((ElementNSImpl)fCurrentNode).setType(type);
        }
    }
    
    // adjust current node reference
    if (fCurrentNode == fFragmentRoot) {
        fCurrentNode = null;
        fFragmentRoot = null;
        return;
    }
    fCurrentNode = fCurrentNode.getParentNode();
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:26,代码来源:DOMResultBuilder.java

示例15: getPrimitiveKind

import org.apache.xerces.impl.Constants; //导入依赖的package包/类
public short getPrimitiveKind() {
    if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
        if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
            return DV_STRING;
        }
        else if (fValidationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return fValidationDV;
        }
    }
    else {
        // REVISIT: error situation. runtime exception?
        return (short)0;
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:21,代码来源:XSSimpleTypeDecl.java


注:本文中的org.apache.xerces.impl.Constants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。