Fix InternalServlet Vulenrabilities
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / InternalServlet.java
1 /*******************************************************************************
2  * ============LICENSE_START==================================================
3  * * org.onap.dmaap
4  * * ===========================================================================
5  * * Copyright © 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
10  * *
11  *  *      http://www.apache.org/licenses/LICENSE-2.0
12  * *
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====================================================
19  * *
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  * *
22  ******************************************************************************/
23
24
25 package org.onap.dmaap.datarouter.provisioning;
26
27 import java.io.ByteArrayOutputStream;
28 import java.io.File;
29 import java.io.IOException;
30 import java.io.InputStream;
31 import java.nio.file.FileStore;
32 import java.nio.file.FileSystem;
33 import java.nio.file.Files;
34 import java.nio.file.Path;
35 import java.nio.file.Paths;
36 import java.nio.file.StandardCopyOption;
37 import java.util.Properties;
38
39 import javax.servlet.http.HttpServletRequest;
40 import javax.servlet.http.HttpServletResponse;
41
42 import org.json.JSONArray;
43 import org.onap.dmaap.datarouter.provisioning.beans.EventLogRecord;
44 import org.onap.dmaap.datarouter.provisioning.beans.LogRecord;
45 import org.onap.dmaap.datarouter.provisioning.beans.Parameters;
46 import org.onap.dmaap.datarouter.provisioning.eelf.EelfMsgs;
47 import org.onap.dmaap.datarouter.provisioning.utils.DB;
48 import org.onap.dmaap.datarouter.provisioning.utils.LogfileLoader;
49 import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
50
51 import com.att.eelf.configuration.EELFLogger;
52 import com.att.eelf.configuration.EELFManager;
53
54 import static org.onap.dmaap.datarouter.provisioning.utils.HttpServletUtils.sendResponseError;
55
56 /**
57  * <p>
58  * This servlet handles requests to URLs under /internal on the provisioning server. These include:
59  * </p>
60  * <div class="contentContainer">
61  * <table class="packageSummary" border="0" cellpadding="3" cellspacing="0">
62  * <caption><span>URL Path Summary</span><span class="tabEnd">&nbsp;</span></caption>
63  * <tr>
64  * <th class="colFirst" width="15%">URL Path</th>
65  * <th class="colOne">Method</th>
66  * <th class="colLast">Purpose</th>
67  * </tr>
68  * <tr class="altColor">
69  * <td class="colFirst">/internal/prov</td>
70  * <td class="colOne">GET</td>
71  * <td class="colLast">used to GET a full JSON copy of the provisioning data.</td>
72  * </tr>
73  * <tr class="rowColor">
74  * <td class="colFirst">/internal/fetchProv</td>
75  * <td class="colOne">GET</td>
76  * <td class="colLast">used to signal to a standby POD that the provisioning data should be fetched from the active
77  * POD.</td>
78  * </tr>
79  * <tr class="altColor">
80  * <td class="colFirst" rowspan="2">/internal/logs</td>
81  * <td class="colOne">GET</td>
82  * <td class="colLast">used to GET an index of log files and individual logs for this provisioning server.</td>
83  * </tr>
84  * <tr class="altColor">
85  * <td class="colOne">POST</td>
86  * <td class="colLast">used to POST log files from the individual nodes to this provisioning server.</td>
87  * </tr>
88  * <tr class="rowColor">
89  * <td class="colFirst" rowspan="4">/internal/api</td>
90  * <td class="colOne">GET</td>
91  * <td class="colLast">used to GET an individual parameter value. The parameter name is specified by the path after
92  * /api/.</td>
93  * </tr>
94  * <tr class="rowColor">
95  * <td class="colOne">PUT</td>
96  * <td class="colLast">used to set an individual parameter value. The parameter name is specified by the path after
97  * /api/.</td>
98  * </tr>
99  * <tr class="rowColor">
100  * <td class="colOne">DELETE</td>
101  * <td class="colLast">used to remove an individual parameter value. The parameter name is specified by the path after
102  * /api/.</td>
103  * </tr>
104  * <tr class="rowColor">
105  * <td class="colOne">POST</td>
106  * <td class="colLast">used to create a new individual parameter value. The parameter name is specified by the path
107  * after /api/.</td>
108  * </tr>
109  * <tr class="altColor">
110  * <td class="colFirst">/internal/halt</td>
111  * <td class="colOne">GET</td>
112  * <td class="colLast">used to halt the server (must be accessed from 127.0.0.1).</td>
113  * </tr>
114  * <tr class="rowColor">
115  * <td class="colFirst" rowspan="2">/internal/drlogs</td>
116  * <td class="colOne">GET</td>
117  * <td class="colLast">used to get a list of DR log entries available for retrieval.
118  * Note: these are the actual data router log entries sent to the provisioning server by the nodes, not the provisioning
119  * server's internal logs (access via /internal/logs above). The range is returned as a list of record sequence
120  * numbers.</td>
121  * </tr>
122  * <tr class="rowColor">
123  * <td class="colOne">POST</td>
124  * <td class="colLast">used to retrieve specific log entries.
125  * The sequence numbers of the records to fetch are POST-ed; the records matching the sequence numbers are
126  * returned.</td>
127  * </tr>
128  * <tr class="altColor">
129  * <td class="colFirst">/internal/route/*</td>
130  * <td class="colOne">*</td>
131  * <td class="colLast">URLs under this path are handled via the {@link org.onap.dmaap.datarouter.provisioning.RouteServlet}</td>
132  * </tr>
133  * </table>
134  * </div>
135  * <p>
136  * Authorization to use these URLs is a little different than for other URLs on the provisioning server. For the most
137  * part, the IP address that the request comes from should be either:
138  * </p>
139  * <ol>
140  * <li>an IP address of a provisioning server, or</li>
141  * <li>the IP address of a node (to allow access to /internal/prov), or</li>
142  * <li>an IP address from the "<i>special subnet</i>" which is configured with
143  * the PROV_SPECIAL_SUBNET parameter.
144  * </ol>
145  * <p>
146  * In addition, requests to /internal/halt can ONLY come from localhost (127.0.0.1) on the HTTP port.
147  * </p>
148  * <p>
149  * All DELETE/GET/PUT/POST requests made to /internal/api on this servlet on the standby server are proxied to the
150  * active server (using the {@link ProxyServlet}) if it is up and reachable.
151  * </p>
152  *
153  * @author Robert Eby
154  * @version $Id: InternalServlet.java,v 1.23 2014/03/24 18:47:10 eby Exp $
155  */
156 @SuppressWarnings("serial")
157 public class InternalServlet extends ProxyServlet {
158
159     private static Integer logseq = 0; // another piece of info to make log spool file names unique
160     //Adding EELF Logger Rally:US664892
161     private static EELFLogger eelflogger = EELFManager.getInstance()
162         .getLogger("org.onap.dmaap.datarouter.provisioning.InternalServlet");
163
164     /**
165      * Delete a parameter at the address /internal/api/&lt;parameter&gt;. See the <b>Internal API</b> document for
166      * details on how this method should be invoked.
167      */
168     @Override
169     public void doDelete(HttpServletRequest req, HttpServletResponse resp) {
170         setIpAndFqdnForEelf("doDelete");
171         eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
172         EventLogRecord elr = new EventLogRecord(req);
173         if (!isAuthorizedForInternal(req)) {
174             elr.setMessage("Unauthorized.");
175             elr.setResult(HttpServletResponse.SC_FORBIDDEN);
176             eventlogger.info(elr);
177             sendResponseError(resp, HttpServletResponse.SC_FORBIDDEN, "Unauthorized.", eventlogger);
178             return;
179         }
180
181         String path = req.getPathInfo();
182         if (path.startsWith("/api/")) {
183             if (isProxyOK(req) && isProxyServer()) {
184                 try {
185                     super.doDelete(req, resp);
186                 } catch (IOException ioe) {
187                     intlogger.error("IOException" + ioe.getMessage());
188                 }
189                 return;
190             }
191             String key = path.substring(5);
192             if (key.length() > 0) {
193                 Parameters param = Parameters.getParameter(key);
194                 if (param != null) {
195                     if (doDelete(param)) {
196                         elr.setResult(HttpServletResponse.SC_OK);
197                         eventlogger.info(elr);
198                         resp.setStatus(HttpServletResponse.SC_OK);
199                         provisioningDataChanged();
200                         provisioningParametersChanged();
201                     } else {
202                         // Something went wrong with the DELETE
203                         elr.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
204                         eventlogger.info(elr);
205                         sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG, eventlogger);
206                     }
207                     return;
208                 }
209             }
210         }
211         sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Bad URL.", eventlogger);
212     }
213
214     /**
215      * Get some information (such as a parameter) underneath the /internal/ namespace. See the <b>Internal API</b>
216      * document for details on how this method should be invoked.
217      */
218     @Override
219     public void doGet(HttpServletRequest req, HttpServletResponse resp) {
220         setIpAndFqdnForEelf("doGet");
221         eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
222         String path = req.getPathInfo();
223         Properties props = (new DB()).getProperties();
224         if (path.equals("/halt") && !req.isSecure()) {
225             // request to halt the server - can ONLY come from localhost
226             String remote = req.getRemoteAddr();
227             if (remote.equals(props.getProperty("org.onap.dmaap.datarouter.provserver.localhost"))) {
228                 intlogger.info("PROV0009 Request to HALT received.");
229                 resp.setStatus(HttpServletResponse.SC_OK);
230                 Main.shutdown();
231             } else {
232                 intlogger.info("PROV0010 Disallowed request to HALT received from " + remote);
233                 resp.setStatus(HttpServletResponse.SC_FORBIDDEN);
234             }
235             return;
236         }
237
238         EventLogRecord elr = new EventLogRecord(req);
239         if (!isAuthorizedForInternal(req)) {
240             elr.setMessage("Unauthorized.");
241             elr.setResult(HttpServletResponse.SC_FORBIDDEN);
242             eventlogger.info(elr);
243             sendResponseError(resp, HttpServletResponse.SC_FORBIDDEN, "Unauthorized.", eventlogger);
244             return;
245         }
246         if (path.equals("/fetchProv") && !req.isSecure()) {
247             // if request came from active_pod or standby_pod and it is not us, reload prov data
248             SynchronizerTask s = SynchronizerTask.getSynchronizer();
249             s.doFetch();
250             resp.setStatus(HttpServletResponse.SC_OK);
251             return;
252         }
253         if (path.equals("/prov")) {
254             if (isProxyOK(req) && isProxyServer()) {
255                 try {
256                     if (super.doGetWithFallback(req, resp)) {
257                         return;
258                     }
259                 } catch (IOException ioe) {
260                     intlogger.error("IOException" + ioe.getMessage());
261                 }
262                 // fall back to returning the local data if the remote is unreachable
263                 intlogger.info("Active server unavailable; falling back to local copy.");
264             }
265             Poker p = Poker.getPoker();
266             resp.setStatus(HttpServletResponse.SC_OK);
267             resp.setContentType(PROVFULL_CONTENT_TYPE2);
268             try {
269                 resp.getOutputStream().print(p.getProvisioningString());
270             } catch (IOException ioe) {
271                 intlogger.error("IOException" + ioe.getMessage());
272             }
273             return;
274         }
275         if (path.equals("/logs") || path.equals("/logs/")) {
276             resp.setStatus(HttpServletResponse.SC_OK);
277             resp.setContentType("application/json");
278             try {
279                 resp.getOutputStream().print(generateLogfileList().toString());
280             } catch (IOException ioe) {
281                 intlogger.error("IOException" + ioe.getMessage());
282             }
283             return;
284         }
285         if (path.startsWith("/logs/")) {
286             String logdir = props.getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir");
287             String logfile = path.substring(6);
288             if (logdir != null && logfile != null && logfile.indexOf('/') < 0) {
289                 File log = new File(logdir + "/" + logfile);
290                 if (log.exists() && log.isFile()) {
291                     resp.setStatus(HttpServletResponse.SC_OK);
292                     resp.setContentType("text/plain");
293                     Path logpath = Paths.get(log.getAbsolutePath());
294                     try {
295                         Files.copy(logpath, resp.getOutputStream());
296                     } catch (IOException ioe) {
297                         intlogger.error("IOException" + ioe.getMessage());
298                     }
299                     return;
300                 }
301             }
302             sendResponseError(resp, HttpServletResponse.SC_NO_CONTENT, "No file.", eventlogger);
303             return;
304         }
305         if (path.startsWith("/api/")) {
306             if (isProxyOK(req) && isProxyServer()) {
307                 try {
308                     super.doGet(req, resp);
309                 } catch (IOException ioe) {
310                     intlogger.error("IOException" + ioe.getMessage());
311                 }
312                 return;
313             }
314             String key = path.substring(5);
315             if (key.length() > 0) {
316                 Parameters param = Parameters.getParameter(key);
317                 if (param != null) {
318                     resp.setStatus(HttpServletResponse.SC_OK);
319                     resp.setContentType("text/plain");
320                     try {
321                         resp.getOutputStream().print(param.getValue() + "\n");
322                     } catch (IOException ioe) {
323                         intlogger.error("IOException" + ioe.getMessage());
324                     }
325                     return;
326                 }
327             }
328         }
329         if (path.equals("/drlogs") || path.equals("/drlogs/")) {
330             // Special POD <=> POD API to determine what log file records are loaded here
331             LogfileLoader lfl = LogfileLoader.getLoader();
332             resp.setStatus(HttpServletResponse.SC_OK);
333             resp.setContentType("text/plain");
334             try {
335                 resp.getOutputStream().print(lfl.getBitSet().toString());
336             } catch (IOException ioe) {
337                 intlogger.error("IOException" + ioe.getMessage());
338             }
339             return;
340         }
341         sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Bad URL.", eventlogger);
342     }
343
344     /**
345      * Modify a parameter at the address /internal/api/&lt;parameter&gt;. See the <b>Internal API</b> document for
346      * details on how this method should be invoked.
347      */
348     @Override
349     public void doPut(HttpServletRequest req, HttpServletResponse resp) {
350         setIpAndFqdnForEelf("doPut");
351         eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF_AND_FEEDID, req.getHeader(BEHALF_HEADER), getIdFromPath(req) + "");
352         EventLogRecord elr = new EventLogRecord(req);
353         if (!isAuthorizedForInternal(req)) {
354             elr.setMessage("Unauthorized.");
355             elr.setResult(HttpServletResponse.SC_FORBIDDEN);
356             eventlogger.info(elr);
357             sendResponseError(resp, HttpServletResponse.SC_FORBIDDEN, "Unauthorized.", eventlogger);
358             return;
359         }
360         String path = req.getPathInfo();
361         if (path.startsWith("/api/")) {
362             if (isProxyOK(req) && isProxyServer()) {
363                 try {
364                     super.doPut(req, resp);
365                 } catch (IOException ioe) {
366                     intlogger.error("IOException" + ioe.getMessage());
367                 }
368                 return;
369             }
370             String key = path.substring(5);
371             if (key.length() > 0) {
372                 Parameters param = Parameters.getParameter(key);
373                 if (param != null) {
374                     String t = catValues(req.getParameterValues("val"));
375                     param.setValue(t);
376                     if (doUpdate(param)) {
377                         elr.setResult(HttpServletResponse.SC_OK);
378                         eventlogger.info(elr);
379                         resp.setStatus(HttpServletResponse.SC_OK);
380                         provisioningDataChanged();
381                         provisioningParametersChanged();
382                     } else {
383                         // Something went wrong with the UPDATE
384                         elr.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
385                         eventlogger.info(elr);
386                         sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG, eventlogger);
387                     }
388                     return;
389                 }
390             }
391         }
392         sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Bad URL.", eventlogger);
393     }
394
395     /**
396      * Create some new information (such as a parameter or log entries) underneath the /internal/ namespace. See the
397      * <b>Internal API</b> document for details on how this method should be invoked.
398      */
399     @SuppressWarnings("resource")
400     @Override
401     public void doPost(HttpServletRequest req, HttpServletResponse resp) {
402         setIpAndFqdnForEelf("doPost");
403         eelflogger.info(EelfMsgs.MESSAGE_WITH_BEHALF, req.getHeader(BEHALF_HEADER));
404         EventLogRecord elr = new EventLogRecord(req);
405         if (!isAuthorizedForInternal(req)) {
406             elr.setMessage("Unauthorized.");
407             elr.setResult(HttpServletResponse.SC_FORBIDDEN);
408             eventlogger.info(elr);
409             sendResponseError(resp, HttpServletResponse.SC_FORBIDDEN, "Unauthorized.", eventlogger);
410             return;
411         }
412
413         String path = req.getPathInfo();
414         if (path.startsWith("/api/")) {
415             if (isProxyOK(req) && isProxyServer()) {
416                 try {
417                     super.doPost(req, resp);
418                 } catch (IOException ioe) {
419                     intlogger.error("IOException" + ioe.getMessage());
420                 }
421                 return;
422             }
423             String key = path.substring(5);
424             if (key.length() > 0) {
425                 Parameters param = Parameters.getParameter(key);
426                 if (param == null) {
427                     String t = catValues(req.getParameterValues("val"));
428                     param = new Parameters(key, t);
429                     if (doInsert(param)) {
430                         elr.setResult(HttpServletResponse.SC_OK);
431                         eventlogger.info(elr);
432                         resp.setStatus(HttpServletResponse.SC_OK);
433                         provisioningDataChanged();
434                         provisioningParametersChanged();
435                     } else {
436                         // Something went wrong with the INSERT
437                         elr.setResult(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
438                         eventlogger.info(elr);
439                         sendResponseError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DB_PROBLEM_MSG, eventlogger);
440                     }
441                     return;
442                 }
443             }
444         }
445
446         if (path.equals("/logs") || path.equals("/logs/")) {
447             String ctype = req.getHeader("Content-Type");
448             if (ctype == null || !ctype.equals("text/plain")) {
449                 elr.setResult(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
450                 elr.setMessage("Bad media type: " + ctype);
451                 resp.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
452                 eventlogger.info(elr);
453                 return;
454             }
455             String spooldir = (new DB()).getProperties().getProperty("org.onap.dmaap.datarouter.provserver.spooldir");
456             String spoolname = String.format("%d-%d-", System.currentTimeMillis(), Thread.currentThread().getId());
457             synchronized (logseq) {
458                 // perhaps unnecessary, but it helps make the name unique
459                 spoolname += logseq.toString();
460                 logseq++;
461             }
462             String encoding = req.getHeader("Content-Encoding");
463             if (encoding != null) {
464                 if (encoding.trim().equals("gzip")) {
465                     spoolname += ".gz";
466                 } else {
467                     elr.setResult(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
468                     resp.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
469                     eventlogger.info(elr);
470                     return;
471                 }
472             }
473             // Determine space available -- available space must be at least 5%
474             FileSystem fs = (Paths.get(spooldir)).getFileSystem();
475             long total = 0;
476             long avail = 0;
477             for (FileStore store : fs.getFileStores()) {
478                 try {
479                     total += store.getTotalSpace();
480                     avail += store.getUsableSpace();
481                 } catch (IOException ioe) {
482                     intlogger.error("IOException" + ioe.getMessage());
483                 }
484             }
485             try {
486                 fs.close();
487             } catch (Exception e) {
488             }
489             if (((avail * 100) / total) < 5) {
490                 elr.setResult(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
491                 resp.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
492                 eventlogger.info(elr);
493                 return;
494             }
495             Path tmppath = Paths.get(spooldir, spoolname);
496             Path donepath = Paths.get(spooldir, "IN." + spoolname);
497             try {
498                 Files.copy(req.getInputStream(), Paths.get(spooldir, spoolname), StandardCopyOption.REPLACE_EXISTING);
499                 Files.move(tmppath, donepath, StandardCopyOption.REPLACE_EXISTING);
500                 elr.setResult(HttpServletResponse.SC_CREATED);
501                 resp.setStatus(HttpServletResponse.SC_CREATED);
502                 eventlogger.info(elr);
503                 LogfileLoader.getLoader();    // This starts the logfile loader "task"
504             } catch (IOException ioe) {
505                 intlogger.error("IOException" + ioe.getMessage());
506             }
507             return;
508         }
509
510         if (path.equals("/drlogs") || path.equals("/drlogs/")) {
511             // Receive post request and generate log entries
512             String ctype = req.getHeader("Content-Type");
513             if (ctype == null || !ctype.equals("text/plain")) {
514                 elr.setResult(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
515                 elr.setMessage("Bad media type: " + ctype);
516                 resp.setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
517                 eventlogger.info(elr);
518                 return;
519             }
520             try {
521                 InputStream is = req.getInputStream();
522                 ByteArrayOutputStream bos = new ByteArrayOutputStream();
523                 int ch;
524                 while ((ch = is.read()) >= 0) {
525                     bos.write(ch);
526                 }
527                 RLEBitSet bs = new RLEBitSet(bos.toString());    // The set of records to retrieve
528                 elr.setResult(HttpServletResponse.SC_OK);
529                 resp.setStatus(HttpServletResponse.SC_OK);
530                 resp.setContentType("text/plain");
531                 LogRecord.printLogRecords(resp.getOutputStream(), bs);
532                 eventlogger.info(elr);
533             } catch (IOException ioe) {
534                 intlogger.error("IOException" + ioe.getMessage());
535             }
536             return;
537         }
538
539         elr.setResult(HttpServletResponse.SC_NOT_FOUND);
540         sendResponseError(resp, HttpServletResponse.SC_NOT_FOUND, "Bad URL.", eventlogger);
541         eventlogger.info(elr);
542     }
543
544     private String catValues(String[] v) {
545         StringBuilder sb = new StringBuilder();
546         if (v != null) {
547             String pfx = "";
548             for (String s : v) {
549                 sb.append(pfx);
550                 sb.append(s);
551                 pfx = "|";
552             }
553         }
554         return sb.toString();
555     }
556
557     private JSONArray generateLogfileList() {
558         JSONArray ja = new JSONArray();
559         Properties p = (new DB()).getProperties();
560         String s = p.getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir");
561         if (s != null) {
562             String[] dirs = s.split(",");
563             for (String dir : dirs) {
564                 File f = new File(dir);
565                 String[] list = f.list();
566                 if (list != null) {
567                     for (String s2 : list) {
568                         if (!s2.startsWith(".")) {
569                             ja.put(s2);
570                         }
571                     }
572                 }
573             }
574         }
575         return ja;
576     }
577 }