2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.apihandler.common;
25 import java.io.IOException;
26 import java.security.GeneralSecurityException;
28 import org.apache.http.HttpResponse;
29 import org.apache.http.client.ClientProtocolException;
30 import org.apache.http.client.HttpClient;
31 import org.onap.so.utils.CryptoUtils;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34 import org.springframework.core.env.Environment;
36 public abstract class RequestClient {
37 private static Logger logger = LoggerFactory.getLogger(RequestClient.class);
38 protected Environment props;
40 protected HttpClient client;
43 public RequestClient(int type){
47 public void setProps(Environment env) {
51 public void setUrl(String url) {
55 public String getUrl() {
63 public HttpClient getClient() {
67 public void setClient(HttpClient client) {
71 public abstract HttpResponse post(String request, String requestId, String requestTimeout, String schemaVersion, String serviceInstanceId, String action) throws IOException;
73 public abstract HttpResponse post(String request) throws ClientProtocolException, IOException;
75 public abstract HttpResponse post(RequestClientParameter parameterObject) throws ClientProtocolException, IOException;
77 public abstract HttpResponse get()
80 protected String decryptPropValue(String prop, String defaultValue, String encryptionKey) {
82 String result = CryptoUtils.decrypt(prop, encryptionKey);
85 catch (GeneralSecurityException e) {
86 logger.debug("Security exception", e);
91 protected String getEncryptedPropValue (String prop, String defaultValue, String encryptionKey) {
93 String result = CryptoUtils.decrypt(prop, encryptionKey);
96 catch (GeneralSecurityException e) {
97 logger.debug("Security exception", e);