From e5c80e9f8e406a32b4e77235337816074b797e3a Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Wed, 22 Sep 2021 18:06:57 +0530 Subject: Fix failure to mount TLS devices when mounted via VES PNFRegistration Include redaction of sensitive information Issue-ID: CCSDK-3469 Signed-off-by: Ravi Pendurty Change-Id: I526df1f04d77b3b4ac382e8d920bb182c5461ccc Signed-off-by: Ravi Pendurty --- .../sdnr/wt/mountpointregistrar/impl/MessageClient.java | 17 ++++++++++++++++- .../mountpointregistrar/impl/PNFMountPointClient.java | 12 +++++------- .../test/TestPNFMountPointClient.java | 4 ++-- 3 files changed, 23 insertions(+), 10 deletions(-) (limited to 'sdnr/wt/mountpoint-registrar') diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MessageClient.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MessageClient.java index 534dbde1b..584982a5b 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MessageClient.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MessageClient.java @@ -18,6 +18,8 @@ import java.util.Base64; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPClient; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPResponse; import org.slf4j.Logger; @@ -86,7 +88,7 @@ public abstract class MessageClient extends BaseHTTPClient { public abstract boolean sendNotification(String message); protected boolean sendNotification(String message, SendMethod method, MessageType messageType) { - LOG.debug("In sendRequestNotification - {}-{}", method, message); + LOG.debug("In sendRequestNotification - {}-{}", method, redactMessage(message)); headerMap.put("Content-Type", "application/".concat(messageType.toString())); headerMap.put("Accept", "application/".concat(messageType.toString())); BaseHTTPResponse response; @@ -104,5 +106,18 @@ public abstract class MessageClient extends BaseHTTPClient { this.notificationUri = notificationUri; } + private String redactMessage(String message) { + String REGEX = ""; + if (message.contains(" REQUIRED_FIELDS_SSH = List.of(PROTOCOL, DEVICE_NAME, DEVICE_IP, DEVICE_PORT, USERNAME, PASSWORD); public static List REQUIRED_FIELDS_TLS = List.of(PROTOCOL, DEVICE_NAME, DEVICE_IP, DEVICE_PORT, USERNAME, KEY_ID); diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestPNFMountPointClient.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestPNFMountPointClient.java index 9db9071ef..0858a7faa 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestPNFMountPointClient.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestPNFMountPointClient.java @@ -43,8 +43,8 @@ public class TestPNFMountPointClient extends PNFMountPointClient { testClient = new TestPNFMountPointClient(); testClient.setAuthorization("admin", "admin"); Map payloadMap = PNFMountPointClient.createPNFNotificationPayloadMap( - "TEST 50001", "127.0.0.1", "TLS", "key_id", - "admin", "admin", "17380"); + "TEST 50001", "127.0.0.1", "17830", "TLS", + "admin", "admin", "key_id"); String msg = testClient.prepareMessageFromPayloadMap(payloadMap); assertTrue(testClient.sendNotification(msg)); -- cgit 1.2.3-korg