Package sk.iway.iwcm.common
Class LogonTools
java.lang.Object
sk.iway.iwcm.common.LogonTools
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidafterLogon(Identity user, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) static voidauditLogon(List<String> errors, Identity user, String username, jakarta.servlet.http.HttpServletRequest request) static booleanSkontroluje ci sa moze pouzivatel prihlasit vzhladom na zadane datumy mozneho prihlaseniastatic intcheckForAlarm(Identity user) static voiddisableAllAdminItems(int userId) For admin created for example by oauth2 you need to disable all admin items because perms will be mapped by perm groupsstatic voidinvalidateSessionOnFirstPost(jakarta.servlet.http.HttpServletRequest request) Ochrana Session Fixation (MFSR pentesty) ktora zabezpeci pri PRVOM odoslani (POST) logon formularu invalidnutie sessionstatic booleanisLoginBlocked(jakarta.servlet.http.HttpServletRequest request) Test if login is not time/IP blockedstatic booleanisPasswordCorrect(String password, String salt, String passwordInDb) Verify if given password is correct including support for old Rijndael encryptionstatic Stringlogon(String username, String password, Identity user, Map<String, String> errors, jakarta.servlet.http.HttpServletRequest request, Prop prop) Description of the MethodlogonUserWithAllChecks(jakarta.servlet.http.HttpServletRequest request, String username, String password) static voidlogonUserWithAllChecks(Identity identity, jakarta.servlet.http.HttpServletRequest request) Load user perms, set user to session and spring context.static voidsaveAfterLogonRedirect(jakarta.servlet.http.HttpServletRequest request) Ulozi URL pred zobrazenim logon formu na ktoru sa po prihlaseni presmerujestatic voidsetLoginBlocked(jakarta.servlet.http.HttpServletRequest request) Cache info about bad credentials/login to block for 10 secondsstatic voidsetUserPerms(Identity user) Nastavi userovi prava na adresare (editable groups a pages)static org.springframework.security.core.AuthenticationsetUserToSession(jakarta.servlet.http.HttpSession session, Identity user) Nastavi usera do session a nastavi spring pravastatic voidupdateLastLogin(int userId) Update last_logon field in database to current date time
-
Constructor Details
-
LogonTools
protected LogonTools()
-
-
Method Details
-
checkAllowLoginDates
Skontroluje ci sa moze pouzivatel prihlasit vzhladom na zadane datumy mozneho prihlasenia- Parameters:
rs-- Returns:
-
logon
public static String logon(String username, String password, Identity user, Map<String, String> errors, jakarta.servlet.http.HttpServletRequest request, Prop prop) Description of the Method- Parameters:
username- Description of the Parameterpassword- Description of the Parameteruser- Description of the Parametererrors- Description of the Parameterrequest- Description of the Parameter- Returns:
- Description of the Return Value
-
setUserPerms
Nastavi userovi prava na adresare (editable groups a pages)- Parameters:
user-
-
auditLogon
-
logonUser
-
logonUserWithAllChecks
-
logonUserWithAllChecks
public static void logonUserWithAllChecks(Identity identity, jakarta.servlet.http.HttpServletRequest request) Load user perms, set user to session and spring context. You should call this method when you get Identity from custom logon method such as OAuth2 or PassKey or another provider.- Parameters:
identity-request-
-
afterLogon
public static void afterLogon(Identity user, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) -
checkForAlarm
-
invalidateSessionOnFirstPost
public static void invalidateSessionOnFirstPost(jakarta.servlet.http.HttpServletRequest request) Ochrana Session Fixation (MFSR pentesty) ktora zabezpeci pri PRVOM odoslani (POST) logon formularu invalidnutie session- Parameters:
request-
-
saveAfterLogonRedirect
public static void saveAfterLogonRedirect(jakarta.servlet.http.HttpServletRequest request) Ulozi URL pred zobrazenim logon formu na ktoru sa po prihlaseni presmeruje- Parameters:
request-
-
setUserToSession
public static org.springframework.security.core.Authentication setUserToSession(jakarta.servlet.http.HttpSession session, Identity user) Nastavi usera do session a nastavi spring prava- Parameters:
session-user-
-
isLoginBlocked
public static boolean isLoginBlocked(jakarta.servlet.http.HttpServletRequest request) Test if login is not time/IP blocked- Parameters:
request-- Returns:
-
setLoginBlocked
public static void setLoginBlocked(jakarta.servlet.http.HttpServletRequest request) Cache info about bad credentials/login to block for 10 seconds- Parameters:
request-
-
isPasswordCorrect
Verify if given password is correct including support for old Rijndael encryption- Parameters:
password-salt-passwordInDb-- Returns:
-
disableAllAdminItems
public static void disableAllAdminItems(int userId) For admin created for example by oauth2 you need to disable all admin items because perms will be mapped by perm groups- Parameters:
userId-
-
updateLastLogin
public static void updateLastLogin(int userId) Update last_logon field in database to current date time- Parameters:
userId-
-