Skip to content

Commit bddb93e

Browse files
committed
System Touch
1 parent 154d2bc commit bddb93e

8 files changed

Lines changed: 40 additions & 40 deletions

source/db/N21Store.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,24 @@ public static void storeException(final ExceptionRecord R, final boolean ISSECUR
7373
{
7474
PreparedStatement ps = N21DataSource.get().prepareStatement(
7575
"INSERT INTO exceptions (exception_type, message, origin, stack_trace, is_security_event, recorded_at) VALUES (?,?,?,?,?,?)");
76-
ps.setString(1, R.exception().getClass().getSimpleName());
77-
ps.setString(2, R.exception().getMessage());
78-
ps.setString(3, R.origin());
79-
ps.setString(4, R.stackTrace());
76+
ps.setString(1, R.EXCEPTION().getClass().getSimpleName());
77+
ps.setString(2, R.EXCEPTION().getMessage());
78+
ps.setString(3, R.ORIGIN());
79+
ps.setString(4, R.STACKTRACE());
8080
ps.setBoolean(5, ISSECURITYEVENT);
81-
ps.setTimestamp(6, Timestamp.from(R.timestamp()));
81+
ps.setTimestamp(6, Timestamp.from(R.TIMESTAMP()));
8282
ps.executeUpdate(); ps.close();
8383
return;
8484
}
8585
catch (Exception e) { fail("exceptions", e); }
8686
}
8787
N21XmlFallback.append("exceptions",
88-
"exception_type", R.exception().getClass().getSimpleName(),
89-
"message", R.exception().getMessage(),
90-
"origin", R.origin(),
91-
"stack_trace", R.stackTrace(),
88+
"exception_type", R.EXCEPTION().getClass().getSimpleName(),
89+
"message", R.EXCEPTION().getMessage(),
90+
"origin", R.ORIGIN(),
91+
"stack_trace", R.STACKTRACE(),
9292
"security", String.valueOf(ISSECURITYEVENT),
93-
"recorded_at", R.timestamp().toString());
93+
"recorded_at", R.TIMESTAMP().toString());
9494
}
9595

9696
// ── security_events ───────────────────────────────────────────────────────
@@ -103,22 +103,22 @@ public static void storeSecurityEvent(final ExceptionRecord R, final String SOUR
103103
{
104104
PreparedStatement ps = N21DataSource.get().prepareStatement(
105105
"INSERT INTO security_events (event_type, message, origin, source_ip, recorded_at) VALUES (?,?,?,?,?)");
106-
ps.setString(1, R.exception().getClass().getSimpleName());
107-
ps.setString(2, R.exception().getMessage());
108-
ps.setString(3, R.origin());
106+
ps.setString(1, R.EXCEPTION().getClass().getSimpleName());
107+
ps.setString(2, R.EXCEPTION().getMessage());
108+
ps.setString(3, R.ORIGIN());
109109
ps.setString(4, SOURCEIP != null ? SOURCEIP : "");
110-
ps.setTimestamp(5, Timestamp.from(R.timestamp()));
110+
ps.setTimestamp(5, Timestamp.from(R.TIMESTAMP()));
111111
ps.executeUpdate(); ps.close();
112112
return;
113113
}
114114
catch (Exception e) { fail("security_events", e); }
115115
}
116116
N21XmlFallback.append("security_events",
117-
"event_type", R.exception().getClass().getSimpleName(),
118-
"message", R.exception().getMessage(),
119-
"origin", R.origin(),
117+
"event_type", R.EXCEPTION().getClass().getSimpleName(),
118+
"message", R.EXCEPTION().getMessage(),
119+
"origin", R.ORIGIN(),
120120
"source_ip", SOURCEIP != null ? SOURCEIP : "",
121-
"recorded_at", R.timestamp().toString());
121+
"recorded_at", R.TIMESTAMP().toString());
122122
}
123123

124124
// ── national_ids ──────────────────────────────────────────────────────────

source/exceptions/ExceptionEventDispatcher.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
public class ExceptionEventDispatcher
77
{
88
private final List<ExceptionListener> LISTENERS;
9-
private final ExceptionPersistenceService persistenceService;
9+
private final ExceptionPersistenceService PERSISTENCESERVICE;
1010
private final BackendSettings SETTINGS;
1111

1212
public ExceptionEventDispatcher(final List<ExceptionListener> LISTENERS, final ExceptionPersistenceService PERSISTENCESERVICE, final BackendSettings SETTINGS)
@@ -15,7 +15,7 @@ public ExceptionEventDispatcher(final List<ExceptionListener> LISTENERS, final E
1515
.sorted(Comparator.comparingInt(ExceptionListener::getPriority))
1616
.toList();
1717

18-
this.persistenceService = PERSISTENCESERVICE;
18+
this.PERSISTENCESERVICE = PERSISTENCESERVICE;
1919

2020
this.SETTINGS = SETTINGS;
2121
}
@@ -31,7 +31,7 @@ public void dispatch(final Exception EX)
3131

3232
if (SETTINGS.isPersistExceptions())
3333
{
34-
persistenceService.persist(record);
34+
PERSISTENCESERVICE.persist(record);
3535
}
3636
}
3737
}

