Search in sources :

Example 21 with SecurityFilterChain

use of org.codice.ddf.platform.filter.SecurityFilterChain in project ddf by codice.

the class PKIHandlerTest method testGetNormalizedTokenFailsWhenCrlFails.

/**
 * Tests that the PKIHandler returns REDIRECTED when the cert fails to pass the CRL check
 */
@Test
public void testGetNormalizedTokenFailsWhenCrlFails() throws Exception {
    PKIHandler handler = getPKIHandlerWithMockedCrl(false);
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpServletResponse response = mock(HttpServletResponse.class);
    SecurityFilterChain chain = mock(SecurityFilterChain.class);
    when(request.getAttribute(("javax.servlet.request.X509Certificate"))).thenReturn(getTestCerts());
    // should return REDIRECTED
    HandlerResult handlerResult = handler.getNormalizedToken(request, response, chain, true);
    assertThat(handlerResult.getStatus(), equalTo(HandlerResult.Status.REDIRECTED));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SecurityFilterChain(org.codice.ddf.platform.filter.SecurityFilterChain) HttpServletResponse(javax.servlet.http.HttpServletResponse) HandlerResult(org.codice.ddf.security.handler.api.HandlerResult) Test(org.junit.Test)

Aggregations

SecurityFilterChain (org.codice.ddf.platform.filter.SecurityFilterChain)21 HttpServletRequest (javax.servlet.http.HttpServletRequest)20 Test (org.junit.Test)20 HttpServletResponse (javax.servlet.http.HttpServletResponse)19 HandlerResult (org.codice.ddf.security.handler.api.HandlerResult)15 ContextPolicyManager (org.codice.ddf.security.policy.context.ContextPolicyManager)11 ContextPolicy (org.codice.ddf.security.policy.context.ContextPolicy)9 ServletRequest (javax.servlet.ServletRequest)6 ServletResponse (javax.servlet.ServletResponse)6 AuthenticationException (org.codice.ddf.platform.filter.AuthenticationException)6 SecurityLogger (ddf.security.audit.SecurityLogger)5 AuthenticationHandler (org.codice.ddf.security.handler.api.AuthenticationHandler)5 SecurityConstants (ddf.security.SecurityConstants)4 Subject (ddf.security.Subject)4 CollectionPermission (ddf.security.permission.CollectionPermission)4 CollectionPermissionImpl (ddf.security.permission.impl.CollectionPermissionImpl)4 KeyValuePermissionImpl (ddf.security.permission.impl.KeyValuePermissionImpl)4 IOException (java.io.IOException)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4