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.ClientProtocolException;
29 import org.apache.http.client.HttpClient;
30 import org.onap.so.utils.CryptoUtils;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33 import org.springframework.core.env.Environment;
35 public abstract class RequestClient {
36 private static Logger logger = LoggerFactory.getLogger(RequestClient.class);
37 protected Environment props;
39 protected HttpClient client;
42 public RequestClient(int type) {
46 public void setProps(Environment env) {
50 public void setUrl(String url) {
54 public String getUrl() {
58 public int getType() {
62 public HttpClient getClient() {
66 public void setClient(HttpClient client) {
70 public abstract HttpResponse post(String request, String requestId, String requestTimeout, String schemaVersion,
71 String serviceInstanceId, String action) throws IOException;
73 public abstract HttpResponse post(String request) throws ClientProtocolException, IOException;
75 public abstract HttpResponse post(RequestClientParameter parameterObject)
76 throws ClientProtocolException, IOException;
78 public abstract HttpResponse get() throws IOException;
80 protected String decryptPropValue(String prop, String defaultValue, String encryptionKey) {
82 String result = CryptoUtils.decrypt(prop, encryptionKey);
84 } catch (GeneralSecurityException e) {
85 logger.debug("Security exception", e);
90 protected String getEncryptedPropValue(String prop, String defaultValue, String encryptionKey) {
92 String result = CryptoUtils.decrypt(prop, encryptionKey);
94 } catch (GeneralSecurityException e) {
95 logger.debug("Security exception", e);