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

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


        } finally {
            try {
                // if the destination is null, probably because some error occur during authentication, use the AuthnRequest
                // AssertionConsumerServiceURL as the destination
                if (destination == null && samlObject instanceof AuthnRequestType) {
                    AuthnRequestType authRequest = (AuthnRequestType) samlObject;

                    destination = authRequest.getAssertionConsumerServiceURL().toASCIIString();
                }

                // if destination is still empty redirect the user to the identity url. If the user is already authenticated he
                // will be probably redirected to the idp hosted page.
                if (destination == null) {
View Full Code Here

        SAML2HandlerChainConfig chainConfigIdp = new DefaultSAML2HandlerChainConfig(chainOptionsIdp);
        issuerTrustHandler.initChainConfig(chainConfigIdp);

        // Create documentHolder
        NameIDType issuer = new NameIDType();
        AuthnRequestType authnRequestType = new AuthnRequestType("ID_123456789", null);
        authnRequestType.setIssuer(issuer);
        SAMLDocumentHolder documentHolder = new SAMLDocumentHolder(authnRequestType);

        // Create request and response
        SAML2HandlerRequest request = new DefaultSAML2HandlerRequest(httpContext, null, documentHolder,
              SAML2Handler.HANDLER_TYPE.IDP);
View Full Code Here

    private String identity = "http://localhost:8080/idp/";

    public void testAuthForIDPServletAndSPFilter() throws Exception {
        String id = IDGenerator.create("ID_");
        SAML2Request saml2Request = new SAML2Request();
        AuthnRequestType art = saml2Request.createAuthnRequestType(id, employee, identity, employee);

        ServletContext servletContext = new MockServletContext();

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

        verificationHandler.generateSAMLRequest(request, response);

        // Parse document and verify that ID is saved in Http session
        Document samlReqDoc = response.getResultingDocument();
        SAMLParser parser = new SAMLParser();
        AuthnRequestType authnRequest = (AuthnRequestType) parser.parse(DocumentUtil.getNodeAsStream(samlReqDoc));
        assertEquals(authnRequest.getID(), servletRequest.getSession().getAttribute(GeneralConstants.AUTH_REQUEST_ID));

        // 3) SEND SAML AUTHENTICATION REQUEST TO IDP

        // Generate request and response for IDP
        SAML2HandlerResponse handlerResponseFromIdp = sendRequestToIdp(authnRequest, samlReqDoc, httpContext, handlerConfig);
View Full Code Here

        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);

        Document authDoc = saml2Request.convert(authnRequest);

        KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
        KeyPair keypair = kpg.genKeyPair();
View Full Code Here

        SAML2HandlerResponse response = new DefaultSAML2HandlerResponse();
        handler.generateSAMLRequest(request, response);

        Document samlReq = response.getResultingDocument();
        SAMLParser parser = new SAMLParser();
        AuthnRequestType authnRequest = (AuthnRequestType) parser.parse(DocumentUtil.getNodeAsStream(samlReq));
        NameIDPolicyType nameIDPolicy = authnRequest.getNameIDPolicy();
        assertEquals(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get(), nameIDPolicy.getFormat().toString());
    }
View Full Code Here

        SAML2HandlerResponse response = new DefaultSAML2HandlerResponse();
        handler.generateSAMLRequest(request, response);

        Document samlReq = response.getResultingDocument();
        SAMLParser parser = new SAMLParser();
        AuthnRequestType authnRequest = (AuthnRequestType) parser.parse(DocumentUtil.getNodeAsStream(samlReq));
        NameIDPolicyType nameIDPolicy = authnRequest.getNameIDPolicy();
        assertEquals(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get(), nameIDPolicy.getFormat().toString());

        ProviderType idpType = new IDPType();
        chainOptions = new HashMap<String, Object>();
        chainOptions.put(GeneralConstants.CONFIGURATION, idpType);
View Full Code Here

        handler.generateSAMLRequest(request, response);

        Document samlReq = response.getResultingDocument();

        SAMLParser parser = new SAMLParser();
        AuthnRequestType authnRequest = (AuthnRequestType) parser.parse(DocumentUtil.getNodeAsStream(samlReq));
        RequestedAuthnContextType requestedAuthnContextType = authnRequest.getRequestedAuthnContext();

        assertNotNull(requestedAuthnContextType.getAuthnContextClassRef());
        assertFalse(requestedAuthnContextType.getAuthnContextClassRef().isEmpty());

        for (String aliasClasses: contextClasses.split(",")) {
View Full Code Here

        if (status != null) {
            write(status);
        }
        Object anyObj = response.getAny();
        if (anyObj instanceof AuthnRequestType) {
            AuthnRequestType authn = (AuthnRequestType) anyObj;
            SAMLRequestWriter requestWriter = new SAMLRequestWriter(writer);
            requestWriter.write(authn);
        } else if (anyObj instanceof ResponseType) {
            ResponseType rt = (ResponseType) anyObj;
            write(rt);
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.saml.v2.protocol.AuthnRequestType

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.