1 package com.atlassian.seraph.elevatedsecurity;
2
3 import com.atlassian.seraph.Initable;
4
5 import javax.servlet.http.HttpServletRequest;
6
7 /**
8 * An ElevatedSecurityGaurd is responsible for checking whether a user has failed authentication too many times and
9 * hence needs to pass an "elevated" security check before they can authenticate again.
10 *
11 * @since v2.1
12 */
13 public interface ElevatedSecurityGuard extends Initable
14 {
15
16 /**
17 * This will be called to perform an elevated security check for a given user name. Its up to the implementor to
18 * decide what if any tests needs to be done. It should return true if the authentication can proceed.
19 *
20 * @param httpServletRequest the HTTP request in play
21 * @param userName the name of the user to get login information about
22 *
23 * @return true if the user passed the elevated security check or false if not. If you dont want any elevated security
24 * checks done them always return true.
25 */
26 boolean performElevatedSecurityCheck(HttpServletRequest httpServletRequest, String userName);
27
28 /**
29 * This is called when a user fails a login check, either because they failed the elevated security check or they
30 * failed the more basic username and password check.
31 * <p/>
32 * The username MAY be null if a valid username cannot be found for example
33 *
34 * @param httpServletRequest the HTTP request in play
35 * @param userName the name of the user to get login information about
36 */
37 void onFailedLoginAttempt(HttpServletRequest httpServletRequest, String userName);
38
39 /**
40 * This is called when a user passes a login check.
41 * <p/>
42 * The username MAY be null if a valid username cannot be found for example
43 *
44 * @param httpServletRequest the HTTP request in play
45 * @param userName the name of the user to get login information about
46 */
47 void onSuccessfulLoginAttempt(HttpServletRequest httpServletRequest, String userName);
48 }