2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.apihandler.common;
\r
23 import java.io.IOException;
\r
25 import javax.xml.bind.DatatypeConverter;
\r
27 import org.apache.http.HttpResponse;
\r
28 import org.apache.http.client.methods.HttpGet;
\r
29 import org.apache.http.client.methods.HttpPost;
\r
30 import org.apache.http.entity.StringEntity;
\r
31 import org.openecomp.mso.logger.MsoLogger;
\r
33 public class CamundaTaskClient extends RequestClient{
\r
34 private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
\r
36 public CamundaTaskClient() {
\r
37 super(CommonConstants.CAMUNDATASK);
\r
41 public HttpResponse post(String jsonReq) throws IOException{
\r
42 HttpPost post = new HttpPost(url);
\r
43 msoLogger.debug("Camunda Task url is: "+ url);
\r
45 StringEntity input = new StringEntity(jsonReq);
\r
46 input.setContentType(CommonConstants.CONTENT_TYPE_JSON);
\r
48 String encryptedCredentials;
\r
50 encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null);
\r
51 if(encryptedCredentials != null){
\r
52 String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY);
\r
53 if(userCredentials != null){
\r
54 post.addHeader("Authorization", "Basic " + DatatypeConverter
\r
55 .printBase64Binary(userCredentials.getBytes()));
\r
60 post.setEntity(input);
\r
61 return client.execute(post);
\r
65 public HttpResponse post(String camundaReqXML, String requestId,
\r
66 String requestTimeout, String schemaVersion, String serviceInstanceId, String action) {
\r
67 throw new UnsupportedOperationException("Method not supported.");
\r
71 public HttpResponse post(RequestClientParamater params) {
\r
72 throw new UnsupportedOperationException("Method not supported.");
\r
76 public HttpResponse get() throws IOException {
\r
77 HttpGet get = new HttpGet(url);
\r
78 msoLogger.debug("Camunda Task url is: "+ url);
\r
79 String encryptedCredentials;
\r
81 encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null);
\r
82 if(encryptedCredentials != null){
\r
83 String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY);
\r
84 if(userCredentials != null){
\r
85 get.addHeader("Authorization", "Basic " + new String(DatatypeConverter
\r
86 .printBase64Binary(userCredentials.getBytes())));
\r
90 return client.execute(get);
\r