Better support for timeouts in RestApiCallNode
[ccsdk/sli/plugins.git] / restapi-call-node / provider / src / main / java / org / onap / ccsdk / sli / plugins / restapicall / RestapiCallNode.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                      reserved.
7  * Modifications Copyright © 2018 IBM.
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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=========================================================
21  */
22
23 package org.onap.ccsdk.sli.plugins.restapicall;
24
25 import static java.lang.Boolean.valueOf;
26 import static javax.ws.rs.client.Entity.entity;
27 import static org.onap.ccsdk.sli.plugins.restapicall.AuthType.fromString;
28 import java.io.File;
29 import java.io.FileInputStream;
30 import java.io.IOException;
31 import java.net.SocketException;
32 import java.net.URI;
33 import java.nio.file.Files;
34 import java.nio.file.Paths;
35 import java.security.KeyStore;
36 import java.util.ArrayList;
37 import java.util.Collections;
38 import java.util.HashMap;
39 import java.util.HashSet;
40 import java.util.Iterator;
41 import java.util.List;
42 import java.util.Map;
43 import java.util.Map.Entry;
44 import java.util.Properties;
45 import java.util.Set;
46 import javax.net.ssl.HttpsURLConnection;
47 import javax.net.ssl.KeyManagerFactory;
48 import javax.net.ssl.SSLContext;
49 import javax.ws.rs.ProcessingException;
50 import javax.ws.rs.client.Client;
51 import javax.ws.rs.client.ClientBuilder;
52 import javax.ws.rs.client.Entity;
53 import javax.ws.rs.client.Invocation;
54 import javax.ws.rs.client.WebTarget;
55 import javax.ws.rs.core.EntityTag;
56 import javax.ws.rs.core.Feature;
57 import javax.ws.rs.core.MediaType;
58 import javax.ws.rs.core.MultivaluedMap;
59 import javax.ws.rs.core.Response;
60 import org.apache.commons.lang3.StringUtils;
61 import org.codehaus.jettison.json.JSONException;
62 import org.codehaus.jettison.json.JSONObject;
63 import org.glassfish.jersey.client.ClientProperties;
64 import org.glassfish.jersey.client.HttpUrlConnectorProvider;
65 import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
66 import org.glassfish.jersey.client.oauth1.ConsumerCredentials;
67 import org.glassfish.jersey.client.oauth1.OAuth1ClientSupport;
68 import org.glassfish.jersey.media.multipart.MultiPart;
69 import org.glassfish.jersey.media.multipart.MultiPartFeature;
70 import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
71 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
72 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
73 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
74 import org.slf4j.Logger;
75 import org.slf4j.LoggerFactory;
76
77 public class RestapiCallNode implements SvcLogicJavaPlugin {
78
79     protected static final String PARTNERS_FILE_NAME = "partners.json";
80     protected static final String UEB_PROPERTIES_FILE_NAME = "ueb.properties";
81     protected static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties";
82     protected static final String PROPERTIES_DIR_KEY = "SDNC_CONFIG_DIR";
83     protected static final int DEFAULT_HTTP_CONNECT_TIMEOUT_MS = 30000; // 30 seconds
84     protected static final int DEFAULT_HTTP_READ_TIMEOUT_MS = 600000; // 10 minutes
85
86     private static final Logger log = LoggerFactory.getLogger(RestapiCallNode.class);
87     private String uebServers;
88     private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json";
89
90     private String responseReceivedMessage = "Response received. Time: {}";
91     private String responseHttpCodeMessage = "HTTP response code: {}";
92     private String requestPostingException = "Exception while posting http request to client ";
93     protected static final String skipSendingMessage = "skipSending";
94     protected static final String responsePrefix = "responsePrefix";
95     protected static final String restapiUrlString = "restapiUrl";
96     protected static final String restapiUserKey = "restapiUser";
97     protected static final String restapiPasswordKey = "restapiPassword";
98     protected Integer httpConnectTimeout;
99     protected Integer httpReadTimeout;
100     
101     protected HashMap<String, PartnerDetails> partnerStore;
102
103     public RestapiCallNode() {
104         String configDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR);
105         try {
106             String jsonString = readFile(configDir + "/" + PARTNERS_FILE_NAME);
107             JSONObject partners = new JSONObject(jsonString);
108             partnerStore = new HashMap<>();
109             loadPartners(partners);
110             log.info("Partners support enabled");
111         } catch (Exception e) {
112             log.warn("Partners file could not be read, Partner support will not be enabled.", e);
113         }
114
115         try (FileInputStream in = new FileInputStream(configDir + "/" + UEB_PROPERTIES_FILE_NAME)) {
116             Properties props = new Properties();
117             props.load(in);
118             uebServers = props.getProperty("servers");
119             log.info("UEB support enabled");
120         } catch (Exception e) {
121             log.warn("UEB properties could not be read, UEB support will not be enabled.", e);
122         }
123         httpConnectTimeout = readOptionalInteger("HTTP_CONNECT_TIMEOUT_MS",DEFAULT_HTTP_CONNECT_TIMEOUT_MS);
124         httpReadTimeout = readOptionalInteger("HTTP_READ_TIMEOUT_MS",DEFAULT_HTTP_READ_TIMEOUT_MS);       
125     }
126
127     protected void loadPartners(JSONObject partners) {
128         Iterator<String> keys = partners.keys();
129         String partnerUserKey = "user";
130         String partnerPasswordKey = "password";
131         String partnerUrlKey = "url";
132
133         while (keys.hasNext()) {
134             String partnerKey = keys.next();
135             try {
136                 JSONObject partnerObject = (JSONObject) partners.get(partnerKey);
137                 if (partnerObject.has(partnerUserKey) && partnerObject.has(partnerPasswordKey)) {
138                     String url = null;
139                     if (partnerObject.has(partnerUrlKey)) {
140                         url = partnerObject.getString(partnerUrlKey);
141                     }
142                     String userName = partnerObject.getString(partnerUserKey);
143                     String password = partnerObject.getString(partnerPasswordKey);
144                     PartnerDetails details = new PartnerDetails(userName, password, url);
145                     partnerStore.put(partnerKey, details);
146                     log.info("mapped partner using partner key " + partnerKey);
147                 } else {
148                     log.info("Partner " + partnerKey + " is missing required keys, it won't be mapped");
149                 }
150             } catch (JSONException e) {
151                 log.info("Couldn't map the partner using partner key " + partnerKey, e);
152             }
153         }
154     }
155
156     /**
157      * Returns parameters from the parameter map.
158      *
159      * @param paramMap parameter map
160      * @param p parameters instance
161      * @return parameters filed instance
162      * @throws SvcLogicException when svc logic exception occurs
163      */
164     public static Parameters getParameters(Map<String, String> paramMap, Parameters p) throws SvcLogicException {
165
166         p.templateFileName = parseParam(paramMap, "templateFileName", false, null);
167         p.requestBody = parseParam(paramMap, "requestBody", false, null);
168         p.restapiUrl = parseParam(paramMap, restapiUrlString, true, null);
169         validateUrl(p.restapiUrl);
170         p.restapiUrlSuffix = parseParam(paramMap, "restapiUrlSuffix", false, null);
171         p.restapiUser = parseParam(paramMap, restapiUserKey, false, null);
172         p.restapiPassword = parseParam(paramMap, restapiPasswordKey, false, null);
173         if (p.restapiUrlSuffix != null) {
174             p.restapiUrl = p.restapiUrl + p.restapiUrlSuffix;
175             validateUrl(p.restapiUrl);
176         }
177         p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", false, null);
178         p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", false, null);
179         p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", false, null);
180         p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null);
181         p.contentType = parseParam(paramMap, "contentType", false, null);
182         p.format = Format.fromString(parseParam(paramMap, "format", false, "json"));
183         p.authtype = fromString(parseParam(paramMap, "authType", false, "unspecified"));
184         p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post"));
185         p.responsePrefix = parseParam(paramMap, responsePrefix, false, null);
186         p.listNameList = getListNameList(paramMap);
187         String skipSendingStr = paramMap.get(skipSendingMessage);
188         p.skipSending = "true".equalsIgnoreCase(skipSendingStr);
189         p.convertResponse = valueOf(parseParam(paramMap, "convertResponse", false, "true"));
190         p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", false, null);
191         p.trustStorePassword = parseParam(paramMap, "trustStorePassword", false, null);
192         p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", false, null);
193         p.keyStorePassword = parseParam(paramMap, "keyStorePassword", false, null);
194         p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null && p.keyStoreFileName != null
195                 && p.keyStorePassword != null;
196         p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null);
197         p.partner = parseParam(paramMap, "partner", false, null);
198         p.dumpHeaders = valueOf(parseParam(paramMap, "dumpHeaders", false, null));
199         p.returnRequestPayload = valueOf(parseParam(paramMap, "returnRequestPayload", false, null));
200         p.accept = parseParam(paramMap, "accept", false, null);
201         p.multipartFormData = valueOf(parseParam(paramMap, "multipartFormData", false, "false"));
202         p.multipartFile = parseParam(paramMap, "multipartFile", false, null);
203         return p;
204     }
205
206     /**
207      * Validates the given URL in the parameters.
208      *
209      * @param restapiUrl rest api URL
210      * @throws SvcLogicException when URL validation fails
211      */
212     private static void validateUrl(String restapiUrl) throws SvcLogicException {
213         if (restapiUrl.contains(",")) {
214             String[] urls = restapiUrl.split(",");
215             for (String url : urls) {
216                 validateUrl(url);
217             }
218         } else {
219             try {
220                 URI.create(restapiUrl);
221             } catch (IllegalArgumentException e) {
222                 throw new SvcLogicException("Invalid input of url " + e.getLocalizedMessage(), e);
223             }
224         }
225     }
226
227     /**
228      * Returns the list of list name.
229      *
230      * @param paramMap parameters map
231      * @return list of list name
232      */
233     private static Set<String> getListNameList(Map<String, String> paramMap) {
234         Set<String> ll = new HashSet<>();
235         for (Map.Entry<String, String> entry : paramMap.entrySet()) {
236             if (entry.getKey().startsWith("listName")) {
237                 ll.add(entry.getValue());
238             }
239         }
240         return ll;
241     }
242
243     /**
244      * Parses the parameter string map of property, validates if required, assigns default value if
245      * present and returns the value.
246      *
247      * @param paramMap string param map
248      * @param name name of the property
249      * @param required if value required
250      * @param def default value
251      * @return value of the property
252      * @throws SvcLogicException if required parameter value is empty
253      */
254     public static String parseParam(Map<String, String> paramMap, String name, boolean required, String def)
255             throws SvcLogicException {
256         String s = paramMap.get(name);
257
258         if (s == null || s.trim().length() == 0) {
259             if (!required) {
260                 return def;
261             }
262             throw new SvcLogicException("Parameter " + name + " is required in RestapiCallNode");
263         }
264
265         s = s.trim();
266         StringBuilder value = new StringBuilder();
267         int i = 0;
268         int i1 = s.indexOf('%');
269         while (i1 >= 0) {
270             int i2 = s.indexOf('%', i1 + 1);
271             if (i2 < 0) {
272                 break;
273             }
274
275             String varName = s.substring(i1 + 1, i2);
276             String varValue = System.getenv(varName);
277             if (varValue == null) {
278                 varValue = "%" + varName + "%";
279             }
280
281             value.append(s.substring(i, i1));
282             value.append(varValue);
283
284             i = i2 + 1;
285             i1 = s.indexOf('%', i);
286         }
287         value.append(s.substring(i));
288
289         log.info("Parameter {}: [{}]", name, maskPassword(name, value));
290
291         return value.toString();
292     }
293
294     private static Object maskPassword(String name, Object value) {
295         String[] pwdNames = {"pwd", "passwd", "password", "Pwd", "Passwd", "Password"};
296         for (String pwdName : pwdNames) {
297             if (name.contains(pwdName)) {
298                 return "**********";
299             }
300         }
301         return value;
302     }
303
304     /**
305      * Allows Directed Graphs the ability to interact with REST APIs.
306      *
307      * @param paramMap HashMap<String,String> of parameters passed by the DG to this function
308      *        <table border="1">
309      *        <thead>
310      *        <th>parameter</th>
311      *        <th>Mandatory/Optional</th>
312      *        <th>description</th>
313      *        <th>example values</th></thead> <tbody>
314      *        <tr>
315      *        <td>templateFileName</td>
316      *        <td>Optional</td>
317      *        <td>full path to template file that can be used to build a request</td>
318      *        <td>/sdncopt/bvc/restapi/templates/vnf_service-configuration-operation_minimal.json</td>
319      *        </tr>
320      *        <tr>
321      *        <td>restapiUrl</td>
322      *        <td>Mandatory</td>
323      *        <td>url to send the request to</td>
324      *        <td>https://sdncodl:8543/restconf/operations/L3VNF-API:create-update-vnf-request</td>
325      *        </tr>
326      *        <tr>
327      *        <td>restapiUser</td>
328      *        <td>Optional</td>
329      *        <td>user name to use for http basic authentication</td>
330      *        <td>sdnc_ws</td>
331      *        </tr>
332      *        <tr>
333      *        <td>restapiPassword</td>
334      *        <td>Optional</td>
335      *        <td>unencrypted password to use for http basic authentication</td>
336      *        <td>plain_password</td>
337      *        </tr>
338      *        <tr>
339      *        <td>oAuthConsumerKey</td>
340      *        <td>Optional</td>
341      *        <td>Consumer key to use for http oAuth authentication</td>
342      *        <td>plain_key</td>
343      *        </tr>
344      *        <tr>
345      *        <td>oAuthConsumerSecret</td>
346      *        <td>Optional</td>
347      *        <td>Consumer secret to use for http oAuth authentication</td>
348      *        <td>plain_secret</td>
349      *        </tr>
350      *        <tr>
351      *        <td>oAuthSignatureMethod</td>
352      *        <td>Optional</td>
353      *        <td>Consumer method to use for http oAuth authentication</td>
354      *        <td>method</td>
355      *        </tr>
356      *        <tr>
357      *        <td>oAuthVersion</td>
358      *        <td>Optional</td>
359      *        <td>Version http oAuth authentication</td>
360      *        <td>version</td>
361      *        </tr>
362      *        <tr>
363      *        <td>contentType</td>
364      *        <td>Optional</td>
365      *        <td>http content type to set in the http header</td>
366      *        <td>usually application/json or application/xml</td>
367      *        </tr>
368      *        <tr>
369      *        <td>format</td>
370      *        <td>Optional</td>
371      *        <td>should match request body format</td>
372      *        <td>json or xml</td>
373      *        </tr>
374      *        <tr>
375      *        <td>httpMethod</td>
376      *        <td>Optional</td>
377      *        <td>http method to use when sending the request</td>
378      *        <td>get post put delete patch</td>
379      *        </tr>
380      *        <tr>
381      *        <td>responsePrefix</td>
382      *        <td>Optional</td>
383      *        <td>location the response will be written to in context memory</td>
384      *        <td>tmp.restapi.result</td>
385      *        </tr>
386      *        <tr>
387      *        <td>listName[i]</td>
388      *        <td>Optional</td>
389      *        <td>Used for processing XML responses with repeating
390      *        elements.</td>vpn-information.vrf-details
391      *        <td></td>
392      *        </tr>
393      *        <tr>
394      *        <td>skipSending</td>
395      *        <td>Optional</td>
396      *        <td></td>
397      *        <td>true or false</td>
398      *        </tr>
399      *        <tr>
400      *        <td>convertResponse</td>
401      *        <td>Optional</td>
402      *        <td>whether the response should be converted</td>
403      *        <td>true or false</td>
404      *        </tr>
405      *        <tr>
406      *        <td>customHttpHeaders</td>
407      *        <td>Optional</td>
408      *        <td>a list additional http headers to be passed in, follow the format in the example</td>
409      *        <td>X-CSI-MessageId=messageId,headerFieldName=headerFieldValue</td>
410      *        </tr>
411      *        <tr>
412      *        <td>dumpHeaders</td>
413      *        <td>Optional</td>
414      *        <td>when true writes http header content to context memory</td>
415      *        <td>true or false</td>
416      *        </tr>
417      *        <tr>
418      *        <td>partner</td>
419      *        <td>Optional</td>
420      *        <td>used to retrieve username, password and url if partner store exists</td>
421      *        <td>aaf</td>
422      *        </tr>
423      *        <tr>
424      *        <td>returnRequestPayload</td>
425      *        <td>Optional</td>
426      *        <td>used to return payload built in the request</td>
427      *        <td>true or false</td>
428      *        </tr>
429      *        </tbody>
430      *        </table>
431      * @param ctx Reference to context memory
432      * @throws SvcLogicException
433      * @since 11.0.2
434      * @see String#split(String, int)
435      */
436     public void sendRequest(Map<String, String> paramMap, SvcLogicContext ctx) throws SvcLogicException {
437         sendRequest(paramMap, ctx, null);
438     }
439
440     protected void sendRequest(Map<String, String> paramMap, SvcLogicContext ctx, RetryPolicy retryPolicy)
441             throws SvcLogicException {
442
443         HttpResponse r = new HttpResponse();
444         try {
445             handlePartner(paramMap);
446             Parameters p = getParameters(paramMap, new Parameters());
447             if (p.restapiUrl.contains(",") && retryPolicy == null) {
448                 String[] urls = p.restapiUrl.split(",");
449                 retryPolicy = new RetryPolicy(urls, urls.length * 2);
450                 p.restapiUrl = urls[0];
451             }
452             String pp = p.responsePrefix != null ? p.responsePrefix + '.' : "";
453
454             String req = null;
455             if (p.templateFileName != null) {
456                 String reqTemplate = readFile(p.templateFileName);
457                 req = buildXmlJsonRequest(ctx, reqTemplate, p.format);
458             } else if (p.requestBody != null) {
459                 req = p.requestBody;
460             }
461             r = sendHttpRequest(req, p);
462             setResponseStatus(ctx, p.responsePrefix, r);
463
464             if (p.dumpHeaders && r.headers != null) {
465                 for (Entry<String, List<String>> a : r.headers.entrySet()) {
466                     ctx.setAttribute(pp + "header." + a.getKey(), StringUtils.join(a.getValue(), ","));
467                 }
468             }
469
470             if (p.returnRequestPayload && req != null) {
471                 ctx.setAttribute(pp + "httpRequest", req);
472             }
473
474             if (r.body != null && r.body.trim().length() > 0) {
475                 ctx.setAttribute(pp + "httpResponse", r.body);
476
477                 if (p.convertResponse) {
478                     Map<String, String> mm = null;
479                     if (p.format == Format.XML) {
480                         mm = XmlParser.convertToProperties(r.body, p.listNameList);
481                     } else if (p.format == Format.JSON) {
482                         mm = JsonParser.convertToProperties(r.body);
483                     }
484
485                     if (mm != null) {
486                         for (Map.Entry<String, String> entry : mm.entrySet()) {
487                             ctx.setAttribute(pp + entry.getKey(), entry.getValue());
488                         }
489                     }
490                 }
491             }
492         } catch (SvcLogicException e) {
493             boolean shouldRetry = false;
494             if (e.getCause().getCause() instanceof SocketException) {
495                 shouldRetry = true;
496             }
497
498             log.error("Error sending the request: " + e.getMessage(), e);
499             String prefix = parseParam(paramMap, responsePrefix, false, null);
500             if (retryPolicy == null || !shouldRetry) {
501                 setFailureResponseStatus(ctx, prefix, e.getMessage(), r);
502             } else {
503                 log.debug(retryPolicy.getRetryMessage());
504                 try {
505                     // calling getNextHostName increments the retry count so it should be called before shouldRetry
506                     String retryString = retryPolicy.getNextHostName();
507                     if (retryPolicy.shouldRetry()) {
508                         paramMap.put(restapiUrlString, retryString);
509                         log.debug("retry attempt {} will use the retry url {}", retryPolicy.getRetryCount(),
510                                 retryString);
511                         sendRequest(paramMap, ctx, retryPolicy);
512                     } else {
513                         log.debug("Maximum retries reached, won't attempt to retry. Calling setFailureResponseStatus.");
514                         setFailureResponseStatus(ctx, prefix, e.getMessage(), r);
515                     }
516                 } catch (Exception ex) {
517                     String retryErrorMessage = "Retry attempt " + retryPolicy.getRetryCount()
518                             + "has failed with error message " + ex.getMessage();
519                     setFailureResponseStatus(ctx, prefix, retryErrorMessage, r);
520                 }
521             }
522         }
523
524         if (r != null && r.code >= 300) {
525             throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message);
526         }
527     }
528
529     protected void handlePartner(Map<String, String> paramMap) {
530         String partner = paramMap.get("partner");
531         if (partner != null && partner.length() > 0) {
532             PartnerDetails details = partnerStore.get(partner);
533             paramMap.put(restapiUserKey, details.username);
534             paramMap.put(restapiPasswordKey, details.password);
535             if (paramMap.get(restapiUrlString) == null) {
536                 paramMap.put(restapiUrlString, details.url);
537             }
538         }
539     }
540
541     protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) throws SvcLogicException {
542         log.info("Building {} started", format);
543         long t1 = System.currentTimeMillis();
544         String originalTemplate = template;
545
546         template = expandRepeats(ctx, template, 1);
547
548         Map<String, String> mm = new HashMap<>();
549         for (String s : ctx.getAttributeKeySet()) {
550             mm.put(s, ctx.getAttribute(s));
551         }
552
553         StringBuilder ss = new StringBuilder();
554         int i = 0;
555         while (i < template.length()) {
556             int i1 = template.indexOf("${", i);
557             if (i1 < 0) {
558                 ss.append(template.substring(i));
559                 break;
560             }
561
562             int i2 = template.indexOf('}', i1 + 2);
563             if (i2 < 0) {
564                 throw new SvcLogicException("Template error: Matching } not found");
565             }
566
567             String var1 = template.substring(i1 + 2, i2);
568             String value1 = format == Format.XML ? XmlJsonUtil.getXml(mm, var1) : XmlJsonUtil.getJson(mm, var1);
569             if (value1 == null || value1.trim().length() == 0) {
570                 // delete the whole element (line)
571                 int i3 = template.lastIndexOf('\n', i1);
572                 if (i3 < 0) {
573                     i3 = 0;
574                 }
575                 int i4 = template.indexOf('\n', i1);
576                 if (i4 < 0) {
577                     i4 = template.length();
578                 }
579
580                 if (i < i3) {
581                     ss.append(template.substring(i, i3));
582                 }
583                 i = i4;
584             } else {
585                 ss.append(template.substring(i, i1)).append(value1);
586                 i = i2 + 1;
587             }
588         }
589
590         String req = format == Format.XML ? XmlJsonUtil.removeEmptyStructXml(ss.toString())
591                 : XmlJsonUtil.removeEmptyStructJson(originalTemplate, ss.toString());
592
593         if (format == Format.JSON) {
594             req = XmlJsonUtil.removeLastCommaJson(req);
595         }
596
597         long t2 = System.currentTimeMillis();
598         log.info("Building {} completed. Time: {}", format, t2 - t1);
599
600         return req;
601     }
602
603     protected String expandRepeats(SvcLogicContext ctx, String template, int level) throws SvcLogicException {
604         StringBuilder newTemplate = new StringBuilder();
605         int k = 0;
606         while (k < template.length()) {
607             int i1 = template.indexOf("${repeat:", k);
608             if (i1 < 0) {
609                 newTemplate.append(template.substring(k));
610                 break;
611             }
612
613             int i2 = template.indexOf(':', i1 + 9);
614             if (i2 < 0) {
615                 throw new SvcLogicException(
616                         "Template error: Context variable name followed by : is required after repeat");
617             }
618
619             // Find the closing }, store in i3
620             int nn = 1;
621             int i3 = -1;
622             int i = i2;
623             while (nn > 0 && i < template.length()) {
624                 i3 = template.indexOf('}', i);
625                 if (i3 < 0) {
626                     throw new SvcLogicException("Template error: Matching } not found");
627                 }
628                 int i32 = template.indexOf('{', i);
629                 if (i32 >= 0 && i32 < i3) {
630                     nn++;
631                     i = i32 + 1;
632                 } else {
633                     nn--;
634                     i = i3 + 1;
635                 }
636             }
637
638             String var1 = template.substring(i1 + 9, i2);
639             String value1 = ctx.getAttribute(var1);
640             log.info("     {}:{}", var1, value1);
641             int n = 0;
642             try {
643                 n = Integer.parseInt(value1);
644             } catch (NumberFormatException e) {
645                 log.info("value1 not set or not a number, n will remain set at zero");
646             }
647
648             newTemplate.append(template.substring(k, i1));
649
650             String rpt = template.substring(i2 + 1, i3);
651
652             for (int ii = 0; ii < n; ii++) {
653                 String ss = rpt.replaceAll("\\[\\$\\{" + level + "\\}\\]", "[" + ii + "]");
654                 if (ii == n - 1 && ss.trim().endsWith(",")) {
655                     int i4 = ss.lastIndexOf(',');
656                     if (i4 > 0) {
657                         ss = ss.substring(0, i4) + ss.substring(i4 + 1);
658                     }
659                 }
660                 newTemplate.append(ss);
661             }
662
663             k = i3 + 1;
664         }
665
666         if (k == 0) {
667             return newTemplate.toString();
668         }
669
670         return expandRepeats(ctx, newTemplate.toString(), level + 1);
671     }
672
673     protected String readFile(String fileName) throws SvcLogicException {
674         try {
675             byte[] encoded = Files.readAllBytes(Paths.get(fileName));
676             return new String(encoded, "UTF-8");
677         } catch (IOException | SecurityException e) {
678             throw new SvcLogicException("Unable to read file " + fileName + e.getLocalizedMessage(), e);
679         }
680     }
681
682     protected Client addAuthType(Client c, FileParam fp) throws SvcLogicException {
683         Parameters p = new Parameters();
684         p.restapiUser = fp.user;
685         p.restapiPassword = fp.password;
686         p.oAuthConsumerKey = fp.oAuthConsumerKey;
687         p.oAuthVersion = fp.oAuthVersion;
688         p.oAuthConsumerSecret = fp.oAuthConsumerSecret;
689         p.oAuthSignatureMethod = fp.oAuthSignatureMethod;
690         p.authtype = fp.authtype;
691         return addAuthType(c, p);
692     }
693
694     public Client addAuthType(Client client, Parameters p) throws SvcLogicException {
695         if (p.authtype == AuthType.Unspecified) {
696             if (p.restapiUser != null && p.restapiPassword != null) {
697                 client.register(HttpAuthenticationFeature.basic(p.restapiUser, p.restapiPassword));
698             } else if (p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null) {
699                 Feature oAuth1Feature =
700                         OAuth1ClientSupport.builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret))
701                                 .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build();
702                 client.register(oAuth1Feature);
703
704             }
705         } else {
706             if (p.authtype == AuthType.DIGEST) {
707                 if (p.restapiUser != null && p.restapiPassword != null) {
708                     client.register(HttpAuthenticationFeature.digest(p.restapiUser, p.restapiPassword));
709                 } else {
710                     throw new SvcLogicException(
711                             "oAUTH authentication type selected but all restapiUser and restapiPassword "
712                                     + "parameters doesn't exist",
713                             new Throwable());
714                 }
715             } else if (p.authtype == AuthType.BASIC) {
716                 if (p.restapiUser != null && p.restapiPassword != null) {
717                     client.register(HttpAuthenticationFeature.basic(p.restapiUser, p.restapiPassword));
718                 } else {
719                     throw new SvcLogicException(
720                             "oAUTH authentication type selected but all restapiUser and restapiPassword "
721                                     + "parameters doesn't exist",
722                             new Throwable());
723                 }
724             } else if (p.authtype == AuthType.OAUTH) {
725                 if (p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null) {
726                     Feature oAuth1Feature = OAuth1ClientSupport
727                             .builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret))
728                             .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build();
729                     client.register(oAuth1Feature);
730                 } else {
731                     throw new SvcLogicException(
732                             "oAUTH authentication type selected but all oAuthConsumerKey, oAuthConsumerSecret "
733                                     + "and oAuthSignatureMethod parameters doesn't exist",
734                             new Throwable());
735                 }
736             }
737         }
738         return client;
739     }
740
741     /**
742      * Receives the http response for the http request sent.
743      *
744      * @param request request msg
745      * @param p parameters
746      * @return HTTP response
747      * @throws SvcLogicException when sending http request fails
748      */
749     public HttpResponse sendHttpRequest(String request, Parameters p) throws SvcLogicException {
750
751         SSLContext ssl = null;
752         if (p.ssl && p.restapiUrl.startsWith("https")) {
753             ssl = createSSLContext(p);
754         }
755         Client client;
756
757         if (ssl != null) {
758             HttpsURLConnection.setDefaultSSLSocketFactory(ssl.getSocketFactory());
759             client = ClientBuilder.newBuilder().sslContext(ssl).hostnameVerifier((s, sslSession) -> true).build();
760         } else {
761             client = ClientBuilder.newBuilder().hostnameVerifier((s, sslSession) -> true).build();
762         }
763         setClientTimeouts(client);
764         // Needed to support additional HTTP methods such as PATCH
765         client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
766
767         WebTarget webTarget = addAuthType(client, p).target(p.restapiUrl);
768
769         log.info("Sending request below to url " + p.restapiUrl);
770         log.info(request);
771         long t1 = System.currentTimeMillis();
772
773         HttpResponse r = new HttpResponse();
774         r.code = 200;
775         String accept = p.accept;
776         if (accept == null) {
777             accept = p.format == Format.XML ? "application/xml" : "application/json";
778         }
779
780         String contentType = p.contentType;
781         if (contentType == null) {
782             contentType = accept + ";charset=UTF-8";
783         }
784
785         if (!p.skipSending && !p.multipartFormData) {
786
787             Invocation.Builder invocationBuilder = webTarget.request(contentType).accept(accept);
788
789             if (p.format == Format.NONE) {
790                 invocationBuilder.header("", "");
791             }
792
793             if (p.customHttpHeaders != null && p.customHttpHeaders.length() > 0) {
794                 String[] keyValuePairs = p.customHttpHeaders.split(",");
795                 for (String singlePair : keyValuePairs) {
796                     int equalPosition = singlePair.indexOf('=');
797                     invocationBuilder.header(singlePair.substring(0, equalPosition),
798                             singlePair.substring(equalPosition + 1, singlePair.length()));
799                 }
800             }
801
802             invocationBuilder.header("X-ECOMP-RequestID", org.slf4j.MDC.get("X-ECOMP-RequestID"));
803
804             invocationBuilder.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
805
806             Response response;
807
808             try {
809                 response = invocationBuilder.method(p.httpMethod.toString(), entity(request, contentType));
810             } catch (ProcessingException | IllegalStateException e) {
811                 throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e);
812             }
813
814             r.code = response.getStatus();
815             r.headers = response.getStringHeaders();
816             EntityTag etag = response.getEntityTag();
817             if (etag != null) {
818                 r.message = etag.getValue();
819             }
820             if (response.hasEntity() && r.code != 204) {
821                 r.body = response.readEntity(String.class);
822             }
823         } else if (!p.skipSending && p.multipartFormData) {
824
825             WebTarget wt = client.register(MultiPartFeature.class).target(p.restapiUrl);
826
827             MultiPart multiPart = new MultiPart();
828             multiPart.setMediaType(MediaType.MULTIPART_FORM_DATA_TYPE);
829
830             FileDataBodyPart fileDataBodyPart =
831                     new FileDataBodyPart("file", new File(p.multipartFile), MediaType.APPLICATION_OCTET_STREAM_TYPE);
832             multiPart.bodyPart(fileDataBodyPart);
833
834
835             Invocation.Builder invocationBuilder = wt.request(contentType).accept(accept);
836
837             if (p.format == Format.NONE) {
838                 invocationBuilder.header("", "");
839             }
840
841             if (p.customHttpHeaders != null && p.customHttpHeaders.length() > 0) {
842                 String[] keyValuePairs = p.customHttpHeaders.split(",");
843                 for (String singlePair : keyValuePairs) {
844                     int equalPosition = singlePair.indexOf('=');
845                     invocationBuilder.header(singlePair.substring(0, equalPosition),
846                             singlePair.substring(equalPosition + 1, singlePair.length()));
847                 }
848             }
849
850             invocationBuilder.header("X-ECOMP-RequestID", org.slf4j.MDC.get("X-ECOMP-RequestID"));
851
852             Response response;
853
854             try {
855                 response =
856                         invocationBuilder.method(p.httpMethod.toString(), entity(multiPart, multiPart.getMediaType()));
857             } catch (ProcessingException | IllegalStateException e) {
858                 throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e);
859             }
860
861             r.code = response.getStatus();
862             r.headers = response.getStringHeaders();
863             EntityTag etag = response.getEntityTag();
864             if (etag != null) {
865                 r.message = etag.getValue();
866             }
867             if (response.hasEntity() && r.code != 204) {
868                 r.body = response.readEntity(String.class);
869             }
870
871         }
872
873         long t2 = System.currentTimeMillis();
874         log.info(responseReceivedMessage, t2 - t1);
875         log.info(responseHttpCodeMessage, r.code);
876         log.info("HTTP response message: {}", r.message);
877         logHeaders(r.headers);
878         log.info("HTTP response: {}", r.body);
879
880         return r;
881     }
882
883     protected SSLContext createSSLContext(Parameters p) {
884         try (FileInputStream in = new FileInputStream(p.keyStoreFileName)) {
885             System.setProperty("jsse.enableSNIExtension", "false");
886             System.setProperty("javax.net.ssl.trustStore", p.trustStoreFileName);
887             System.setProperty("javax.net.ssl.trustStorePassword", p.trustStorePassword);
888
889             HttpsURLConnection.setDefaultHostnameVerifier((string, ssls) -> true);
890
891             KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
892             KeyStore ks = KeyStore.getInstance("PKCS12");
893             char[] pwd = p.keyStorePassword.toCharArray();
894             ks.load(in, pwd);
895             kmf.init(ks, pwd);
896
897             SSLContext ctx = SSLContext.getInstance("TLS");
898             ctx.init(kmf.getKeyManagers(), null, null);
899             return ctx;
900         } catch (Exception e) {
901             log.error("Error creating SSLContext: {}", e.getMessage(), e);
902         }
903         return null;
904     }
905
906     protected void setFailureResponseStatus(SvcLogicContext ctx, String prefix, String errorMessage,
907             HttpResponse resp) {
908         resp.code = 500;
909         resp.message = errorMessage;
910         String pp = prefix != null ? prefix + '.' : "";
911         ctx.setAttribute(pp + "response-code", String.valueOf(resp.code));
912         ctx.setAttribute(pp + "response-message", resp.message);
913     }
914
915     protected void setResponseStatus(SvcLogicContext ctx, String prefix, HttpResponse r) {
916         String pp = prefix != null ? prefix + '.' : "";
917         ctx.setAttribute(pp + "response-code", String.valueOf(r.code));
918         ctx.setAttribute(pp + "response-message", r.message);
919     }
920
921     public void sendFile(Map<String, String> paramMap, SvcLogicContext ctx) throws SvcLogicException {
922         HttpResponse r = null;
923         try {
924             FileParam p = getFileParameters(paramMap);
925             byte[] data = Files.readAllBytes(Paths.get(p.fileName));
926
927             r = sendHttpData(data, p);
928             setResponseStatus(ctx, p.responsePrefix, r);
929
930         } catch (SvcLogicException | IOException e) {
931             log.error("Error sending the request: {}", e.getMessage(), e);
932
933             r = new HttpResponse();
934             r.code = 500;
935             r.message = e.getMessage();
936             String prefix = parseParam(paramMap, responsePrefix, false, null);
937             setResponseStatus(ctx, prefix, r);
938         }
939
940         if (r != null && r.code >= 300) {
941             throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message);
942         }
943     }
944
945     private FileParam getFileParameters(Map<String, String> paramMap) throws SvcLogicException {
946         FileParam p = new FileParam();
947         p.fileName = parseParam(paramMap, "fileName", true, null);
948         p.url = parseParam(paramMap, "url", true, null);
949         p.user = parseParam(paramMap, "user", false, null);
950         p.password = parseParam(paramMap, "password", false, null);
951         p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post"));
952         p.responsePrefix = parseParam(paramMap, responsePrefix, false, null);
953         String skipSendingStr = paramMap.get(skipSendingMessage);
954         p.skipSending = "true".equalsIgnoreCase(skipSendingStr);
955         p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", false, null);
956         p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null);
957         p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", false, null);
958         p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", false, null);
959         p.authtype = fromString(parseParam(paramMap, "authType", false, "unspecified"));
960         return p;
961     }
962
963     public void postMessageOnUeb(Map<String, String> paramMap, SvcLogicContext ctx) throws SvcLogicException {
964         HttpResponse r;
965         try {
966             UebParam p = getUebParameters(paramMap);
967
968             String pp = p.responsePrefix != null ? p.responsePrefix + '.' : "";
969
970             String req;
971
972             if (p.templateFileName == null) {
973                 log.info("No template file name specified. Using default UEB template: {}", defaultUebTemplateFileName);
974                 p.templateFileName = defaultUebTemplateFileName;
975             }
976
977             String reqTemplate = readFile(p.templateFileName);
978             reqTemplate = reqTemplate.replaceAll("rootVarName", p.rootVarName);
979             req = buildXmlJsonRequest(ctx, reqTemplate, Format.JSON);
980
981             r = postOnUeb(req, p);
982             setResponseStatus(ctx, p.responsePrefix, r);
983             if (r.body != null) {
984                 ctx.setAttribute(pp + "httpResponse", r.body);
985             }
986
987         } catch (SvcLogicException e) {
988             log.error("Error sending the request: {}", e.getMessage(), e);
989
990             r = new HttpResponse();
991             r.code = 500;
992             r.message = e.getMessage();
993             String prefix = parseParam(paramMap, responsePrefix, false, null);
994             setResponseStatus(ctx, prefix, r);
995         }
996
997         if (r.code >= 300) {
998             throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message);
999         }
1000     }
1001
1002     protected HttpResponse sendHttpData(byte[] data, FileParam p) throws SvcLogicException {
1003
1004         Client client = ClientBuilder.newBuilder().build();
1005         setClientTimeouts(client);
1006         client.property(ClientProperties.FOLLOW_REDIRECTS, true);
1007         WebTarget webTarget = addAuthType(client, p).target(p.url);
1008
1009         log.info("Sending file");
1010         long t1 = System.currentTimeMillis();
1011
1012         HttpResponse r = new HttpResponse();
1013         r.code = 200;
1014
1015         if (!p.skipSending) {
1016             String tt = "application/octet-stream";
1017             Invocation.Builder invocationBuilder = webTarget.request(tt).accept(tt);
1018
1019             Response response;
1020
1021             try {
1022                 if (p.httpMethod == HttpMethod.POST) {
1023                     response = invocationBuilder.post(Entity.entity(data, tt));
1024                 } else if (p.httpMethod == HttpMethod.PUT) {
1025                     response = invocationBuilder.put(Entity.entity(data, tt));
1026                 } else {
1027                     throw new SvcLogicException("Http operation" + p.httpMethod + "not supported");
1028                 }
1029             } catch (ProcessingException e) {
1030                 throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e);
1031             }
1032
1033             r.code = response.getStatus();
1034             r.headers = response.getStringHeaders();
1035             EntityTag etag = response.getEntityTag();
1036             if (etag != null) {
1037                 r.message = etag.getValue();
1038             }
1039             if (response.hasEntity() && r.code != 204) {
1040                 r.body = response.readEntity(String.class);
1041             }
1042
1043             if (r.code == 301) {
1044                 String newUrl = response.getStringHeaders().getFirst("Location");
1045
1046                 log.info("Got response code 301. Sending same request to URL: {}", newUrl);
1047
1048                 webTarget = client.target(newUrl);
1049                 invocationBuilder = webTarget.request(tt).accept(tt);
1050
1051                 try {
1052                     if (p.httpMethod == HttpMethod.POST) {
1053                         response = invocationBuilder.post(Entity.entity(data, tt));
1054                     } else if (p.httpMethod == HttpMethod.PUT) {
1055                         response = invocationBuilder.put(Entity.entity(data, tt));
1056                     } else {
1057                         throw new SvcLogicException("Http operation" + p.httpMethod + "not supported");
1058                     }
1059                 } catch (ProcessingException e) {
1060                     throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e);
1061                 }
1062
1063                 r.code = response.getStatus();
1064                 etag = response.getEntityTag();
1065                 if (etag != null) {
1066                     r.message = etag.getValue();
1067                 }
1068                 if (response.hasEntity() && r.code != 204) {
1069                     r.body = response.readEntity(String.class);
1070                 }
1071             }
1072         }
1073
1074         long t2 = System.currentTimeMillis();
1075         log.info(responseReceivedMessage, t2 - t1);
1076         log.info(responseHttpCodeMessage, r.code);
1077         log.info("HTTP response message: {}", r.message);
1078         logHeaders(r.headers);
1079         log.info("HTTP response: {}", r.body);
1080
1081         return r;
1082     }
1083
1084     private UebParam getUebParameters(Map<String, String> paramMap) throws SvcLogicException {
1085         UebParam p = new UebParam();
1086         p.topic = parseParam(paramMap, "topic", true, null);
1087         p.templateFileName = parseParam(paramMap, "templateFileName", false, null);
1088         p.rootVarName = parseParam(paramMap, "rootVarName", false, null);
1089         p.responsePrefix = parseParam(paramMap, responsePrefix, false, null);
1090         String skipSendingStr = paramMap.get(skipSendingMessage);
1091         p.skipSending = "true".equalsIgnoreCase(skipSendingStr);
1092         return p;
1093     }
1094
1095     protected void logProperties(Map<String, Object> mm) {
1096         List<String> ll = new ArrayList<>();
1097         for (Object o : mm.keySet()) {
1098             ll.add((String) o);
1099         }
1100         Collections.sort(ll);
1101
1102         log.info("Properties:");
1103         for (String name : ll) {
1104             log.info("--- {}:{}", name, String.valueOf(mm.get(name)));
1105         }
1106     }
1107
1108     protected void logHeaders(MultivaluedMap<String, String> mm) {
1109         log.info("HTTP response headers:");
1110
1111         if (mm == null) {
1112             return;
1113         }
1114
1115         List<String> ll = new ArrayList<>();
1116         for (Object o : mm.keySet()) {
1117             ll.add((String) o);
1118         }
1119         Collections.sort(ll);
1120
1121         for (String name : ll) {
1122             log.info("--- {}:{}", name, String.valueOf(mm.get(name)));
1123         }
1124     }
1125
1126     protected HttpResponse postOnUeb(String request, UebParam p) throws SvcLogicException {
1127         String[] urls = uebServers.split(" ");
1128         for (int i = 0; i < urls.length; i++) {
1129             if (!urls[i].endsWith("/")) {
1130                 urls[i] += "/";
1131             }
1132             urls[i] += "events/" + p.topic;
1133         }
1134
1135         Client client = ClientBuilder.newBuilder().build();
1136         setClientTimeouts(client);
1137         WebTarget webTarget = client.target(urls[0]);
1138
1139         log.info("UEB URL: {}", urls[0]);
1140         log.info("Sending request:");
1141         log.info(request);
1142         long t1 = System.currentTimeMillis();
1143
1144         HttpResponse r = new HttpResponse();
1145         r.code = 200;
1146
1147         if (!p.skipSending) {
1148             String tt = "application/json";
1149             String tt1 = tt + ";charset=UTF-8";
1150
1151             Response response;
1152             Invocation.Builder invocationBuilder = webTarget.request(tt1).accept(tt);
1153
1154             try {
1155                 response = invocationBuilder.post(Entity.entity(request, tt1));
1156             } catch (ProcessingException e) {
1157                 throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e);
1158             }
1159             r.code = response.getStatus();
1160             r.headers = response.getStringHeaders();
1161             if (response.hasEntity()) {
1162                 r.body = response.readEntity(String.class);
1163             }
1164         }
1165
1166         long t2 = System.currentTimeMillis();
1167         log.info(responseReceivedMessage, t2 - t1);
1168         log.info(responseHttpCodeMessage, r.code);
1169         logHeaders(r.headers);
1170         log.info("HTTP response:\n {}", r.body);
1171
1172         return r;
1173     }
1174
1175     public void setUebServers(String uebServers) {
1176         this.uebServers = uebServers;
1177     }
1178
1179     public void setDefaultUebTemplateFileName(String defaultUebTemplateFileName) {
1180         this.defaultUebTemplateFileName = defaultUebTemplateFileName;
1181     }
1182     
1183     protected void setClientTimeouts(Client client) {
1184         client.property(ClientProperties.CONNECT_TIMEOUT, httpConnectTimeout);
1185         client.property(ClientProperties.READ_TIMEOUT, httpReadTimeout);
1186     }
1187
1188     protected Integer readOptionalInteger(String propertyName, Integer defaultValue) {
1189         String stringValue = System.getProperty(propertyName);
1190         if (stringValue != null && stringValue.length() > 0) {
1191             try {
1192                 return Integer.valueOf(stringValue);
1193             } catch (NumberFormatException e) {
1194                 log.warn("property " + propertyName + " had the value " + stringValue + " that could not be converted to an Integer, default " + defaultValue + " will be used instead", e);
1195             }
1196         }
1197         return defaultValue;
1198     }
1199
1200     
1201     private static class FileParam {
1202
1203         public String fileName;
1204         public String url;
1205         public String user;
1206         public String password;
1207         public HttpMethod httpMethod;
1208         public String responsePrefix;
1209         public boolean skipSending;
1210         public String oAuthConsumerKey;
1211         public String oAuthConsumerSecret;
1212         public String oAuthSignatureMethod;
1213         public String oAuthVersion;
1214         public AuthType authtype;
1215     }
1216
1217     private static class UebParam {
1218
1219         public String topic;
1220         public String templateFileName;
1221         public String rootVarName;
1222         public String responsePrefix;
1223         public boolean skipSending;
1224     }
1225 }