Fix authentication info in request to SO 27/47927/3
authorJim Hahn <jrh3@att.com>
Wed, 16 May 2018 22:07:23 +0000 (18:07 -0400)
committerJim Hahn <jrh3@att.com>
Wed, 16 May 2018 22:12:02 +0000 (18:12 -0400)
The code was passing two different sets of credentials to the REST
manager, and the wrong one was taking precedence.  Modified the code
to only pass the correct set of credentials.
Updated license date.

Change-Id: I13e2db93a8eebbb0cd77fdfaca80125cd28a2553
Issue-ID: POLICY-800
Signed-off-by: Jim Hahn <jrh3@att.com>
controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java

index a40a2d1..8190b1a 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * so
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@ package org.onap.policy.so;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonSyntaxException;
 
-import java.util.Base64;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.Callable;
@@ -153,7 +152,7 @@ public final class SOManager {
             String soJson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create().toJson(request);
 
             netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, LINE_SEPARATOR, soJson);
-            Pair<Integer, String> httpResponse = restManager.post(url, "policy",    "policy", createAuthenticateHeaders(username, password), MEDIA_TYPE, soJson);
+            Pair<Integer, String> httpResponse = restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, soJson);
 
             // Process the response from SO
             SOResponse response =  waitForSOOperationCompletion(urlBase, username, password, url, httpResponse);
@@ -164,23 +163,6 @@ public final class SOManager {
             
             return response;
         }
-        
-        /**
-         * Create HTTP headers for authenticated requests to SO.
-         * @param username user name on SO
-         * @param password password on SO
-         * @return the HTTP headers
-         */
-        private Map<String, String> createAuthenticateHeaders(final String username, final String password) {
-            String auth = username + ":" + password;
-
-            Map<String, String> headers = new HashMap<>();
-            byte[] encodedBytes = Base64.getEncoder().encode(auth.getBytes());
-            headers.put("Accept", MEDIA_TYPE);
-            headers.put("Authorization", "Basic " + new String(encodedBytes));
-            
-            return headers;
-        }
     }
 
     /**