source/exceptions/ExceptionPersistenceService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ public void persist(final ExceptionRecord RECORD)
2525
{
2626

2727
writer.write("[EXCEPTION] " + Instant.now() + System.lineSeparator() +
28-
"Type: " + RECORD.exception().getClass().getName() + System.lineSeparator() +
29-
"Message: " + RECORD.exception().getMessage() + System.lineSeparator() +
30-
"Origin: " + RECORD.origin() + System.lineSeparator() +
28+
"Type: " + RECORD.EXCEPTION().getClass().getName() + System.lineSeparator() +
29+
"Message: " + RECORD.EXCEPTION().getMessage() + System.lineSeparator() +
30+
"Origin: " + RECORD.ORIGIN() + System.lineSeparator() +
3131
"StackTrace:" + System.lineSeparator() +
32-
RECORD.stackTrace() + System.lineSeparator() +
32+
RECORD.STACKTRACE() + System.lineSeparator() +
3333
"------------------------------------------------------------" +
3434
System.lineSeparator()
3535
);

source/exceptions/ExceptionRecord.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import java.util.stream.Collectors;
66

77
public record ExceptionRecord(
8-
Throwable exception,
9-
String origin,
10-
String stackTrace,
11-
Instant timestamp
8+
Throwable EXCEPTION,
9+
String ORIGIN,
10+
String STACKTRACE,
11+
Instant TIMESTAMP
1212
) {
1313

1414
public static ExceptionRecord from(final Throwable EX) {

source/exceptions/N21ExceptionListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public class N21ExceptionListener implements ExceptionListener
1616
@Override
1717
public void onException(final ExceptionRecord RECORD)
1818
{
19-
boolean isSecurity = RECORD.exception() instanceof SecurityException
20-
|| isSecurityKeyword(RECORD.exception());
19+
boolean isSecurity = RECORD.EXCEPTION() instanceof SecurityException
20+
|| isSecurityKeyword(RECORD.EXCEPTION());
2121

2222
N21Store.storeException(RECORD, isSecurity);
2323

source/exceptions/NullPointerConstructorHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ public void onException(final ExceptionRecord RECORD)
2727

2828
private boolean isConstructorNPE(final ExceptionRecord RECORD)
2929
{
30-
Throwable ex = RECORD.exception();
30+
Throwable ex = RECORD.EXCEPTION();
3131

3232
if (!(ex instanceof NullPointerException))
3333
{
3434
return false;
3535
}
3636

37-
String origin = RECORD.origin();
37+
String origin = RECORD.ORIGIN();
3838

3939
return origin != null && origin.contains("<init>");
4040
}
4141

4242
private void logConstructorFailure(final ExceptionRecord RECORD)
4343
{
44-
System.err.println("[CONSTRUCTOR-NPE] " + Instant.now() + " | " + "Origin=" + RECORD.origin() + " | " + "Message=" + RECORD.exception().getMessage());
44+
System.err.println("[CONSTRUCTOR-NPE] " + Instant.now() + " | " + "Origin=" + RECORD.ORIGIN() + " | " + "Message=" + RECORD.EXCEPTION().getMessage());
4545
}
4646

4747
private void annotateForDiagnostics(final ExceptionRecord RECORD)

source/exceptions/PersistenceListener.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ public class PersistenceListener implements ExceptionListener
88
{
99
private static final int PRIORITY = 100;
1010

11-
private final String filePath;
11+
private final String FILEPATH;
1212

1313
public PersistenceListener(final String FILEPATH)
1414
{
15-
this.filePath = FILEPATH;
15+
this.FILEPATH = FILEPATH;
1616
}
1717

1818
@Override
@@ -29,9 +29,9 @@ public void onException(final ExceptionRecord RECORD)
2929

3030
private void writeRecordToFile(final ExceptionRecord RECORD)
3131
{
32-
try (FileWriter writer = new FileWriter(filePath, true))
32+
try (FileWriter writer = new FileWriter(FILEPATH, true))
3333
{
34-
writer.write("[EXCEPTION] " + Instant.now() + System.lineSeparator() + "Type: " + RECORD.exception().getClass().getName() + System.lineSeparator() + "Message: " + RECORD.exception().getMessage() + System.lineSeparator() + "Origin: " + RECORD.origin() + System.lineSeparator() + "StackTrace: " + RECORD.stackTrace() + System.lineSeparator() + "------------------------------------------------------------" + System.lineSeparator());
34+
writer.write("[EXCEPTION] " + Instant.now() + System.lineSeparator() + "Type: " + RECORD.EXCEPTION().getClass().getName() + System.lineSeparator() + "Message: " + RECORD.EXCEPTION().getMessage() + System.lineSeparator() + "Origin: " + RECORD.ORIGIN() + System.lineSeparator() + "StackTrace: " + RECORD.STACKTRACE() + System.lineSeparator() + "------------------------------------------------------------" + System.lineSeparator());
3535
}
3636
catch (IOException ioEx)
3737
{

source/exceptions/SecurityExceptionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void onException(final ExceptionRecord RECORD)
2727

2828
private boolean isSecurityEvent(final ExceptionRecord RECORD)
2929
{
30-
Throwable ex = RECORD.exception();
30+
Throwable ex = RECORD.EXCEPTION();
3131

3232
if (ex instanceof SecurityException)
3333
{
@@ -48,7 +48,7 @@ private boolean isSecurityEvent(final ExceptionRecord RECORD)
4848

4949
private void logSecurityEvent(final ExceptionRecord RECORD)
5050
{
51-
System.err.println("[SECURITY] " + Instant.now() + " | " + "Type=" + RECORD.exception().getClass().getSimpleName() + " | " + "Message=" + RECORD.exception().getMessage() + " | " + "Origin=" + RECORD.origin());
51+
System.err.println("[SECURITY] " + Instant.now() + " | " + "Type=" + RECORD.EXCEPTION().getClass().getSimpleName() + " | " + "Message=" + RECORD.EXCEPTION().getMessage() + " | " + "Origin=" + RECORD.ORIGIN());
5252
}
5353

5454
private void triggerSecurityAlert(final ExceptionRecord RECORD)

0 commit comments

Comments
 (0)