diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2021-09-22 18:06:57 +0530 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2021-09-23 15:37:59 +0000 |
commit | e5c80e9f8e406a32b4e77235337816074b797e3a (patch) | |
tree | 938d9794088d1c6c366f9f27c1b361b644fb9ed6 /sdnr/wt | |
parent | 0eaf2d56a8ac8de275cd80d3db38c02f110faa30 (diff) |
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 <ravi.pendurty@highstreet-technologies.com>
Change-Id: I526df1f04d77b3b4ac382e8d920bb182c5461ccc
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt')
3 files changed, 23 insertions, 10 deletions
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("<key-id")) { + REGEX = "(<key-id.*>)(.*)(<\\/key-id>)"; + } else if (message.contains("<password")) { + REGEX = "(<password.*>)(.*)(<\\/password>)"; + } else { + return message; + } + Pattern p = Pattern.compile(REGEX, Pattern.MULTILINE); + Matcher matcher = p.matcher(message); + return matcher.replaceAll("$1*********$3"); + } } diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java index 961f7fef3..169e43c47 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java @@ -19,15 +19,13 @@ package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl; -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.common.database.requests.BaseRequest; - +import static org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.MessageClient.MessageType.xml; +import static org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.MessageClient.SendMethod.PUT; import java.util.HashMap; import java.util.List; import java.util.Map; - -import static org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.MessageClient.MessageType.*; -import static org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.MessageClient.SendMethod.PUT; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.common.database.requests.BaseRequest; public class PNFMountPointClient extends MessageClient { @@ -35,7 +33,7 @@ public class PNFMountPointClient extends MessageClient { "restconf/config/network-topology:network-topology/topology/topology-netconf/node/"; public static final String DEVICE_NAME = "@device-name@", DEVICE_IP = "@device-ip@", DEVICE_PORT = "@device-port@", USERNAME = "@username@", PASSWORD = "@password@", KEY_ID = "@key-id@"; - private static final String PROTOCOL = "protocol"; + private static final String PROTOCOL = "protocol_sec"; public static List<String> REQUIRED_FIELDS_SSH = List.of(PROTOCOL, DEVICE_NAME, DEVICE_IP, DEVICE_PORT, USERNAME, PASSWORD); public static List<String> 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<String, String> 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)); |