Examples of AuthnRequestType


Examples of org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType

        SAML2Request saml2Request = new SAML2Request();
        String id = IDGenerator.create("ID_");
        String assertionConsumerURL = "http://sp";
        String destination = "http://idp";
        String issuerValue = "http://sp";
        AuthnRequestType authnRequest = saml2Request.createAuthnRequestType(id, assertionConsumerURL, destination, issuerValue);

        KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA");
        KeyPair kp = kpg.genKeyPair();
        PublicKey publicKey = kp.getPublic();
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType

    public void testSAMLAuthnRequestParse() throws Exception {
        ClassLoader tcl = Thread.currentThread().getContextClassLoader();
        InputStream configStream = tcl.getResourceAsStream("parser/saml2/saml2-authnrequest.xml");

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

        assertEquals("http://localhost/org.eclipse.higgins.saml2idp.test/SAMLEndpoint", authnRequest
                .getAssertionConsumerServiceURL().toString());
        assertEquals("http://localhost/org.eclipse.higgins.saml2idp.server/SAMLEndpoint", authnRequest.getDestination()
                .toString());
        assertEquals("a2sffdlgdhgfg32fdldsdghdsgdgfdglgx", authnRequest.getID());
        assertEquals(XMLTimeUtil.parse("2007-12-17T18:40:52.203Z"), authnRequest.getIssueInstant());
        assertEquals("urn:oasis:names.tc:SAML:2.0:bindings:HTTP-Redirect", authnRequest.getProtocolBinding().toString());
        assertEquals("Test SAML2 SP", authnRequest.getProviderName());
        assertEquals("2.0", authnRequest.getVersion());

        // Issuer
        assertEquals("Test SAML2 SP", authnRequest.getIssuer().getValue());

        // NameID Policy
        NameIDPolicyType nameIDPolicy = authnRequest.getNameIDPolicy();
        assertEquals("urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", nameIDPolicy.getFormat().toString());
        assertEquals(Boolean.TRUE, nameIDPolicy.isAllowCreate());

        // Try out writing
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType

    public void testAuthnRequestExample() throws Exception {
        String resourceName = "saml/v2/authnrequest/samlAuthnRequestExample.xml";

        SAML2Request request = new SAML2Request();

        AuthnRequestType authnRequestType = request.getAuthnRequestType(resourceName);

        assertEquals("http://www.example.com/", authnRequestType.getDestination().toString());
        assertEquals("urn:oasis:names:tc:SAML:2.0:consent:obtained", authnRequestType.getConsent());
        assertEquals("http://www.example.com/", authnRequestType.getAssertionConsumerServiceURL().toString());
        assertEquals(Integer.valueOf("0"), authnRequestType.getAttributeConsumingServiceIndex());

        SubjectType subjectType = authnRequestType.getSubject();
        assertNotNull(subjectType);

        STSubType subType = subjectType.getSubType();
        NameIDType nameIDType = (NameIDType) subType.getBaseID();

        assertEquals("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", nameIDType.getFormat().toString());
        assertEquals("j.doe@company.com", nameIDType.getValue());

        ConditionsType conditionsType = authnRequestType.getConditions();
        List<ConditionAbstractType> conditions = conditionsType.getConditions();
        assertTrue(conditions.size() == 1);

        ConditionAbstractType condition = conditions.get(0);
        assertTrue(condition instanceof AudienceRestrictionType);
        AudienceRestrictionType audienceRestrictionType = (AudienceRestrictionType) condition;
        List<URI> audiences = audienceRestrictionType.getAudience();
        assertTrue(audiences.size() == 1);
        assertEquals("urn:foo:sp.example.org", audiences.get(0).toASCIIString());

        RequestedAuthnContextType requestedAuthnContext = authnRequestType.getRequestedAuthnContext();
        assertEquals("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport", requestedAuthnContext
                .getAuthnContextClassRef().get(0));

        // Let us marshall it back to an output stream
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType

        JAXPValidationUtil.validate(configStream);
        configStream = tcl.getResourceAsStream("parser/saml2/saml2-authnrequest-2.xml");

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

        /*
         * assertEquals("http://localhost/org.eclipse.higgins.saml2idp.test/SAMLEndpoint", authnRequest
         * .getAssertionConsumerServiceURL().toString());
 
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType

    public void testAuthnRequestWithSignature() throws Exception {
        String resourceName = "saml/v2/authnrequest/samlAuthnRequestWithSignature.xml";

        SAML2Request request = new SAML2Request();

        AuthnRequestType authnRequestType = request.getAuthnRequestType(resourceName);
        assertNotNull(authnRequestType);

        Element signatureType = authnRequestType.getSignature();
        assertNotNull("Signature is not null", signatureType);

        // Let us marshall it back to an output stream
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        request.marshall(authnRequestType, baos);
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType

    @Test
    public void testAuthnRequestCreation() throws Exception {
        String id = IDGenerator.create("ID_");

        SAML2Request request = new SAML2Request();
        AuthnRequestType authnRequest = request.createAuthnRequestType(id, "http://sp", "http://idp", "http://sp");

        // Verify whether NameIDPolicy exists
        NameIDPolicyType nameIDPolicy = authnRequest.getNameIDPolicy();
        assertNotNull("NameIDPolicy is not null", nameIDPolicy);
        assertTrue(nameIDPolicy.isAllowCreate());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        request.marshall(authnRequest, baos);
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType

    @SuppressWarnings("deprecation")
    public void testSAML2Post() throws Exception {
        System.setProperty("picketlink.schema.validate", "true");
        String id = IDGenerator.create("ID_");
        SAML2Request saml2Request = new SAML2Request();
        AuthnRequestType art = saml2Request.createAuthnRequestType(id, employee, identity, employee);

        MockCatalinaContext servletContext = new MockCatalinaContext();

        // First we go to the employee application
        MockCatalinaContextClassLoader mclSPEmp = setupTCL(profile + "/sp/employee");
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType

    private void sendAuthenticationRequest(MockCatalinaRequest request, MockCatalinaResponse response, String issuer,
            String assertionConsumerURL, boolean signToken) {
        try {
            SAML2Request samlRequest = new SAML2Request();

            AuthnRequestType authnRequestType = samlRequest.createAuthnRequestType(IDGenerator.create("ID_"),
                  assertionConsumerURL, getAuthenticator().getConfiguration().getIdpOrSP().getIdentityURL(), issuer);

            Document authnRequestDocument = samlRequest.convert(authnRequestType);

            logger.info("AuthRequestType:" + prettyPrintDocument(authnRequestDocument).toString());
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType

    private String invokeIDPAndGetSAMLResponse(IDPWebBrowserSSOValve idpAuthenticator, String authnRequest)
            throws ConfigurationException, ProcessingException, ParsingException, LifecycleException, IOException,
            ServletException, Exception {
        byte[] base64Decode = PostBindingUtil.base64Decode(authnRequest);

        AuthnRequestType art = new SAML2Request().getAuthnRequestType(new ByteArrayInputStream(base64Decode));

        // now let's send the previous AuthnRequest to the IDP and authenticate an user. The IDP should return a valid and
        // signed SAML Response.
        MockCatalinaResponse response = new MockCatalinaResponse();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

Examples of org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType

* @author Anil.Saldhana@redhat.com
* @since Dec 11, 2008
*/
public class DeflateEncodingDecodingUnitTestCase extends TestCase {
    public void testDeflateEncoding() throws Exception {
        AuthnRequestType authnRequest = (new SAML2Request()).createAuthnRequestType(IDGenerator.create("ID_"), "http://sp",
                "http://localhost:8080/idp", "http://sp");

        StringWriter sw = new StringWriter();
        SAML2Request request = new SAML2Request();
        request.marshall(authnRequest, sw);
        byte[] deflatedMsg = DeflateUtil.encode(sw.toString());

        String base64Request = Base64.encodeBytes(deflatedMsg, Base64.DONT_BREAK_LINES);

        base64Request = URLEncoder.encode(base64Request, "UTF-8");

        // Decode
        String urlDecodedMsg = URLDecoder.decode(base64Request, "UTF-8");
        byte[] decodedMessage = Base64.decode(urlDecodedMsg);
        InputStream is = DeflateUtil.decode(decodedMessage);
        AuthnRequestType decodedRequestType = request.getAuthnRequestType(is);

        assertNotNull(decodedRequestType);
    }
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.