public AssertionType fromElement(Element element) throws ConfigurationException, ProcessingException, ParsingException { XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(element)); return (AssertionType) parse(xmlEventReader); }
public SAML11AssertionType fromElement(Element element) throws ConfigurationException, ProcessingException, ParsingException { XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(element)); return (SAML11AssertionType) parse(xmlEventReader); }
public SAML11AssertionType fromElement(Element element) throws ConfigurationException, ProcessingException, ParsingException { XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(element)); return (SAML11AssertionType) parse(xmlEventReader); }
public SAML11AssertionType fromElement(Element element) throws ConfigurationException, ProcessingException, ParsingException { XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(element)); return (SAML11AssertionType) parse(xmlEventReader); }
public AssertionType fromElement(Element element) throws ConfigurationException, ProcessingException, ParsingException { XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(element)); return (AssertionType) parse(xmlEventReader); }
public AssertionType fromElement(Element element) throws ConfigurationException, ProcessingException, ParsingException { XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(element)); return (AssertionType) parse(xmlEventReader); }
@SuppressWarnings("unchecked") private ResponseType getXACMLResponse(XMLEventReader xmlEventReader) throws ParsingException { Element xacmlResponse = StaxParserUtil.getDOMElement(xmlEventReader); // xacml request String xacmlPath = "org.jboss.security.xacml.core.model.context"; try { JAXBContext jaxb = JAXBContext.newInstance(xacmlPath); Unmarshaller un = jaxb.createUnmarshaller(); un.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler()); JAXBElement<ResponseType> jaxbResponseType = (JAXBElement<ResponseType>) un.unmarshal(DocumentUtil .getNodeAsStream(xacmlResponse)); return jaxbResponseType.getValue(); } catch (Exception e) { throw new ParsingException(e); } }
@SuppressWarnings("unchecked") private RequestType getXACMLRequest(XMLEventReader xmlEventReader) throws ParsingException { Element xacmlRequest = StaxParserUtil.getDOMElement(xmlEventReader); // xacml request String xacmlPath = "org.jboss.security.xacml.core.model.context"; try { JAXBContext jaxb = JAXBContext.newInstance(xacmlPath); Unmarshaller un = jaxb.createUnmarshaller(); un.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler()); JAXBElement<RequestType> jaxbRequestType = (JAXBElement<RequestType>) un.unmarshal(DocumentUtil .getNodeAsStream(xacmlRequest)); return jaxbRequestType.getValue(); } catch (Exception e) { throw new ParsingException(e); } } }
/** * 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)); } }
/** * 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)); } }
/** * 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)); } }
/** * <p> * Utility method that unmarshals the specified {@code Element} into an {@code AssertionType} instance. * </p> * * @param assertionElement the {@code Element} that contains the marshaled SAMLV2.0 assertion. * @return a reference to the unmarshaled {@code AssertionType} instance. * @throws ConfigurationException * @throws ProcessingException * @throws ParsingException */ public static AssertionType fromElement(Element assertionElement) throws ProcessingException, ConfigurationException, ParsingException { SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(assertionElement); AssertionType assertion = (AssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(assertionElement)); return assertion; }
/** * Parse the XACML Authorization Decision Query from the Dom Element * * @param samlRequest * @return * @throws ProcessingException * @throws ConfigurationException * @throws ParsingException */ public static XACMLAuthzDecisionQueryType getXACMLQueryType(Node samlRequest) throws ParsingException, ConfigurationException, ProcessingException { // We reparse it because the document may have issues with namespaces // String elementString = DocumentUtil.getDOMElementAsString(samlRequest); XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(samlRequest)); SAMLXACMLRequestParser samlXACMLRequestParser = new SAMLXACMLRequestParser(); return (XACMLAuthzDecisionQueryType) samlXACMLRequestParser.parse(xmlEventReader); }
/** * Get an encrypted assertion from the stream * @param is * @return * @throws ParsingException * @throws ProcessingException * @throws ConfigurationException */ public EncryptedAssertionType getEncryptedAssertion(InputStream is) throws ParsingException, ConfigurationException, ProcessingException { if (is == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "inputstream"); Document samlDocument = DocumentUtil.getDocument(is); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlDocument); return (EncryptedAssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(samlDocument)); }
/** * Read an assertion from an input stream * @param is * @return * @throws ParsingException * @throws ProcessingException * @throws ConfigurationException */ public AssertionType getAssertionType(InputStream is) throws ParsingException, ConfigurationException, ProcessingException { if (is == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "inputstream"); Document samlDocument = DocumentUtil.getDocument(is); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlDocument); return (AssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(samlDocument)); }
/** * Read an assertion from an input stream * * @param is * @return * @throws ParsingException * @throws ProcessingException * @throws ConfigurationException */ public AssertionType getAssertionType(InputStream is) throws ParsingException, ConfigurationException, ProcessingException { if (is == null) throw logger.nullArgumentError("InputStream"); Document samlDocument = DocumentUtil.getDocument(is); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlDocument); return (AssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(samlDocument)); }
/** * Get an encrypted assertion from the stream * * @param is * @return * @throws ParsingException * @throws ProcessingException * @throws ConfigurationException */ public EncryptedAssertionType getEncryptedAssertion(InputStream is) throws ParsingException, ConfigurationException, ProcessingException { if (is == null) throw logger.nullArgumentError("InputStream"); Document samlDocument = DocumentUtil.getDocument(is); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlDocument); return (EncryptedAssertionType) samlParser.parse(DocumentUtil.getNodeAsStream(samlDocument)); }
/** * Get the Underlying SAML2Object from the input stream * * @param is * @return * @throws IOException * @throws ParsingException */ public SAML2Object getSAML2ObjectFromStream(InputStream is) throws ConfigurationException, ParsingException, ProcessingException { if (is == null) throw logger.nullArgumentError("InputStream"); Document samlDocument = DocumentUtil.getDocument(is); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlDocument); SAML2Object requestType = (SAML2Object) samlParser.parse(DocumentUtil.getNodeAsStream(samlDocument)); samlDocumentHolder = new SAMLDocumentHolder(requestType, samlDocument); return requestType; }
/** * Read a ResponseType from an input stream * * @param is * @return * @throws ParsingException * @throws ConfigurationException */ public ResponseType getResponseType(InputStream is) throws ParsingException, ConfigurationException, ProcessingException { if (is == null) throw logger.nullArgumentError("InputStream"); Document samlResponseDocument = DocumentUtil.getDocument(is); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlResponseDocument); ResponseType responseType = (ResponseType) samlParser.parse(DocumentUtil.getNodeAsStream(samlResponseDocument)); samlDocumentHolder = new SAMLDocumentHolder(responseType, samlResponseDocument); return responseType; }