37600f7b9de79423612e74c81b98536469ef568a
[vid.git] / vid-app-common / src / main / java / org / onap / vid / mso / rest / MsoRestClientNew.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2018 Nokia. All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.vid.mso.rest;
22
23 import com.google.common.collect.ImmutableMap;
24 import io.joshworks.restclient.http.HttpResponse;
25 import java.util.HashMap;
26 import java.util.Map;
27 import javax.ws.rs.core.HttpHeaders;
28 import javax.ws.rs.core.MediaType;
29 import org.apache.commons.codec.binary.Base64;
30 import org.eclipse.jetty.util.security.Password;
31 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
32 import org.onap.portalsdk.core.util.SystemProperties;
33 import org.onap.vid.changeManagement.MsoRequestDetails;
34 import org.onap.vid.changeManagement.RequestDetailsWrapper;
35 import org.onap.vid.client.SyncRestClient;
36 import org.onap.vid.model.RequestReferencesContainer;
37 import org.onap.vid.mso.*;
38
39 import java.text.DateFormat;
40 import java.text.SimpleDateFormat;
41 import java.util.Date;
42 import org.onap.vid.utils.Logging;
43
44
45 /**
46  * Created by pickjonathan on 21/06/2017.
47  */
48 public class MsoRestClientNew implements MsoInterface {
49
50     /**
51      * The Constant dateFormat.
52      */
53     public static final String X_FROM_APP_ID = "X-FromAppId";
54     final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
55     private static final String START = " start";
56     private final SyncRestClient client;
57     private final String baseUrl;
58     private final Map<String, String> commonHeaders;
59     /**
60      * The logger.
61      */
62     EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class);
63
64     public MsoRestClientNew(SyncRestClient client, String baseUrl) {
65         this.client = client;
66         this.baseUrl = baseUrl;
67         this.commonHeaders = initCommonHeaders();
68     }
69
70     @Override
71     public MsoResponseWrapper createSvcInstance(RequestDetails requestDetails, String endpoint) {
72         String methodName = "createSvcInstance ";
73         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
74         String path = baseUrl + endpoint;
75
76         return createInstance(requestDetails, path);
77     }
78     
79     @Override
80     public MsoResponseWrapper createE2eSvcInstance(Object requestDetails, String endpoint) {
81         String methodName = "createE2eSvcInstance ";
82         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
83         String path = baseUrl + endpoint;
84
85         return createInstance(requestDetails, path);
86     }
87
88     @Override
89     public MsoResponseWrapper createVnf(RequestDetails requestDetails, String endpoint) {
90
91         String methodName = "createVnf";
92         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
93         String path = baseUrl + endpoint;
94
95         return createInstance(requestDetails, path);
96     }
97
98     @Override
99     public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String endpoint) {
100
101         String methodName = "createNwInstance";
102         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
103         String path = baseUrl + endpoint;
104
105         return createInstance(requestDetails, path);
106     }
107
108     @Override
109     public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String endpoint) {
110         String methodName = "createVolumeGroupInstance";
111         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
112         String path = baseUrl + endpoint;
113
114         return createInstance(requestDetails, path);
115     }
116
117     @Override
118     public MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String endpoint) {
119         String methodName = "createVfModuleInstance";
120         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
121         String path = baseUrl + endpoint;
122
123         return createInstance(requestDetails, path);
124     }
125
126     @Override
127     public MsoResponseWrapper scaleOutVFModuleInstance(RequestDetailsWrapper requestDetailsWrapper, String endpoint) {
128         String methodName = "scaleOutVFModuleInstance";
129         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
130         String path = baseUrl + endpoint;
131         return createInstance(requestDetailsWrapper, path);
132     }
133
134     @Override
135     public MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String endpoint) {
136         String methodName = "createConfigurationInstance";
137         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
138         String path = baseUrl + endpoint;
139
140         return createInstance(requestDetailsWrapper, path);
141     }
142
143     @Override
144     public MsoResponseWrapper deleteE2eSvcInstance(Object requestDetails, String endpoint) {
145         String methodName = "deleteE2eSvcInstance";
146         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
147         String path = baseUrl + endpoint;
148         return deleteInstance(requestDetails, path);
149     }
150
151     @Override
152     public MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint) {
153         String methodName = "deleteSvcInstance";
154         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
155         String path = baseUrl + endpoint;
156         return deleteInstance(requestDetails, path);
157     }
158
159     @Override
160     public MsoResponseWrapper unassignSvcInstance(RequestDetails requestDetails, String endpoint) {
161         String methodName = "unassignSvcInstance";
162         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
163         HttpResponse<String> response = client.post(endpoint, commonHeaders, requestDetails, String.class);
164         return MsoUtil.wrapResponse(response);
165     }
166
167     @Override
168     public MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String endpoint) {
169         String methodName = "deleteVnf";
170         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
171         String path = baseUrl + endpoint;
172
173         return deleteInstance(requestDetails, path);
174     }
175
176     @Override
177     public MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String endpoint) {
178         String methodName = "deleteVfModule";
179         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
180         String path = baseUrl + endpoint;
181
182         return deleteInstance(requestDetails, path);
183     }
184
185     @Override
186     public MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String endpoint) {
187         String methodName = "deleteVolumeGroupInstance";
188         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
189         String path = baseUrl + endpoint;
190
191         return deleteInstance(requestDetails, path);
192     }
193
194     @Override
195     public MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String endpoint) {
196         String methodName = "deleteNwInstance";
197         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
198         String path = baseUrl + endpoint;
199
200         return deleteInstance(requestDetails, path);
201     }
202
203     @Override
204     public MsoResponseWrapper getOrchestrationRequest(String endpoint) {
205         String path = baseUrl + endpoint;
206
207         HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class);
208         return MsoUtil.wrapResponse(response);
209     }
210
211     public MsoResponseWrapper getManualTasks(String endpoint) {
212         String path = baseUrl + endpoint;
213
214         HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class);
215         return MsoUtil.wrapResponse(response);
216     }
217
218     public MsoResponseWrapper getOrchestrationRequestsForDashboard(String t, String sourceId, String path, RestObject restObject) {
219         String methodName = "getOrchestrationRequestsForDashboard";
220         logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START);
221
222         try {
223             MsoResponseWrapper w = getOrchestrationRequest(path);
224             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
225
226             return w;
227
228         } catch (Exception e) {
229             logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
230             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
231             throw e;
232         }
233     }
234
235     public MsoResponseWrapper getManualTasksByRequestId(String t, String sourceId, String endpoint, RestObject restObject) {
236         String methodName = "getManualTasksByRequestId";
237         logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START);
238
239         try {
240             String path = baseUrl + endpoint;
241
242             MsoResponseWrapper w =getManualTasks(path);
243             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
244
245             return w;
246
247         } catch (Exception e) {
248             logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
249             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
250             throw e;
251         }
252     }
253
254     @Override
255     public MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject restObject) {
256         String methodName = "completeManualTask";
257         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Complete ");
258         try {
259             String path = baseUrl + endpoint;
260
261             HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
262             MsoResponseWrapper w = MsoUtil.wrapResponse(response);
263
264             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
265             return w;
266
267         } catch (Exception e) {
268             logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
269             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
270             throw e;
271         }
272     }
273
274     @Override
275     public MsoResponseWrapper replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String endpoint) {
276         String methodName = "replaceVnf";
277         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
278         String path = baseUrl + endpoint;
279         return replaceInstance(requestDetails, path);
280     }
281
282     @Override
283     public MsoResponseWrapper deleteConfiguration(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String pmc_endpoint) {
284         String methodName = "deleteConfiguration";
285         logger.debug(EELFLoggerDelegate.debugLogger,
286                 dateFormat.format(new Date()) + "<== " + methodName + START);
287         String path = baseUrl + pmc_endpoint;
288
289         return deleteInstance(requestDetailsWrapper, path);
290     }
291
292     @Override
293     public MsoResponseWrapper setConfigurationActiveStatus(RequestDetails request, String endpoint) {
294         String methodName = "setConfigurationActiveStatus";
295         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
296
297         try {
298             String path = baseUrl + endpoint;
299
300             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== "
301                   + methodName + " calling change configuration active status, path =[" + path + "]");
302             HttpResponse<String> response = client.post(path, commonHeaders, request, String.class);
303             return MsoUtil.wrapResponse(response);
304         } catch (Exception e) {
305             logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
306             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
307             throw e;
308         }
309     }
310
311     @Override
312     public MsoResponseWrapper setPortOnConfigurationStatus(RequestDetails request, String endpoint) {
313         String methodName = "setPortOnConfigurationStatus";
314         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
315
316         try {
317             String path = baseUrl + endpoint;
318             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== "
319                 + methodName + " calling change port configuration status, path =[" + path + "]");
320             HttpResponse<String> response = client.post(path, commonHeaders, request, String.class);
321             return MsoUtil.wrapResponse(response);
322         } catch (Exception e) {
323             logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
324             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
325             throw e;
326         }
327     }
328
329     @Override
330     public MsoResponseWrapperInterface changeManagementUpdate(RequestDetailsWrapper requestDetails, String endpoint) {
331         String path = baseUrl + endpoint;
332         HttpResponse<RequestReferencesContainer> response = client.post(path, commonHeaders, requestDetails, RequestReferencesContainer.class);
333         return MsoUtil.wrapResponse(response);
334     }
335
336     public MsoResponseWrapper replaceInstance(org.onap.vid.changeManagement.RequestDetails request, String path) {
337         String methodName = "replaceInstance";
338         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
339
340         try {
341             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Replace VNF, path =[" + path + "]");
342
343             HttpResponse<String> response = client.post(path, commonHeaders, request, String.class);
344             MsoResponseWrapper msoResponseWrapperObject = MsoUtil.wrapResponse(response);
345             int status = msoResponseWrapperObject.getStatus();
346             if (status == 202) {
347                 logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName +
348                         ",post succeeded, msoResponseWrapperObject response:" + msoResponseWrapperObject.getResponse());
349             } else {
350                 logger.error(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName +
351                         ": post failed, msoResponseWrapperObject status" + status + ", response:" + msoResponseWrapperObject.getResponse());
352
353                 // TODO
354             }
355             return msoResponseWrapperObject;
356
357         } catch (Exception e) {
358             logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
359             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
360             throw e;
361         }
362
363     }
364
365     @Override
366     public MsoResponseWrapper updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String endpoint) {
367         String methodName = "updateVnf";
368         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
369         String path = baseUrl + endpoint;
370
371         RequestDetailsWrapper wrapper = new RequestDetailsWrapper();
372         wrapper.requestDetails = new MsoRequestDetails(requestDetails);
373         return updateInstance(requestDetails, path);
374     }
375
376     public MsoResponseWrapper updateInstance(org.onap.vid.changeManagement.RequestDetails request, String path) {
377         String methodName = "updateInstance";
378         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
379
380         try {
381             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]");
382
383             HttpResponse<String> response = client.post(path, commonHeaders, request, String.class);
384             MsoResponseWrapper w = MsoUtil.wrapResponse(response);
385
386             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
387             return w;
388
389         } catch (Exception e) {
390             logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
391             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
392             throw e;
393         }
394
395     }
396
397     public void setServiceInstanceStatus(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject<String> restObject) {
398         String methodName = "activateServiceInstance";
399         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start ");
400         try {
401             String path = baseUrl + endpoint;
402             HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
403             MsoResponseWrapper w = MsoUtil.wrapResponse(response);
404             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w =" + w.getResponse());
405
406         } catch (Exception e) {
407             logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
408             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
409             throw e;
410         }
411     }
412
413     @Override
414     public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String endpoint) {
415         String methodName = "removeRelationshipFromServiceInstance";
416         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
417
418         try {
419             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Remove relationship from service instance, path =[" + endpoint + "]");
420             String path = baseUrl + endpoint;
421             HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
422             return MsoUtil.wrapResponse(response);
423         } catch (Exception e) {
424             logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
425             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
426             throw e;
427         }
428     }
429
430     @Override
431     public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath) {
432         String methodName = "addRelationshipToServiceInstance";
433         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
434
435         try {
436             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Add relationship to service instance, path =[" + addRelationshipsPath + "]");
437             String path = baseUrl + addRelationshipsPath;
438
439             HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
440             return MsoUtil.wrapResponse(response);
441         } catch (Exception e) {
442             logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
443             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
444             throw e;
445         }
446     }
447
448     @Override
449     public <T> HttpResponse<T> get(String path, Class<T> responseClass) {
450         return client.get(path, commonHeaders, new HashMap<>(), responseClass);
451     }
452
453     @Override
454     public <T> HttpResponse<T> post(String path, RequestDetailsWrapper<?> requestDetailsWrapper,
455         Class<T> responseClass) {
456         return client.post(path, commonHeaders, requestDetailsWrapper, responseClass);
457     }
458
459
460     private MsoResponseWrapper createInstance(Object request, String endpoint) {
461         String methodName = "createInstance";
462         logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START);
463
464         try {
465             HttpResponse<String> response = client.post(endpoint, commonHeaders, request, String.class);
466             return MsoUtil.wrapResponse(response);
467         } catch (Exception e) {
468             logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
469             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
470             throw e;
471         }
472     }
473
474     /**
475      * Delete instance.
476      *
477      * @param request the request
478      * @param path    the path
479      * @return the mso response wrapper
480      * @throws Exception the exception
481      */
482     private MsoResponseWrapper deleteInstance(Object request, String path) {
483         String methodName = "deleteInstance";
484         logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
485
486         try {
487             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]");
488
489             HttpResponse<String> response = client.delete(path, commonHeaders, request, String.class);
490             MsoResponseWrapper w = MsoUtil.wrapResponse(response);
491
492             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
493             return w;
494
495         } catch (Exception e) {
496             logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
497             logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
498             throw e;
499         }
500
501     }
502
503     private Map<String, String> initCommonHeaders() {
504         String username = SystemProperties.getProperty(MsoProperties.MSO_USER_NAME);
505         String password = SystemProperties.getProperty(MsoProperties.MSO_PASSWORD);
506         String decrypted_password = Password.deobfuscate(password);
507
508         String authString = username + ":" + decrypted_password;
509
510         byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
511         String authStringEnc = new String(authEncBytes);
512
513         Map<String, String> map = new HashMap<>();
514         map.put(HttpHeaders.AUTHORIZATION,  "Basic " + authStringEnc);
515         map.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
516         map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
517         map.put(X_FROM_APP_ID, SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME));
518         map.put(SystemProperties.ECOMP_REQUEST_ID, Logging.extractOrGenerateRequestId());
519         return ImmutableMap.copyOf(map);
520     }
521
522 }