Search in sources :

Example 1 with ProxyFilter

use of org.codice.ddf.security.handler.cas.filter.ProxyFilter in project ddf by codice.

the class CasHandlerTest method createHandler.

private CasHandler createHandler() {
    CasHandler handler = new CasHandler();
    STSClientConfiguration clientConfiguration = mock(STSClientConfiguration.class);
    when(clientConfiguration.getAddress()).thenReturn(STS_ADDRESS);
    handler.setClientConfiguration(clientConfiguration);
    Filter testFilter = mock(Filter.class);
    handler.setProxyFilter(new ProxyFilter(Arrays.asList(testFilter)));
    return handler;
}
Also used : STSClientConfiguration(ddf.security.sts.client.configuration.STSClientConfiguration) ProxyFilter(org.codice.ddf.security.handler.cas.filter.ProxyFilter) AbstractCasFilter(org.jasig.cas.client.util.AbstractCasFilter) Filter(javax.servlet.Filter) ProxyFilter(org.codice.ddf.security.handler.cas.filter.ProxyFilter)

Example 2 with ProxyFilter

use of org.codice.ddf.security.handler.cas.filter.ProxyFilter in project ddf by codice.

the class CasHandlerTest method testNoPrincipalResolve.

/**
     * Tests that the handler properly returns a REDIRECTED result if the assertion is not in the
     * session and resolve is true.
     *
     * @throws ServletException
     * @throws IOException
     */
@Test
public void testNoPrincipalResolve() throws ServletException, IOException {
    CasHandler handler = createHandler();
    Filter testFilter = mock(Filter.class);
    handler.setProxyFilter(new ProxyFilter(Arrays.asList(testFilter)));
    HandlerResult result = handler.getNormalizedToken(createServletRequest(false), mock(HttpServletResponse.class), new ProxyFilterChain(null), true);
    assertEquals(HandlerResult.Status.REDIRECTED, result.getStatus());
    // verify that the filter was called once
    verify(testFilter).doFilter(any(ServletRequest.class), any(ServletResponse.class), any(FilterChain.class));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletResponse(javax.servlet.ServletResponse) ProxyFilter(org.codice.ddf.security.handler.cas.filter.ProxyFilter) AbstractCasFilter(org.jasig.cas.client.util.AbstractCasFilter) Filter(javax.servlet.Filter) ProxyFilter(org.codice.ddf.security.handler.cas.filter.ProxyFilter) FilterChain(javax.servlet.FilterChain) ProxyFilterChain(org.codice.ddf.security.handler.cas.filter.ProxyFilterChain) HttpServletResponse(javax.servlet.http.HttpServletResponse) HandlerResult(org.codice.ddf.security.handler.api.HandlerResult) ProxyFilterChain(org.codice.ddf.security.handler.cas.filter.ProxyFilterChain) Test(org.junit.Test)

Aggregations

Filter (javax.servlet.Filter)2 ProxyFilter (org.codice.ddf.security.handler.cas.filter.ProxyFilter)2 AbstractCasFilter (org.jasig.cas.client.util.AbstractCasFilter)2 STSClientConfiguration (ddf.security.sts.client.configuration.STSClientConfiguration)1 FilterChain (javax.servlet.FilterChain)1 ServletRequest (javax.servlet.ServletRequest)1 ServletResponse (javax.servlet.ServletResponse)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 HandlerResult (org.codice.ddf.security.handler.api.HandlerResult)1 ProxyFilterChain (org.codice.ddf.security.handler.cas.filter.ProxyFilterChain)1 Test (org.junit.Test)1