2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.apihandler.common;
23 import java.io.IOException;
24 import java.security.GeneralSecurityException;
26 import org.apache.http.HttpResponse;
27 import org.apache.http.client.ClientProtocolException;
28 import org.apache.http.client.HttpClient;
29 import org.openecomp.mso.logger.MsoLogger;
30 import org.openecomp.mso.properties.MsoJavaProperties;
31 import org.openecomp.mso.utils.CryptoUtils;
33 public abstract class RequestClient {
34 private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
35 protected MsoJavaProperties props;
37 protected HttpClient client;
40 public RequestClient(int type){
44 public void setProps(MsoJavaProperties props) {
48 public void setUrl(String url) {
52 public String getUrl() {
60 public HttpClient getClient() {
64 public void setClient(HttpClient client) {
68 public abstract HttpResponse post(String request, String requestId, String requestTimeout, String schemaVersion, String serviceInstanceId, String action) throws ClientProtocolException, IOException;
70 public abstract HttpResponse post(String request) throws IOException;
72 public abstract HttpResponse post(RequestClientParamater params) throws IOException;
74 public abstract HttpResponse get() throws IOException;
76 protected String getEncryptedPropValue (String prop, String defaultValue, String encryptionKey) {
78 return CryptoUtils.decrypt(prop, encryptionKey);
80 catch (GeneralSecurityException e) {
81 msoLogger.debug("Security exception", e);