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;
27 import org.apache.http.HttpResponse;
28 import org.apache.http.client.HttpClient;
29 import org.onap.so.utils.CryptoUtils;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32 import org.springframework.core.env.Environment;
34 public abstract class RequestClient {
35 private static Logger logger = LoggerFactory.getLogger(RequestClient.class);
36 protected Environment props;
38 protected HttpClient client;
41 public RequestClient(int type) {
45 public void setProps(Environment env) {
49 public void setUrl(String url) {
53 public String getUrl() {
57 public int getType() {
61 public HttpClient getClient() {
65 public void setClient(HttpClient client) {
69 public abstract HttpResponse post(String request, String requestId, String requestTimeout, String schemaVersion,
70 String serviceInstanceId, String action) throws IOException;
72 public abstract HttpResponse post(String request) throws IOException;
74 public abstract HttpResponse post(RequestClientParameter parameterObject) throws IOException;
76 public abstract HttpResponse get() throws IOException;
78 protected String getEncryptedPropValue(String prop, String defaultValue, String encryptionKey) {
80 return CryptoUtils.decrypt(prop, encryptionKey);
81 } catch (GeneralSecurityException e) {
82 logger.debug("Security exception", e);