/** * Returns properly configured (e.g. security features) factory * - securityProcessing == is set based on security processing property, default is true */ public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException { try { XPathFactory factory = XPathFactory.newInstance(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory); } factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing)); return factory; } catch (XPathFactoryConfigurationException ex) { LOGGER.log(Level.SEVERE, null, ex); throw new IllegalStateException( ex); } catch (AbstractMethodError er) { LOGGER.log(Level.SEVERE, null, er); throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er); } }
xpf = XPathFactory.newInstance(); try { xpf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); } catch (XPathFactoryConfigurationException ex) { throw new TransformerException(ex);
xpf = XPathFactory.newInstance(); try { xpf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); } catch (XPathFactoryConfigurationException ex) { throw new TransformerException(ex);
/** * Returns properly configured (e.g. security features) factory * - securityProcessing == is set based on security processing property, default is true */ public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException { try { XPathFactory factory = XPathFactory.newInstance(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory); } factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing)); return factory; } catch (XPathFactoryConfigurationException ex) { LOGGER.log(Level.SEVERE, null, ex); throw new IllegalStateException( ex); } catch (AbstractMethodError er) { LOGGER.log(Level.SEVERE, null, er); throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er); } }
public void setFeature(String name, boolean value) throws XPathFactoryConfigurationException { actual.setFeature(name, value); }
private static synchronized XPathFactory getXpathFactory() { XPathFactory xPathFactory = XPathFactory.newInstance(); try { xPathFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); } catch (XPathFactoryConfigurationException ex) { // ignore } return xPathFactory; }
public static XPathFactory newXPathFactory(boolean disableSecurity) { XPathFactory factory = XPathFactory.newInstance(); try { factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity)); } catch (XPathFactoryConfigurationException e) { LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[] { factory.getClass().getName() } ); } return factory; }
public static XPathFactory newXPathFactory(boolean disableSecurity) { XPathFactory factory = XPathFactory.newInstance(); try { factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity)); } catch (XPathFactoryConfigurationException e) { LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[] { factory.getClass().getName() } ); } return factory; }
public static XPathFactory newXPathFactory(boolean disableSecurity) { XPathFactory factory = XPathFactory.newInstance(); try { factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity)); } catch (XPathFactoryConfigurationException e) { LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[] { factory.getClass().getName() } ); } return factory; }
/** * Create the specified XPath expression with the namespaces added via * addNamespace(). */ public static XPath createXPath(Map<String, String> namespaces) throws Exception { XPathFactory xpathFactory = XPathFactory.newInstance(); try { xpathFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); } catch (javax.xml.xpath.XPathFactoryConfigurationException ex) { // ignore } XPath xpath = xpathFactory.newXPath(); if (namespaces != null) { xpath.setNamespaceContext(new MapNamespaceContext(namespaces)); } return xpath; }
/** * Returns properly configured (e.g. security features) factory * - securityProcessing == is set based on security processing property, default is true */ public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException { try { XPathFactory factory = XPathFactory.newInstance(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory); } factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing)); return factory; } catch (XPathFactoryConfigurationException ex) { LOGGER.log(Level.SEVERE, null, ex); throw new IllegalStateException( ex); } catch (AbstractMethodError er) { LOGGER.log(Level.SEVERE, null, er); throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er); } }
/** * Returns properly configured (e.g. security features) factory * - securityProcessing == is set based on security processing property, default is true */ public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException { try { XPathFactory factory = XPathFactory.newInstance(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory); } factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing)); return factory; } catch (XPathFactoryConfigurationException ex) { LOGGER.log(Level.SEVERE, null, ex); throw new IllegalStateException( ex); } catch (AbstractMethodError er) { LOGGER.log(Level.SEVERE, null, er); throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er); } }
/** * Returns properly configured (e.g. security features) factory * - securityProcessing == is set based on security processing property, default is true */ public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException { try { XPathFactory factory = XPathFactory.newInstance(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory); } factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing)); return factory; } catch (XPathFactoryConfigurationException ex) { LOGGER.log(Level.SEVERE, null, ex); throw new IllegalStateException( ex); } catch (AbstractMethodError er) { LOGGER.log(Level.SEVERE, null, er); throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er); } }
/** * Returns properly configured (e.g. security features) factory * - securityProcessing == is set based on security processing property, default is true */ public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException { try { XPathFactory factory = XPathFactory.newInstance(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory); } factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing)); return factory; } catch (XPathFactoryConfigurationException ex) { LOGGER.log(Level.SEVERE, null, ex); throw new IllegalStateException( ex); } catch (AbstractMethodError er) { LOGGER.log(Level.SEVERE, null, er); throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er); } }
public void applyTo (@Nonnull final XPathFactory aXPathFactory, final boolean bValue) { ValueEnforcer.notNull (aXPathFactory, "XPathFactory"); if (m_eType != EXMLParserFeatureType.GENERAL) if (LOGGER.isWarnEnabled ()) LOGGER.warn ("Parser feature '" + name () + "' is not applicable for XPathFactory!"); try { aXPathFactory.setFeature (m_sName, bValue); } catch (final XPathFactoryConfigurationException ex) { if (LOGGER.isWarnEnabled ()) LOGGER.warn ("XPathFactory does not support feature '" + name () + "'"); } }
protected boolean doFilter(Element content) { if (contentFilter != null) { if (!contentFilter.getDialect().equals(XPATH1_URI)) { throw new IllegalStateException("Unsupported dialect: " + contentFilter.getDialect()); } try { XPathFactory xpfactory = XPathFactory.newInstance(); try { xpfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); } catch (Throwable t) { //possibly old version, though doesn't really matter as content is already parsed as an Element } XPath xpath = xpfactory.newXPath(); XPathExpression exp = xpath.compile(contentFilter.getContent().get(0).toString()); Boolean ret = (Boolean) exp.evaluate(content, XPathConstants.BOOLEAN); return ret.booleanValue(); } catch (XPathExpressionException e) { LOGGER.log(Level.WARNING, "Could not filter notification", e); } return false; } return true; }
private Object evaluate(String expression, Map<String, String> namespaces, QName type) { XPathFactory factory = XPathFactory.newInstance(); try { factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); } catch (XPathFactoryConfigurationException e) { throw new RuntimeException(e); } XPath xpath = factory.newXPath(); xpath.setNamespaceContext(new NamespaceContextImpl(namespaces)); boolean releaseDoc = false; try { if (stream != null) { //xalan xpath evaluate parses to a DOM via a DocumentBuilderFactory, but doesn't //set the SecureProcessing on that. Since a DOM is always created, might as well //do it via stax and avoid the service factory performance hits that the //DocumentBuilderFactory will entail as well as get the extra security //that woodstox provides setBuffering(); releaseDoc = true; } return xpath.compile(expression).evaluate(doc, type); } catch (XPathExpressionException ex) { throw new IllegalArgumentException("Illegal XPath expression '" + expression + "'", ex); } finally { if (releaseDoc) { //don't need to maintain the doc doc = null; } } }
private Node queryXPathNode(Node target, String expression) { NodeList nlst; try { ContextImpl contextImpl = new ContextImpl(target); XPathFactory xpathFactory = XPathFactory.newInstance(); try { xpathFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); } catch (javax.xml.xpath.XPathFactoryConfigurationException ex) { // ignore } XPath xpath = xpathFactory.newXPath(); xpath.setNamespaceContext(contextImpl); nlst = (NodeList)xpath.evaluate(expression, target, XPathConstants.NODESET); } catch (XPathExpressionException e) { Message msg = new Message("XPATH_ERROR", LOG, new Object[] {expression}); throw new ToolException(msg, e); } if (nlst.getLength() != 1) { Message msg = new Message("ERROR_TARGETNODE_WITH_XPATH", LOG, new Object[] {expression}); throw new ToolException(msg); } Node rnode = nlst.item(0); if (!(rnode instanceof Element)) { return null; } return rnode; }
/** * Returns properly configured (e.g. security features) factory * - securityProcessing == is set based on security processing property, default is true */ public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException { SessionLog logger = AbstractSessionLog.getLog(); try { XPathFactory factory = XPathFactory.newInstance(); if (logger.shouldLog(SessionLog.FINE, SessionLog.MOXY)) { logger.log(SessionLog.FINE, SessionLog.MOXY, "xpath_factory", new Object[] {factory}); } factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing)); return factory; } catch (XPathFactoryConfigurationException ex) { logger.logThrowable(SessionLog.SEVERE, SessionLog.MOXY, ex); throw new IllegalStateException( ex); } catch (AbstractMethodError er) { logger.logThrowable(SessionLog.SEVERE, SessionLog.MOXY, er); throw new IllegalStateException(er); } }
XPathFactory factory = XPathFactory.newInstance(); try { factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); } catch (javax.xml.xpath.XPathFactoryConfigurationException ex) {