sonar critical for Exception Handling
[dmaap/messagerouter/mirroragent.git] / src / main / java / com / att / nsa / dmaapMMAgent / MirrorMakerAgent.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  *        http://www.apache.org/licenses/LICENSE-2.0
11  *  
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *  ============LICENSE_END=========================================================
18  *
19  *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
20  *  
21  *******************************************************************************/
22
23 package com.att.nsa.dmaapMMAgent;
24
25 import java.io.BufferedReader;
26 import java.io.DataOutputStream;
27 import java.io.File;
28 import java.io.FileInputStream;
29 import java.io.FileOutputStream;
30 import java.io.IOException;
31 import java.io.InputStream;
32 import java.io.InputStreamReader;
33 import java.io.OutputStream;
34 import java.net.HttpURLConnection;
35 import java.net.URL;
36 import java.util.ArrayList;
37 import java.util.Properties;
38
39 import org.apache.log4j.Logger;
40 import org.jasypt.util.text.BasicTextEncryptor;
41
42 import com.att.nsa.dmaapMMAgent.dao.CreateMirrorMaker;
43 import com.att.nsa.dmaapMMAgent.dao.DeleteMirrorMaker;
44 import com.att.nsa.dmaapMMAgent.dao.ListMirrorMaker;
45 import com.att.nsa.dmaapMMAgent.dao.MirrorMaker;
46 import com.att.nsa.dmaapMMAgent.dao.UpdateMirrorMaker;
47 import com.att.nsa.dmaapMMAgent.dao.UpdateWhiteList;
48 import com.att.nsa.dmaapMMAgent.utils.MirrorMakerProcessHandler;
49 import com.google.gson.Gson;
50 import com.google.gson.internal.LinkedTreeMap;
51 import com.sun.org.apache.xerces.internal.impl.dtd.models.CMAny;
52 import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
53
54 public class MirrorMakerAgent {
55         static final Logger logger = Logger.getLogger(MirrorMakerAgent.class);
56         Properties mirrorMakerProperties = new Properties();
57         ListMirrorMaker mirrorMakers = null;
58         String mmagenthome = "";
59         String kafkahome = "";
60         String topicURL = "";
61         String topicname = "";
62         String mechid = "";
63         String password = "";
64         private static String secret = "utdfpWlgyDQ2ZB8SLVRtmN834I1JcT9J";
65
66         public static void main(String[] args) {
67                 if (args != null && args.length == 2) {
68                         if (args[0].equals("-encrypt")) {
69                                 BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
70                                 textEncryptor.setPassword(secret);
71                                 String plainText = textEncryptor.encrypt(args[1]);
72                                 System.out.println("Encrypted Password is :" + plainText);
73                                 return;
74                         }
75                 } else if (args != null && args.length > 0) {
76                         System.out.println(
77                                         "Usage: ./mmagent to run with the configuration \n -encrypt <password> to Encrypt Password for config ");
78                         return;
79                 }
80                 MirrorMakerAgent agent = new MirrorMakerAgent();
81                 if (agent.checkStartup()) {
82                         logger.info("mmagent started, loading properties");
83                         agent.checkAgentProcess();
84                         agent.readAgentTopic();
85                 } else {
86                         System.out.println(
87                                         "ERROR: mmagent startup unsuccessful, please make sure the mmagenthome /etc/mmagent.config is set and mechid have the rights to the topic");
88                 }
89         }
90
91         private boolean checkStartup() {
92                 FileInputStream input = null;
93                 try {
94                         this.mmagenthome = System.getProperty("MMAGENTHOME");
95                         input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
96                         logger.info("mmagenthome is set :" + mmagenthome + " loading properties at /etc/mmagent.config");
97                 } catch (IOException ex) {
98                         logger.error(mmagenthome + "/etc/mmagent.config not found.  Set -DMMAGENTHOME and check the config file" + ex);
99                         return false;
100                 } finally {
101                         if (input != null) {
102                                 try {
103                                         input.close();
104                                 } catch (IOException e) {
105                                         logger.error(" IOException occers " + e);
106                                 }
107                         }
108                 }
109                 loadProperties();
110                 input = null;
111                 try {
112                         /*input = new FileInputStream(kafkahome + "/bin/kafka-run-class.sh");*/
113                         if(false) {
114                                 throw new IOException();
115                         }
116                         logger.info("kakahome is set :" + kafkahome);
117                 } catch (IOException ex) {
118                         logger.error(kafkahome + "/bin/kafka-run-class.sh not found.  Make sure kafka home is set correctly" + ex);
119                         return false;
120                 } finally {
121                         if (input != null) {
122                                 try {
123                                         input.close();
124                                 } catch (IOException e) {
125                                         logger.error("IOException" + e);
126                                 }
127                         }
128                 }
129                 String response = publishTopic("{\"test\":\"test\"}");
130                 if (response.startsWith("ERROR:")) {
131                         logger.error("Problem publishing to topic, please verify the config " + this.topicname + " MR URL is:"
132                                         + this.topicURL + " Error is:  " + response);
133                         return false;
134                 }
135                 logger.info("Published to Topic :" + this.topicname + " Successfully");
136                 response = subscribeTopic("1");
137                 if (response != null && response.startsWith("ERROR:")) {
138                         logger.error("Problem subscribing to topic, please verify the config " + this.topicname + " MR URL is:"
139                                         + this.topicURL + " Error is:  " + response);
140                         return false;
141                 }
142                 logger.info("Subscribed to Topic :" + this.topicname + " Successfully");
143                 return true;
144         }
145
146         private void checkPropertiesFile(String agentName, String propName, String info, boolean refresh) {
147                 InputStream input = null;
148                 OutputStream out = null;
149                 try {
150                         if (refresh) {
151                                 throw new IOException();
152                         }
153                         input = new FileInputStream(mmagenthome + "/etc/" + agentName + propName + ".properties");
154                 } catch (IOException ex) {
155                         logger.error(" IOException will be handled " + ex);
156                         try {
157                                 input = new FileInputStream(mmagenthome + "/etc/" + propName + ".properties");
158                                 Properties prop = new Properties();
159                                 prop.load(input);
160                                 if (propName.equals("consumer")) {
161                                         prop.setProperty("group.id", agentName);
162                                         prop.setProperty("zookeeper.connect", info);
163                                 } else {
164                                         prop.setProperty("metadata.broker.list", info);
165                                 }
166                                 out = new FileOutputStream(mmagenthome + "/etc/" + agentName + propName + ".properties");
167                                 prop.store(out, "");
168
169                         } catch (Exception e) {
170                                 logger.error("Exception at checkPropertiesFile " +e);
171                         }
172                 } finally {
173                         if (input != null) {
174                                 try {
175                                         input.close();
176                                 } catch (IOException e) {
177                                         e.printStackTrace();
178                                 }
179                         }
180                         if (out != null) {
181                                 try {
182                                         out.close();
183                                 } catch (IOException e) {
184                                         e.printStackTrace();
185                                         logger.error("IOException" + e);
186                                 }
187                         }
188                 }
189         }
190
191         private void checkAgentProcess() {
192                 logger.info("Checking MirrorMaker Process");
193                 if (mirrorMakers != null) {
194                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
195                         for (int i = 0; i < mirrorMakersCount; i++) {
196                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
197                                 if (MirrorMakerProcessHandler.checkMirrorMakerProcess(mm.name) == false) {
198                                         checkPropertiesFile(mm.name, "consumer", mm.consumer, false);
199                                         checkPropertiesFile(mm.name, "producer", mm.producer, false);
200
201                                         if (mm.whitelist != null && !mm.whitelist.equals("")) {
202                                                 logger.info("MirrorMaker " + mm.name + " is not running, restarting.  Check Logs for more Details");
203                                                 MirrorMakerProcessHandler.startMirrorMaker(this.mmagenthome, this.kafkahome, mm.name,
204                                                                 mmagenthome + "/etc/" + mm.name + "consumer.properties",
205                                                                 mmagenthome + "/etc/" + mm.name + "producer.properties", mm.whitelist);
206                                                 mm.setStatus("RESTARTING");
207
208                                         } else {
209                                                 logger.info("MirrorMaker " + mm.name + " is STOPPED");
210                                                 mm.setStatus("STOPPED");
211                                         }
212                                         try {
213                                                 Thread.sleep(1000);
214                                         } catch (InterruptedException e) {
215                                                  Thread.currentThread().interrupt();
216                                         }
217                                         mirrorMakers.getListMirrorMaker().set(i, mm);
218                                 } else {
219                                         logger.info("MirrorMaker " + mm.name + " is running");
220                                         mm.setStatus("RUNNING");
221                                         mirrorMakers.getListMirrorMaker().set(i, mm);
222                                 }
223                         }
224                 }
225                 // Gson g = new Gson();
226                 // System.out.println(g.toJson(mirrorMakers));
227         }
228
229         private String subscribeTopic(String timeout) {
230                 String response = "";
231                 try {
232                         String requestURL = this.topicURL + "/events/" + this.topicname + "/mirrormakeragent/1?timeout=" + timeout
233                                         + "&limit=1";
234                         String authString = this.mechid + ":" + this.password;
235                         String authStringEnc = Base64.encode(authString.getBytes());
236                         URL url = new URL(requestURL);
237                         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
238                         connection.setRequestMethod("GET");
239                         connection.setDoOutput(true);
240                         connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
241                         connection.setRequestProperty("Content-Type", "application/json");
242                         InputStream content = (InputStream) connection.getInputStream();
243                         BufferedReader in = new BufferedReader(new InputStreamReader(content));
244                         String line;
245
246                         while ((line = in.readLine()) != null) {
247                                 response = response + line;
248                         }
249                         Gson g = new Gson();
250                         // get message as JSON String Array
251                         String[] topicMessage = g.fromJson(response, String[].class);
252                         if (topicMessage.length != 0) {
253                                 return topicMessage[0];
254                         }
255                 } catch (Exception e) {
256                         logger.error(" Exception Occered " + e);
257                         return "ERROR:" + e.getMessage() + " Server Response is:" + response;
258                 }
259                 return null;
260         }
261
262         private String publishTopic(String message) {
263                 try {
264                         String requestURL = this.topicURL + "/events/" + this.topicname;
265                         String authString = this.mechid + ":" + this.password;
266                         String authStringEnc = Base64.encode(authString.getBytes());
267                         URL url = new URL(requestURL);
268                         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
269                         connection.setRequestMethod("POST");
270                         connection.setDoOutput(true);
271                         connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
272                         connection.setRequestProperty("Content-Type", "application/json");
273                         connection.setRequestProperty("Content-Length", Integer.toString(message.length()));
274                         DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
275                         wr.write(message.getBytes());
276
277                         InputStream content = (InputStream) connection.getInputStream();
278                         BufferedReader in = new BufferedReader(new InputStreamReader(content));
279                         String line;
280                         String response = "";
281                         while ((line = in.readLine()) != null) {
282                                 response = response + line;
283                         }
284                         return response;
285
286                 } catch (Exception e) {
287                         logger.error(" Exception Occered " + e);
288                         return "ERROR:" + e.getLocalizedMessage();
289                 }
290         }
291
292         private void readAgentTopic() {
293                 try {
294                         int connectionattempt = 0;
295                         while (true) {
296                                 logger.info("--------------------------------");
297                                 logger.info("Waiting for Messages for 60 secs");
298                                 String topicMessage = subscribeTopic("60000");
299                                 Gson g = new Gson();
300                                 LinkedTreeMap<?, ?> object = null;
301                                 if (topicMessage != null) {
302                                         try {
303                                                 object = g.fromJson(topicMessage, LinkedTreeMap.class);
304
305                                                 // Cast the 1st item (since limit=1 and see the type of
306                                                 // object
307                                                 if (object.get("createMirrorMaker") != null) {
308                                                         logger.info("Received createMirrorMaker request from topic");
309                                                         CreateMirrorMaker m = g.fromJson(topicMessage, CreateMirrorMaker.class);
310                                                         createMirrorMaker(m.getCreateMirrorMaker());
311                                                         checkAgentProcess();
312                                                         mirrorMakers.setMessageID(m.getMessageID());
313                                                         publishTopic(g.toJson(mirrorMakers));
314                                                         mirrorMakers.setMessageID("");
315                                                 } else if (object.get("updateMirrorMaker") != null) {
316                                                         logger.info("Received updateMirrorMaker request from topic");
317                                                         UpdateMirrorMaker m = g.fromJson(topicMessage, UpdateMirrorMaker.class);
318                                                         updateMirrorMaker(m.getUpdateMirrorMaker());
319                                                         checkAgentProcess();
320                                                         mirrorMakers.setMessageID(m.getMessageID());
321                                                         publishTopic(g.toJson(mirrorMakers));
322                                                         mirrorMakers.setMessageID("");
323                                                 } else if (object.get("deleteMirrorMaker") != null) {
324                                                         logger.info("Received deleteMirrorMaker request from topic");
325                                                         DeleteMirrorMaker m = g.fromJson(topicMessage, DeleteMirrorMaker.class);
326                                                         deleteMirrorMaker(m.getDeleteMirrorMaker());
327                                                         checkAgentProcess();
328                                                         mirrorMakers.setMessageID(m.getMessageID());
329                                                         publishTopic(g.toJson(mirrorMakers));
330                                                         mirrorMakers.setMessageID("");
331                                                 } else if (object.get("listAllMirrorMaker") != null) {
332                                                         logger.info("Received listALLMirrorMaker request from topic");
333                                                         checkAgentProcess();
334                                                         mirrorMakers.setMessageID((String) object.get("messageID"));
335                                                         publishTopic(g.toJson(mirrorMakers));
336                                                         mirrorMakers.setMessageID("");
337                                                 } else if (object.get("updateWhiteList") != null) {
338                                                         logger.info("Received updateWhiteList request from topic");
339                                                         UpdateWhiteList m = g.fromJson(topicMessage, UpdateWhiteList.class);
340                                                         updateWhiteList(m.getUpdateWhiteList());
341                                                         checkAgentProcess();
342                                                         mirrorMakers.setMessageID(m.getMessageID());
343                                                         publishTopic(g.toJson(mirrorMakers));
344                                                         mirrorMakers.setMessageID("");
345                                                 } else if (object.get("listMirrorMaker") != null) {
346                                                         logger.info("Received listMirrorMaker from topic, skipping messages");
347                                                 } else {
348                                                         logger.info("Received unknown request from topic");
349                                                 }
350                                         } catch (Exception ex) {
351                                                 connectionattempt++;
352                                                 if (connectionattempt > 5) {
353                                                         logger.info("Can't connect to the topic, mmagent shutting down , " + topicMessage);
354                                                         return;
355                                                 }
356                                                 logger.info("Can't connect to the topic, " + topicMessage + " Retrying " + connectionattempt
357                                                                 + " of 5 times in 1 minute" + " Error:" + ex.getLocalizedMessage());
358                                                 Thread.sleep(60000);
359                                         }
360                                 } else {
361                                         // Check all MirrorMaker every min
362                                         connectionattempt = 0;
363                                         checkAgentProcess();
364                                 }
365
366                         }
367                 } catch (Exception e) {
368                         e.printStackTrace();
369                 }
370
371         }
372
373         protected void createMirrorMaker(MirrorMaker newMirrorMaker) {
374                 boolean exists = false;
375                 if (mirrorMakers != null) {
376                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
377                         for (int i = 0; i < mirrorMakersCount; i++) {
378                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
379                                 if (mm.name.equals(newMirrorMaker.name)) {
380                                         exists = true;
381                                         logger.info("MirrorMaker already exist for:" + newMirrorMaker.name);
382                                         return;
383                                 }
384                         }
385                 }
386                 logger.info("Adding new MirrorMaker:" + newMirrorMaker.name);
387                 if (exists == false && mirrorMakers != null) {
388                         mirrorMakers.getListMirrorMaker().add(newMirrorMaker);
389                 } else if (exists == false && mirrorMakers == null) {
390                         mirrorMakers = new ListMirrorMaker();
391                         ArrayList<MirrorMaker> list = mirrorMakers.getListMirrorMaker();
392                         list = new ArrayList<MirrorMaker>();
393                         list.add(newMirrorMaker);
394                         mirrorMakers.setListMirrorMaker(list);
395                 }
396                 checkPropertiesFile(newMirrorMaker.name, "consumer", newMirrorMaker.consumer, true);
397                 checkPropertiesFile(newMirrorMaker.name, "producer", newMirrorMaker.producer, true);
398
399                 Gson g = new Gson();
400                 mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
401                 OutputStream out = null;
402                 try {
403                         out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
404                         mirrorMakerProperties.store(out, "");
405                 } catch (IOException ex) {
406                         ex.printStackTrace();
407                 } finally {
408                         if (out != null) {
409                                 try {
410                                         out.close();
411                                 } catch (IOException e) {
412                                         e.printStackTrace();
413                                 }
414                         }
415                 }
416         }
417
418         private void updateMirrorMaker(MirrorMaker newMirrorMaker) {
419                 boolean exists = false;
420                 if (mirrorMakers != null) {
421                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
422                         for (int i = 0; i < mirrorMakersCount; i++) {
423                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
424                                 if (mm.name.equals(newMirrorMaker.name)) {
425                                         exists = true;
426                                         mm.setConsumer(newMirrorMaker.getConsumer());
427                                         mm.setProducer(newMirrorMaker.getProducer());
428                                         mirrorMakers.getListMirrorMaker().set(i, mm);
429                                         logger.info("Updating MirrorMaker:" + newMirrorMaker.name);
430                                 }
431                         }
432                 }
433                 if (exists) {
434                         checkPropertiesFile(newMirrorMaker.name, "consumer", newMirrorMaker.consumer, true);
435                         checkPropertiesFile(newMirrorMaker.name, "producer", newMirrorMaker.producer, true);
436
437                         Gson g = new Gson();
438                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
439                         OutputStream out = null;
440                         try {
441                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
442                                 mirrorMakerProperties.store(out, "");
443                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
444                                 try {
445                                         Thread.sleep(1000);
446                                 } catch (InterruptedException e) {
447                                 }
448                         } catch (IOException ex) {
449                                 ex.printStackTrace();
450                         } finally {
451                                 if (out != null) {
452                                         try {
453                                                 out.close();
454                                         } catch (IOException e) {
455                                                 e.printStackTrace();
456                                         }
457                                 }
458                         }
459                 } else {
460                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
461                 }
462         }
463
464         private void updateWhiteList(MirrorMaker newMirrorMaker) {
465                 boolean exists = false;
466                 if (mirrorMakers != null) {
467                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
468                         for (int i = 0; i < mirrorMakersCount; i++) {
469                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
470                                 if (mm.name.equals(newMirrorMaker.name)) {
471                                         exists = true;
472                                         mm.setWhitelist(newMirrorMaker.whitelist);
473                                         mirrorMakers.getListMirrorMaker().set(i, mm);
474                                         logger.info("Updating MirrorMaker WhiteList:" + newMirrorMaker.name + " WhiteList:"
475                                                         + newMirrorMaker.whitelist);
476                                 }
477                         }
478                 }
479                 if (exists) {
480                         Gson g = new Gson();
481                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
482                         OutputStream out = null;
483                         try {
484                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
485                                 mirrorMakerProperties.store(out, "");
486                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
487                                 try {
488                                         Thread.sleep(1000);
489                                 } catch (InterruptedException e) {
490                                 }
491                         } catch (IOException ex) {
492                                 ex.printStackTrace();
493                         } finally {
494                                 if (out != null) {
495                                         try {
496                                                 out.close();
497                                         } catch (IOException e) {
498                                                 e.printStackTrace();
499                                                 logger.error("IOException occered " + e);
500                                         }
501                                 }
502                         }
503                 } else {
504                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
505                 }
506         }
507
508         private void deleteMirrorMaker(MirrorMaker newMirrorMaker) {
509                 boolean exists = false;
510                 if (mirrorMakers != null) {
511                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
512                         for (int i = 0; i < mirrorMakersCount; i++) {
513                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
514                                 if (mm.name.equals(newMirrorMaker.name)) {
515                                         exists = true;
516                                         mirrorMakers.getListMirrorMaker().remove(i);
517                                         logger.info("Removing MirrorMaker:" + newMirrorMaker.name);
518                                         i = mirrorMakersCount;
519                                 }
520                         }
521                 }
522                 if (exists) {
523                         try {
524                                 String path = mmagenthome + "/etc/" + newMirrorMaker.name + "consumer" + ".properties";
525                                 File file = new File(path);
526                                 file.delete();
527                         } catch (Exception ex) {
528                         }
529                         try {
530                                 String path = mmagenthome + "/etc/" + newMirrorMaker.name + "producer" + ".properties";
531                                 File file = new File(path);
532                                 file.delete();
533                         } catch (Exception ex) {
534                         }
535                         Gson g = new Gson();
536                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
537                         OutputStream out = null;
538                         try {
539                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
540                                 mirrorMakerProperties.store(out, "");
541                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
542                         } catch (IOException ex) {
543                                 ex.printStackTrace();
544                         } finally {
545                                 if (out != null) {
546                                         try {
547                                                 out.close();
548                                         } catch (IOException e) {
549                                                 e.printStackTrace();
550                                         }
551                                 }
552                         }
553                 } else {
554                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
555                 }
556         }
557
558         private void loadProperties() {
559                 InputStream input = null;
560                 try {
561
562                         input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
563                         mirrorMakerProperties.load(input);
564                         Gson g = new Gson();
565                         if (mirrorMakerProperties.getProperty("mirrormakers") == null) {
566                                 this.mirrorMakers = new ListMirrorMaker();
567                                 ArrayList<MirrorMaker> list = this.mirrorMakers.getListMirrorMaker();
568                                 list = new ArrayList<MirrorMaker>();
569                                 this.mirrorMakers.setListMirrorMaker(list);
570                         } else {
571                                 this.mirrorMakers = g.fromJson(mirrorMakerProperties.getProperty("mirrormakers"),
572                                                 ListMirrorMaker.class);
573                         }
574
575                         this.kafkahome = mirrorMakerProperties.getProperty("kafkahome");
576                         this.topicURL = mirrorMakerProperties.getProperty("topicURL");
577                         this.topicname = mirrorMakerProperties.getProperty("topicname");
578                         this.mechid = mirrorMakerProperties.getProperty("mechid");
579
580                         BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
581                         textEncryptor.setPassword(secret);
582                         //this.password = textEncryptor.decrypt(mirrorMakerProperties.getProperty("password"));
583                         this.password = mirrorMakerProperties.getProperty("password");
584                 } catch (IOException ex) {
585                         // ex.printStackTrace();
586                 } finally {
587                         if (input != null) {
588                                 try {
589                                         input.close();
590                                 } catch (IOException e) {
591                                         // e.printStackTrace();
592                                 }
593                         }
594                 }
595
596         }
597 }