From a3c172f26798c97bf822312ffcfdede738e44853 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 16 May 2018 18:07:23 -0400 Subject: Fix authentication info in request to SO 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 --- .../main/java/org/onap/policy/so/SOManager.java | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'controlloop/common/model-impl/so/src/main') diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java index a40a2d10f..8190b1a54 100644 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java +++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java @@ -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 httpResponse = restManager.post(url, "policy", "policy", createAuthenticateHeaders(username, password), MEDIA_TYPE, soJson); + Pair 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 createAuthenticateHeaders(final String username, final String password) { - String auth = username + ":" + password; - - Map headers = new HashMap<>(); - byte[] encodedBytes = Base64.getEncoder().encode(auth.getBytes()); - headers.put("Accept", MEDIA_TYPE); - headers.put("Authorization", "Basic " + new String(encodedBytes)); - - return headers; - } } /** -- cgit 1.2.3-korg