1 package com.atlassian.security.auth.trustedapps.filter;
2
3 import javax.servlet.http.HttpServletRequest;
4 import javax.servlet.http.HttpServletResponse;
5 import java.security.Principal;
6
7
8
9 public class MockTrustedApplicationsFilter extends TrustedApplicationsFilter
10 {
11 private final MockCertificateServer certificateServer;
12 private final MockAuthenticator mockAuthenticator;
13
14 public MockTrustedApplicationsFilter()
15 {
16 this(new MockCertificateServer(), new MockAuthenticator());
17 }
18
19 private MockTrustedApplicationsFilter(MockCertificateServer certificateServer, MockAuthenticator mockAuthenticator)
20 {
21 super(certificateServer, mockAuthenticator, new MockAuthenticationController(), new MockAuthenticationListener());
22 this.certificateServer = certificateServer;
23 this.mockAuthenticator = mockAuthenticator;
24 }
25
26 public MockCertificateServer getMockCertificateServer()
27 {
28 return certificateServer;
29 }
30
31 public MockAuthenticator getMockAuthenticator()
32 {
33 return mockAuthenticator;
34 }
35
36 private static class MockAuthenticationController implements AuthenticationController
37 {
38 public boolean shouldAttemptAuthentication(HttpServletRequest request)
39 {
40 return true;
41 }
42
43 public boolean canLogin(Principal principal, HttpServletRequest request)
44 {
45 return true;
46 }
47 }
48
49 private static class MockAuthenticationListener implements AuthenticationListener
50 {
51 public void authenticationSuccess(Authenticator.Result result, HttpServletRequest request, HttpServletResponse response)
52 {
53 }
54
55 public void authenticationFailure(Authenticator.Result result, HttpServletRequest request, HttpServletResponse response)
56 {
57 }
58
59 public void authenticationError(Authenticator.Result result, HttpServletRequest request, HttpServletResponse response)
60 {
61 }
62
63 public void authenticationNotAttempted(HttpServletRequest request, HttpServletResponse response)
64 {
65 }
66 }
67 }