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