Examples of SimpleHttpRequest


Examples of waffle.mock.http.SimpleHttpRequest

            clientContext.initialize(null, null, WindowsAccountImpl.getCurrentUsername());
            // filter chain
            SimpleFilterChain filterChain = new SimpleFilterChain();
            // negotiate
            boolean authenticated = false;
            SimpleHttpRequest request = new SimpleHttpRequest();
            while (true) {
                String clientToken = BaseEncoding.base64().encode(clientContext.getToken());
                request.addHeader("Authorization", securityPackage + " " + clientToken);

                SimpleHttpResponse response = new SimpleHttpResponse();
                this.filter.doFilter(request, response, filterChain);

                Subject subject = (Subject) request.getSession().getAttribute("javax.security.auth.subject");
                authenticated = (subject != null && subject.getPrincipals().size() > 0);

                if (authenticated) {
                    Assertions.assertThat(response.getHeaderNamesSize()).isGreaterThanOrEqualTo(0);
                    break;
View Full Code Here

Examples of waffle.mock.http.SimpleHttpRequest

    }

    @Test
    public void testNegotiatePreviousAuthWithWindowsPrincipal() throws IOException, ServletException {
        MockWindowsIdentity mockWindowsIdentity = new MockWindowsIdentity("user", new ArrayList<String>());
        SimpleHttpRequest request = new SimpleHttpRequest();
        WindowsPrincipal windowsPrincipal = new WindowsPrincipal(mockWindowsIdentity);
        request.setUserPrincipal(windowsPrincipal);
        SimpleFilterChain filterChain = new SimpleFilterChain();
        SimpleHttpResponse response = new SimpleHttpResponse();
        this.filter.doFilter(request, response, filterChain);
        assertTrue(filterChain.getRequest() instanceof NegotiateRequestWrapper);
        NegotiateRequestWrapper wrappedRequest = (NegotiateRequestWrapper) filterChain.getRequest();
View Full Code Here

Examples of waffle.mock.http.SimpleHttpRequest

    }

    @Test
    public void testChallengeNTLMPOST() throws IOException, ServletException {
        MockWindowsIdentity mockWindowsIdentity = new MockWindowsIdentity("user", new ArrayList<String>());
        SimpleHttpRequest request = new SimpleHttpRequest();
        WindowsPrincipal windowsPrincipal = new WindowsPrincipal(mockWindowsIdentity);
        request.setUserPrincipal(windowsPrincipal);
        request.setMethod("POST");
        request.setContentLength(0);
        request.addHeader("Authorization", "NTLM TlRMTVNTUAABAAAABzIAAAYABgArAAAACwALACAAAABXT1JLU1RBVElPTkRPTUFJTg==");
        SimpleFilterChain filterChain = new SimpleFilterChain();
        SimpleHttpResponse response = new SimpleHttpResponse();
        this.filter.doFilter(request, response, filterChain);
        assertEquals(401, response.getStatus());
        String[] wwwAuthenticates = response.getHeaderValues("WWW-Authenticate");
View Full Code Here

Examples of waffle.mock.http.SimpleHttpRequest

    }

    @Test
    public void testChallengeNTLMPUT() throws IOException, ServletException {
        MockWindowsIdentity mockWindowsIdentity = new MockWindowsIdentity("user", new ArrayList<String>());
        SimpleHttpRequest request = new SimpleHttpRequest();
        WindowsPrincipal windowsPrincipal = new WindowsPrincipal(mockWindowsIdentity);
        request.setUserPrincipal(windowsPrincipal);
        request.setMethod("PUT");
        request.setContentLength(0);
        request.addHeader("Authorization", "NTLM TlRMTVNTUAABAAAABzIAAAYABgArAAAACwALACAAAABXT1JLU1RBVElPTkRPTUFJTg==");
        SimpleFilterChain filterChain = new SimpleFilterChain();
        SimpleHttpResponse response = new SimpleHttpResponse();
        this.filter.doFilter(request, response, filterChain);
        assertEquals(401, response.getStatus());
        String[] wwwAuthenticates = response.getHeaderValues("WWW-Authenticate");
View Full Code Here

Examples of waffle.mock.http.SimpleHttpRequest

*/
public class AuthorizationHeaderTests {

    @Test
    public void testIsNull() {
        SimpleHttpRequest request = new SimpleHttpRequest();
        AuthorizationHeader header = new AuthorizationHeader(request);
        assertTrue(header.isNull());
        request.addHeader("Authorization", "");
        assertTrue(header.isNull());
        request.addHeader("Authorization", "12344234");
        assertFalse(header.isNull());
    }
View Full Code Here

Examples of waffle.mock.http.SimpleHttpRequest

        assertFalse(header.isNull());
    }

    @Test
    public void testGetSecurityPackage() {
        SimpleHttpRequest request = new SimpleHttpRequest();
        AuthorizationHeader header = new AuthorizationHeader(request);
        request.addHeader("Authorization", "NTLM TlRMTVNTUAABAAAABzIAAAYABgArAAAACwALACAAAABXT1JLU1RBVElPTkRPTUFJTg==");
        assertEquals("NTLM", header.getSecurityPackage());
        request.addHeader("Authorization",
                "Negotiate TlRMTVNTUAABAAAABzIAAAYABgArAAAACwALACAAAABXT1JLU1RBVElPTkRPTUFJTg==");
        assertEquals("Negotiate", header.getSecurityPackage());
    }
View Full Code Here

Examples of waffle.mock.http.SimpleHttpRequest

        assertEquals("Negotiate", header.getSecurityPackage());
    }

    @Test
    public void testIsNtlmType1Message() {
        SimpleHttpRequest request = new SimpleHttpRequest();
        AuthorizationHeader header = new AuthorizationHeader(request);
        assertFalse(header.isNtlmType1Message());
        request.addHeader("Authorization", "");
        assertFalse(header.isNtlmType1Message());
        request.addHeader("Authorization", "NTLM TlRMTVNTUAABAAAABzIAAAYABgArAAAACwALACAAAABXT1JLU1RBVElPTkRPTUFJTg==");
        assertTrue(header.isNtlmType1Message());
    }
View Full Code Here

Examples of waffle.mock.http.SimpleHttpRequest

        assertTrue(header.isNtlmType1Message());
    }

    @Test
    public void testIsNtlmType1PostAuthorizationHeader() {
        SimpleHttpRequest request = new SimpleHttpRequest();
        request.setContentLength(0);
        request.addHeader("Authorization", "NTLM TlRMTVNTUAABAAAABzIAAAYABgArAAAACwALACAAAABXT1JLU1RBVElPTkRPTUFJTg==");
        // GET
        request.setMethod("GET");
        AuthorizationHeader header = new AuthorizationHeader(request);
        assertFalse(header.isNtlmType1PostAuthorizationHeader());
        // POST
        request.setMethod("POST");
        assertTrue(header.isNtlmType1PostAuthorizationHeader());
        // PUT
        request.setMethod("PUT");
        assertTrue(header.isNtlmType1PostAuthorizationHeader());
    }
