You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/09/05 18:30:42 UTC
[camel] 02/02: CAMEL-18461: camel-ahc-ws - Should mask sensitive url that contains api_key in logs
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit c77903146607606651c7df94997fe61d101e986e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Sep 5 20:29:58 2022 +0200
CAMEL-18461: camel-ahc-ws - Should mask sensitive url that contains api_key in logs
---
.../org/apache/camel/component/ahc/ws/WsEndpoint.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java
index 1f6bb579ca6..5f297acce29 100644
--- a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java
+++ b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java
@@ -28,6 +28,8 @@ import org.apache.camel.component.ahc.AhcEndpoint;
import org.apache.camel.spi.ExceptionHandler;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
+import org.apache.camel.util.SensitiveUtils;
+import org.apache.camel.util.URISupport;
import org.asynchttpclient.AsyncHttpClient;
import org.asynchttpclient.AsyncHttpClientConfig;
import org.asynchttpclient.DefaultAsyncHttpClient;
@@ -52,6 +54,7 @@ public class WsEndpoint extends AhcEndpoint {
private final Set<WsConsumer> consumers = new HashSet<>();
private final WsListener listener = new WsListener();
private transient WebSocket websocket;
+ private transient String sanitizedUri;
@UriParam(label = "producer")
private boolean useStreaming;
@@ -62,6 +65,15 @@ public class WsEndpoint extends AhcEndpoint {
super(endpointUri, component, null);
}
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+
+ if (getHttpUri() != null) {
+ sanitizedUri = URISupport.sanitizeUri(getHttpUri().toASCIIString());
+ }
+ }
+
@Override
public WsComponent getComponent() {
return (WsComponent) super.getComponent();
@@ -128,7 +140,7 @@ public class WsEndpoint extends AhcEndpoint {
public void connect() throws ExecutionException, InterruptedException {
String uri = getHttpUri().toASCIIString();
- LOG.debug("Connecting to {}", uri);
+ LOG.debug("Connecting to {}", sanitizedUri);
websocket = getClient().prepareGet(uri).execute(
new WebSocketUpgradeHandler.Builder()
.addWebSocketListener(listener).build())
@@ -139,7 +151,7 @@ public class WsEndpoint extends AhcEndpoint {
protected void doStop() throws Exception {
if (websocket != null && websocket.isOpen()) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Disconnecting from {}", getHttpUri().toASCIIString());
+ LOG.debug("Disconnecting from {}", sanitizedUri);
}
websocket.removeWebSocketListener(listener);
websocket.sendCloseFrame();
@@ -159,8 +171,7 @@ public class WsEndpoint extends AhcEndpoint {
void reConnect() throws ExecutionException, InterruptedException {
if (websocket == null || !websocket.isOpen()) {
- String uri = getHttpUri().toASCIIString();
- LOG.info("Reconnecting websocket: {}", uri);
+ LOG.info("Reconnecting websocket: {}", sanitizedUri);
connect();
}
}