+++ /dev/null
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SDNC-FEATURES
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-* ============LICENSE_END=========================================================
-*/
-package com.onap.sdnc.vnfbackupservice.scheduler;
-
-
-import java.util.Arrays;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
-
-
-@Service
-public class VnfRestClient {
-
- @Autowired
- private RestTemplate restTemplate;
-
- public String vnfRestClient(String url, String userName, String password) {
- restTemplate = new RestTemplate();
- HttpHeaders headers = new HttpHeaders();
- HttpEntity<String> entity = new HttpEntity<String>(generateHeaders(headers, userName, password));
- ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
- String result = response.getBody();
- return result;
- }
-
- public HttpHeaders generateHeaders(HttpHeaders headers, String userName, String password) {
- headers.setAccept(Arrays.asList(new MediaType[] { MediaType.APPLICATION_JSON }));
- headers.setContentType(MediaType.APPLICATION_JSON);
- String base64Username = userName + ":" + password;
- byte[] message = base64Username.getBytes();
- headers.set("Authorization", "Basic " + java.util.Base64.getEncoder().encodeToString(message));
- return headers;
- }
-}