Class OAuth2LoginHelper
java.lang.Object
sk.iway.iwcm.system.spring.oauth2.OAuth2LoginHelper
Helper class with shared functionality for OAuth2 handlers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturns redirect URL for admin zonestatic StringgetErrorRedirectUrl(boolean isAdminLogin) Returns redirect URL for error based on login typegetLogonUrls(boolean isAdmin, jakarta.servlet.http.HttpServletRequest request) Gets logon URLs for configured OAuth2 clients to display on login pagestatic StringReturns redirect URL for user zonestatic voidhandleError(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 typestatic voidhandleError(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String errorCode, String redirectUrl) Sets error code to session and performs redirectstatic booleanisAdminLogin(jakarta.servlet.http.HttpServletRequest request) Determines if this is an administration login Based on session attribute set in admin/user logon pagestatic booleanisAdminLoginAndClear(jakarta.servlet.http.HttpServletRequest request) Determines if this is an administration login and removes session attributestatic voidsetAdminLogin(jakarta.servlet.http.HttpServletRequest request) Set info that login will be for admin section
-
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
Returns redirect URL for error based on login type- Parameters:
isAdminLogin- true if this is admin login- Returns:
- redirect URL
-
getAdminRedirectUrl
Returns redirect URL for admin zone- Returns:
- redirect URL for admin zone
-
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 requestresponse- HTTP responseerrorCode- error coderedirectUrl- 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 requestresponse- HTTP responseerrorCode- error codeisAdminLogin- 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
-