Fixing dmaap authentication exception 77/7377/2
authorPatrick Brady <pb071s@att.com>
Fri, 11 Aug 2017 18:41:51 +0000 (11:41 -0700)
committerPatrick Brady <pb071s@att.com>
Fri, 11 Aug 2017 19:20:42 +0000 (12:20 -0700)
Dmaap http client was incorrectly throwing an exception if
no authetication was present. This should not be since
dmaap does not require authentication.

Change-Id: If90ce1e52bf226bacc5a6c57bfe8aaa98e583bc5
Signed-off-by: Patrick Brady <pb071s@att.com>
Issue-Id: APPC-135

appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/CommonHttpClient.java

index ed2f13f..cd42e9d 100644 (file)
@@ -50,23 +50,19 @@ public class CommonHttpClient {
     }
 
     public HttpGet getReq(URI uri, int timeoutMs) throws Exception {
-        if (AUTH_STR == null) {
-            throw new Exception("All DMaaP requests require authentication and none was provided.");
-        }
-
         HttpGet out = (uri == null) ? new HttpGet() : new HttpGet(uri);
-        out.setHeader("Authorization", String.format("Basic %s", AUTH_STR));
+        if (AUTH_STR != null) {
+            out.setHeader("Authorization", String.format("Basic %s", AUTH_STR));
+        }
         out.setConfig(getConfig(timeoutMs));
         return out;
     }
 
     public HttpPost postReq(String url) throws Exception {
-        if (AUTH_STR == null) {
-            throw new Exception("All DMaaP requests require authentication and none was provided.");
-        }
-
         HttpPost out = (url == null) ? new HttpPost() : new HttpPost(url);
-        out.setHeader("Authorization", String.format("Basic %s", AUTH_STR));
+        if (AUTH_STR != null) {
+            out.setHeader("Authorization", String.format("Basic %s", AUTH_STR));
+        }
         out.setConfig(getConfig(0));
         return out;
     }