Package org.picketlink.identity.federation.saml.v2.assertion

Examples of org.picketlink.identity.federation.saml.v2.assertion.AssertionType


        // Status
        StatusType status = response.getStatus();
        assertEquals("urn:oasis:names:tc:SAML:2.0:status:Success", status.getStatusCode().getValue().toString());

        // Get the assertion
        AssertionType assertion = response.getAssertions().get(0).getAssertion();
        assertEquals("ID_8be1534d-9155-4837-9f26-70ea2c15e327", assertion.getID());
        assertEquals(XMLTimeUtil.parse("2010-11-04T00:19:16.842-05:00"), assertion.getIssueInstant());
        assertEquals("2.0", assertion.getVersion());

        assertEquals("http://localhost:8080/idp/", assertion.getIssuer().getValue());

        // Subject
        SubjectType subject = assertion.getSubject();

        NameIDType subjectNameID = (NameIDType) subject.getSubType().getBaseID();
        assertEquals("anil", subjectNameID.getValue());
        assertEquals("urn:oasis:names:tc:SAML:2.0:nameid-format:persistent", subjectNameID.getFormat().toString());

        SubjectConfirmationType subjectConfirmation = subject.getConfirmation().get(0);

        assertEquals("urn:oasis:names:tc:SAML:2.0:cm:bearer", subjectConfirmation.getMethod());

        SubjectConfirmationDataType subjectConfirmationData = subjectConfirmation.getSubjectConfirmationData();
        assertEquals("ID_04ded476-d73c-48af-b3a9-232a52905ffb", subjectConfirmationData.getInResponseTo());
        assertEquals(XMLTimeUtil.parse("2010-11-04T00:19:16.842-05:00"), subjectConfirmationData.getNotBefore());
        assertEquals(XMLTimeUtil.parse("2010-11-04T00:19:16.842-05:00"), subjectConfirmationData.getNotOnOrAfter());
        assertEquals("http://localhost:8080/employee/", subjectConfirmationData.getRecipient());

        AttributeStatementType attributeStatement = (AttributeStatementType) assertion.getStatements().iterator().next();

        List<AttributeStatementType.ASTChoiceType> attributes = attributeStatement.getAttributes();
        assertEquals(2, attributes.size());

        for (AttributeStatementType.ASTChoiceType attr : attributes) {
View Full Code Here


        SAMLParser parser = new SAMLParser();
        ResponseType response = (ResponseType) parser.parse(configStream);
        assertNotNull("ResponseType is not null", response);

        // Get the assertion
        AssertionType assertion = response.getAssertions().get(0).getAssertion();
        assertEquals("ID_response-id_1", assertion.getID());
        assertEquals(XMLTimeUtil.parse("2008-03-19T22:17:13Z"), assertion.getIssueInstant());
        assertEquals("2.0", assertion.getVersion());

        XACMLAuthzDecisionStatementType xacmlStat = (XACMLAuthzDecisionStatementType) assertion.getStatements().iterator()
                .next();
        assertNotNull(xacmlStat.getRequest());
        assertNotNull(xacmlStat.getResponse());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

        assertNotNull("ResponseType is not null", response);

        List<RTChoiceType> choices = response.getAssertions();
        assertEquals(1, choices.size());
        RTChoiceType rtc = choices.get(0);
        AssertionType assertion = rtc.getAssertion();
        Set<StatementAbstractType> statements = assertion.getStatements();
        for (StatementAbstractType statement : statements) {
            if (statement instanceof AuthnStatementType) {
                AuthnStatementType authnStat = (AuthnStatementType) statement;
                AuthnContextType authnContext = authnStat.getAuthnContext();
View Full Code Here

    @Test
    public void testValidAssertion() throws Exception {
        NameIDType nameIdType = new NameIDType();
        nameIdType.setValue("somename");

        AssertionType assertion = new AssertionType("SomeID", XMLTimeUtil.getIssueInstant());
        assertion.setIssuer(nameIdType);

        // Assertions with no conditions are everlasting
        assertTrue(AssertionUtil.hasExpired(assertion) == false);

        XMLGregorianCalendar now = XMLTimeUtil.getIssueInstant();

        XMLGregorianCalendar sometimeLater = XMLTimeUtil.add(now, 5555);

        ConditionsType conditions = new ConditionsType();
        conditions.setNotBefore(now);
        conditions.setNotOnOrAfter(sometimeLater);
        assertion.setConditions(conditions);
        assertTrue(AssertionUtil.hasExpired(assertion) == false);
    }
View Full Code Here

    @Test
    public void testExpiredAssertion() throws Exception {
        NameIDType nameIdType = new NameIDType();
        nameIdType.setValue("somename");

        AssertionType assertion = new AssertionType("SomeID", XMLTimeUtil.getIssueInstant());
        assertion.setIssuer(nameIdType);

        XMLGregorianCalendar now = XMLTimeUtil.getIssueInstant();

        XMLGregorianCalendar sometimeAgo = XMLTimeUtil.subtract(now, 55555);

        ConditionsType conditions = new ConditionsType();
        conditions.setNotBefore(XMLTimeUtil.subtract(now, 55575));
        conditions.setNotOnOrAfter(sometimeAgo);
        assertion.setConditions(conditions);
        assertTrue(AssertionUtil.hasExpired(assertion));
    }
View Full Code Here

    @Test
    public void testExpiredAssertionWithClockSkew() throws Exception {
        NameIDType nameIdType = new NameIDType();
        nameIdType.setValue("somename");

        AssertionType assertion = new AssertionType("SomeID", XMLTimeUtil.getIssueInstant());
        assertion.setIssuer(nameIdType);

        XMLGregorianCalendar now = XMLTimeUtil.getIssueInstant();

        XMLGregorianCalendar sometimeAgo = XMLTimeUtil.subtract(now, 55555);

        ConditionsType conditions = new ConditionsType();
        conditions.setNotBefore(XMLTimeUtil.subtract(now, 55575));
        conditions.setNotOnOrAfter(sometimeAgo);
        assertion.setConditions(conditions);

        assertFalse(AssertionUtil.hasExpired(assertion, 60000));
        assertTrue(AssertionUtil.hasExpired(assertion, 600));
    }
View Full Code Here

        SAMLParser parser = new SAMLParser();
        ResponseType response = (ResponseType) parser.parse(is);
        List<RTChoiceType> assertionList = response.getAssertions();
        assertEquals(1, assertionList.size());
        RTChoiceType rtc = assertionList.get(0);
        AssertionType assertion = rtc.getAssertion();
        List<String> roles = AssertionUtil.getRoles(assertion, null);
        assertEquals(2, roles.size());
        assertTrue(roles.contains("manager"));
        assertTrue(roles.contains("employee"));
    }
View Full Code Here

        SAMLParser parser = new SAMLParser();
        ResponseType response = (ResponseType) parser.parse(is);
        List<RTChoiceType> assertionList = response.getAssertions();
        assertEquals(1, assertionList.size());
        RTChoiceType rtc = assertionList.get(0);
        AssertionType assertion = rtc.getAssertion();
        List<String> roles = AssertionUtil.getRoles(assertion, null);
        assertEquals(2, roles.size());
        assertTrue(roles.contains("manager"));
        assertTrue(roles.contains("employee"));
    }
View Full Code Here

        ResponseType rt = JBossSAMLAuthnResponseFactory
                .createResponseType("response111", new SPInfoHolder(), idp, issuerHolder);
        assertNotNull(rt);

        AssertionType assertion = rt.getAssertions().get(0).getAssertion();
        assertion.addStatement(attrStat);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        SAMLResponseWriter writer = new SAMLResponseWriter(StaxUtil.getXMLStreamWriter(baos));
        writer.write(rt);
View Full Code Here

        AttributeStatementType attributeStatement = StatementUtil.createAttributeStatement(attributes);

        String assertionId = IDGenerator.create("ID_");

        AssertionType assertion = AssertionUtil.createAssertion(assertionId, issuerInfo.getIssuer());
        assertion.addStatement(attributeStatement);

        ResponseType responseType = samlResponse.createResponseType(ID, sp, idp, issuerInfo, assertion);
        SAML2Signature sig = new SAML2Signature();
        Document signedDoc = sig.sign(responseType, getKeyPair());
        assertNotNull(signedDoc);
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.saml.v2.assertion.AssertionType

Copyright © 2018 www.massapicom. 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.