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; }
private static Schema getSchema() throws IOException { schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); schemaFactory.setResourceResolver(new IDFedLSInputResolver()); schemaFactory.setErrorHandler(new CustomErrorHandler()); Schema schemaGrammar = null; try { schemaGrammar = schemaFactory.newSchema(sources()); } catch (SAXException e) { log.error("Cannot get schema", e); } return schemaGrammar; }
/** * 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); } } }
/** * Given a {@link Element} that represents a SAML 1.1 assertion, convert it into a {@link SAML11AssertionType} * @param assertionElement * @return * @throws GeneralSecurityException */ public static SAML11AssertionType saml11FromElement(Element assertionElement) throws GeneralSecurityException { SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(assertionElement); return (SAML11AssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(assertionElement)); } }
/** * Get the {@link Validator} for JAXP Validation * * @return * @throws SAXException * @throws IOException */ public static Validator getSchemaValidator() throws SAXException, IOException { return JAXPValidationUtil.validator(); }
/** * Given a {@link Element} that represents a SAML 1.1 assertion, convert it into a {@link SAML11AssertionType} * @param assertionElement * @return * @throws GeneralSecurityException */ public static SAML11AssertionType saml11FromElement(Element assertionElement) throws GeneralSecurityException { SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(assertionElement); return (SAML11AssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(assertionElement)); } }
/** * Get the {@link Validator} for JAXP Validation * @return * @throws SAXException * @throws IOException */ public static Validator getSchemaValidator() throws SAXException, IOException { return JAXPValidationUtil.validator(); } }
/** * Given a {@link Element} that represents a SAML 1.1 assertion, convert it into a {@link SAML11AssertionType} * * @param assertionElement * @return * @throws GeneralSecurityException */ public static SAML11AssertionType saml11FromElement(Element assertionElement) throws GeneralSecurityException { SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(assertionElement); return (SAML11AssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(assertionElement)); } }
/** * Get the {@link Validator} for JAXP Validation * @return * @throws SAXException * @throws IOException */ public static Validator getSchemaValidator() throws SAXException, IOException { return JAXPValidationUtil.validator(); } }
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; }
/** * 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); } } }
private static Schema getSchema() throws IOException { schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); schemaFactory.setResourceResolver(new IDFedLSInputResolver()); schemaFactory.setErrorHandler(new CustomErrorHandler()); Schema schemaGrammar = null; try { schemaGrammar = schemaFactory.newSchema(sources()); } catch (SAXException e) { log.error("Cannot get schema", e); } return schemaGrammar; }
/** * Given a {@link Element} that represents a SAML 1.1 assertion, convert it into a {@link SAML11AssertionType} * * @param assertionElement * * @return * * @throws GeneralSecurityException */ public static SAML11AssertionType saml11FromElement(Element assertionElement) throws GeneralSecurityException { SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(assertionElement); return (SAML11AssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(assertionElement)); } }
public static void validate(String str) throws SAXException, IOException { validator().validate(new StreamSource(str)); }
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; }
/** * 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); } } }
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; }
/** * Given a {@link Element} that represents a SAML 1.1 assertion, convert it into a {@link SAML11AssertionType} * * @param assertionElement * * @return * * @throws GeneralSecurityException */ public static SAML11AssertionType saml11FromElement(Element assertionElement) throws GeneralSecurityException { SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(assertionElement); return (SAML11AssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(assertionElement)); } }
public static void validate(InputStream stream) throws SAXException, IOException { validator().validate(new StreamSource(stream)); }
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; }