AlarmEngineConfig.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.monitor.engine.alarm;

  21. import java.io.Serializable;

  22. import org.apache.commons.lang.StringUtils;
  23. import org.openspcoop2.monitor.engine.constants.CostantiConfigurazione;
  24. import org.openspcoop2.utils.mail.SenderType;
  25. import org.openspcoop2.utils.transport.http.HttpUtilities;
  26. import org.openspcoop2.utils.transport.http.SSLConfig;
  27. import org.slf4j.Logger;

  28. /**
  29.  * AlarmEngineConfig
  30.  *
  31.  * @author Poli Andrea (apoli@link.it)
  32.  * @author $Author$
  33.  * @version $Rev$, $Date$
  34.  */
  35. public class AlarmEngineConfig implements Serializable {

  36.     /**
  37.      *
  38.      */
  39.     private static final long serialVersionUID = 1L;
  40.    
  41.     private String activeAlarm_serviceUrl;
  42.     private String activeAlarm_serviceUrl_manager_username;
  43.     private String activeAlarm_serviceUrl_manager_password;
  44.    
  45.     private Integer activeAlarm_serviceUrl_connectionTimeout = HttpUtilities.HTTP_CONNECTION_TIMEOUT;
  46.     private Integer activeAlarm_serviceUrl_readConnectionTimeout = HttpUtilities.HTTP_READ_CONNECTION_TIMEOUT;
  47.    
  48.     private boolean activeAlarm_serviceUrl_https = false;
  49.     private boolean activeAlarm_serviceUrl_https_verificaHostName = true;
  50.     private boolean activeAlarm_serviceUrl_https_autenticazioneServer = true;
  51.     private String activeAlarm_serviceUrl_https_truststorePath = null;
  52.     private String activeAlarm_serviceUrl_https_truststoreType = null;
  53.     private String activeAlarm_serviceUrl_https_truststorePassword = null;
  54.    
  55.     private boolean historyEnabled = true;
  56.    
  57.     private SenderType mailSenderType;
  58.     private Integer mailSenderConnectionTimeout;
  59.     private Integer mailSenderReadTimeout;
  60.     private String mailHost;
  61.     private Integer mailPort;
  62.     private String mailUsername;
  63.     private String mailPassword;
  64.     private SSLConfig mailSSLConfig;
  65.     private boolean mailStartTls;
  66.     private String mailAgent;
  67.     private String mailFrom;
  68.     private String mailSubject;
  69.     private String mailBody;
  70.     private boolean mailDebug;
  71.     private boolean mailSendChangeStatusOk;
  72.     private boolean mailCheckAcknowledgedStatus;
  73.     private boolean mailShowAllOptions;
  74.    
  75.     private String defaultScriptPath;
  76.     private String defaultScriptArgs;
  77.     private boolean scriptDebug;
  78.     private boolean scriptSendChangeStatusOk;
  79.     private boolean scriptCheckAcknowledgedStatus;
  80.     private boolean scriptShowAllOptions;
  81.    
  82.     private boolean optionsUpdateStateActiveAlarm;
  83.     private boolean optionsUpdateStatePassiveAlarm;
  84.     private boolean optionsUpdateAckCriteriaActiveAlarm;
  85.     private boolean optionsUpdateAckCriteriaPassiveAlarm;
  86.     private boolean optionsAcknowledgedStatusAssociation;
  87.     private boolean optionsGroupByApi;
  88.     private boolean optionsFilterApi;
  89.     private boolean optionsFilterApiOrganization;
  90.    
  91.     public boolean isHistoryEnabled() {
  92.         return this.historyEnabled;
  93.     }

  94.     public void setHistoryEnabled(boolean historyEnabled) {
  95.         this.historyEnabled = historyEnabled;
  96.     }
  97.    
  98.     public SenderType getMailSenderType() {
  99.         return this.mailSenderType;
  100.     }

  101.     public void setMailSenderType(SenderType mailSenderType) {
  102.         this.mailSenderType = mailSenderType;
  103.     }

  104.     public Integer getMailSenderConnectionTimeout() {
  105.         return this.mailSenderConnectionTimeout;
  106.     }

  107.     public void setMailSenderConnectionTimeout(Integer mailSenderConnectionTimeout) {
  108.         this.mailSenderConnectionTimeout = mailSenderConnectionTimeout;
  109.     }

  110.     public Integer getMailSenderReadTimeout() {
  111.         return this.mailSenderReadTimeout;
  112.     }

  113.     public void setMailSenderReadTimeout(Integer mailSenderReadTimeout) {
  114.         this.mailSenderReadTimeout = mailSenderReadTimeout;
  115.     }

  116.     public String getMailHost() {
  117.         return this.mailHost;
  118.     }

  119.     public void setMailHost(String mailHost) {
  120.         this.mailHost = mailHost;
  121.     }

  122.     public Integer getMailPort() {
  123.         return this.mailPort;
  124.     }

  125.     public void setMailPort(Integer mailPort) {
  126.         this.mailPort = mailPort;
  127.     }

  128.     public String getMailUsername() {
  129.         return this.mailUsername;
  130.     }

  131.     public void setMailUsername(String mailUsername) {
  132.         this.mailUsername = mailUsername;
  133.     }

  134.     public String getMailPassword() {
  135.         return this.mailPassword;
  136.     }

  137.     public void setMailPassword(String mailPassword) {
  138.         this.mailPassword = mailPassword;
  139.     }

  140.     public SSLConfig getMailSSLConfig() {
  141.         return this.mailSSLConfig;
  142.     }

  143.     public void setMailSSLConfig(SSLConfig mailSSLConfig) {
  144.         this.mailSSLConfig = mailSSLConfig;
  145.     }
  146.    
  147.     public boolean isMailStartTls() {
  148.         return this.mailStartTls;
  149.     }

  150.     public void setMailStartTls(boolean mailStartTls) {
  151.         this.mailStartTls = mailStartTls;
  152.     }

  153.     public String getMailAgent() {
  154.         return this.mailAgent;
  155.     }

  156.     public void setMailAgent(String mailAgent) {
  157.         this.mailAgent = mailAgent;
  158.     }
  159.    
  160.     public String getMailFrom() {
  161.         return this.mailFrom;
  162.     }

  163.     public void setMailFrom(String mailFrom) {
  164.         this.mailFrom = mailFrom;
  165.     }

  166.     public String getMailSubject() {
  167.         return this.mailSubject;
  168.     }

  169.     public void setMailSubject(String mailSubject) {
  170.         this.mailSubject = mailSubject;
  171.     }

  172.     public String getMailBody() {
  173.         return this.mailBody;
  174.     }

  175.     public void setMailBody(String mailBody) {
  176.         this.mailBody = mailBody;
  177.     }

  178.     public String getDefaultScriptPath() {
  179.         return this.defaultScriptPath;
  180.     }

  181.     public void setDefaultScriptPath(String defaultScriptPath) {
  182.         this.defaultScriptPath = defaultScriptPath;
  183.     }

  184.     public String getDefaultScriptArgs() {
  185.         return this.defaultScriptArgs;
  186.     }

  187.     public void setDefaultScriptArgs(String defaultScriptArgs) {
  188.         this.defaultScriptArgs = defaultScriptArgs;
  189.     }

  190.     public boolean isMailCheckAcknowledgedStatus() {
  191.         return this.mailCheckAcknowledgedStatus;
  192.     }

  193.     public void setMailCheckAcknowledgedStatus(boolean mailCheckAcknowledgedStatus) {
  194.         this.mailCheckAcknowledgedStatus = mailCheckAcknowledgedStatus;
  195.     }

  196.     public boolean isMailSendChangeStatusOk() {
  197.         return this.mailSendChangeStatusOk;
  198.     }

  199.     public void setMailSendChangeStatusOk(boolean mailSendChangeStatusOk) {
  200.         this.mailSendChangeStatusOk = mailSendChangeStatusOk;
  201.     }
  202.    
  203.     public boolean isMailShowAllOptions() {
  204.         return this.mailShowAllOptions;
  205.     }

  206.     public void setMailShowAllOptions(boolean mailShowAllOptions) {
  207.         this.mailShowAllOptions = mailShowAllOptions;
  208.     }
  209.    
  210.     public boolean isMailDebug() {
  211.         return this.mailDebug;
  212.     }

  213.     public void setMailDebug(boolean mailDebug) {
  214.         this.mailDebug = mailDebug;
  215.     }

  216.     public boolean isScriptDebug() {
  217.         return this.scriptDebug;
  218.     }

  219.     public void setScriptDebug(boolean scriptDebug) {
  220.         this.scriptDebug = scriptDebug;
  221.     }
  222.    
  223.     public boolean isScriptCheckAcknowledgedStatus() {
  224.         return this.scriptCheckAcknowledgedStatus;
  225.     }

  226.     public void setScriptCheckAcknowledgedStatus(boolean scriptCheckAcknowledgedStatus) {
  227.         this.scriptCheckAcknowledgedStatus = scriptCheckAcknowledgedStatus;
  228.     }
  229.    
  230.     public boolean isScriptSendChangeStatusOk() {
  231.         return this.scriptSendChangeStatusOk;
  232.     }

  233.     public void setScriptSendChangeStatusOk(boolean scriptSendChangeStatusOk) {
  234.         this.scriptSendChangeStatusOk = scriptSendChangeStatusOk;
  235.     }
  236.    
  237.     public boolean isScriptShowAllOptions() {
  238.         return this.scriptShowAllOptions;
  239.     }

  240.     public void setScriptShowAllOptions(boolean scriptShowAllOptions) {
  241.         this.scriptShowAllOptions = scriptShowAllOptions;
  242.     }
  243.    
  244.     public String getActiveAlarm_serviceUrl() {
  245.         return this.activeAlarm_serviceUrl;
  246.     }

  247.     public void setActiveAlarm_serviceUrl(String activeAlarm_serviceUrl) {
  248.         this.activeAlarm_serviceUrl = activeAlarm_serviceUrl;
  249.     }
  250.    
  251.     public String getActiveAlarm_serviceUrl_manager_username() {
  252.         return this.activeAlarm_serviceUrl_manager_username;
  253.     }

  254.     public void setActiveAlarm_serviceUrl_manager_username(String activeAlarm_serviceUrl_manager_username) {
  255.         this.activeAlarm_serviceUrl_manager_username = activeAlarm_serviceUrl_manager_username;
  256.     }

  257.     public String getActiveAlarm_serviceUrl_manager_password() {
  258.         return this.activeAlarm_serviceUrl_manager_password;
  259.     }

  260.     public void setActiveAlarm_serviceUrl_manager_password(String activeAlarm_serviceUrl_manager_password) {
  261.         this.activeAlarm_serviceUrl_manager_password = activeAlarm_serviceUrl_manager_password;
  262.     }
  263.    
  264.     public Integer getActiveAlarm_serviceUrl_connectionTimeout() {
  265.         return this.activeAlarm_serviceUrl_connectionTimeout;
  266.     }

  267.     public void setActiveAlarm_serviceUrl_connectionTimeout(Integer activeAlarm_serviceUrl_connectionTimeout) {
  268.         this.activeAlarm_serviceUrl_connectionTimeout = activeAlarm_serviceUrl_connectionTimeout;
  269.     }

  270.     public Integer getActiveAlarm_serviceUrl_readConnectionTimeout() {
  271.         return this.activeAlarm_serviceUrl_readConnectionTimeout;
  272.     }

  273.     public void setActiveAlarm_serviceUrl_readConnectionTimeout(Integer activeAlarm_serviceUrl_readConnectionTimeout) {
  274.         this.activeAlarm_serviceUrl_readConnectionTimeout = activeAlarm_serviceUrl_readConnectionTimeout;
  275.     }

  276.     public boolean isActiveAlarm_serviceUrl_https() {
  277.         return this.activeAlarm_serviceUrl_https;
  278.     }

  279.     public void setActiveAlarm_serviceUrl_https(boolean activeAlarm_serviceUrl_https) {
  280.         this.activeAlarm_serviceUrl_https = activeAlarm_serviceUrl_https;
  281.     }

  282.     public boolean isActiveAlarm_serviceUrl_https_verificaHostName() {
  283.         return this.activeAlarm_serviceUrl_https_verificaHostName;
  284.     }

  285.     public void setActiveAlarm_serviceUrl_https_verificaHostName(boolean activeAlarm_serviceUrl_https_verificaHostName) {
  286.         this.activeAlarm_serviceUrl_https_verificaHostName = activeAlarm_serviceUrl_https_verificaHostName;
  287.     }

  288.     public boolean isActiveAlarm_serviceUrl_https_autenticazioneServer() {
  289.         return this.activeAlarm_serviceUrl_https_autenticazioneServer;
  290.     }

  291.     public void setActiveAlarm_serviceUrl_https_autenticazioneServer(
  292.             boolean activeAlarm_serviceUrl_https_autenticazioneServer) {
  293.         this.activeAlarm_serviceUrl_https_autenticazioneServer = activeAlarm_serviceUrl_https_autenticazioneServer;
  294.     }

  295.     public String getActiveAlarm_serviceUrl_https_truststorePath() {
  296.         return this.activeAlarm_serviceUrl_https_truststorePath;
  297.     }

  298.     public void setActiveAlarm_serviceUrl_https_truststorePath(String activeAlarm_serviceUrl_https_truststorePath) {
  299.         this.activeAlarm_serviceUrl_https_truststorePath = activeAlarm_serviceUrl_https_truststorePath;
  300.     }

  301.     public String getActiveAlarm_serviceUrl_https_truststoreType() {
  302.         return this.activeAlarm_serviceUrl_https_truststoreType;
  303.     }

  304.     public void setActiveAlarm_serviceUrl_https_truststoreType(String activeAlarm_serviceUrl_https_truststoreType) {
  305.         this.activeAlarm_serviceUrl_https_truststoreType = activeAlarm_serviceUrl_https_truststoreType;
  306.     }

  307.     public String getActiveAlarm_serviceUrl_https_truststorePassword() {
  308.         return this.activeAlarm_serviceUrl_https_truststorePassword;
  309.     }

  310.     public void setActiveAlarm_serviceUrl_https_truststorePassword(String activeAlarm_serviceUrl_https_truststorePassword) {
  311.         this.activeAlarm_serviceUrl_https_truststorePassword = activeAlarm_serviceUrl_https_truststorePassword;
  312.     }
  313.    
  314.     public boolean isOptionsUpdateStateActiveAlarm() {
  315.         return this.optionsUpdateStateActiveAlarm;
  316.     }

  317.     public void setOptionsUpdateStateActiveAlarm(boolean optionsUpdateState) {
  318.         this.optionsUpdateStateActiveAlarm = optionsUpdateState;
  319.     }
  320.    
  321.     public boolean isOptionsUpdateStatePassiveAlarm() {
  322.         return this.optionsUpdateStatePassiveAlarm;
  323.     }

  324.     public void setOptionsUpdateStatePassiveAlarm(boolean optionsUpdateState) {
  325.         this.optionsUpdateStatePassiveAlarm = optionsUpdateState;
  326.     }
  327.    
  328.     public boolean isOptionsUpdateAckCriteriaActiveAlarm() {
  329.         return this.optionsUpdateAckCriteriaActiveAlarm;
  330.     }

  331.     public void setOptionsUpdateAckCriteriaActiveAlarm(boolean optionsUpdateAckCriteria) {
  332.         this.optionsUpdateAckCriteriaActiveAlarm = optionsUpdateAckCriteria;
  333.     }
  334.    
  335.     public boolean isOptionsUpdateAckCriteriaPassiveAlarm() {
  336.         return this.optionsUpdateAckCriteriaPassiveAlarm;
  337.     }

  338.     public void setOptionsUpdateAckCriteriaPassiveAlarm(boolean optionsUpdateAckCriteria) {
  339.         this.optionsUpdateAckCriteriaPassiveAlarm = optionsUpdateAckCriteria;
  340.     }

  341.     public boolean isOptionsAcknowledgedStatusAssociation() {
  342.         return this.optionsAcknowledgedStatusAssociation;
  343.     }

  344.     public void setOptionsAcknowledgedStatusAssociation(boolean optionsAcknowledgedStatusAssociation) {
  345.         this.optionsAcknowledgedStatusAssociation = optionsAcknowledgedStatusAssociation;
  346.     }

  347.     public boolean isOptionsGroupByApi() {
  348.         return this.optionsGroupByApi;
  349.     }

  350.     public void setOptionsGroupByApi(boolean optionsGroupByApi) {
  351.         this.optionsGroupByApi = optionsGroupByApi;
  352.     }

  353.     public boolean isOptionsFilterApi() {
  354.         return this.optionsFilterApi;
  355.     }

  356.     public void setOptionsFilterApi(boolean optionsFilterApi) {
  357.         this.optionsFilterApi = optionsFilterApi;
  358.     }

  359.     public boolean isOptionsFilterApiOrganization() {
  360.         return this.optionsFilterApiOrganization;
  361.     }

  362.     public void setOptionsFilterApiOrganization(boolean optionsFilterApiOrganization) {
  363.         this.optionsFilterApiOrganization = optionsFilterApiOrganization;
  364.     }
  365.    
  366.     protected static AlarmEngineConfig readAlarmEngineConfig(Logger log,AlarmConfigProperties alarmConfigProperties) throws Exception{
  367.        
  368.         AlarmEngineConfig config = new AlarmEngineConfig();
  369.        
  370.         config.setActiveAlarm_serviceUrl(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ACTIVE_SERVICE_URL, true, true));
  371.         config.setActiveAlarm_serviceUrl_manager_username(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ACTIVE_SERVICE_URL_MANAGER_USERNAME, true, true));
  372.         config.setActiveAlarm_serviceUrl_manager_password(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ACTIVE_SERVICE_URL_MANAGER_PASSWORD, true, true));
  373.        
  374.         String readConnectionTimeout = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ACTIVE_SERVICE_READ_CONNECTION_TIMEOUT, false, true);
  375.         if(StringUtils.isNotEmpty(readConnectionTimeout)) {
  376.             config.setActiveAlarm_serviceUrl_readConnectionTimeout(Integer.valueOf(readConnectionTimeout));
  377.         }
  378.         String connectionTimeout = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ACTIVE_SERVICE_CONNECTION_TIMEOUT, false, true);
  379.         if(StringUtils.isNotEmpty(connectionTimeout)) {
  380.             config.setActiveAlarm_serviceUrl_readConnectionTimeout(Integer.valueOf(connectionTimeout));
  381.         }
  382.        
  383.         String https = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ACTIVE_SERVICE_URL_HTTPS, false, true);
  384.         if(https!=null) {
  385.             config.setActiveAlarm_serviceUrl_https(Boolean.parseBoolean(https));
  386.         }
  387.         if(config.isActiveAlarm_serviceUrl_https()) {
  388.            
  389.             String hostnameVerifier = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ACTIVE_SERVICE_URL_HTTPS_HOSTNAME_VERIFIER, false, true);
  390.             if(hostnameVerifier!=null) {
  391.                 config.setActiveAlarm_serviceUrl_https_verificaHostName(Boolean.parseBoolean(hostnameVerifier));
  392.             }
  393.            
  394.             String serverAuth = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ACTIVE_SERVICE_URL_HTTPS_SERVER_AUTH, false, true);
  395.             if(serverAuth!=null) {
  396.                 config.setActiveAlarm_serviceUrl_https_autenticazioneServer(Boolean.parseBoolean(serverAuth));
  397.             }
  398.             if(config.isActiveAlarm_serviceUrl_https_autenticazioneServer()) {
  399.                 config.setActiveAlarm_serviceUrl_https_truststorePath(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ACTIVE_SERVICE_URL_HTTPS_SERVER_AUTH_TRUSTSTORE_PATH, true, true));
  400.                 config.setActiveAlarm_serviceUrl_https_truststoreType(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ACTIVE_SERVICE_URL_HTTPS_SERVER_AUTH_TRUSTSTORE_TYPE, true, true));
  401.                 config.setActiveAlarm_serviceUrl_https_truststorePassword(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ACTIVE_SERVICE_URL_HTTPS_SERVER_AUTH_TRUSTSTORE_PASSWORD, true, true));
  402.             }
  403.        
  404.         }
  405.        
  406.         String alarmHistoryEnabled = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_HISTORY_ENABLED, false, true);
  407.         if(alarmHistoryEnabled!=null) {
  408.             config.setHistoryEnabled(Boolean.parseBoolean(alarmHistoryEnabled));
  409.         }
  410.        
  411.         String mailSenderHost = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_HOST, false, true);
  412.         if(mailSenderHost!=null){
  413.             config.setMailHost(mailSenderHost);
  414.            
  415.             String mailSenderType = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SENDER_TYPE, true, true);
  416.             config.setMailSenderType(SenderType.valueOf(mailSenderType));
  417.            
  418.             String mailSenderConnectionTimeout = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SENDER_CONNECTION_TIMEOUT, false, true);
  419.             if(mailSenderConnectionTimeout!=null){
  420.                 config.setMailSenderConnectionTimeout(Integer.parseInt(mailSenderConnectionTimeout));
  421.             }
  422.            
  423.             String mailSenderReadTimeout = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SENDER_READ_TIMEOUT, false, true);
  424.             if(mailSenderReadTimeout!=null){
  425.                 config.setMailSenderReadTimeout(Integer.parseInt(mailSenderReadTimeout));
  426.             }
  427.            
  428.             config.setMailPort(Integer.parseInt(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_PORT, true, true)));
  429.            
  430.             String mailSenderUsername = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_USERNAME, false, true);
  431.             if(mailSenderUsername!=null){
  432.                 config.setMailUsername(mailSenderUsername);
  433.             }
  434.            
  435.             String mailSenderPassword = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_PASSWORD, false, true);
  436.             if(mailSenderPassword!=null){
  437.                 config.setMailPassword(mailSenderPassword);
  438.             }
  439.            
  440.             String mailSenderSSLType = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SSL_TYPE, false, true);
  441.             if(mailSenderSSLType!=null){
  442.                 SSLConfig mailSSLConfig = new SSLConfig();
  443.            
  444.                 mailSSLConfig.setSslType(mailSenderSSLType);
  445.                
  446.                 mailSSLConfig.setHostnameVerifier(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SSL_HOSTNAME_VERIFIER, true, true)));
  447.                 boolean serverAuth = Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SSL_SERVER_AUTH, true, true));
  448.                 if(serverAuth) {
  449.                     mailSSLConfig.setTrustStoreLocation(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SSL_TRUSTSTORE_LOCATION, true, true));
  450.                     mailSSLConfig.setTrustStoreType(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SSL_TRUSTSTORE_TYPE, true, true));
  451.                     mailSSLConfig.setTrustStorePassword(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SSL_TRUSTSTORE_PASSWORD, true, true));
  452.                     mailSSLConfig.setTrustManagementAlgorithm(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SSL_TRUSTSTORE_MANAGEMENT_ALGORITHM, true, true));
  453.                 }
  454.                 else {
  455.                     mailSSLConfig.setTrustAllCerts(true);
  456.                 }
  457.                 config.setMailStartTls(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SSL_START_TLS, true, true)));
  458.                
  459.                 config.setMailSSLConfig(mailSSLConfig);
  460.             }
  461.            
  462.             config.setMailAgent(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_AGENT, false, true));
  463.            
  464.             config.setMailFrom(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_FROM, true, true));
  465.             config.setMailSubject(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SUBJECT, true, true));
  466.             config.setMailBody(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_BODY, true, true));
  467.        
  468.             config.setMailDebug(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_DEBUG, true, true)));
  469.            
  470.             config.setMailCheckAcknowledgedStatus(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_CHECK_ACKNOWLEDGED_STATUS, true, true)));
  471.            
  472.             config.setMailSendChangeStatusOk(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SEND_CHANGE_STATUS_OK, true, true)));
  473.            
  474.             config.setMailShowAllOptions(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_MAIL_SHOW_ALL_OPTIONS, true, true)));

  475.         }
  476.        
  477.         String alarmScript = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_SCRIPT_PATH, false, true);
  478.         if(alarmScript!=null){
  479.             config.setDefaultScriptPath(alarmScript);
  480.             config.setDefaultScriptArgs(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_SCRIPT_ARGS, true, true));
  481.         }
  482.         // L'ack mode è obbligatorio (lo script può essere impostato anche dentro l'allarme)
  483.         config.setScriptDebug(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_SCRIPT_DEBUG, true, true)));
  484.         config.setScriptCheckAcknowledgedStatus(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_SCRIPT_CHECK_ACKNOWLEDGED_STATUS, true, true)));
  485.         config.setScriptSendChangeStatusOk(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_SCRIPT_SEND_CHANGE_STATUS_OK, true, true)));
  486.         config.setScriptShowAllOptions(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_SCRIPT_SHOW_ALL_OPTIONS, true, true)));

  487.        
  488.         config.setOptionsUpdateStateActiveAlarm(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ADVANCED_OPTIONS_UPDATE_STATE_ACTIVE_ALARM, true, true)));
  489.         config.setOptionsUpdateStatePassiveAlarm(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ADVANCED_OPTIONS_UPDATE_STATE_PASSIVE_ALARM, true, true)));
  490.        
  491.         config.setOptionsAcknowledgedStatusAssociation(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ADVANCED_OPTIONS_ACK_STATUS_ASSOCIATION, true, true)));
  492.        
  493.         String s = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ADVANCED_OPTIONS_UPDATE_ACK_CRITERIA_ACTIVE_ALARM, false, true);
  494.         if(StringUtils.isNotEmpty(s)) {
  495.             config.setOptionsUpdateAckCriteriaActiveAlarm(Boolean.parseBoolean(s));
  496.         }
  497.         else {
  498.             config.setOptionsUpdateAckCriteriaActiveAlarm(true);
  499.         }
  500.         s = alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ADVANCED_OPTIONS_UPDATE_ACK_CRITERIA_PASSIVE_ALARM, false, true);
  501.         if(StringUtils.isNotEmpty(s)) {
  502.             config.setOptionsUpdateAckCriteriaPassiveAlarm(Boolean.parseBoolean(s));
  503.         }
  504.         else {
  505.             config.setOptionsUpdateAckCriteriaPassiveAlarm(false);
  506.         }
  507.        
  508.         config.setOptionsGroupByApi(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ADVANCED_OPTIONS_GROUP_BY_API, true, true)));
  509.         config.setOptionsFilterApi(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ADVANCED_OPTIONS_FILTER_API, true, true)));
  510.         config.setOptionsFilterApiOrganization(Boolean.parseBoolean(alarmConfigProperties.getProperty(CostantiConfigurazione.ALARM_ADVANCED_OPTIONS_FILTER_API_ORGANIZATION, true, true)));
  511.        
  512.         return config;
  513.     }
  514. }