Skip to content

Commit 8580b77

Browse files
committed
add guardian security logging
1 parent 2869e5d commit 8580b77

29 files changed

+332
-82
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ dependency-reduced-pom.xml
55
.classpath
66
.settings/
77
.gradle/
8+
.vscode/
89

910
**/build/
1011

1112
*.iml
1213
.idea/
1314
**/bin/
14-
*~
1515
nb-configuration.xml
1616
nbactions.xml
1717
/common/nbproject/

common/src/main/java/com/tc/net/core/TCConnectionManagerImpl.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ public class TCConnectionManagerImpl implements TCConnectionManager {
7272
private final TCDirectByteBufferCache buffers = new TCDirectByteBufferCache(TCByteBufferFactory.getFixedBufferSize(), 16 * 1024);
7373

7474
public TCConnectionManagerImpl() {
75-
this("ConnectionMgr", 0, new ClearTextSocketEndpointFactory());
75+
this("ConnectionMgr", null, 0, new ClearTextSocketEndpointFactory());
7676
}
7777

78-
public TCConnectionManagerImpl(String name, int workerCommCount, SocketEndpointFactory socketEndpointFactory) {
79-
this.connEvents = new ConnectionEvents();
78+
public TCConnectionManagerImpl(String name, TCConnectionEventListener listener, int workerCommCount, SocketEndpointFactory socketEndpointFactory) {
79+
this.connEvents = new ConnectionEvents(listener);
8080
this.listenerEvents = new ListenerEvents();
8181
this.socketParams = new SocketParams();
8282
this.socketEndpointFactory = socketEndpointFactory;
@@ -269,18 +269,30 @@ private void checkShutdown() throws IOException {
269269
}
270270

271271
static class ConnectionEvents implements TCConnectionEventListener {
272+
private final TCConnectionEventListener subl;
273+
274+
public ConnectionEvents(TCConnectionEventListener subl) {
275+
this.subl = subl;
276+
}
277+
272278
@Override
273279
public final void connectEvent(TCConnectionEvent event) {
274280
if (logger.isDebugEnabled()) {
275281
logger.debug("connect event: " + event.toString());
276282
}
283+
if (subl != null) {
284+
subl.connectEvent(event);
285+
}
277286
}
278287

279288
@Override
280289
public final void closeEvent(TCConnectionEvent event) {
281290
if (logger.isDebugEnabled()) {
282291
logger.debug("close event: " + event.toString());
283292
}
293+
if (subl != null) {
294+
subl.closeEvent(event);
295+
}
284296
}
285297

286298
@Override
@@ -297,6 +309,9 @@ public final void errorEvent(TCConnectionErrorEvent event) {
297309
} else {
298310
logger.error("Exception: ", err);
299311
}
312+
if (subl != null) {
313+
subl.errorEvent(event);
314+
}
300315
}
301316
} finally {
302317
event.getSource().asynchClose();
@@ -308,7 +323,9 @@ public final void endOfFileEvent(TCConnectionEvent event) {
308323
if (logger.isDebugEnabled()) {
309324
logger.debug("EOF event: " + event.toString());
310325
}
311-
326+
if (subl != null) {
327+
subl.endOfFileEvent(event);
328+
}
312329
event.getSource().asynchClose();
313330
}
314331
}

common/src/main/java/com/tc/net/core/TCListener.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.tc.net.core;
1919

2020
import com.tc.net.core.event.TCListenerEventListener;
21-
import com.tc.util.TCTimeoutException;
2221

2322
import java.net.InetSocketAddress;
2423

common/src/main/java/com/tc/net/core/TCListenerImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.tc.net.core.event.TCListenerEventListener;
2727
import com.tc.net.protocol.ProtocolAdaptorFactory;
2828
import com.tc.util.Assert;
29-
import com.tc.util.TCTimeoutException;
3029
import com.tc.util.concurrent.SetOnceFlag;
3130
import com.tc.util.concurrent.TCExceptionResultException;
3231
import com.tc.util.concurrent.TCFuture;

common/src/test/java/com/tc/net/core/NoReconnectThreadTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private NetworkStackHarnessFactory getNetworkStackHarnessFactory() {
7878
}
7979

8080
private ClientMessageChannel createClientMsgCh() {
81-
TCConnectionManager connMgr = new TCConnectionManagerImpl("TestCommMgr-Client", 0, new ClearTextSocketEndpointFactory());
81+
TCConnectionManager connMgr = new TCConnectionManagerImpl("TestCommMgr-Client", null, 0, new ClearTextSocketEndpointFactory());
8282
clientConnectionMgrs.add(connMgr);
8383
CommunicationsManager clientComms = new CommunicationsManagerImpl(new NullMessageMonitor(),
8484
getNetworkStackHarnessFactory(),
@@ -91,7 +91,7 @@ private ClientMessageChannel createClientMsgCh() {
9191
}
9292

9393
public void testConnectionEstablisherThreadExit() throws Exception {
94-
TCConnectionManager connectionMgr = new TCConnectionManagerImpl("TestCommsMgr-Server", 3, new ClearTextSocketEndpointFactory());
94+
TCConnectionManager connectionMgr = new TCConnectionManagerImpl("TestCommsMgr-Server", null, 3, new ClearTextSocketEndpointFactory());
9595
CommunicationsManager serverCommsMgr = new CommunicationsManagerImpl(
9696
new NullMessageMonitor(),
9797
new TCMessageRouterImpl(),

common/src/test/java/com/tc/net/core/TCConnectionManagerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public class TCConnectionManagerTest extends TestCase {
4343
protected void setUp() throws Exception {
4444
super.setUp();
4545
TCPropertiesImpl.getProperties().overwriteTcPropertiesFromConfig(Collections.emptyMap());
46-
this.clientConnMgr = new TCConnectionManagerImpl("Client", 0, new ClearTextSocketEndpointFactory());
47-
this.serverConnMgr = new TCConnectionManagerImpl("Server", 0, new ClearTextSocketEndpointFactory());
46+
this.clientConnMgr = new TCConnectionManagerImpl("Client", null, 0, new ClearTextSocketEndpointFactory());
47+
this.serverConnMgr = new TCConnectionManagerImpl("Server", null, 0, new ClearTextSocketEndpointFactory());
4848
this.lsnr = this.serverConnMgr.createListener(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), new ProtocolAdaptorFactory() {
4949
@Override
5050
public TCProtocolAdaptor getInstance() {
@@ -203,7 +203,7 @@ public void testActiveClientConnections() throws Exception {
203203
}
204204

205205
public void testInActiveClientConnections() throws Exception {
206-
this.serverConnMgr = new TCConnectionManagerImpl("TestConnMgr", 0, new ClearTextSocketEndpointFactory());
206+
this.serverConnMgr = new TCConnectionManagerImpl("TestConnMgr", null, 0, new ClearTextSocketEndpointFactory());
207207
this.lsnr = this.serverConnMgr.createListener(new InetSocketAddress(0), new ProtocolAdaptorFactory() {
208208
@Override
209209
public TCProtocolAdaptor getInstance() {

common/src/test/java/com/tc/net/core/TCWorkerCommManagerTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public TCWorkerCommManagerTest() {
5858
}
5959

6060
private synchronized ClientMessageTransport createClient(String clientName) {
61-
TCConnectionManager connection = new TCConnectionManagerImpl("Client-TestCommMgr-" + clientName, 0, new ClearTextSocketEndpointFactory());
61+
TCConnectionManager connection = new TCConnectionManagerImpl("Client-TestCommMgr-" + clientName, null, 0, new ClearTextSocketEndpointFactory());
6262
clientConnectionMgrs.add(connection);
6363
CommunicationsManager commsMgr = new CommunicationsManagerImpl(new NullMessageMonitor(),
6464
new TransportNetworkStackHarnessFactory(),
@@ -99,7 +99,7 @@ protected void setUp() throws Exception {
9999
public void testSimpleOpenAndClose() throws Exception {
100100
// comms manager with 4 worker comms
101101
logger.debug("Running target test");
102-
TCConnectionManager connMgr = new TCConnectionManagerImpl("Target-Server-TestCommsMgr", 1, new ClearTextSocketEndpointFactory());
102+
TCConnectionManager connMgr = new TCConnectionManagerImpl("Target-Server-TestCommsMgr", null, 1, new ClearTextSocketEndpointFactory());
103103
CommunicationsManager commsMgr = new CommunicationsManagerImpl(new NullMessageMonitor(),
104104
new TransportNetworkStackHarnessFactory(),
105105
connMgr,
@@ -131,7 +131,7 @@ public void testSimpleOpenAndClose() throws Exception {
131131
}
132132

133133
public void testOverweight() throws Exception {
134-
TCConnectionManager connMgr = new TCConnectionManagerImpl("Target-Server-TestCommsMgr", 2, new ClearTextSocketEndpointFactory());
134+
TCConnectionManager connMgr = new TCConnectionManagerImpl("Target-Server-TestCommsMgr", null, 2, new ClearTextSocketEndpointFactory());
135135
CommunicationsManager commsMgr = new CommunicationsManagerImpl(new NullMessageMonitor(),
136136
new TransportNetworkStackHarnessFactory(),
137137
connMgr,
@@ -180,7 +180,7 @@ public void testOverweight() throws Exception {
180180
public void testReaderandWriterCommThread() throws Exception {
181181
// comms manager with 4 worker comms
182182
logger.debug("Running target test");
183-
TCConnectionManager connMgr = new TCConnectionManagerImpl("Target-Server-TestCommsMgr", 4, new ClearTextSocketEndpointFactory());
183+
TCConnectionManager connMgr = new TCConnectionManagerImpl("Target-Server-TestCommsMgr", null, 4, new ClearTextSocketEndpointFactory());
184184
CommunicationsManager commsMgr = new CommunicationsManagerImpl(new NullMessageMonitor(),
185185
new TransportNetworkStackHarnessFactory(),
186186
connMgr,
@@ -238,7 +238,7 @@ public void testReaderandWriterCommThread() throws Exception {
238238
}
239239

240240
public void testWorkerCommDistributionAfterClose() throws Exception {
241-
TCConnectionManager connMgr = new TCConnectionManagerImpl("Server-TestCommsMgr", 3, new ClearTextSocketEndpointFactory());
241+
TCConnectionManager connMgr = new TCConnectionManagerImpl("Server-TestCommsMgr", null, 3, new ClearTextSocketEndpointFactory());
242242
// comms manager with 3 worker comms
243243
CommunicationsManager commsMgr = new CommunicationsManagerImpl(new NullMessageMonitor(),
244244
getNetworkStackHarnessFactory(),
@@ -299,7 +299,7 @@ public void testWorkerCommDistributionAfterClose() throws Exception {
299299

300300
// @Ignore("this test expects add more weight from a thread not able to do it")
301301
public void testWorkerCommDistributionAfterAddMoreWeight() throws Exception {
302-
TCConnectionManager connMgr = new TCConnectionManagerImpl("Server-TestCommsMgr", 3, new ClearTextSocketEndpointFactory());
302+
TCConnectionManager connMgr = new TCConnectionManagerImpl("Server-TestCommsMgr", null, 3, new ClearTextSocketEndpointFactory());
303303
// comms manager with 3 worker comms
304304
CommunicationsManager commsMgr = new CommunicationsManagerImpl(new NullMessageMonitor(),
305305
getNetworkStackHarnessFactory(),
@@ -367,7 +367,7 @@ public void testWorkerCommDistributionAfterAddMoreWeight() throws Exception {
367367
}
368368

369369
private ClientMessageChannel createClientMsgCh() {
370-
TCConnectionManager connection = new TCConnectionManagerImpl("Client-TestCommMgr", 0, new ClearTextSocketEndpointFactory());
370+
TCConnectionManager connection = new TCConnectionManagerImpl("Client-TestCommMgr", null, 0, new ClearTextSocketEndpointFactory());
371371
clientConnectionMgrs.add(connection);
372372
CommunicationsManager clientComms = new CommunicationsManagerImpl(new NullMessageMonitor(),
373373
getNetworkStackHarnessFactory(),

common/src/test/java/com/tc/net/protocol/tcm/LazyHandshakeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ protected void setUp() throws Exception {
7777
}
7878

7979
private void lazySetUp(int proxyPort) {
80-
serverConn = new TCConnectionManagerImpl("Server-Connections", 0, new ClearTextSocketEndpointFactory());
81-
clientConn = new TCConnectionManagerImpl("Client-Connections", 0, new ClearTextSocketEndpointFactory());
80+
serverConn = new TCConnectionManagerImpl("Server-Connections", null, 0, new ClearTextSocketEndpointFactory());
81+
clientConn = new TCConnectionManagerImpl("Client-Connections", null, 0, new ClearTextSocketEndpointFactory());
8282
serverComms = new CommunicationsManagerImpl(new NullMessageMonitor(), new PlainNetworkStackHarnessFactory(),
8383
serverConn,
8484
new NullConnectionPolicy());

common/src/test/java/com/tc/net/protocol/tcm/MessageChannelTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ protected void setUp(ProductID product, NetworkStackHarnessFactory clientStackHa
107107
clientMessageRouter = new TCMessageRouterImpl();
108108
serverMessageRouter = new TCMessageRouterImpl();
109109
MessageMonitor mm = new NullMessageMonitor();
110-
clientConns = new TCConnectionManagerImpl("TestCommMgr-client", 0, new ClearTextSocketEndpointFactory());
110+
clientConns = new TCConnectionManagerImpl("TestCommMgr-client", null, 0, new ClearTextSocketEndpointFactory());
111111
clientComms = new CommunicationsManagerImpl(mm, clientMessageRouter,
112112
clientStackHarnessFactory, clientConns, new NullConnectionPolicy(),
113113
new DisabledHealthCheckerConfigImpl(), new TransportHandshakeErrorHandlerForL1(),
114114
Collections.<TCMessageType, Class<? extends TCAction>>emptyMap(),
115115
Collections.<TCMessageType, GeneratedMessageFactory>emptyMap());
116116

117-
serverConns = new TCConnectionManagerImpl("TestCommMgr-server", 0, new ClearTextSocketEndpointFactory());
117+
serverConns = new TCConnectionManagerImpl("TestCommMgr-server", null, 0, new ClearTextSocketEndpointFactory());
118118
serverComms = new CommunicationsManagerImpl(mm, serverMessageRouter,
119119
serverStackHarnessFactory, serverConns, new NullConnectionPolicy(),
120120
new DisabledHealthCheckerConfigImpl(), new TransportHandshakeErrorNullHandler(),
@@ -280,17 +280,17 @@ public void testClientSwitchOver() throws Exception {
280280

281281
MessageMonitor mm = new NullMessageMonitor();
282282

283-
clientConns = new TCConnectionManagerImpl("TestCommMgr-client-1", 0, new ClearTextSocketEndpointFactory());
283+
clientConns = new TCConnectionManagerImpl("TestCommMgr-client-1", null, 0, new ClearTextSocketEndpointFactory());
284284
clientComms = new CommunicationsManagerImpl(mm, new PlainNetworkStackHarnessFactory(),
285285
clientConns,
286286
new NullConnectionPolicy());
287287

288-
TCConnectionManager serverConns1 = new TCConnectionManagerImpl("TestCommMgr-server-1", 0, new ClearTextSocketEndpointFactory());
288+
TCConnectionManager serverConns1 = new TCConnectionManagerImpl("TestCommMgr-server-1", null, 0, new ClearTextSocketEndpointFactory());
289289
CommunicationsManagerImpl serverComms1 = new CommunicationsManagerImpl(mm,
290290
new PlainNetworkStackHarnessFactory(),
291291
serverConns1,
292292
new NullConnectionPolicy());
293-
TCConnectionManager serverConns2 = new TCConnectionManagerImpl("TestCommMgr-server-2", 0, new ClearTextSocketEndpointFactory());
293+
TCConnectionManager serverConns2 = new TCConnectionManagerImpl("TestCommMgr-server-2", null, 0, new ClearTextSocketEndpointFactory());
294294
CommunicationsManagerImpl serverComms2 = new CommunicationsManagerImpl(mm,
295295
new PlainNetworkStackHarnessFactory(),
296296
serverConns2, new NullConnectionPolicy());
@@ -301,7 +301,7 @@ public void testClientSwitchOver() throws Exception {
301301
addCommsMappingAndRouting(clientWatcher, serverWatcher, serverComms2);
302302
NetworkListener lsnr2 = getListener(clientWatcher, serverWatcher, false, serverComms2);
303303

304-
TCConnectionManager clientConns2 = new TCConnectionManagerImpl("TestCommMgr-client-2", 0, new ClearTextSocketEndpointFactory());
304+
TCConnectionManager clientConns2 = new TCConnectionManagerImpl("TestCommMgr-client-2", null, 0, new ClearTextSocketEndpointFactory());
305305
CommunicationsManager clComms = new CommunicationsManagerImpl(mm,
306306
new PlainNetworkStackHarnessFactory(),
307307
clientConns2, new NullConnectionPolicy());

common/src/test/java/com/tc/net/protocol/tcm/NetworkListenerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class NetworkListenerTest extends TestCase {
4949
@Override
5050
public void setUp() throws Exception {
5151
super.setUp();
52-
connMgr = new TCConnectionManagerImpl("TestCommMgr", 0, new ClearTextSocketEndpointFactory());
52+
connMgr = new TCConnectionManagerImpl("TestCommMgr", null, 0, new ClearTextSocketEndpointFactory());
5353
commsMgr = new CommunicationsManagerImpl(new NullMessageMonitor(),
5454
new PlainNetworkStackHarnessFactory(), connMgr, new NullConnectionPolicy());
5555
}

0 commit comments

Comments
 (0)