Class OAuth2LoginHelper

java.lang.Object
sk.iway.iwcm.system.spring.oauth2.OAuth2LoginHelper

public class OAuth2LoginHelper extends Object
Helper class with shared functionality for OAuth2 handlers
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Returns redirect URL for admin zone
    static String
    getErrorRedirectUrl(boolean isAdminLogin)
    Returns redirect URL for error based on login type
    static Map<String,String>
    getLogonUrls(boolean isAdmin, jakarta.servlet.http.HttpServletRequest request)
    Gets logon URLs for configured OAuth2 clients to display on login page
    static String
    Returns redirect URL for user zone
    static void
    handleError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String errorCode, boolean isAdminLogin)
    Sets error code to session and performs redirect based on login type
    static void
    handleError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String errorCode, String redirectUrl)
    Sets error code to session and performs redirect
    static boolean
    isAdminLogin(jakarta.servlet.http.HttpServletRequest request)
    Determines if this is an administration login Based on session attribute set in admin/user logon page
    static boolean
    isAdminLoginAndClear(jakarta.servlet.http.HttpServletRequest request)
    Determines if this is an administration login and removes session attribute
    static void
    setAdminLogin(jakarta.servlet.http.HttpServletRequest request)
    Set info that login will be for admin section

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OAuth2LoginHelper

      public OAuth2LoginHelper()
  • Method Details

    • setAdminLogin

      public static void setAdminLogin(jakarta.servlet.http.HttpServletRequest request)
      Set info that login will be for admin section
      Parameters:
      request -
    • isAdminLogin

      public static boolean isAdminLogin(jakarta.servlet.http.HttpServletRequest request)
      Determines if this is an administration login Based on session attribute set in admin/user logon page
      Parameters:
      request - HTTP request
      Returns:
      true if this is admin login
    • isAdminLoginAndClear

      public static boolean isAdminLoginAndClear(jakarta.servlet.http.HttpServletRequest request)
      Determines if this is an administration login and removes session attribute
      Parameters:
      request - HTTP request
      Returns:
      true if this is admin login
    • getErrorRedirectUrl

      public static String getErrorRedirectUrl(boolean isAdminLogin)
      Returns redirect URL for error based on login type
      Parameters:
      isAdminLogin - true if this is admin login
      Returns:
      redirect URL
    • getAdminRedirectUrl

      public static String getAdminRedirectUrl()
      Returns redirect URL for admin zone
      Returns:
      redirect URL for admin zone
    • getUserRedirectUrl

      public static String getUserRedirectUrl()
      Returns redirect URL for user zone
      Returns:
      redirect URL for user zone
    • handleError

      public static void handleError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String errorCode, String redirectUrl) throws IOException
      Sets error code to session and performs redirect
      Parameters:
      request - HTTP request
      response - HTTP response
      errorCode - error code
      redirectUrl - redirect URL
      Throws:
      IOException - if redirect fails
    • handleError

      public static void handleError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String errorCode, boolean isAdminLogin) throws IOException
      Sets error code to session and performs redirect based on login type
      Parameters:
      request - HTTP request
      response - HTTP response
      errorCode - error code
      isAdminLogin - true if this is admin login
      Throws:
      IOException - if redirect fails
    • getLogonUrls

      public static Map<String,String> getLogonUrls(boolean isAdmin, jakarta.servlet.http.HttpServletRequest request)
      Gets logon URLs for configured OAuth2 clients to display on login page
      Parameters:
      request - HTTP request
      Returns:
      map of client names to authorization URLs