bug6099: only update user record in DB if locking record changed

This commit is contained in:
Axel Uhl committed 2025-03-18 15:58:08 +01:00
1 parent fc87c080a1
commit c1211cb3d8
4 files changed
+43 -16

No files matched your search

@@ -11,8 +11,8 @@ import com.sap.sse.common.TimePoint;
*
* For example, failed password authentication requests shall be logged by the realm using calls to
* {@link #failedPasswordAuthentication()}, successful ones with {@link #successfulPasswordAuthentication()}. Using the
* {@link #isAuthenticationLocked()} method, a realm can determine if the user account to which this object
* belongs shall currently accept password authentication.
* {@link #isAuthenticationLocked()} method, a realm can determine if the user account to which this object belongs
* shall currently accept password authentication.
* <p>
*
* A possible strategy for an implementation could be to add an increasing delay for each failed password
@@ -23,7 +23,13 @@ import com.sap.sse.common.TimePoint;
*/
public interface LockingAndBanning extends Serializable {
void failedPasswordAuthentication();
void successfulPasswordAuthentication();
/**
* @return {@code true} if this locking and banning record changed due to this call
*/
boolean successfulPasswordAuthentication();
boolean isAuthenticationLocked();
TimePoint getLockedUntil();
}
@@ -2,6 +2,7 @@ package com.sap.sse.security.shared.impl;
import com.sap.sse.common.Duration;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
public class LockingAndBanningImpl implements LockingAndBanning {
private static final long serialVersionUID = 3547356744366236677L;
@@ -43,9 +44,12 @@ public class LockingAndBanningImpl implements LockingAndBanning {
}
@Override
public void successfulPasswordAuthentication() {
public boolean successfulPasswordAuthentication() {
final Duration oldLockingDelay = nextLockingDelay;
nextLockingDelay = DEFAULT_INITIAL_LOCKING_DELAY;
final TimePoint oldLockedUntil = lockedUntil;
lockedUntil = TimePoint.BeginningOfTime;
return !Util.equalsWithNull(oldLockingDelay, nextLockingDelay) || !Util.equalsWithNull(oldLockedUntil, lockedUntil);
}
@Override