Examples of SAMLAssertionWriter


Examples of org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter

     * @return
     * @throws ProcessingException
     */
    public static String asString(AssertionType assertion) throws ProcessingException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        SAMLAssertionWriter writer = new SAMLAssertionWriter(StaxUtil.getXMLStreamWriter(baos));
        writer.write(assertion);
        return new String(baos.toByteArray());
    }
View Full Code Here

Examples of org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter

     * @return
     * @throws ProcessingException
     */
    public static Document asDocument(AssertionType assertion) throws ProcessingException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        SAMLAssertionWriter writer = new SAMLAssertionWriter(StaxUtil.getXMLStreamWriter(baos));
       
        writer.write(assertion);
       
        try {
            return DocumentUtil.getDocument(new ByteArrayInputStream(baos.toByteArray()));
        } catch (Exception e) {
            throw logger.processingError(e);
View Full Code Here

Examples of org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter

     * @return a reference to the {@code Element} that contains the marshaled SAML assertion.
     * @throws Exception if an error occurs while marshaling the assertion.
     */
    public static Element toElement(AssertionType assertion) throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        SAMLAssertionWriter writer = new SAMLAssertionWriter(StaxUtil.getXMLStreamWriter(baos));
        writer.write(assertion);

        byte[] assertionBytes = baos.toByteArray();
        ByteArrayInputStream bis = new ByteArrayInputStream(assertionBytes);
        Document document = DocumentUtil.getDocument(bis);

View Full Code Here

Examples of org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter

        List<Object> list = validateTarget.getAny();
        for (Object validateTargetObj : list) {
            if (validateTargetObj instanceof AssertionType) {
                AssertionType assertion = (AssertionType) validateTargetObj;
                SAMLAssertionWriter samlAssertionWriter = new SAMLAssertionWriter(this.writer);
                samlAssertionWriter.write(assertion);
            } else if (validateTargetObj instanceof Element) {
                StaxUtil.writeDOMElement(writer, (Element) validateTargetObj);
            } else
                throw logger.writerUnknownTypeError(validateTargetObj.getClass().getName());
        }
View Full Code Here

Examples of org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter

        List<Object> list = renewTarget.getAny();
        for (Object renewTargetObj : list) {
            if (renewTargetObj instanceof AssertionType) {
                AssertionType assertion = (AssertionType) renewTargetObj;
                SAMLAssertionWriter samlAssertionWriter = new SAMLAssertionWriter(this.writer);
                samlAssertionWriter.write(assertion);
            } else if (renewTargetObj instanceof Element) {
                StaxUtil.writeDOMElement(writer, (Element) renewTargetObj);
            } else
                throw logger.writerUnknownTypeError(renewTargetObj.getClass().getName());
        }
View Full Code Here

Examples of org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter

        List<Object> list = cancelTarget.getAny();

        for (Object cancelTargetObj : list) {
            if (cancelTargetObj instanceof AssertionType) {
                AssertionType assertion = (AssertionType) cancelTargetObj;
                SAMLAssertionWriter samlAssertionWriter = new SAMLAssertionWriter(this.writer);
                samlAssertionWriter.write(assertion);
            } else if (cancelTargetObj instanceof Element) {
                StaxUtil.writeDOMElement(writer, (Element) cancelTargetObj);
            } else
                throw logger.writerUnknownTypeError(cancelTargetObj.getClass().getName());
        }
View Full Code Here

Examples of org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter

                    WSTrustConstants.BASE_NAMESPACE);
            List<Object> theList = response.getRequestedSecurityToken().getAny();
            for (Object securityToken : theList) {
                if (securityToken instanceof AssertionType) {
                    AssertionType assertion = (AssertionType) securityToken;
                    SAMLAssertionWriter samlAssertionWriter = new SAMLAssertionWriter(this.writer);
                    samlAssertionWriter.write(assertion);
                } else if (securityToken instanceof Element) {
                    StaxUtil.writeDOMElement(this.writer, (Element) securityToken);
                } else
                    throw logger.writerUnknownTypeError(securityToken.getClass().getName());
            }
View Full Code Here

Examples of org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter

        assertEquals(XMLTimeUtil.parse("2010-09-30T19:13:37.869Z"), conditions.getNotBefore());
        assertEquals(XMLTimeUtil.parse("2010-09-30T21:13:37.869Z"), conditions.getNotOnOrAfter());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        // Lets do the writing
        SAMLAssertionWriter writer = new SAMLAssertionWriter(StaxUtil.getXMLStreamWriter(baos));
        writer.write(assertion);
        String writtenString = new String(baos.toByteArray());
        Logger.getLogger(SAMLAssertionParserTestCase.class).debug(writtenString);
        validateSchema(writtenString);
    }
View Full Code Here

Examples of org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter

        AudienceRestrictionType audienceRestrictionType = (AudienceRestrictionType) conditions.getConditions().get(0);
        assertEquals(1, audienceRestrictionType.getAudience().size());
        assertEquals("http://services.testcorp.org/provider2", audienceRestrictionType.getAudience().get(0).toASCIIString());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        // Lets do the writing
        SAMLAssertionWriter writer = new SAMLAssertionWriter(StaxUtil.getXMLStreamWriter(baos));
        writer.write(assertion);
        String writtenString = new String(baos.toByteArray());
        Logger.getLogger(SAMLAssertionParserTestCase.class).debug(writtenString);
        validateSchema(writtenString);
    }
View Full Code Here

Examples of org.picketlink.identity.federation.core.saml.v2.writers.SAMLAssertionWriter

        AudienceRestrictionType audienceRestrictionType = (AudienceRestrictionType) conditions.getConditions().get(0);
        assertEquals(1, audienceRestrictionType.getAudience().size());
        assertEquals("https://sp.example.com/SAML2", audienceRestrictionType.getAudience().get(0).toString());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        SAMLAssertionWriter writer = new SAMLAssertionWriter(StaxUtil.getXMLStreamWriter(baos));
        writer.write(assertion);

        byte[] bytes = baos.toByteArray();
        ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
        DocumentUtil.getDocument(bis); // throws exceptions
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.