Examples of SAML11AssertionType


Examples of org.picketlink.identity.federation.saml.v1.assertion.SAML11AssertionType

    public void testSAML11AssertionWithAttributeStatements() throws Exception {
        ClassLoader tcl = Thread.currentThread().getContextClassLoader();
        InputStream configStream = tcl.getResourceAsStream("parser/saml1/saml1-assertion-attribstat.xml");

        SAMLParser parser = new SAMLParser();
        SAML11AssertionType assertion = (SAML11AssertionType) parser.parse(configStream);
        assertNotNull(assertion);

        // Validate assertion
        assertEquals(1, assertion.getMajorVersion());
        assertEquals(1, assertion.getMinorVersion());
        assertEquals("buGxcG4gILg5NlocyLccDz6iXrUb", assertion.getID());
        assertEquals("https://idp.example.org/saml", assertion.getIssuer());
        assertEquals(XMLTimeUtil.parse("2002-06-19T17:05:37.795Z"), assertion.getIssueInstant());

        SAML11ConditionsType conditions = assertion.getConditions();
        assertEquals(XMLTimeUtil.parse("2002-06-19T17:05:37.795Z"), conditions.getNotBefore());
        assertEquals(XMLTimeUtil.parse("2002-06-19T17:15:37.795Z"), conditions.getNotOnOrAfter());

        SAML11AuthenticationStatementType stat = (SAML11AuthenticationStatementType) assertion.getStatements().get(0);
        assertEquals("urn:oasis:names:tc:SAML:1.0:am:password", stat.getAuthenticationMethod().toString());
        assertEquals(XMLTimeUtil.parse("2002-06-19T17:08:37.795Z"), stat.getAuthenticationInstant());

        SAML11SubjectType subject = stat.getSubject();
        SAML11SubjectType.SAML11SubjectTypeChoice choice = subject.getChoice();
        assertEquals("user@idp.example.org", choice.getNameID().getValue());
        assertEquals("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", choice.getNameID().getFormat().toString());

        SAML11SubjectConfirmationType subjectConfirm = subject.getSubjectConfirmation();
        URI confirmationMethod = subjectConfirm.getConfirmationMethod().get(0);
        assertEquals("urn:oasis:names:tc:SAML:1.0:cm:bearer", confirmationMethod.toString());

        SAML11AttributeStatementType attribStat = (SAML11AttributeStatementType) assertion.getStatements().get(1);
        assertNotNull(attribStat);
        subject = attribStat.getSubject();

        choice = subject.getChoice();
        assertEquals("user@idp.example.org", choice.getNameID().getValue());
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v1.assertion.SAML11AssertionType

    public void testSAML11AssertionWithAuthzDecisionStatement() throws Exception {
        ClassLoader tcl = Thread.currentThread().getContextClassLoader();
        InputStream configStream = tcl.getResourceAsStream("parser/saml1/saml1-assertion-authzdecision.xml");

        SAMLParser parser = new SAMLParser();
        SAML11AssertionType assertion = (SAML11AssertionType) parser.parse(configStream);
        assertNotNull(assertion);

        // Validate assertion
        assertEquals(1, assertion.getMajorVersion());
        assertEquals(1, assertion.getMinorVersion());
        assertEquals("buGxcG4gILg5NlocyLccDz6iXrUb", assertion.getID());
        assertEquals("https://idp.example.org/saml", assertion.getIssuer());
        assertEquals(XMLTimeUtil.parse("2002-06-19T17:05:37.795Z"), assertion.getIssueInstant());

        SAML11ConditionsType conditions = assertion.getConditions();
        assertEquals(XMLTimeUtil.parse("2002-06-19T17:05:37.795Z"), conditions.getNotBefore());
        assertEquals(XMLTimeUtil.parse("2002-06-19T17:15:37.795Z"), conditions.getNotOnOrAfter());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        // Lets do the writing
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v1.assertion.SAML11AssertionType

    public void testSAML11AssertionWithAuthAndAuthz() throws Exception {
        ClassLoader tcl = Thread.currentThread().getContextClassLoader();
        InputStream configStream = tcl.getResourceAsStream("parser/saml1/saml1-assertion-auth-authz.xml");

        SAMLParser parser = new SAMLParser();
        SAML11AssertionType assertion = (SAML11AssertionType) parser.parse(configStream);
        assertNotNull(assertion);

        // Validate assertion
        assertEquals(1, assertion.getMajorVersion());
        assertEquals(1, assertion.getMinorVersion());
        assertEquals("_e5c23ff7a3889e12fa01802a47331653", assertion.getID());
        assertEquals("localhost", assertion.getIssuer());
        assertEquals(XMLTimeUtil.parse("2008-12-10T14:12:14.817Z"), assertion.getIssueInstant());

        SAML11ConditionsType conditions = assertion.getConditions();
        assertEquals(XMLTimeUtil.parse("2008-12-10T14:12:14.817Z"), conditions.getNotBefore());
        assertEquals(XMLTimeUtil.parse("2008-12-10T14:12:44.817Z"), conditions.getNotOnOrAfter());
        List<SAML11ConditionAbstractType> theConditions = conditions.get();
        assertEquals(1, theConditions.size());
        SAML11AudienceRestrictionCondition restrictCond = (SAML11AudienceRestrictionCondition) theConditions.get(0);
        assertEquals("https://some-service.example.com/app/", restrictCond.get().get(0).toString());

        List<SAML11StatementAbstractType> statements = assertion.getStatements();
        assertEquals(2, statements.size());

        SAML11AttributeStatementType attrStat = (SAML11AttributeStatementType) statements.get(0);
        SAML11SubjectType subject = attrStat.getSubject();
        SAML11SubjectTypeChoice choice = subject.getChoice();
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v1.assertion.SAML11AssertionType

    public void testSAML11AssertionWithKeyInfo() throws Exception {
        ClassLoader tcl = Thread.currentThread().getContextClassLoader();
        InputStream configStream = tcl.getResourceAsStream("parser/saml1/saml1-assertion-keyinfo.xml");

        SAMLParser parser = new SAMLParser();
        SAML11AssertionType assertion = (SAML11AssertionType) parser.parse(configStream);
        assertNotNull(assertion);

        // Validate assertion
        assertEquals(1, assertion.getMajorVersion());
        assertEquals(1, assertion.getMinorVersion());
        assertEquals("s69f7e2599d4eb0c548782432bf", assertion.getID());
        assertEquals("http://jboss.org/test", assertion.getIssuer());
        assertEquals(XMLTimeUtil.parse("2006-05-24T05:52:32Z"), assertion.getIssueInstant());

        List<SAML11StatementAbstractType> statements = assertion.getStatements();
        assertEquals(1, statements.size());
        SAML11AuthenticationStatementType authStat = (SAML11AuthenticationStatementType) statements.get(0);
        assertEquals(XMLTimeUtil.parse("2006-05-24T05:52:30Z"), authStat.getAuthenticationInstant());
        assertEquals("urn:picketlink:auth", authStat.getAuthenticationMethod().toString());
        SAML11SubjectType subject = authStat.getSubject();
        SAML11SubjectTypeChoice choice = subject.getChoice();
        SAML11NameIdentifierType nameID = choice.getNameID();
        assertEquals("anil", nameID.getValue());
        SAML11SubjectConfirmationType subjConf = subject.getSubjectConfirmation();
        URI confirmationMethod = subjConf.getConfirmationMethod().get(0);
        assertEquals("urn:oasis:names:tc:SAML:1.0:cm:holder-of-key", confirmationMethod.toString());
        assertNotNull(subjConf.getKeyInfo());

        Element sig = assertion.getSignature();
        assertNotNull(sig);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        // Lets do the writing
        SAML11AssertionWriter writer = new SAML11AssertionWriter(StaxUtil.getXMLStreamWriter(baos));
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v1.assertion.SAML11AssertionType

        SAML11StatusCodeType statusCode = status.getStatusCode();
        assertEquals("samlp:Success", statusCode.getValue().toString());

        List<SAML11AssertionType> assertions = response.get();
        assertEquals(1, assertions.size());
        SAML11AssertionType assertion = assertions.get(0);
        assertEquals("buGxcG4gILg5NlocyLccDz6iXrUa", assertion.getID());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        // Lets do the writing
        SAML11ResponseWriter writer = new SAML11ResponseWriter(StaxUtil.getXMLStreamWriter(baos));
        writer.write(response);
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v1.assertion.SAML11AssertionType

        collection = (RequestSecurityTokenResponseCollection) baseResponse;
        Element renewedAssertionElement = (Element) collection.getRequestSecurityTokenResponses().get(0)
                .getRequestedSecurityToken().getAny().get(0);

        // compare the assertions, checking if the lifetime has been updated.
        SAML11AssertionType originalAssertion = SAMLUtil.saml11FromElement(assertionElement);
        SAML11AssertionType renewedAssertion = SAMLUtil.saml11FromElement(renewedAssertionElement);

        // assertions should have different ids and lifetimes.
        assertFalse("Renewed assertion should have a unique id", originalAssertion.getID().equals(renewedAssertion.getID()));
        assertEquals(DatatypeConstants.LESSER,
                originalAssertion.getConditions().getNotBefore().compare(renewedAssertion.getConditions().getNotBefore()));
        assertEquals(DatatypeConstants.LESSER,
                originalAssertion.getConditions().getNotOnOrAfter().compare(renewedAssertion.getConditions().getNotOnOrAfter()));
    }
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v1.assertion.SAML11AssertionType

        SAML11StatusCodeType statusCode = status.getStatusCode();
        assertEquals("samlp:Success", statusCode.getValue().toString());

        List<SAML11AssertionType> assertions = response.get();
        assertEquals(1, assertions.size());
        SAML11AssertionType assertion = assertions.get(0);
        assertEquals("buGxcG4gILg5NlocyLccDz6iXrUa", assertion.getID());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        // Lets do the writing
        SAML11ResponseWriter writer = new SAML11ResponseWriter(StaxUtil.getXMLStreamWriter(baos));
        writer.write(response);
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v1.assertion.SAML11AssertionType

        RequestedSecurityTokenType requestedToken = response.getRequestedSecurityToken();
        assertNotNull("Unexpected null requested security token", requestedToken);

        // unmarshall the SAMLV1.1 assertion.
        Element assertionElement = (Element) requestedToken.getAny().get(0);
        SAML11AssertionType assertion = SAMLUtil.saml11FromElement(assertionElement);

        // verify the contents of the unmarshalled assertion.
        assertNotNull("Invalid null assertion ID", assertion.getID());
        assertEquals(keyId.getValue().substring(1), assertion.getID());
        assertEquals(lifetime.getCreated(), assertion.getIssueInstant());
        assertEquals(1, assertion.getMajorVersion());
        assertEquals(1, assertion.getMinorVersion());

        // validate the assertion issuer.
        assertNotNull("Unexpected null assertion issuer", assertion.getIssuer());
        assertEquals("Unexpected assertion issuer name", "Test STS", assertion.getIssuer());

        // validate the assertion authentication statement.
        List<SAML11StatementAbstractType> statements = assertion.getStatements();
        assertTrue("At least one statement is expected in a SAMLV1.1 assertion", statements.size() > 0);
        SAML11AuthenticationStatementType authStatement = null;
        for (SAML11StatementAbstractType statement : statements) {
            if (statement instanceof SAML11AuthenticationStatementType) {
                authStatement = (SAML11AuthenticationStatementType) statement;
                break;
            }
        }
        assertNotNull("SAMLV1.1 assertion is missing the authentication statement", authStatement);

        // validate the assertion subject.
        assertNotNull("Unexpected null subject", authStatement.getSubject());
        SAML11SubjectType subject = authStatement.getSubject();

        SAML11NameIdentifierType nameID = subject.getChoice().getNameID();
        assertEquals("Unexpected NameIdentifier format", SAML11Constants.FORMAT_UNSPECIFIED, nameID.getFormat().toString());
        assertEquals("Unexpected NameIdentifier value", principal, nameID.getValue());

        SAML11SubjectConfirmationType subjType = subject.getSubjectConfirmation();
        assertEquals("Unexpected confirmation method", confirmationMethod, subjType.getConfirmationMethod().get(0).toString());

        // validate the assertion conditions.
        assertNotNull("Unexpected null conditions", assertion.getConditions());
        assertEquals(lifetime.getCreated(), assertion.getConditions().getNotBefore());
        assertEquals(lifetime.getExpires(), assertion.getConditions().getNotOnOrAfter());

        assertNotNull("Assertion should have been signed", assertion.getSignature());

        return assertion;
    }
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v1.assertion.SAML11AssertionType

                if (assertions.size() > 1) {
                    logger.trace("More than one assertion from IDP. Considering the first one.");
                }
                String username = null;
                List<String> roles = new ArrayList<String>();
                SAML11AssertionType assertion = assertions.get(0);
                if (assertion != null) {
                    // Get the subject
                    List<SAML11StatementAbstractType> statements = assertion.getStatements();
                    for (SAML11StatementAbstractType statement : statements) {
                        if (statement instanceof SAML11AuthenticationStatementType) {
                            SAML11AuthenticationStatementType subStat = (SAML11AuthenticationStatementType) statement;
                            SAML11SubjectType subject = subStat.getSubject();
                            username = subject.getChoice().getNameID().getValue();
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.