private PolicyDecisionPoint getPDP() throws PrivilegedActionException { SystemPropertiesUtil.ensure(); URL url = SecurityActions.loadResource(getClass(), policyConfigFileName); if (url == null) throw new IllegalStateException(ErrorCodes.FILE_NOT_LOCATED + policyConfigFileName); InputStream is; try { is = url.openStream(); } catch (IOException e) { throw new RuntimeException(e); } return new JBossPDP(is); } }
private static XMLInputFactory getXMLInputFactory() { boolean tccl_jaxp = SystemPropertiesUtil.getSystemProperty(GeneralConstants.TCCL_JAXP, "false") .equalsIgnoreCase("true"); ClassLoader prevTCCL = SecurityActions.getTCCL(); try { if (tccl_jaxp) { SecurityActions.setTCCL(StaxParserUtil.class.getClassLoader()); } return XMLInputFactory.newInstance(); } finally { if (tccl_jaxp) { SecurityActions.setTCCL(prevTCCL); } } } }
private PolicyDecisionPoint getPDP() throws PrivilegedActionException { SystemPropertiesUtil.ensure(); URL url = SecurityActions.loadResource(getClass(), policyConfigFileName); if (url == null) throw new IllegalStateException(ErrorCodes.FILE_NOT_LOCATED + policyConfigFileName); InputStream is; try { is = url.openStream(); } catch (IOException e) { throw new RuntimeException(e); } return new JBossPDP(is); } }
private static XMLOutputFactory getXMLOutputFactory() { boolean tccl_jaxp = SystemPropertiesUtil.getSystemProperty(GeneralConstants.TCCL_JAXP, "false") .equalsIgnoreCase("true"); ClassLoader prevTCCL = SecurityActions.getTCCL(); try { if (tccl_jaxp) { SecurityActions.setTCCL(StaxUtil.class.getClassLoader()); } return XMLOutputFactory.newInstance(); } finally { if (tccl_jaxp) { SecurityActions.setTCCL(prevTCCL); } } } }
public static Validator validator() throws SAXException, IOException { SystemPropertiesUtil.ensure(); if (validator == null) { Schema schema = getSchema(); if (schema == null) throw new RuntimeException(ErrorCodes.NULL_VALUE + "schema"); validator = schema.newValidator(); validator.setErrorHandler(new CustomErrorHandler()); } return validator; }
/** * Get the JAXP {@link XMLInputFactory} * @return */ protected XMLInputFactory getXMLInputFactory() { boolean tccl_jaxp = SystemPropertiesUtil.getSystemProperty(GeneralConstants.TCCL_JAXP, "false") .equalsIgnoreCase("true"); ClassLoader prevTCCL = getTCCL(); try { if (tccl_jaxp) { setTCCL(getClass().getClassLoader()); } return XMLInputFactory.newInstance(); } finally { if (tccl_jaxp) { setTCCL(prevTCCL); } } }
public static Validator validator() throws SAXException, IOException { SystemPropertiesUtil.ensure(); if (validator == null) { Schema schema = getSchema(); if (schema == null) throw new RuntimeException(ErrorCodes.NULL_VALUE + "schema"); validator = schema.newValidator(); validator.setErrorHandler(new CustomErrorHandler()); } return validator; }
/** * Create a new {@link DatatypeFactory} * @return * @throws DatatypeConfigurationException */ public static DatatypeFactory newDatatypeFactory() throws DatatypeConfigurationException { boolean tccl_jaxp = SystemPropertiesUtil.getSystemProperty(GeneralConstants.TCCL_JAXP, "false") .equalsIgnoreCase("true"); ClassLoader prevTCCL = SecurityActions.getTCCL(); try{ if(tccl_jaxp){ SecurityActions.setTCCL(XMLTimeUtil.class.getClassLoader()); } return DatatypeFactory.newInstance(); }finally{ if(tccl_jaxp){ SecurityActions.setTCCL(prevTCCL); } } } }
private PolicyDecisionPoint getPDP() throws PrivilegedActionException { SystemPropertiesUtil.ensure(); URL url = SecurityActions.loadResource(getClass(), policyConfigFileName); if (url == null) throw logger.fileNotLocated(policyConfigFileName); InputStream is; try { is = url.openStream(); } catch (IOException e) { throw new RuntimeException(logger.resourceNotFound(url.getPath())); } return new JBossPDP(is); } }
/** * <p>Creates a {@link TransformerFactory}. The returned instance is cached and shared between different threads.</p> * * @return * @throws TransformerFactoryConfigurationError */ public static TransformerFactory getTransformerFactory() throws TransformerFactoryConfigurationError { if (transformerFactory == null) { boolean tccl_jaxp = SystemPropertiesUtil.getSystemProperty(GeneralConstants.TCCL_JAXP, "false") .equalsIgnoreCase("true"); ClassLoader prevTCCL = SecurityActions.getTCCL(); try{ if(tccl_jaxp){ SecurityActions.setTCCL(TransformerUtil.class.getClassLoader()); } transformerFactory = TransformerFactory.newInstance(); } finally { if(tccl_jaxp){ SecurityActions.setTCCL(prevTCCL); } } } return transformerFactory; }
public static Validator validator() throws SAXException, IOException { SystemPropertiesUtil.ensure(); if (validator == null) { Schema schema = getSchema(); if (schema == null) throw logger.nullValueError("schema"); validator = schema.newValidator(); validator.setErrorHandler(new CustomErrorHandler()); } return validator; }
/** * <p> * Creates a namespace aware {@link DocumentBuilderFactory}. The returned instance is cached and shared between different * threads. * </p> * * @return */ private static DocumentBuilderFactory getDocumentBuilderFactory() { boolean tccl_jaxp = SystemPropertiesUtil.getSystemProperty(GeneralConstants.TCCL_JAXP, "false") .equalsIgnoreCase("true"); ClassLoader prevTCCL = SecurityActions.getTCCL(); if (documentBuilderFactory == null) { try { if (tccl_jaxp) { SecurityActions.setTCCL(DocumentUtil.class.getClassLoader()); } documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setXIncludeAware(true); } finally { if (tccl_jaxp) { SecurityActions.setTCCL(prevTCCL); } } } return documentBuilderFactory; } }
/** * Use the transformer to transform * * @param transformer * @param source * @param result * @throws ParsingException */ public static void transform(Transformer transformer, Source source, DOMResult result) throws ParsingException { boolean tccl_jaxp = SystemPropertiesUtil.getSystemProperty(GeneralConstants.TCCL_JAXP,"false").equalsIgnoreCase("true"); ClassLoader prevCL = SecurityActions.getTCCL(); try { if(tccl_jaxp){ SecurityActions.setTCCL(TransformerUtil.class.getClassLoader()); } transformer.transform(source, result); } catch (TransformerException e) { throw logger.parserError(e); }finally{ if(tccl_jaxp){ SecurityActions.setTCCL(prevCL); } } }
private static Schema getSchema() throws IOException { boolean tccl_jaxp = SystemPropertiesUtil.getSystemProperty(GeneralConstants.TCCL_JAXP,"false").equalsIgnoreCase("true"); ClassLoader prevTCCL = SecurityActions.getTCCL(); try{ if(tccl_jaxp){ SecurityActions.setTCCL(JAXPValidationUtil.class.getClassLoader()); } schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); schemaFactory.setResourceResolver(new IDFedLSInputResolver()); schemaFactory.setErrorHandler(new CustomErrorHandler()); } finally{ if(tccl_jaxp){ SecurityActions.setTCCL(prevTCCL); } } Schema schemaGrammar = null; try { schemaGrammar = schemaFactory.newSchema(sources()); } catch (SAXException e) { logger.xmlCouldNotGetSchema(e); } return schemaGrammar; }