1 package com.atlassian.sal.api.auth;
2
3 import javax.servlet.http.HttpServletRequest;
4 import javax.servlet.http.HttpServletResponse;
5
6 /**
7 * Allows the underlying framework to take some actions on authentication events.
8 *
9 * @since 2.0
10 */
11 public interface AuthenticationListener
12 {
13 /**
14 * Called when the signature is validated and the user is resolved and permissions are verified. Responsible
15 * for preparing the HTTP request or session such that the application sees the user as logged in for the rest of
16 * this request.
17 *
18 * @param result Authentication result containing the user
19 * @param request Current HTTP request being processed
20 * @param response HTTP response for the current request, provided so the application can set any headers it might
21 * need set
22 */
23 void authenticationSuccess(Authenticator.Result result, HttpServletRequest request, HttpServletResponse response);
24
25 /**
26 * Called when the signature cannot be validated or the user cannot be resolved or does not have permission
27 * to access the resource.
28 *
29 * @param result Authentication result containing the details of the failure
30 * @param request Current HTTP request being processed
31 * @param response HTTP response for the current request, provided so the application can set any headers it might
32 * need set
33 */
34 void authenticationFailure(Authenticator.Result result, HttpServletRequest request, HttpServletResponse response);
35
36 /**
37 * Called when there is a failure in trying to process the request, such as an IO failure.
38 *
39 * @param result Authentication result containing the details of the error
40 * @param request Current HTTP request being processed
41 * @param response HTTP response for the current request, provided so the application can set any headers it might
42 * need set
43 */
44 void authenticationError(Authenticator.Result result, HttpServletRequest request, HttpServletResponse response);
45
46 /**
47 * Called if it was determined that authentication should not be attempted, usually because the
48 * {@link AuthenticationController#shouldAttemptAuthentication(HttpServletRequest)} returned {@code false}.
49 *
50 * @param request Current HTTP request being processed
51 * @param response HTTP response for the current request, provided so the application can set any headers it might
52 * need set
53 */
54 void authenticationNotAttempted(HttpServletRequest request, HttpServletResponse response);
55 }