/** * @see IMetadataProvider#getMetaData() */ public EntityDescriptorType getMetaData() { if (this.metadataFileStream == null) throw new RuntimeException(ErrorCodes.INJECTED_VALUE_MISSING + "Metadata file"); try { SAMLEntityDescriptorParser parser = new SAMLEntityDescriptorParser(); return (EntityDescriptorType) parser.parse(StaxParserUtil.getXMLEventReader(metadataFileStream)); } catch (Exception e) { throw new RuntimeException(e); } }
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); }
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); }
/** * @see IMetadataProvider#getMetaData() */ public EntityDescriptorType getMetaData() { if (this.metadataFileStream == null) throw new RuntimeException(ErrorCodes.INJECTED_VALUE_MISSING + "Metadata file"); try { SAMLEntityDescriptorParser parser = new SAMLEntityDescriptorParser(); return (EntityDescriptorType) parser.parse(StaxParserUtil.getXMLEventReader(metadataFileStream)); } catch (Exception e) { throw new RuntimeException(e); } }
public SAML11AssertionType fromElement(Element element) throws ConfigurationException, ProcessingException, ParsingException { XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(element)); return (SAML11AssertionType) parse(xmlEventReader); }
/** * @see IMetadataConfigurationStore#load(String) */ public EntityDescriptorType load(String id) throws IOException { File persistedFile = validateIdAndReturnMDFile(id); SAMLEntityDescriptorParser parser = new SAMLEntityDescriptorParser(); try { return (EntityDescriptorType) parser.parse(StaxParserUtil.getXMLEventReader(new FileInputStream(persistedFile))); } catch (ParsingException e) { throw new RuntimeException(e); } }
public AssertionType fromElement(Element element) throws ConfigurationException, ProcessingException, ParsingException { XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(element)); return (AssertionType) parse(xmlEventReader); }
/** * @see IMetadataProvider#getMetaData() */ public EntitiesDescriptorType getMetaData() { if (this.metadataFileStream == null) throw logger.injectedValueMissing("Metadata file"); try { SAMLEntitiesDescriptorParser parser = new SAMLEntitiesDescriptorParser(); return (EntitiesDescriptorType) parser.parse(StaxParserUtil.getXMLEventReader(metadataFileStream)); } catch (Exception e) { throw new RuntimeException(e); } }
/** * @see IMetadataProvider#getMetaData() */ public EntityDescriptorType getMetaData() { if (this.metadataFileStream == null) throw logger.injectedValueMissing("Metadata file"); try { SAMLEntityDescriptorParser parser = new SAMLEntityDescriptorParser(); return (EntityDescriptorType) parser.parse(StaxParserUtil.getXMLEventReader(metadataFileStream)); } catch (Exception e) { throw new RuntimeException(e); } }
/** * @see IMetadataConfigurationStore#load(String) */ public EntityDescriptorType load(String id) throws IOException { File persistedFile = validateIdAndReturnMDFile(id); SAMLEntityDescriptorParser parser = new SAMLEntityDescriptorParser(); try { return (EntityDescriptorType) parser.parse(StaxParserUtil .getXMLEventReader(new FileInputStream(persistedFile))); } catch (ParsingException e) { throw new RuntimeException(e); } }
/** * @see IMetadataConfigurationStore#load(String) */ public EntityDescriptorType load(String id) throws IOException { File persistedFile = validateIdAndReturnMDFile(id); SAMLEntityDescriptorParser parser = new SAMLEntityDescriptorParser(); try { return (EntityDescriptorType) parser.parse(StaxParserUtil .getXMLEventReader(new FileInputStream(persistedFile))); } catch (ParsingException e) { throw new RuntimeException(e); } }
/** * 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); }
/** * 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); /*Unmarshaller um = JAXBUtil.getUnmarshaller(collectivePackage); um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler()); JAXBElement<?> obj = (JAXBElement<?>) um.unmarshal(new StringReader(elementString)); Object xacmlObject = obj.getValue(); if(xacmlObject instanceof XACMLAuthzDecisionQueryType == false) throw new RuntimeException("Unsupported type:" + xacmlObject); return (XACMLAuthzDecisionQueryType)xacmlObject; */ }
/** * 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); /*Unmarshaller um = JAXBUtil.getUnmarshaller(collectivePackage); um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler()); JAXBElement<?> obj = (JAXBElement<?>) um.unmarshal(new StringReader(elementString)); Object xacmlObject = obj.getValue(); if(xacmlObject instanceof XACMLAuthzDecisionQueryType == false) throw new RuntimeException("Unsupported type:" + xacmlObject); return (XACMLAuthzDecisionQueryType)xacmlObject; */ }
public static XACMLAuthzDecisionStatementType getDecisionStatement(Node samlResponse) throws ConfigurationException, ProcessingException, ParsingException { XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(samlResponse)); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlResponse); org.picketlink.identity.federation.saml.v2.protocol.ResponseType response = (org.picketlink.identity.federation.saml.v2.protocol.ResponseType) samlParser .parse(xmlEventReader); List<RTChoiceType> choices = response.getAssertions(); for (RTChoiceType rst : choices) { AssertionType assertion = rst.getAssertion(); if (assertion == null) continue; Set<StatementAbstractType> stats = assertion.getStatements(); for (StatementAbstractType stat : stats) { if (stat instanceof XACMLAuthzDecisionStatementType) { return (XACMLAuthzDecisionStatementType) stat; } } } throw new RuntimeException("Not found XACMLAuthzDecisionStatementType"); }
public static XACMLAuthzDecisionStatementType getDecisionStatement(Node samlResponse) throws ConfigurationException, ProcessingException, ParsingException { XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(samlResponse)); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlResponse); org.picketlink.identity.federation.saml.v2.protocol.ResponseType response = (org.picketlink.identity.federation.saml.v2.protocol.ResponseType) samlParser .parse(xmlEventReader); List<RTChoiceType> choices = response.getAssertions(); for (RTChoiceType rst : choices) { AssertionType assertion = rst.getAssertion(); if (assertion == null) continue; Set<StatementAbstractType> stats = assertion.getStatements(); for (StatementAbstractType stat : stats) { if (stat instanceof XACMLAuthzDecisionStatementType) { return (XACMLAuthzDecisionStatementType) stat; } } } throw new RuntimeException("Not found XACMLAuthzDecisionStatementType"); }
public static XACMLAuthzDecisionStatementType getDecisionStatement(Node samlResponse) throws ConfigurationException, ProcessingException, ParsingException { XMLEventReader xmlEventReader = StaxParserUtil.getXMLEventReader(DocumentUtil.getNodeAsStream(samlResponse)); SAMLParser samlParser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(samlResponse); org.picketlink.identity.federation.saml.v2.protocol.ResponseType response = (org.picketlink.identity.federation.saml.v2.protocol.ResponseType) samlParser .parse(xmlEventReader); List<RTChoiceType> choices = response.getAssertions(); for (RTChoiceType rst : choices) { AssertionType assertion = rst.getAssertion(); if (assertion == null) continue; Set<StatementAbstractType> stats = assertion.getStatements(); for (StatementAbstractType stat : stats) { if (stat instanceof XACMLAuthzDecisionStatementType) { return (XACMLAuthzDecisionStatementType) stat; } } } throw new RuntimeException("Not found XACMLAuthzDecisionStatementType"); }
private ResponseType decryptAssertion(ResponseType responseType, PrivateKey privateKey) throws ProcessingException { if (privateKey == null) throw logger.nullArgumentError("privateKey"); SAML2Response saml2Response = new SAML2Response(); try { Document doc = saml2Response.convert(responseType); Element enc = DocumentUtil.getElement(doc, new QName(JBossSAMLConstants.ENCRYPTED_ASSERTION.get())); if (enc == null) throw logger.samlHandlerNullEncryptedAssertion(); String oldID = enc.getAttribute(JBossSAMLConstants.ID.get()); Document newDoc = DocumentUtil.createDocument(); Node importedNode = newDoc.importNode(enc, true); newDoc.appendChild(importedNode); Element decryptedDocumentElement = XMLEncryptionUtil.decryptElementInDocument(newDoc, privateKey); SAMLParser parser = new SAMLParser(); JAXPValidationUtil.checkSchemaValidation(decryptedDocumentElement); AssertionType assertion = (AssertionType) parser.parse(StaxParserUtil.getXMLEventReader(DocumentUtil .getNodeAsStream(decryptedDocumentElement))); responseType.replaceAssertion(oldID, new RTChoiceType(assertion)); return responseType; } catch (Exception e) { throw logger.processingError(e); } }