/** * Get the System Property * @param key key of the system property * @param defaultValue default value to be returned if the system property is not set * @return */ public static String getSystemProperty(final String key, final String defaultValue){ return SecurityActions.getSystemProperty(key,defaultValue); } }
public InputStream getByteStream() { URL url = SecurityActions.loadResource(getClass(), loc); InputStream is; try { is = url.openStream(); } catch (IOException e) { throw new RuntimeException(ErrorCodes.CLASS_NOT_LOADED + loc); } if (is == null) throw new RuntimeException(ErrorCodes.NULL_VALUE + "inputstream is null for " + loc); return 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); } } } }
/** * <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 InputStream getByteStream() { URL url = SecurityActions.loadResource(getClass(), loc); InputStream is; try { is = url.openStream(); } catch (IOException e) { throw new RuntimeException(ErrorCodes.CLASS_NOT_LOADED + loc); } if (is == null) throw new RuntimeException(ErrorCodes.NULL_VALUE + "inputstream is null for " + loc); return is; }
subString = subString.substring(0, index); sysPropertyValue = SecurityActions.getSystemProperty(subString, defaultValue); if (sysPropertyValue.isEmpty())
/** * 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 getJAXPSchemaInstance(String schemaLocation) throws SAXException { URL schemaURL = SecurityActions.loadResource(JAXBUtil.class, schemaLocation); if (schemaURL == null) throw new IllegalStateException(ErrorCodes.NULL_VALUE + "Schema URL :" + schemaLocation); SchemaFactory scFact = getSchemaFactory(); Schema schema = scFact.newSchema(schemaURL); return schema; }
subString = subString.substring(0, index); sysPropertyValue = SecurityActions.getSystemProperty(subString, defaultValue); if (sysPropertyValue.isEmpty())
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; }
private static Schema getJAXPSchemaInstance(String schemaLocation) throws SAXException { URL schemaURL = SecurityActions.loadResource(JAXBUtil.class, schemaLocation); if (schemaURL == null) throw new IllegalStateException(ErrorCodes.NULL_VALUE + "Schema URL :" + schemaLocation); SchemaFactory scFact = getSchemaFactory(); Schema schema = scFact.newSchema(schemaURL); return schema; }
subString = subString.substring(0, index); sysPropertyValue = SecurityActions.getSystemProperty(subString, defaultValue); if (sysPropertyValue.isEmpty()) { throw logger.systemPropertyMissingError(matcher.group(1));
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; }
private static Source[] sources() throws IOException { List<String> schemas = SchemaManagerUtil.getSchemas(); Source[] sourceArr = new Source[schemas.size()]; int i = 0; for (String schema : schemas) { URL url = SecurityActions.loadResource(JAXPValidationUtil.class, schema); if (url == null) throw new RuntimeException(ErrorCodes.NULL_VALUE + "schema url:" + schema); sourceArr[i++] = new StreamSource(url.openStream()); } return sourceArr; }
/** * Based on system property "picketlink.schema.validate" set to "true", do schema validation * * @param samlDocument * @throws ProcessingException */ public static void checkSchemaValidation(Node samlDocument) throws ProcessingException { if (SecurityActions.getSystemProperty("picketlink.schema.validate", "false").equalsIgnoreCase("true")) { try { JAXPValidationUtil.validate(DocumentUtil.getNodeAsStream(samlDocument)); } catch (Exception e) { throw logger.processingError(e); } } }