check for null usernamd and password 79/55279/1
authorSmokowski, Kevin (ks6305) <ks6305@att.com>
Fri, 22 Jun 2018 18:32:27 +0000 (18:32 +0000)
committerSmokowski, Kevin (ks6305) <ks6305@att.com>
Fri, 22 Jun 2018 18:33:23 +0000 (18:33 +0000)
only populate auth header if credentials are provided, this support was requested by a client

Change-Id: I2fb60995260506a29482d340a031dfad72348b8c
Issue-ID: CCSDK-310
Signed-off-by: Smokowski, Kevin (ks6305) <ks6305@att.com>
dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/MessageRouterHttpClient.java

index 234a202..d261d1c 100644 (file)
@@ -135,11 +135,14 @@ public class MessageRouterHttpClient implements SdncDmaapConsumer {
             Integer readTimeoutMinutes =
                     Integer.valueOf(baseProperties.getProperty("readTimeoutMinutes", DEFAULT_READ_TIMEOUT_MINUTES));
 
-            String authorizationString = buildAuthorizationString(username, password);
+            Builder builder = client.target(uri).request("application/json");
+            if (username != null && password != null && username.length() > 0 && password.length() > 0) {
+                String authorizationString = buildAuthorizationString(username, password);
+                builder.header("Authorization", authorizationString);
+            }
             this.uri = buildUri(topic, group, id, host, timeoutQueryParamValue, limit, filter);
             this.client = getClient(connectTimeoutSeconds, readTimeoutMinutes);
-            Builder builder =
-                    client.target(uri).request("application/json").header("Authorization", authorizationString);
+
             this.getMessages = builder.buildGet();
             this.fetchPause = Integer.valueOf(baseProperties.getProperty("fetchPause"));
             this.isReady = true;