aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/helper/LogAction.java
diff options
context:
space:
mode:
authordeveloperKurt <mustafakurt.business@gmail.com>2020-01-01 13:42:05 +0300
committerdeveloperKurt <mustafakurt.business@gmail.com>2020-01-01 13:42:05 +0300
commitfcad646a7c912463c53de946b2586e4a49a6e1ff (patch)
tree665e5f82a531d19ed2f762bb451157326f3a0e9c /src/main/java/org/traccar/helper/LogAction.java
parent1ca6c8561f1aa21d5f73030bcd0ab3e9c578a9f1 (diff)
downloadtrackermap-server-fcad646a7c912463c53de946b2586e4a49a6e1ff.tar.gz
trackermap-server-fcad646a7c912463c53de946b2586e4a49a6e1ff.tar.bz2
trackermap-server-fcad646a7c912463c53de946b2586e4a49a6e1ff.zip
As requested in issue #4393, added logging IP address functionality when login attempts fail.
Diffstat (limited to 'src/main/java/org/traccar/helper/LogAction.java')
-rw-r--r--src/main/java/org/traccar/helper/LogAction.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/helper/LogAction.java b/src/main/java/org/traccar/helper/LogAction.java
index db13337b8..1fbd78c4d 100644
--- a/src/main/java/org/traccar/helper/LogAction.java
+++ b/src/main/java/org/traccar/helper/LogAction.java
@@ -38,12 +38,14 @@ public final class LogAction {
private static final String ACTION_LOGIN = "login";
private static final String ACTION_LOGOUT = "logout";
+ private static final String ACTION_FAILED_LOGIN_NO_IP = "Failed Login Attempt. IP address: failed to retrieve";
private static final String ACTION_DEVICE_ACCUMULATORS = "resetDeviceAccumulators";
private static final String PATTERN_OBJECT = "user: %d, action: %s, object: %s, id: %d";
private static final String PATTERN_LINK = "user: %d, action: %s, owner: %s, id: %d, property: %s, id: %d";
private static final String PATTERN_LOGIN = "user: %d, action: %s";
+ private static final String PATTERN_FAILED_LOGIN = "Failed Login Attempt. IP address: %s";
private static final String PATTERN_DEVICE_ACCUMULATORS = "user: %d, action: %s, deviceId: %d";
public static void create(long userId, BaseModel object) {
@@ -74,6 +76,20 @@ public final class LogAction {
logLoginAction(ACTION_LOGOUT, userId);
}
+ public static void failedLogin(String ipAddress) {
+
+ if(ipAddress == null || ipAddress.isEmpty()) {
+ LOGGER.info(ACTION_FAILED_LOGIN_NO_IP);
+ }
+
+ else{
+ LOGGER.info(String.format(
+ PATTERN_FAILED_LOGIN, ipAddress));
+ }
+
+ }
+
+
public static void resetDeviceAccumulators(long userId, long deviceId) {
LOGGER.info(String.format(
PATTERN_DEVICE_ACCUMULATORS, userId, ACTION_DEVICE_ACCUMULATORS, deviceId));