2  * ============LICENSE_START=======================================================
 
   3  *  Copyright (C) 2020 Ericsson. All rights reserved.
 
   4  * ================================================================================
 
   5  * Licensed under the Apache License, Version 2.0 (the "License");
 
   6  * you may not use this file except in compliance with the License.
 
   7  * You may obtain a copy of the License at
 
   9  *      http://www.apache.org/licenses/LICENSE-2.0
 
  11  * Unless required by applicable law or agreed to in writing, software
 
  12  * distributed under the License is distributed on an "AS IS" BASIS,
 
  13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  14  * See the License for the specific language governing permissions and
 
  15  * limitations under the License.
 
  17  * SPDX-License-Identifier: Apache-2.0
 
  18  * ============LICENSE_END=========================================================
 
  20 package org.onap.so.adapters.etsisol003adapter.pkgm.subscriptionmanagement;
 
  22 import static org.onap.so.adapters.etsisol003adapter.pkgm.extclients.vnfm.VnfmHttpServiceProviderConfiguration.VNFM_ADAPTER_HTTP_SERVICE_PROVIDER_BEAN;
 
  23 import java.nio.charset.StandardCharsets;
 
  24 import org.apache.commons.codec.binary.Base64;
 
  25 import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
 
  26 import org.onap.so.rest.service.HttpRestServiceProvider;
 
  27 import org.springframework.beans.factory.annotation.Autowired;
 
  28 import org.springframework.beans.factory.annotation.Qualifier;
 
  31  * A base class that can be extended by classes for providing notification services. Provides common methods that will
 
  32  * be useful to those classes.
 
  34  * @author Waqas Ikram (waqas.ikram@est.tech)
 
  35  * @author Andrew Lamb (andrew.a.lamb@est.tech)
 
  37 public abstract class AbstractNotificationServiceProvider {
 
  40     @Qualifier(VNFM_ADAPTER_HTTP_SERVICE_PROVIDER_BEAN)
 
  41     private HttpRestServiceProvider httpRestServiceProvider;
 
  43     protected HttpRestServiceProvider getHttpRestServiceProvider() {
 
  44         return httpRestServiceProvider;
 
  47     protected BasicHttpHeadersProvider getBasicHttpHeadersProviderWithBasicAuth(final String username,
 
  48             final String password) {
 
  49         final byte[] encodedAuth = getBasicAuth(username, password);
 
  50         final String authHeader = "Basic " + new String(encodedAuth);
 
  51         return new BasicHttpHeadersProvider(authHeader);
 
  54     protected byte[] getBasicAuth(final String username, final String password) {
 
  55         final String auth = username + ":" + password;
 
  56         return Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));