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.onap.so.apihandler.common;
23 import java.io.IOException;
25 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.onap.so.logger.MsoLogger;
33 public class CamundaTaskClient extends RequestClient{
34 private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, CamundaTaskClient.class);
36 public CamundaTaskClient() {
37 super(CommonConstants.CAMUNDATASK);
41 public HttpResponse post(String jsonReq) throws IOException{
42 HttpPost post = new HttpPost(url);
43 msoLogger.debug("Camunda Task url is: "+ url);
45 StringEntity input = new StringEntity(jsonReq);
46 input.setContentType(CommonConstants.CONTENT_TYPE_JSON);
48 String encryptedCredentials;
50 encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH);
51 if(encryptedCredentials != null){
52 String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, props.getProperty(CommonConstants.ENCRYPTION_KEY_PROP));
53 if(userCredentials != null){
54 post.addHeader("Authorization", "Basic " + DatatypeConverter
55 .printBase64Binary(userCredentials.getBytes()));
60 post.setEntity(input);
61 return client.execute(post);
65 public HttpResponse post(String camundaReqXML, String requestId,
66 String requestTimeout, String schemaVersion, String serviceInstanceId, String action) {
67 throw new UnsupportedOperationException("Method not supported.");
71 public HttpResponse post(RequestClientParameter params) {
72 throw new UnsupportedOperationException("Method not supported.");
76 public HttpResponse get() throws IOException {
77 HttpGet get = new HttpGet(url);
78 msoLogger.debug("Camunda Task url is: "+ url);
79 String encryptedCredentials;
81 encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH);
82 if(encryptedCredentials != null){
83 String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, props.getProperty(CommonConstants.ENCRYPTION_KEY_PROP));
84 if(userCredentials != null){
85 get.addHeader("Authorization", "Basic " + new String(DatatypeConverter
86 .printBase64Binary(userCredentials.getBytes())));
90 return client.execute(get);