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