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 javax.xml.bind.DatatypeConverter;
27 import org.apache.http.HttpResponse;
28 import org.apache.http.client.methods.HttpGet;
29 import org.apache.http.client.methods.HttpPost;
30 import org.apache.http.entity.StringEntity;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public class CamundaTaskClient extends RequestClient {
35 private static Logger logger = LoggerFactory.getLogger(CamundaTaskClient.class);
37 public CamundaTaskClient() {
38 super(CommonConstants.CAMUNDATASK);
42 public HttpResponse post(String jsonReq) throws IOException {
43 HttpPost post = new HttpPost(url);
44 logger.debug("Camunda Task url is: {}", url);
46 StringEntity input = new StringEntity(jsonReq);
47 input.setContentType(CommonConstants.CONTENT_TYPE_JSON);
49 String encryptedCredentials;
51 encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH);
52 if (encryptedCredentials != null) {
53 String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH,
54 props.getProperty(CommonConstants.ENCRYPTION_KEY_PROP));
55 if (userCredentials != null) {
56 post.addHeader("Authorization",
57 "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()));
62 post.setEntity(input);
63 return client.execute(post);
67 public HttpResponse post(String camundaReqXML, String requestId, String requestTimeout, String schemaVersion,
68 String serviceInstanceId, String action) {
69 throw new UnsupportedOperationException("Method not supported.");
73 public HttpResponse post(RequestClientParameter params) {
74 throw new UnsupportedOperationException("Method not supported.");
78 public HttpResponse get() throws IOException {
79 HttpGet get = new HttpGet(url);
80 logger.debug("Camunda Task url is: {}", url);
81 String encryptedCredentials;
83 encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH);
84 if (encryptedCredentials != null) {
85 String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH,
86 props.getProperty(CommonConstants.ENCRYPTION_KEY_PROP));
87 if (userCredentials != null) {
88 get.addHeader("Authorization",
89 "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes())));
93 return client.execute(get);