@@ -0,0 +1,3528 @@
+package net.sf.acegisecurity.ui.x509;%0A%0Aimport junit.framework.TestCase;%0A%0A//import org.mortbay.http.*;%0A//import org.mortbay.jetty.servlet.*;%0A%0Aimport java.net.URL;%0Aimport java.io.IOException;%0Aimport java.security.cert.X509Certificate;%0A%0Aimport net.sf.acegisecurity.*;%0Aimport net.sf.acegisecurity.context.security.SecureContext;%0Aimport net.sf.acegisecurity.context.security.SecureContextUtils;%0Aimport net.sf.acegisecurity.context.security.SecureContextImpl;%0Aimport net.sf.acegisecurity.context.ContextHolder;%0Aimport net.sf.acegisecurity.providers.x509.X509TestUtils;%0Aimport net.sf.acegisecurity.ui.cas.CasProcessingFilter;%0A%0Aimport javax.servlet.FilterChain;%0Aimport javax.servlet.ServletRequest;%0Aimport javax.servlet.ServletResponse;%0Aimport javax.servlet.ServletException;%0A%0A/**%0A * @author Luke%0A */%0Apublic class X509ProcessingFilterTests extends TestCase %7B%0A    //~ Constructors ===========================================================%0A%0A    public X509ProcessingFilterTests() %7B%0A        super();%0A    %7D%0A%0A    public X509ProcessingFilterTests(String arg0) %7B%0A        super(arg0);%0A    %7D%0A%0A    //~ Methods ================================================================%0A%0A    public final void setUp() throws Exception %7B%0A        super.setUp();%0A    %7D%0A%0A    public void testNormalOperation() throws Exception %7B%0A        MockHttpServletRequest request = new MockHttpServletRequest(null, new MockHttpSession());%0A        MockHttpServletResponse response = new MockHttpServletResponse();%0A        FilterChain chain = new MockFilterChain();%0A%0A        request.setAttribute(%22javax.servlet.request.X509Certificate%22,%0A                new X509Certificate%5B%5D %7BX509TestUtils.buildTestCertificate()%7D);%0A%0A        MockAuthenticationManager authMgr = new MockAuthenticationManager(true);%0A%0A        ContextHolder.setContext(new SecureContextImpl());%0A%0A        SecureContext ctx = SecureContextUtils.getSecureContext();%0A%0A        ctx.setAuthentication(null);%0A%0A        X509ProcessingFilter filter = new X509ProcessingFilter();%0A%0A        filter.setAuthenticationManager(authMgr);%0A        filter.afterPropertiesSet();%0A        filter.init(null);%0A        filter.doFilter(request, response, chain);%0A%0A        Authentication result = ctx.getAuthentication();%0A%0A        assertNotNull(result);%0A    %7D%0A%0A    //~ Inner Classes ==========================================================%0A%0A    private class MockFilterChain implements FilterChain %7B%0A        public void doFilter(ServletRequest arg0, ServletResponse arg1)%0A            throws IOException, ServletException %7B%0A                // do nothing.%0A        %7D%0A    %7D%0A//    public void testFilterIntegration() throws Exception %7B%0A//%0A//        // set up server.%0A//        HttpServer server = new HttpServer();%0A//        try %7B%0A//            SunJsseListener listener = new SunJsseListener();%0A//            listener.setNeedClientAuth(true);%0A//            listener.setPort(9443);%0A////            listener.setKeystore();%0A//%0A//            server.addListener(listener);%0A//%0A//            // map servlet.%0A//            HttpContext context = server.getContext(%22/%22);%0A//%0A////            ServletHandler handler = new ServletHandler();%0A////            handler.addServlet(%22MyServlet%22, %22/myServlet%22, MyServlet.class.getName());%0A////            context.addHandler(handler);%0A//%0A//            // start server.%0A//            server.start();%0A//%0A//            // test client code against url.%0A//            URL url = new URL(%22http://localhost:%22 + 9443 + %22/myServlet%22);%0A//%0A//%0A//%0A//        %7D%0A//        finally %7B%0A//          server.stop();%0A//        %7D%0A//    %7D%0A%0A%0A%0A%7D%0A

Test class for X509 filter.