View Full Code Here

Examples of waffle.mock.http.SimpleHttpRequest

        assertTrue(header.isNtlmType1PostAuthorizationHeader());
    }

    @Test
    public void testIsSPNegoMessage() {
        SimpleHttpRequest request = new SimpleHttpRequest();
        AuthorizationHeader header = new AuthorizationHeader(request);
        assertFalse(header.isSPNegoMessage());
        request.addHeader("Authorization", "");
        assertFalse(header.isSPNegoMessage());
        request.addHeader(
                "Authorization",
                "Negotiate YHYGBisGAQUFAqBsMGqgMDAuBgorBgEEAYI3AgIKBgkqhkiC9xIBAgIGCSqGSIb3EgECAgYKKwYBBAGCNwICHqI2BDROVExNU1NQAAEAAACXsgjiAwADADEAAAAJAAkAKAAAAAYBsR0AAAAPR0xZQ0VSSU5FU0FE");
        assertTrue(header.isSPNegoMessage());
    }
View Full Code Here

Examples of waffle.mock.http.SimpleHttpRequest

        assertTrue(header.isSPNegoMessage());
    }

    @Test
    public void testIsSPNegoPostAuthorizationHeader() {
        SimpleHttpRequest request = new SimpleHttpRequest();
        request.setContentLength(0);
        request.addHeader(
                "Authorization",
                "Negotiate YHYGBisGAQUFAqBsMGqgMDAuBgorBgEEAYI3AgIKBgkqhkiC9xIBAgIGCSqGSIb3EgECAgYKKwYBBAGCNwICHqI2BDROVExNU1NQAAEAAACXsgjiAwADADEAAAAJAAkAKAAAAAYBsR0AAAAPR0xZQ0VSSU5FU0FE");
        // GET
        request.setMethod("GET");
        AuthorizationHeader header = new AuthorizationHeader(request);
        assertFalse(header.isNtlmType1PostAuthorizationHeader());
        // POST
        request.setMethod("POST");
        assertTrue(header.isNtlmType1PostAuthorizationHeader());
        // PUT
        request.setMethod("PUT");
        assertTrue(header.isNtlmType1PostAuthorizationHeader());
    }
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.