diff --git a/antifurto/bin/code/Antifurto.class b/antifurto/bin/code/Antifurto.class
index 43b851c415891f675e6187c84cf73694cd7bc082..12945e7039b8b0405b15cb5080541a4137dddfe3 100644
Binary files a/antifurto/bin/code/Antifurto.class and b/antifurto/bin/code/Antifurto.class differ
diff --git a/antifurto/bin/code/Automa.class b/antifurto/bin/code/Automa.class
index c606cfee341329883be8d41f4f90d6a9e3bc4d65..9ee24747ba7dfbd2afb48f9cf9bbb09b3eade611 100644
Binary files a/antifurto/bin/code/Automa.class and b/antifurto/bin/code/Automa.class differ
diff --git a/antifurto/bin/code/Esecutore.class b/antifurto/bin/code/Esecutore.class
index 5a9a55bbfcd00494cc875ff88c33a56c0e9f1e4b..adfd4a031bf2c22d8b40e866da7f46202eccb30f 100644
Binary files a/antifurto/bin/code/Esecutore.class and b/antifurto/bin/code/Esecutore.class differ
diff --git a/antifurto/bin/code/Helper.class b/antifurto/bin/code/Helper.class
index 27eb86ed7d768ec518afd3d2d023d10e0143c0aa..cbfca13d4240a1884a93c6cbb7ccbb591b612e09 100644
Binary files a/antifurto/bin/code/Helper.class and b/antifurto/bin/code/Helper.class differ
diff --git a/antifurto/bin/code/MyQueue.class b/antifurto/bin/code/MyQueue.class
index 9801fb6cbdbcc4c4617ce10657e8202676670f8f..50ac71d1e9f4ea9afa31bd320196bcda41a7245b 100644
Binary files a/antifurto/bin/code/MyQueue.class and b/antifurto/bin/code/MyQueue.class differ
diff --git a/antifurto/bin/code/Pair.class b/antifurto/bin/code/Pair.class
index 63c21e1fcc5b31b57a8ebe1d164faa30bbad0c41..86b1dcf26b53593f2adc887c6453e5aa817d353f 100644
Binary files a/antifurto/bin/code/Pair.class and b/antifurto/bin/code/Pair.class differ
diff --git a/antifurto/bin/code/Publisher.class b/antifurto/bin/code/Publisher.class
index 7f601d48df6a54254ba827d30fb5fe762a636eca..4d607d806d239c2b6883e4b242d430e7d963e18a 100644
Binary files a/antifurto/bin/code/Publisher.class and b/antifurto/bin/code/Publisher.class differ
diff --git a/antifurto/bin/code/SubscribeCallback.class b/antifurto/bin/code/SubscribeCallback.class
index 1d482a3ae71725639e0a6261a65cf3d1aa32831e..39b015fa02874cceef916f7b8aafb994c701a80d 100644
Binary files a/antifurto/bin/code/SubscribeCallback.class and b/antifurto/bin/code/SubscribeCallback.class differ
diff --git a/antifurto/bin/code/Timer.class b/antifurto/bin/code/Timer.class
index 2edff9f10d2659030c9ea4fad254d1e005b90b87..453e7f52694373063e3dfdbee7b4c29d1ec4ba84 100644
Binary files a/antifurto/bin/code/Timer.class and b/antifurto/bin/code/Timer.class differ
diff --git a/antifurto/certificates/localhost/README b/antifurto/certificates/localhost/README
deleted file mode 100644
index 30b62c593df8d7a8e9dbafebaf3d6a36191fec21..0000000000000000000000000000000000000000
--- a/antifurto/certificates/localhost/README
+++ /dev/null
@@ -1,2 +0,0 @@
-In questa directory ci sono i certificati che ho creato. 
-La password usata è: pissir
diff --git a/antifurto/certificates/localhost/ca.crt b/antifurto/certificates/localhost/ca.crt
deleted file mode 100644
index 8d8e5513809afd89d64515cc6291a71105077c4d..0000000000000000000000000000000000000000
--- a/antifurto/certificates/localhost/ca.crt
+++ /dev/null
@@ -1,24 +0,0 @@
------BEGIN CERTIFICATE-----
-MIID/TCCAuWgAwIBAgIUC9arj1dlWXFbpFhOY4tTSHvpPQcwDQYJKoZIhvcNAQEL
-BQAwgY0xCzAJBgNVBAYTAklUMQswCQYDVQQIDAJBTDEUMBIGA1UEBwwLQWxlc3Nh
-bmRyaWExDzANBgNVBAoMBnVuaXVwbzEOMAwGA1UECwwFRElTSVQxDjAMBgNVBAMM
-BW1pYUNBMSowKAYJKoZIhvcNAQkBFhsyMDAzMDc4NEBzdHVkZW50aS51bml1cG8u
-aXQwHhcNMjIwMTEwMTQzMDE1WhcNMjMwMjE0MTQzMDE1WjCBjTELMAkGA1UEBhMC
-SVQxCzAJBgNVBAgMAkFMMRQwEgYDVQQHDAtBbGVzc2FuZHJpYTEPMA0GA1UECgwG
-dW5pdXBvMQ4wDAYDVQQLDAVESVNJVDEOMAwGA1UEAwwFbWlhQ0ExKjAoBgkqhkiG
-9w0BCQEWGzIwMDMwNzg0QHN0dWRlbnRpLnVuaXVwby5pdDCCASIwDQYJKoZIhvcN
-AQEBBQADggEPADCCAQoCggEBAJ0JxzeKCC0rChOt9C+ixBi3BtFLMNxF0EY2lraY
-80gIneAVNub/UMnv7UiWcfWOQgt1qaPwSRyW9TMu9EK7wG/Ak5ldj7Q7saGj2QU0
-S8u3iesfwjazHYfI2lE39uLe55toRmgH4Zo2vFnMXxj3Ch1Clysjy4L14KpgmmMd
-rfhZEu27ZqxZ4cyKE54slCPHxmBamBq7q/ZpDhEFtqRXDyH59wfzHhPsm/wAcCSR
-MFdDR6ZGNvYIyH9HdSu/PW+Fg4oeC4JZs8g9ZmiaR99B0VRMSrKOotpJkkUPeR5X
-uIdO91CSieuAsXFR0isSgWPN28aGKuDZ+q9usuop/wVxfC0CAwEAAaNTMFEwHQYD
-VR0OBBYEFKnDlntcV1O604yubWyepbv2x0z2MB8GA1UdIwQYMBaAFKnDlntcV1O6
-04yubWyepbv2x0z2MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEB
-ADr0hF+pqZL96JI2MazxuJ8aaShNM+JHsaTuicR7gBFMB9C21QOmLD6lREun1pdD
-oldfr+WtfnFkYjvACTbRkCShfmMIVOimXGw2xxzx1o+nRrIRyvqlisidb1QCl28c
-BXtr3Mm8U+lsdIoUcKT+nWvHFlXpqtSNoRpO4SCawJr/dkgZi3D5MmlsiYYMA/3V
-gJPyDX5XuEvRmGIf1kluAWIWebyCc4KDyM/PT3QQKAyeQwAhRJGnnx6LLP5nBscn
-+FumrHPBKf8KBgP3+DjdzVC+5o23VqXoRGCf8J6ectzkPmH+zUZUZfRF2dZk4rVR
-Lmm+2hhoFwvyAlVCPLqnNnk=
------END CERTIFICATE-----
diff --git a/antifurto/certificates/localhost/ca.key b/antifurto/certificates/localhost/ca.key
deleted file mode 100644
index c590a5816b3b01a8e4a516a3831a086ba8091018..0000000000000000000000000000000000000000
--- a/antifurto/certificates/localhost/ca.key
+++ /dev/null
@@ -1,30 +0,0 @@
------BEGIN ENCRYPTED PRIVATE KEY-----
-MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIB3awHNyDig8CAggA
-MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECJmPW6mIm/P6BIIEyKGZWCtCmZ8f
-rxSS4T7MEhWtURpSsOZxFewf9NPp2/ac0Q2i8+K0qU+1NTuEduxla97JBSVCtb1c
-Gz3R9oIEz6RtSWmueyFABdiXgIcSThTf+j/XQF+k7kwKk++MJVufWT5VNcPtifQ+
-pkwWGOz/qx9MWzEyKLv2u5lC3S+VCqYQkCQFDNQrZf+VCbn33EScxMjwg6MlbzMB
-t8UqzJ/R1l+06lQ/C2aGwNOq9F1yvvrayZMkHdQG1qvveBjbX+yKDAZvqolpZW0z
-jh1IE6wsy1tdyBUbqG6g7cAwzngaz2g3+O72JnLP7zAeIX/86whbPSUyCPIviuoV
-qT4lkTaU1LacvvjemSSry6ws13V6wJ1lgOk1gBoanOExaHPN1GNarbOT/HX1Qo28
-i3XQbmEiIzmk5O6VQjxO6lon04rYHJ4CF0dS3OW0cC1XBH2WZoFuhcPNSRrE4NcQ
-WwIx6TDm6DxlFuYiuf8Q5k5531VKEsPfdD4HiTiJWBwt+V66V63AMeiPM7nKD2Se
-ACs8wor1D1iFTw20BXG20w/I7TvZ9d2UrVtBiIUszJHzRm2hSXxptcLey06RF+qi
-qscs248MlcnheDWPiKdXPICATgF8G0xjSvoAr6STw9n3agKeNLVsqkBex8Ao496R
-hqGtQ70P2PcF6Aq2CjmtqjLHSLTiGmfVOYH0bWFUWNpasXiZXwLPKu9/M9e7NERD
-i7lwUJgevz8VL9afq5pc9vTf9K36kpfIXUpQt/+QkPYiiMdeiqbiRncS3Kp/m+Ks
-vfCaJYuOwNXVvpg+cGiLIeFbEVQeSbl9kVQvpposQ/oIFHZekaH1fP0fE9pw0w72
-etix/OZ2BXOSR2XxxZsTvrjdyOk89Ulz0/ZB4RQ0Fn+H9IQgqPTeU4ioYwza2x8y
-rBT9QW52TJAPEHHPLkqKDZl0a8vCS3JARZ+OpeKoqhDM4cnEC3ASuFIBhtxmbBio
-AGFAZcTys1PENha0L956LoQ+9TvsvJrDVIA+yT+BuHqVhdJoYJ/n9Z1UQgv3vKDO
-2XWlEnK/me8n2cDsFC6CB6IrHurofXAeMQosV+KoSn/oGNOpFWDfXMbaxyRpi4rj
-qRbqw7Fzs7BC7MdLAGq2pN8yvbgEs1N3lzkJBNFodxc+Y2iU3CCD1TWv2eEW3/x1
-74RFZFmHRhdH1pBlp+7TCiw/nc33Kn34jpANuYWKv3eJdq0TghjPgDpL7vIaYKbb
-gzR6lboYnFWSude2zd8OLjadUWzoCk67Qcd+dkNnCSTDTb7auckzDWU8NDH7zHca
-jbQ+5Xq86U/glvExw4VBtiCrtBbHbqXhbnTB7u3Elx6HFD2lDmjAwX1pK6HgTqLo
-8h7lgtpgZ4rXQD/b8r8AHrjcas5h5n3pLw1UGIcH+6AQ8Z4DYL9X4dWiZpsw+fGo
-BpHUYrgRMYWG7IVB6Ta2lskrpEBYMZJFOzvLUGwhZnD7wd5GWRbq9r4Im7f7Ee5d
-ntJjgz7e1Je+CFCxl/wESsa2LOkaODKhWbJNJa+jpGrBcXcA87W/LBSy0mn66B3f
-0OBSBG50rgwUvbYtMFvV4k6uj0YjAg/gASOiMU9QXrljOiSE/vINQgYPOuJhVUri
-nMbdQnuNJ27s+a/l8XdS7A==
------END ENCRYPTED PRIVATE KEY-----
diff --git a/antifurto/certificates/localhost/ca.srl b/antifurto/certificates/localhost/ca.srl
deleted file mode 100644
index 791528c2ccf0de920e6a01daa97ee89192c10dd9..0000000000000000000000000000000000000000
--- a/antifurto/certificates/localhost/ca.srl
+++ /dev/null
@@ -1 +0,0 @@
-6F563B2A9592BC5962855BCC51155644910E685A
diff --git a/antifurto/certificates/localhost/client.crt b/antifurto/certificates/localhost/client.crt
deleted file mode 100644
index f9e8b0576167207a6a8871d48a5b127e4b6474c7..0000000000000000000000000000000000000000
--- a/antifurto/certificates/localhost/client.crt
+++ /dev/null
@@ -1,22 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDpDCCAowCFG9WOyqVkrxZYoVbzFEVVkSRDmhaMA0GCSqGSIb3DQEBCwUAMIGN
-MQswCQYDVQQGEwJJVDELMAkGA1UECAwCQUwxFDASBgNVBAcMC0FsZXNzYW5kcmlh
-MQ8wDQYDVQQKDAZ1bml1cG8xDjAMBgNVBAsMBURJU0lUMQ4wDAYDVQQDDAVtaWFD
-QTEqMCgGCSqGSIb3DQEJARYbMjAwMzA3ODRAc3R1ZGVudGkudW5pdXBvLml0MB4X
-DTIyMDExMDE0Mzk1NloXDTIzMDExMDE0Mzk1NlowgY4xCzAJBgNVBAYTAklUMQsw
-CQYDVQQIDAJBTDEUMBIGA1UEBwwLQWxlc3NhbmRyaWExDzANBgNVBAoMBlVOSVVQ
-TzEOMAwGA1UECwwFRElTSVQxDzANBgNVBAMMBnBpc3NpcjEqMCgGCSqGSIb3DQEJ
-ARYbMjAwMzA3ODRAc3R1ZGVudGkudW5pdXBvLml0MIIBIjANBgkqhkiG9w0BAQEF
-AAOCAQ8AMIIBCgKCAQEA03P5/25CxPGTBFgfJHXzZMoT986OwPG9zyYUnhCXLEI7
-GYdF+42OVdY/NPLQqvCe+G70Q2g6B4nYBlFc1VugjcZpvnm/pbJWHs1T6QIcp8CY
-29BqHMztoYjCciK5xLO65hZ9+w4EwoBqlyXfqXbJBgatomh7W7hpM/s/c7uh+/e8
-CAEexPnRXC7URAYJ0UZmFonpKOm0iM1GsxZEARhpmEDfiPSBlPmX42YeAWHQWVJw
-9bZccD2X5u9MeHa1sSorPWmsKVgCOPFoOh8wAmo+ANgDCGlMjPRlH8b8szy/mEAL
-p2Jf1XbIAB4xlIZnA5GCN45SBbT7ExjrF48V7yg1eQIDAQABMA0GCSqGSIb3DQEB
-CwUAA4IBAQCFWrxUlJL/t+w+vZUZQBli1EM42fkc/9E1zet4kgjda8x776fLse9J
-ghynwR+2Dy7Ct+L7fyjSRXrrQ0iV1Y+h6oQyBwrnlpIwTC6T2UxRO40/XyPAKBT1
-RVakHpzObi3Q2RqsVT45wjVeRRui0WTLMuQ8z8ntKtMnNQ35uvdpCChF7ceY7Zcs
-F3ip+P3tUKGjw782wDVirTNyAa602JKS5pOfxWCoRSckdiC56Jd26BITEaKRUEQh
-Lcs729HwKU0rU0F3hD2BkJvpyp4bdZcpMNjW6FrdudMFqjOdwvCfvPcx4Rv5MdX1
-2YjJ1axBuN75y4DMGhh+4Mbn3L4n812i
------END CERTIFICATE-----
diff --git a/antifurto/certificates/localhost/client.csr b/antifurto/certificates/localhost/client.csr
deleted file mode 100644
index 54a3948547fe0f9db4bd552e47e2662182850062..0000000000000000000000000000000000000000
--- a/antifurto/certificates/localhost/client.csr
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN CERTIFICATE REQUEST-----
-MIIC6zCCAdMCAQAwgY4xCzAJBgNVBAYTAklUMQswCQYDVQQIDAJBTDEUMBIGA1UE
-BwwLQWxlc3NhbmRyaWExDzANBgNVBAoMBlVOSVVQTzEOMAwGA1UECwwFRElTSVQx
-DzANBgNVBAMMBnBpc3NpcjEqMCgGCSqGSIb3DQEJARYbMjAwMzA3ODRAc3R1ZGVu
-dGkudW5pdXBvLml0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA03P5
-/25CxPGTBFgfJHXzZMoT986OwPG9zyYUnhCXLEI7GYdF+42OVdY/NPLQqvCe+G70
-Q2g6B4nYBlFc1VugjcZpvnm/pbJWHs1T6QIcp8CY29BqHMztoYjCciK5xLO65hZ9
-+w4EwoBqlyXfqXbJBgatomh7W7hpM/s/c7uh+/e8CAEexPnRXC7URAYJ0UZmFonp
-KOm0iM1GsxZEARhpmEDfiPSBlPmX42YeAWHQWVJw9bZccD2X5u9MeHa1sSorPWms
-KVgCOPFoOh8wAmo+ANgDCGlMjPRlH8b8szy/mEALp2Jf1XbIAB4xlIZnA5GCN45S
-BbT7ExjrF48V7yg1eQIDAQABoBcwFQYJKoZIhvcNAQkHMQgMBnBpc3NpcjANBgkq
-hkiG9w0BAQsFAAOCAQEAwUWZxRNPK4DujSRt834LblMRE8q6r7Uc7i/lcjULsQYe
-1My89BwG3f166xOyEi373NQVjGPeQMWcO9ZgfZsGq+9UrYKaP2F9hER0A4clzhlU
-htwrWzTK2ixq4i/xlh0zTCr9P9l5ljfAN1B62k/8sK4UVkUmMu9iWzjKKctt43SP
-0v9sQIP/5mtQpJ5/a/M9pxis455W4gPKBs3OOXIWycoXWFOKGkP2bS4JBIhzi/88
-zRrkkQQfJD7Af0Vf4NTVu1Lx4C0RK+XIvzQ6VO74uIvRwmOMaotwikW9KiKB46kk
-UFNRKy1gze2afBPBRX9paQ9uzTgkFIZZdlsGsySWfA==
------END CERTIFICATE REQUEST-----
diff --git a/antifurto/certificates/localhost/client.key b/antifurto/certificates/localhost/client.key
deleted file mode 100644
index 18c7d64b82a34c0face258f8554a5f93b5c9a718..0000000000000000000000000000000000000000
--- a/antifurto/certificates/localhost/client.key
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEpAIBAAKCAQEA03P5/25CxPGTBFgfJHXzZMoT986OwPG9zyYUnhCXLEI7GYdF
-+42OVdY/NPLQqvCe+G70Q2g6B4nYBlFc1VugjcZpvnm/pbJWHs1T6QIcp8CY29Bq
-HMztoYjCciK5xLO65hZ9+w4EwoBqlyXfqXbJBgatomh7W7hpM/s/c7uh+/e8CAEe
-xPnRXC7URAYJ0UZmFonpKOm0iM1GsxZEARhpmEDfiPSBlPmX42YeAWHQWVJw9bZc
-cD2X5u9MeHa1sSorPWmsKVgCOPFoOh8wAmo+ANgDCGlMjPRlH8b8szy/mEALp2Jf
-1XbIAB4xlIZnA5GCN45SBbT7ExjrF48V7yg1eQIDAQABAoIBACmOkYNx2A18rLgd
-2YEA7WTRkjsRjVy+Jd+gTE0EVbGNErBhtY9Ksr6L7MArOHdf8t5AcCEPSthQbvRO
-6T/FUjiK1h1pMBEQi3xiPit9DsSpRWFuBGzEma81gYGM8ZWG/SRbJ0c/6g+PzWMH
-Pn2/qqJUjattfVD5XTOqHT5RkfRC0A2Chh6btbw717etEhFSKfzORCYvDqlkxmci
-BM+R7Nm+yafZxncm1+i9SfMepttCREge4KIUOrXBwgJhzP6q78rLCCqobTygkPDM
-dNlgo6C/o4zNVg7ZDkv5PIdbB2rYNpDqMio85nXth5RTLR+QRNbU7qWvCnNvUvvZ
-nbze2AECgYEA/r67EBQJK1PVKuIvzodEv05QxSRdVXe6HIkIgVLMh9CIpqDb0rjA
-haMTCHwtsaLmrAp8BkUelknjQ3TOH8KHler0tlzk5/3ycrYKtvvYyKDZ5gON8uXo
-nbNCdptLLVsqP+P4/R4H4bnk5wj2LFCaly2ZScOVJt3/Lc1NHIQOcfECgYEA1H6m
-BmZ9H6xpzT9ldidCTR+DN/bPYCu4N5olDlYStfsBnZWpuu0hjpo3/+MqEDR9lkhX
-vN4QwnLSUhMqWN1OBcjcQV9cDHSZj7mOy5fKcTaWCbDiSiVQhsR1Fxht8EDonDKz
-a9nMEDIcFWZ1zjPPtw/OIDdbnNL1W8GUd4pVdAkCgYEA6Mx+gLP+qSTEcpsfmzqM
-vdMhBvgzfy6Z2wfzyNNU7GzK5JOuL8T802NyuldZHrPC38f5DXXO/QLq+DNfRzDr
-3TpJhfogik3Nab0oz44Zz0cHuibXavll+e/etis2qW1dj+OTICV4iHTsVaIf7eF/
-VNar9fgRbuKDF2U9qeiYltECgYAd90Y+fNGEV/ILqbcLNHobGiiNCdcwvrmZzbkQ
-Dn9Q/na53FM1Mx+aVpEzGrvh0SUsvkLxNXezlDGotV8xbPQFyM+WwHXgo8jMBeTn
-PR6lXIdIEpO21RBIEQhaG23VhbHH5TZ8LRij6A0hz3MpgxD1xdrRnDzlHrLPH7tq
-KC3o0QKBgQCDzcHP6IT+ATnZ8uGxCtdB7F/NiHKotx4mmCYw2G4EXkmFEef+t41V
-Xieo6Aoj/f2BfS5qsiW+EEvQMCIAF8+Gcaggz6p4UAAC3MbLpmcTeE+rpxBLxI7v
-VWBDeb3MRU6PkPL/fFW7Uf/Qvv1qwhzKG18Dv7SKPk4lUv1fbpSUkg==
------END RSA PRIVATE KEY-----
diff --git a/antifurto/certificates/localhost/server.crt b/antifurto/certificates/localhost/server.crt
deleted file mode 100644
index ac30db9672456ffeeb38ec0981bc0df28f57990d..0000000000000000000000000000000000000000
--- a/antifurto/certificates/localhost/server.crt
+++ /dev/null
@@ -1,22 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDpDCCAowCFG9WOyqVkrxZYoVbzFEVVkSRDmhZMA0GCSqGSIb3DQEBCwUAMIGN
-MQswCQYDVQQGEwJJVDELMAkGA1UECAwCQUwxFDASBgNVBAcMC0FsZXNzYW5kcmlh
-MQ8wDQYDVQQKDAZ1bml1cG8xDjAMBgNVBAsMBURJU0lUMQ4wDAYDVQQDDAVtaWFD
-QTEqMCgGCSqGSIb3DQEJARYbMjAwMzA3ODRAc3R1ZGVudGkudW5pdXBvLml0MB4X
-DTIyMDExMDE0MzYyNFoXDTIzMDExMDE0MzYyNFowgY4xCzAJBgNVBAYTAklUMQsw
-CQYDVQQIDAJBTDEUMBIGA1UEBwwLQWxlc3NhbmRyaWExDDAKBgNVBAoMA1VQTzEO
-MAwGA1UECwwFRElTSVQxEjAQBgNVBAMMCWxvY2FsaG9zdDEqMCgGCSqGSIb3DQEJ
-ARYbMjAwMzA3ODRAc3R1ZGVudGkudW5pdXBvLml0MIIBIjANBgkqhkiG9w0BAQEF
-AAOCAQ8AMIIBCgKCAQEAx0Uvd1dkTF7c0z9+6LkaasOlXN2na98GDIQgE/0tyKDb
-WFFKn3AiA4JlKsMQy6iv6deAyJPxNXBdgQ5U1QxJtp/WS7W7MvJwm1nTN2+0M0DZ
-OYu5jvDUcq2jovxuQ4EMzUCzmfUPQ972Pl4Slf9uG6AWlsm7gnzF7a2mKG4QfxLT
-o4coYG3M+Wwo0z9YQKbVrEQ+khUT0mSXe305Wj/l7amKaADrNAaHI2f357p1SJPX
-FVAIp0tl9dpJ8HWtSEuPjoNnoLUHLcviLX8saRz8hnxjuvxBOxIJFkunndqLo6wY
-2K//3Y8rLTm4aiXnRVhR0kkwxFVYsHtCWtvTF1VrjQIDAQABMA0GCSqGSIb3DQEB
-CwUAA4IBAQB/U+S1oMe4c2B51AkTcDc3lccBpR5OTUrcuOCLLTc37SP/+8lpzGin
-RmgX9rJ8vshEVPNhoAHYAk0ueuf/7g3atWPPFzovhLH7Z9Q+zuBA/zl9Ae/xs5e2
-1t53Uok+zhvP0CBGz2nfPrVlfSRqc9KX6voyrQqKpJ9v6UBOLLGQ6b+OCAGAWQ3F
-q59dskih9RF+riCLuprOdjCOlTjgD/Pw3jmR0Szdio2/2bMEjrZQnpJoDG+JZnMt
-AbpxANFsZhTp8ezrVNbs8omAvMjUbjaVvnM3c7l3PTpIE4UMbYhsl9J5RXj56Tnb
-5lNLitkvWon5ZKQ8BynqOHS/nqZPujIs
------END CERTIFICATE-----
diff --git a/antifurto/certificates/localhost/server.csr b/antifurto/certificates/localhost/server.csr
deleted file mode 100644
index 6461b4b3b76413b9e2c808c0a886d7302367e64e..0000000000000000000000000000000000000000
--- a/antifurto/certificates/localhost/server.csr
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN CERTIFICATE REQUEST-----
-MIIC6zCCAdMCAQAwgY4xCzAJBgNVBAYTAklUMQswCQYDVQQIDAJBTDEUMBIGA1UE
-BwwLQWxlc3NhbmRyaWExDDAKBgNVBAoMA1VQTzEOMAwGA1UECwwFRElTSVQxEjAQ
-BgNVBAMMCWxvY2FsaG9zdDEqMCgGCSqGSIb3DQEJARYbMjAwMzA3ODRAc3R1ZGVu
-dGkudW5pdXBvLml0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx0Uv
-d1dkTF7c0z9+6LkaasOlXN2na98GDIQgE/0tyKDbWFFKn3AiA4JlKsMQy6iv6deA
-yJPxNXBdgQ5U1QxJtp/WS7W7MvJwm1nTN2+0M0DZOYu5jvDUcq2jovxuQ4EMzUCz
-mfUPQ972Pl4Slf9uG6AWlsm7gnzF7a2mKG4QfxLTo4coYG3M+Wwo0z9YQKbVrEQ+
-khUT0mSXe305Wj/l7amKaADrNAaHI2f357p1SJPXFVAIp0tl9dpJ8HWtSEuPjoNn
-oLUHLcviLX8saRz8hnxjuvxBOxIJFkunndqLo6wY2K//3Y8rLTm4aiXnRVhR0kkw
-xFVYsHtCWtvTF1VrjQIDAQABoBcwFQYJKoZIhvcNAQkHMQgMBnBpc3NpcjANBgkq
-hkiG9w0BAQsFAAOCAQEAxETR2K8P8HvjemMVOKocDuMOcMZMz0gzOgXipj8Ekm1N
-Lt/jjE1oC1VLjXfP+7Ahb7KTSGYrJKuWTq0ZDMDemOaKqQN0qrrwiQZEhKPrTWuZ
-I2luFKOx/KL7NVlPRu71EfQCyAWZwoBh/LUMFAlZZdXkf7/kmPEgx/BGXXoEN+H/
-0SS3s2lT9Ow++OTyl1pMS2Gsh3zx/Wd0dgXTqsty5+0hpgVK+6Hh8VUByZ8sS+aA
-tGgnf/Wz+/URrr9I7idWiQ9CrfusIJAlmAs1ssEQWzdIkGH3B9rrFl9zPdqWUay2
-+b8fyfGXj+ieL70u/MF6I+EwJ+Di/Aq0y9/zQcsreg==
------END CERTIFICATE REQUEST-----
diff --git a/antifurto/certificates/localhost/server.key b/antifurto/certificates/localhost/server.key
deleted file mode 100644
index 6acf8284510725fc9395c77d258d3a1eaa7f553c..0000000000000000000000000000000000000000
--- a/antifurto/certificates/localhost/server.key
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEowIBAAKCAQEAx0Uvd1dkTF7c0z9+6LkaasOlXN2na98GDIQgE/0tyKDbWFFK
-n3AiA4JlKsMQy6iv6deAyJPxNXBdgQ5U1QxJtp/WS7W7MvJwm1nTN2+0M0DZOYu5
-jvDUcq2jovxuQ4EMzUCzmfUPQ972Pl4Slf9uG6AWlsm7gnzF7a2mKG4QfxLTo4co
-YG3M+Wwo0z9YQKbVrEQ+khUT0mSXe305Wj/l7amKaADrNAaHI2f357p1SJPXFVAI
-p0tl9dpJ8HWtSEuPjoNnoLUHLcviLX8saRz8hnxjuvxBOxIJFkunndqLo6wY2K//
-3Y8rLTm4aiXnRVhR0kkwxFVYsHtCWtvTF1VrjQIDAQABAoIBAElMlsA0Yk2BW4NN
-SPZ8GE6Ldwlo80vHtubltxMDP1MccHLVPDjXu3tE/Me1BzmS7Fp9Df86BDEfCxYM
-2oGfyoGl2+Lvj1OXQHq0mPA8Y7GyufTkA7ajudIRMy8h4cFs9/OMSERqk1no6vVY
-D0gjtDHvOj/vJs1B7mCWTpdynRjQgkdruPzvTMBMr1vv8g4963+IBPD1GyqIdATa
-gS/uXixn6ZyjjTB1mp11DNetUcR8ApEW98lT2o1LqqbJ3ZCRzml8wxPKysu2O0y3
-kr4dj690bzVXyofwlhJ3rFTpFGVz66dDHmrvizktfaI3a8P8OzU6H6rZUkJ0u6rw
-GH53xuECgYEA9i4HMg1tezKOMumHIpvc0ZnrC2iBAHVSQnFIbO3sfIgK1UC6fn7m
-cYxk0z6RWzP4Ef5Kvzlmtk/d155Z5svcIVtsptBHrzrKLVcGKKPr9vevI5ci5Xfp
-S5+QBtIMHVpgkIOr6mWzxtUAGozpIHAVy5cv8RvxGqi0otKITHKO4EUCgYEAzzge
-wltdwGcODGtYrZ5q9FmsRREcanIiPqP1Nafv0pVwFq+gHgSqjzvLvTBiofTxq0X2
-hvyBBmrS1HsdZXacqIn8JVH2h0DC1EryYMnJU34rrl73gg74H+zzLg8LJhnjFGuV
-nUyjAyYgSqTI1cqWZMkmV+mgTdWUEuo6cvs2xqkCgYEArzUVE+9wkvTpNZz0+5G4
-eEi2ezkWTvAw6m7boAM5g2wDYcEeufaxJfFItPvb0fBLxuqX4j8FNg3jkpj13QgM
-FIWP761ex3zs9ZXxIS2BPBUNxiPDx1MvbA4VIHWP/7gZ7+B2k21spL9lwn+1T8vW
-Bz8D9PLxBws4/IUgUmBaBY0CgYBSLufEHYhpLnYb5tccxJ+WmZoBKnAip3F9dnlh
-9mDfG/WAidbvENq0Q/rh5ba4lPTkALNtheeGLAfBzbIy83/eOBuQkZk8uyqKF89Z
-I659NqUMWw2+v0EZKFiqA71gNxQgnSqRYDumnBBiikg8wkQzZLOYWkgBlptLhSn5
-QDjRQQKBgBwGEJUX2O23HCUxS24i8cbNJishkoqPsRg2o2oeNLTleRlReJoenuEW
-N5NP1J4zr37BIHgXYn3jCQdPWKc7cKWsLPAFFC1zCqmCQDULEo6fJ2inZ4VN3Umu
-Kdl08D5KHCAHDj+dBCwMnLwlZmYmMT8kdxloBK/IWtbKITQgd7IE
------END RSA PRIVATE KEY-----
diff --git a/antifurto/res/CONF/deltaSensoriMovimento.json b/antifurto/res/CONF/deltaSensoriMovimento.json
index 54e876224801c257831395165991aea616deb60b..061b7bddf0b16dd6e5b1520d52d20a9df685d52b 100644
--- a/antifurto/res/CONF/deltaSensoriMovimento.json
+++ b/antifurto/res/CONF/deltaSensoriMovimento.json
@@ -1 +1 @@
-{"IN2":4,"IN1":33,"IN3":8}
+{"IN2":4,"IN1":33}
diff --git a/antifurto/res/CONF/zona.json b/antifurto/res/CONF/zona.json
index a702f5b9fb5a0945b7c8b9d7d1866e3785bde0a6..3d6ac917c2624c0e400418893a057668c50bd9fe 100644
--- a/antifurto/res/CONF/zona.json
+++ b/antifurto/res/CONF/zona.json
@@ -1 +1 @@
-{"interruttore":"IN0","sensoriMovimento":["IN1","IN2","IN3"],"outputSuono":"OUT0", "nomeOutputAntifurto":"OUT1"}
+{"nomeOutputAntifurto":"OUT1","interruttore":"IN0","sensoriMovimento":["IN1","IN2"],"outputSuono":"OUT0"}
diff --git a/antifurto/res/stato.json b/antifurto/res/stato.json
index 2eb08bd04ff59cb55efccf5489dddc6737679734..3e3cef827f45365006beaeb22aa23d38859fc6b6 100644
--- a/antifurto/res/stato.json
+++ b/antifurto/res/stato.json
@@ -1 +1 @@
-{"soglia":32,"stato":0,"valore":0}
\ No newline at end of file
+{"soglia":32,"stato":0,"valore":0,"tempoAllarme":"2022-09-16T19:06:34.450705"}
\ No newline at end of file
diff --git a/antifurto/src/code/Antifurto.java b/antifurto/src/code/Antifurto.java
index 9337c6925e43e4a6ba93959e017d2f987ce96715..f93094d589b8d850f58874445d05a94c2a2ef97e 100644
--- a/antifurto/src/code/Antifurto.java
+++ b/antifurto/src/code/Antifurto.java
@@ -45,72 +45,73 @@ public class Antifurto {
 	private Date date = new Date();
 	private String clientId = Long.toString(date.getTime()) + "-sub-pub"; // unique client id
 	private Automa automa;
-
+	
 	private MqttClient mqttClient;
 	private static String mqttDomain;
 	private static String mqttSubdomain;
-
+	
 	private final String CONF_FILE = "../res/CONF/conf.json";
 	public static final String CONF_ZONA = "../res/CONF/zona.json";
-
+	
 	public Antifurto(Automa automa) throws JSONException, IOException, MqttException {
 		this.automa = automa;
-
+		
 		JSONObject jsonObject = new JSONObject(Helper.leggiFile(CONF_FILE));
 		brokerUrl = jsonObject.getString("protocol") + "://" + jsonObject.getString("broker") + ":" + jsonObject.getInt("port");
 		mqttDomain = jsonObject.getString("mqttDomain");
 		mqttSubdomain = jsonObject.getString("mqttSubdomain");
 		topicsSub = new ArrayList<String>();
-
-		// Su questo topic ricevero' un messaggio del tipo {request:description}
+		
+		// Su questo topic ricevero' un messaggio del tipo {request:description} 
 		// Dovro' quindi mandare la mia descrizione json
-		topicsSub.add("to/all");
-
+		topicsSub.add("to/all"); 
+		
 		// Su questo topic ricevero' le richieste di inviare il mio stato attuale
 		topicsSub.add("rpc/"+getMqttTree()+"/antifurto");
-
-
+		
+		
 		jsonObject = new JSONObject(Helper.leggiFile(CONF_ZONA));
-		interruttore = jsonObject.getString("interruttore");
-
+		interruttore = jsonObject.getString("interruttore"); 
+		
 		topicsSub.add("from/"+getMqttTree()+"/gpio/" + interruttore); // Sottoscrivo i messaggi che notificano il cambiamento di stato dell'interruttore
-
-		// Per ogni sensore di movimento, sottoscrivo i messaggi che notificano il loro cambiamento di stato
+		
+		// Per ogni sensore di movimento, sottoscrivo i messaggi che notificano il loro cambiamento di stato 
 		sensori = jsonObject.getJSONArray("sensoriMovimento");
 		for(int i=0; i<sensori.length(); i++) {
-			topicsSub.add("from/"+getMqttTree()+"/gpio/" + sensori.get(i));
+			topicsSub.add("from/"+getMqttTree()+"/gpio/" + sensori.get(i)); 
 		}
-
+		
 		nomeOutputAntifurto = jsonObject.getString("nomeOutputAntifurto");
 		topicsSub.add("from/"+getMqttTree()+"/gpio/" + nomeOutputAntifurto);
-
+		
 		interruttoreOutputSuono = jsonObject.getString("outputSuono");
 		topicsSub.add("from/"+getMqttTree()+"/gpio/" + interruttoreOutputSuono); // Sottoscrivo i messaggi che notificano il cambiamento di stato dell'interruttore
-
-
+		
+		
 		topicsSub.add("to/"+getMqttTree()+"/antifurto/soglia"); // Su questo topic mi arrivera' un messaggio {"soglia": 30} e dovrò impostare la soglia di conseguenza
-
-		topicsSub.add("conf/"+getMqttTree()+"/antifurto/sensore"); // Su questo topic mi arrivera' un messaggio per l'aggiunta di un sensore di movimento.
-																   // Ad esempio se mi arriva il messaggio {"in": "IN3", "delta":33 } devo aggiungere il sensore di movimento che si
+		
+		topicsSub.add("conf/"+getMqttTree()+"/antifurto");
+		topicsSub.add("conf/"+getMqttTree()+"/antifurto/sensore"); // Su questo topic mi arrivera' un messaggio per l'aggiunta di un sensore di movimento. 
+																   // Ad esempio se mi arriva il messaggio {"in": "IN3", "delta":33 } devo aggiungere il sensore di movimento che si 
 																   // chiama IN3, il cui valore di delta e' 33 (devo quindi aggiornare il file deltaSensoriMovimento.json
-
+		
 		topicsSub.add("to/"+getMqttTree()+"/antifurto/luceAntifurto");
 		this.mqttClient = new MqttClient(brokerUrl, clientId, new MemoryPersistence());
-
+		
 	}
-
+	
 	public void startClient(Esecutore esec, Publisher publisher) throws MqttException {
 		String caFilePath = "";
 		String clientCrtFilePath = "";
 		String clientKeyFilePath = "";
-
-		MqttConnectOptions options = new MqttConnectOptions();
+		
+		MqttConnectOptions options = new MqttConnectOptions();  
 		options.setCleanSession(false);
 		if(brokerUrl.contains("luci.local")) {  // devo connettermi al mosquitto della beaglebone
 			caFilePath = "../certificates/beaglebone/caGruppo2.crt";
 			clientCrtFilePath = "../certificates/beaglebone/clientGruppo2.crt";
 			clientKeyFilePath = "../certificates/beaglebone/clientGruppo2.key";
-
+			
 			options.setUserName("gruppo2");
 			options.setPassword("funziona".toCharArray());
 		}
@@ -120,7 +121,7 @@ public class Antifurto {
 		}
 
 		options.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1);
-
+		
 		SSLSocketFactory socketFactory;
 		try {
 			socketFactory = getSocketFactory(caFilePath, clientCrtFilePath, clientKeyFilePath, "");
@@ -128,100 +129,100 @@ public class Antifurto {
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
-
-		mqttClient.setCallback(new SubscribeCallback(this, publisher, interruttore, interruttoreOutputSuono, esec, automa, nomeOutputAntifurto));
-
+		
+		mqttClient.setCallback(new SubscribeCallback(this, publisher, esec, automa));
+		
 		mqttClient.connect(options);
-
-		for(String t: topicsSub)
+		
+		for(String t: topicsSub) 
 			addTopicToSubscribe(t);
 	}
-
+	
 	// sottoscrive il topic passato come parametro
 	public void addTopicToSubscribe(String topic) throws MqttException {
-		mqttClient.subscribe(topic);
+		mqttClient.subscribe(topic); 
 	}
-
+	
 	public void publishMethod(String topic, String msg) throws MqttException {
 		final MqttTopic msgTopic = mqttClient.getTopic(topic);
 		msgTopic.publish(new MqttMessage(msg.getBytes()));
 	}
-
-
-
-
-
+	
+	
+	
+	
+	
 	/*
 	 * Abbiamo 3 tipi di eventi:
-	 * 		to 		Command Events - mi viene richiesto di eseguire un comando --> sottoscrivo
-	 * 		from 	Status Events - io annuncio un cambiamento di stato
+	 * 		to 		Command Events - mi viene richiesto di eseguire un comando --> sottoscrivo 
+	 * 		from 	Status Events - io annuncio un cambiamento di stato  	
 	 * 								(inviato a tutti i client che hanno sottoscritto il topic su cui faccio la publish)
-	 * 		rpc 	Query Events - richiesta di inviare uno stato a un client (o microservizio). --> sottoscrivo
+	 * 		rpc 	Query Events - richiesta di inviare uno stato a un client (o microservizio). --> sottoscrivo 
 	 * 			  				   Query implementati come coppia di eventi: <query event, status event>
 	 * RICORDIAMO COME ABBIAMO IMPLEMENTATO LA RPC SU MQTT
-	 *
-	 *
-	 *
-	 * Il cuore della nostra business logic è un metodo in cui mi metto in attesa su mqtt e:
+	 * 
+	 * 
+	 * 
+	 * Il cuore della nostra business logic è un metodo in cui mi metto in attesa su mqtt e: 
 	 * 		se arriva un comando, chiamo il metodo responsabile per eseguire quel comando;
 	 * 		se arriva un evento di stato, chiamo il metodo responsabile per gestire quell'evento di stato;
-	 * 		se arriva una remote procedure call, attivo la risposta sulla remote procedure call
-	 *
-	 *
-	 *
+	 * 		se arriva una remote procedure call, attivo la risposta sulla remote procedure call 
+	 * 
+	 * 
+	 * 
 	 * Capire come gestire sistema a regole (vedi slide "Esempio" in "Applicazioni IoT "Cloud Based"")
-	 *
-	 *
-	 *
+	 * 
+	 * 
+	 * 
 	 * Sicurezza gestita con TLS
-	 *
-	 *
-	 *
+	 * 
+	 * 
+	 * 
 	 * FILE DA FARE per un servizio: (?)
-	 * 		file che contiene le informazioni per connettersi al mosquitto locale
+	 * 		file che contiene le informazioni per connettersi al mosquitto locale 
 	 * 		file che dice qual'è la porta che lui deve esporre
 	 * 		file che mi dice tutte le cose che lo configurano, ad esempio quanti device deve guardare
 	 * 		...
-	 *
+	 * 
 	 * 	I file di configurazione sono in JSON o in XML
 	 * I dati persistiti si troveranno nella sottodirectory (chiamata con il nome del servizio) di Home
-	 *
-	 *
-	 * Nella fase di configurazione potremo ancora modificare i file di configurazione (ad esempio aggiungendo device,
-	 * regole). Dopodiché quando si fa partire il servizio si inizierà a usare l'altra parte di file system (ovvero il Local
+	 * 
+	 * 
+	 * Nella fase di configurazione potremo ancora modificare i file di configurazione (ad esempio aggiungendo device, 
+	 * regole). Dopodiché quando si fa partire il servizio si inizierà a usare l'altra parte di file system (ovvero il Local 
 	 * Dynamic File System) dove si andranno a salvare gli stati per renderli persistenti.
-	 *
-	 *
-	 *
-	 * Ho un processo principale che come unico compito ha quello di fare una fork() e creare un processo figlio.
-	 * Sarà questo processo figlio a eseguire effettivamente il programma. Se il processo figlio termina (PER UN QUALCHE
+	 * 
+	 * 
+	 * 
+	 * Ho un processo principale che come unico compito ha quello di fare una fork() e creare un processo figlio. 
+	 * Sarà questo processo figlio a eseguire effettivamente il programma. Se il processo figlio termina (PER UN QUALCHE 
 	 * PROBLEMA), allora il processo padre se ne accorge e fa ripartire un nuovo processo figlio.
-	 *
-	 *
-	 * Devo avere una thread di configurazione che obbedisce ai miei comandi (dati sulla HAT interface andando su
+	 * 
+	 *  
+	 * Devo avere una thread di configurazione che obbedisce ai miei comandi (dati sulla HAT interface andando su 
 	 * 	192.168.0.101:9001/configure.html (dove 192.168.0.101 è l'indirizzo della beaglebone)
-	 *
-	 *
+	 * 
+	 * 
 	 * Ho una classe che implementa l'automa a stati finiti
-	 *
-	 *
-	 *
-	 *
+	 * 
+	 * 
+	 * 
+	 * 
 	 * NOTA:
-	 * All'avvio, leggo il file stato e mi imposto di conseguenza. Poi interrogo la beaglebone per sapere SOLO lo stato
-	 * dell'antifurto (luce rossa), ovvero se l'antifurto e' on o off. Lo stato del sensore di suono, non mi interessa: poiche'
+	 * All'avvio, leggo il file stato e mi imposto di conseguenza. Poi interrogo la beaglebone per sapere SOLO lo stato 
+	 * dell'antifurto (luce rossa), ovvero se l'antifurto e' on o off. Lo stato del sensore di suono, non mi interessa: poiche' 
 	 * sono solo io a impostarlo (la web app si comporta in conseguenza dei miei messaggi).
-	 * Mi serve interrogare la beaglebone per lo stato dell'antifurto perche' puo' succedere che l'antifurto abbia avuto
-	 * dei problemi e quindi non abbia funzionato per un po' e nel mentre l'utente ha attivato l'antifurto dagli scenari.
+	 * Mi serve interrogare la beaglebone per lo stato dell'antifurto perche' puo' succedere che l'antifurto abbia avuto 
+	 * dei problemi e quindi non abbia funzionato per un po' e nel mentre l'utente ha attivato l'antifurto dagli scenari. 
 	 * Quindi proprio perche' sia il mio antifurto sia gli scenari comandano lo stesso antifurto, devo fare questa richiesta
 	 * alla beaglebone.
-	 * Dopo aver chiesto lo stato dell'antifurto alla beaglebone, so esattamente lo stato in cui devo essere --> mi imposto
+	 * Dopo aver chiesto lo stato dell'antifurto alla beaglebone, so esattamente lo stato in cui devo essere --> mi imposto 
 	 * di conseguenza!
 	*/
-
+	
 	public static void main(String args[]) {
-
-		// while(true) {
+		
+//		while(true) {
 			try {
 				startSystem();
 			}
@@ -229,42 +230,42 @@ public class Antifurto {
 				System.out.println("Error: "+ e.getMessage() + "\nRestarting system...");
 				e.printStackTrace();
 			}
-		// }
+//		}
 	}
-
-
+	
+	
 	private static void startSystem() throws JSONException, IOException, MqttException {
-
+		
 		MyQueue<Integer> codaVal = new MyQueue<Integer>();
 		MyQueue<Pair> codaMsg = new MyQueue<Pair>();
 		Automa automa = new Automa();
-
+		
 		Antifurto antifurto = new Antifurto(automa);
 		Publisher publisher = new Publisher(codaMsg, antifurto);
-		Esecutore esec = new Esecutore(publisher, codaVal, automa, antifurto.interruttoreOutputSuono);
+		Esecutore esec = new Esecutore(publisher, codaVal, automa, antifurto);
 		Timer timer = new Timer(6000,-1,esec,automa);
-
+		
 		antifurto.startClient(esec, publisher);
 		publisher.start();
 		esec.start();
-		timer.start();
+		timer.start(); 
 	}
-
+	
 
 	public static void stopSystem() {
 		// DA FARE
 //		codaVal.removeAll();
 //		codaMsg.removeAll();
-//
+//		
 //		publisher.interrupt();
 //		esec.interrupt();
 //		timer.interrupt();
 //		mqttClient.disconnect();
-//
+//		
 //		startSystem();
-
+		
 	}
-
+	
 	public static String getMqttTree() {
 		return mqttDomain+"/"+mqttSubdomain;
 	}
@@ -272,12 +273,43 @@ public class Antifurto {
 	public static JSONArray getSensori() {
 		return sensori;
 	}
-
+	
 	public static void addSensore(String newSensore) { // aggiunge un sensore di movimento
 		sensori.put(newSensore);
 	}
-
-
+	
+	public String getNomeInterruttoreAntifurto() {
+		return interruttore;
+	}
+	
+	public String getNomeOutputAntifurto() {
+		return nomeOutputAntifurto; 
+	}
+	
+	public String getNomeOutputSuono() {
+		return interruttoreOutputSuono;
+	}
+	
+	public void setNomeInterruttoreAntifurto(String nuovoNome) {
+		if(nuovoNome.startsWith("IN"))
+			this.interruttore = nuovoNome;
+	}
+	
+	public void setNomeOutputAntifurto(String nuovoNome) {
+		if(nuovoNome.startsWith("OUT")) 	
+			this.nomeOutputAntifurto = nuovoNome;
+	}
+	
+	public void setNomeOutputSuono(String nuovoNome) {
+		if(nuovoNome.startsWith("OUT")) 
+			this.interruttoreOutputSuono = nuovoNome;
+	}
+	
+	public void unsubscribeTopic(String topic) throws MqttException {
+		mqttClient.unsubscribe(topic);
+	}
+	
+	
 	private static SSLSocketFactory getSocketFactory(final String caCrtFile,
 			final String crtFile, final String keyFile, final String password)
 			throws Exception {
@@ -343,6 +375,6 @@ public class Antifurto {
 
 		return context.getSocketFactory();
 	}
-
+	
 
 }
diff --git a/antifurto/src/code/Esecutore.java b/antifurto/src/code/Esecutore.java
index ac2dbe5131c865acaf05015e2d0a39a567e188d1..1fba06462209e3c3bf62731250136d6e69679a65 100644
--- a/antifurto/src/code/Esecutore.java
+++ b/antifurto/src/code/Esecutore.java
@@ -17,14 +17,15 @@ public class Esecutore extends Thread {
 	private static  int soglia;
 	private Publisher publisher;
 	private Automa automa;
-	private String outputSuono; // nome logico dell'interruttore che fa scattare il suono dell'allarme 
+//	private String outputSuono; // nome logico dell'interruttore che fa scattare il suono dell'allarme 
+	private Antifurto antifurto;
 	private LocalDateTime tempoAllarme; //valorizzato solo quando l'allarme sta suonando. Contiene l'ora in cui l'allarme ha iniziato a suonare 
 	
-	public Esecutore(Publisher publisher, MyQueue<Integer> codaVal, Automa automa, String outputSuono) throws JSONException, IOException {
+	public Esecutore(Publisher publisher, MyQueue<Integer> codaVal, Automa automa, Antifurto antifurto) throws JSONException, IOException {
 		this.codaVal = codaVal;
 		this.automa = automa;
 		this.publisher = publisher;
-		this.outputSuono = outputSuono;
+		this.antifurto = antifurto;
 		
 		JSONObject statoJson = new JSONObject(Helper.leggiFile(Automa.FILE_STATO));
 		this.valore = statoJson.getInt("valore");
@@ -62,7 +63,7 @@ public class Esecutore extends Thread {
 					JSONObject statoJson = new JSONObject(Helper.leggiFile(Automa.FILE_STATO));
 					statoJson.put("valore", valore);
 					if(valore >= soglia && (!automa.allarme()) && delta>0) {	
-						publisher.aggiungiComando("to/"+Antifurto.getMqttTree()+"/gpio/"+outputSuono, "{cmd:1}");
+						publisher.aggiungiComando("to/"+Antifurto.getMqttTree()+"/gpio/"+antifurto.getNomeOutputSuono(), "{cmd:1}");
 						tempoAllarme = LocalDateTime.now();
 						statoJson.put("tempoAllarme",tempoAllarme.toString());
 					}
@@ -71,7 +72,7 @@ public class Esecutore extends Thread {
 							LocalDateTime tempoAttuale = LocalDateTime.now();
 							long durata = Math.abs(Duration.between(tempoAllarme, tempoAttuale).toMinutes());
 							if(valore < soglia || durata >= DURATA_SUONO || !automa.antifurtoAttivo() ) {
-								publisher.aggiungiComando("to/"+Antifurto.getMqttTree()+"/gpio/"+outputSuono, "{cmd:0}"); // l'allarme viene disattivato
+								publisher.aggiungiComando("to/"+Antifurto.getMqttTree()+"/gpio/"+antifurto.getNomeOutputSuono(), "{cmd:0}"); // l'allarme viene disattivato
 							}
 						}
 					}
diff --git a/antifurto/src/code/Helper.java b/antifurto/src/code/Helper.java
index 7732e4c5afee2dbd7374c78d6744a8d2cb78ddc1..9b12be4f9ad87a37b9c2d2409249896f986eb8ed 100644
--- a/antifurto/src/code/Helper.java
+++ b/antifurto/src/code/Helper.java
@@ -29,95 +29,4 @@ public class Helper {
 		return answer;
 	}
 	
-	// se add = true, aggiungo il valore n alla codaVal; 
-	// se add = false, rimuovo il valore n dalla codaVal
-//	public static synchronized void modificaFileStato(MyQueue<Integer> coda, boolean add, int n, int valore, String path) {
-//		try {
-//			JSONObject statoJson = new JSONObject(Helper.leggiFile(path));
-//			statoJson.put("valore",valore);
-//			JSONArray arrayCodaVal = statoJson.getJSONArray("codaVal");
-//			if(add)
-//				arrayCodaVal.put(n);
-//			else {
-//				int index = -1;
-//				for(int i=0; i<arrayCodaVal.length(); i++) {
-//					if(arrayCodaVal.getInt(i)==n)
-//						index = i;
-//				}
-//				arrayCodaVal.remove(index);
-//			}
-//			Helper.scriviFile(statoJson.put("codaVal",arrayCodaVal), path);
-//		} catch (JSONException e) {
-//			e.printStackTrace();
-//		} catch (IOException e) {
-//			e.printStackTrace();
-//		}
-//	}
-//	
-//	public static synchronized void modificaFileStato(boolean add, int n, String path) {
-//		try {
-//			JSONObject statoJson = new JSONObject(Helper.leggiFile(path));
-//			JSONArray arrayCodaVal = statoJson.getJSONArray("codaVal");
-//			if(add)
-//				arrayCodaVal.put(n);
-//			else {
-//				int index = -1;
-//				for(int i=0; i<arrayCodaVal.length(); i++) {
-//					if(arrayCodaVal.getInt(i)==n)
-//						index = i;
-//				}
-//				arrayCodaVal.remove(index);
-//			}
-//			Helper.scriviFile(statoJson.put("codaVal",arrayCodaVal), path);
-//		} catch (JSONException e) {
-//			e.printStackTrace();
-//		} catch (IOException e) {
-//			e.printStackTrace();
-//		}
-//	}
-//
-//	public static synchronized void modificaFileStato(boolean add, Pair p, String path) {
-//		try { System.out.println("pair = " + p+ " path  = " + path);
-//			JSONObject statoJson = new JSONObject(Helper.leggiFile(path)); 
-//			JSONArray arrayCodaMsg = statoJson.getJSONArray("codaMsg"); 
-//			if(add) 
-//				arrayCodaMsg.put(p.toJsonObject());
-//			else {
-//				int index = -1;
-//				for(int i=0; i<arrayCodaMsg.length(); i++) {
-//					JSONObject msgJson = arrayCodaMsg.getJSONObject(i); 
-//					if(msgJson.getString("topic").equals(p.getTopic()) && msgJson.getJSONObject("msg").toString().equals(p.getMsg()) )
-//						index = i;
-//				}
-//				arrayCodaMsg.remove(index);
-//			}
-//			Helper.scriviFile(statoJson.put("codaMsg",arrayCodaMsg), path);  System.out.println("FINE");
-//		} catch (JSONException e) {
-//			e.printStackTrace();
-//		} catch (IOException e) {
-//			e.printStackTrace();
-//		}
-//	}
-	
-//	public static synchronized <T> void getFromFileStato(MyQueue<T> coda, String key, String path) throws JSONException, IOException {
-//		JSONObject statoJson = new JSONObject(Helper.leggiFile(path));
-//		JSONArray arrayCoda = statoJson.getJSONArray(key);
-//		if(coda.getClass().equals(Pair.class)) {
-//			MyQueue<Pair> codaMsg = (MyQueue<Pair>) coda;
-//			for(int i = 0; i<arrayCoda.length(); i++) {
-//				JSONObject pairJson = arrayCoda.getJSONObject(i);
-//				Pair p = new Pair(pairJson.getString("topic"), pairJson.getString("msg"));
-//				codaMsg.send(p);
-//				
-//			}
-//		}
-//		if(coda.getClass().equals(Integer.class)) {
-//			MyQueue<Integer> codaVal = (MyQueue<Integer>) coda;
-//			for(int i = 0; i<arrayCoda.length(); i++) {
-//				codaVal.send(arrayCoda.getInt(i));
-//			}
-//		}
-//			
-//	}
-	
 }
diff --git a/antifurto/src/code/SubscribeCallback.java b/antifurto/src/code/SubscribeCallback.java
index d6691c2eedb4561fbab400f78afc026068e24f73..66f8908c93ca758b19b0f42fa712be173583c5e8 100644
--- a/antifurto/src/code/SubscribeCallback.java
+++ b/antifurto/src/code/SubscribeCallback.java
@@ -1,6 +1,7 @@
 package code;
 
 import java.io.IOException;
+import java.sql.ClientInfoStatus;
 import java.util.Date;
 
 import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
@@ -13,9 +14,9 @@ import org.json.JSONObject;
 public class SubscribeCallback implements MqttCallback {
 	private Antifurto client;
 	private Publisher publisher;
-	private String nomeInterruttore;
-	private String nomeOutputSuono;
-	private String nomeOutputAntifurto;
+//	private String nomeInterruttore;
+//	private String nomeOutputSuono;
+//	private String nomeOutputAntifurto;
 	private Esecutore esec;
 	private Automa automa;
 	private int contatore = 0; // quando pubblico un messaggio per accendere la luce che indica che l'antifurto
@@ -26,13 +27,12 @@ public class SubscribeCallback implements MqttCallback {
 								// sia il microservizio degli scenari
 								// inviano il comando allo stesso OUT per dire che l'antifurto e' acceso
 
-	public SubscribeCallback(Antifurto client, Publisher publisher, String nomeInterruttore, String nomeOutputSuono,
-			Esecutore esec, Automa automa, String nomeOutputAntifurto) {
+	public SubscribeCallback(Antifurto client, Publisher publisher, Esecutore esec, Automa automa) {
 		this.client = client;
 		this.publisher = publisher;
-		this.nomeInterruttore = nomeInterruttore;
-		this.nomeOutputSuono = nomeOutputSuono;
-		this.nomeOutputAntifurto = nomeOutputAntifurto;
+//		this.nomeInterruttore = nomeInterruttore;
+//		this.nomeOutputSuono = nomeOutputSuono;
+//		this.nomeOutputAntifurto = nomeOutputAntifurto;
 		this.esec = esec;
 		this.automa = automa;
 	}
@@ -81,8 +81,8 @@ public class SubscribeCallback implements MqttCallback {
 				handleConfSensoreMovimento(msgJson);
 			return;
 		}
-		if (topic.equals("conf/" + Antifurto.getMqttTree() + "/antifurto")) {
-			// DA FARE
+		if (topic.equals("conf/" + Antifurto.getMqttTree() + "/antifurto")) { 
+			handleNewConfig(msgJson);
 			return;
 		}
 		if (topic.equals("to/" + Antifurto.getMqttTree() + "/antifurto/luceAntifurto")) {
@@ -100,7 +100,7 @@ public class SubscribeCallback implements MqttCallback {
 				sendMyState("from/" + Antifurto.getMqttTree() + "/antifurto");
 			return;
 		}
-		if (topic.equals("from/" + Antifurto.getMqttTree() + "/gpio/" + nomeOutputSuono)) {
+		if (topic.equals("from/" + Antifurto.getMqttTree() + "/gpio/" + client.getNomeOutputSuono())) {
 			int newStatus = -1;
 			if (msgJson.has("status"))
 				newStatus = msgJson.getInt("status");
@@ -111,7 +111,7 @@ public class SubscribeCallback implements MqttCallback {
 			handleStateMsgFromOutputSuono(newStatus);
 			return;
 		}
-		if (topic.equals("from/" + Antifurto.getMqttTree() + "/gpio/" + nomeOutputAntifurto)) {
+		if (topic.equals("from/" + Antifurto.getMqttTree() + "/gpio/" + client.getNomeOutputAntifurto())) {
 			if (msgJson.has("event"))
 				handleLuceAntifurto();
 			if (msgJson.has("status"))
@@ -122,7 +122,7 @@ public class SubscribeCallback implements MqttCallback {
 		if (event == 1) {
 			// e' stato premuto l'interruttore / il sensore di movimento ha rilevato
 			// qualcuno
-			if (topic.equals("from/" + Antifurto.getMqttTree() + "/gpio/" + nomeInterruttore)) {
+			if (topic.equals("from/" + Antifurto.getMqttTree() + "/gpio/" + client.getNomeInterruttoreAntifurto())) {
 				handleStateMsgFromInterruttore();
 				return;
 			}
@@ -137,7 +137,7 @@ public class SubscribeCallback implements MqttCallback {
 
 	private synchronized void handleStateMsgFromInterruttore() {
 		if (automa.getStatoInterruttore().equals("on"))
-			publisher.aggiungiComando("to/" + Antifurto.getMqttTree() + "/gpio/" + nomeOutputAntifurto, "{cmd:0}"); // voglio
+			publisher.aggiungiComando("to/" + Antifurto.getMqttTree() + "/gpio/" + client.getNomeOutputAntifurto(), "{cmd:0}"); // voglio
 																													// spegnere
 																													// l'antifurto,
 																													// quindi
@@ -155,7 +155,7 @@ public class SubscribeCallback implements MqttCallback {
 																													// e'
 																													// acceso
 		else
-			publisher.aggiungiComando("to/" + Antifurto.getMqttTree() + "/gpio/" + nomeOutputAntifurto, "{cmd:1}"); // voglio
+			publisher.aggiungiComando("to/" + Antifurto.getMqttTree() + "/gpio/" + client.getNomeOutputAntifurto(), "{cmd:1}"); // voglio
 																													// accendere
 																													// l'antifurto,
 																													// quindi
@@ -186,7 +186,7 @@ public class SubscribeCallback implements MqttCallback {
 			JSONObject js = new JSONObject();
 			automa.changeStatoInterruttore();
 			if (automa.getStatoInterruttore().equals("off")) {
-				publisher.aggiungiComando("to/" + Antifurto.getMqttTree() + "/gpio/" + nomeOutputSuono, "{cmd:0}");
+				publisher.aggiungiComando("to/" + Antifurto.getMqttTree() + "/gpio/" + client.getNomeOutputSuono(), "{cmd:0}");
 				esec.reset();
 				js.put("event", esec.getValore());
 				publisher.aggiungiComando("from/" + Antifurto.getMqttTree() + "/antifurto/valore", js.toString());
@@ -274,10 +274,10 @@ public class SubscribeCallback implements MqttCallback {
 	private void sendMyState(String topic) throws JSONException {
 		JSONObject json = new JSONObject();
 		json.put("stato", automa.getStatoAutoma());
-		json.put("interruttore", nomeInterruttore);
+		json.put("interruttore", client.getNomeInterruttoreAntifurto());
 		json.put("sensori-movimento", Antifurto.getSensori());
-		json.put("output-suono", nomeOutputSuono);
-		json.put("output-antifurto", nomeOutputAntifurto);
+		json.put("output-suono", client.getNomeOutputSuono());
+		json.put("output-antifurto", client.getNomeOutputAntifurto());
 		json.put("soglia", Esecutore.getSoglia());
 		json.put("allarme", automa.getStatoSuonoTrueFalse());
 		json.put("valore-attuale", esec.getValore());
@@ -307,7 +307,7 @@ public class SubscribeCallback implements MqttCallback {
 
 	private void sendOutAntifurto() throws JSONException {
 		JSONObject js = new JSONObject();
-		js.put("attiva-scenari", nomeOutputAntifurto);
+		js.put("attiva-scenari", client.getNomeOutputAntifurto());
 		publisher.aggiungiComando("to/" + Antifurto.getMqttTree() + "/scenari/luceAntifurto", js.toString());
 	}
 
@@ -316,5 +316,49 @@ public class SubscribeCallback implements MqttCallback {
 		js.put("status", automa.getStatoAutoma());
 		publisher.aggiungiComando(topic, js.toString());
 	}
+	
+	private void handleNewConfig(JSONObject msgJson) throws JSONException {
+		JSONObject jsResponse = new JSONObject();
+		try {
+		if(msgJson.has("interruttore")) {
+			client.unsubscribeTopic("from/"+Antifurto.getMqttTree()+"/gpio/" + client.getNomeInterruttoreAntifurto());
+			String interruttore = msgJson.getString("interruttore");
+			client.setNomeInterruttoreAntifurto(interruttore);
+			client.addTopicToSubscribe("from/"+Antifurto.getMqttTree()+"/gpio/" + interruttore);
+		}
+		
+		
+		if(msgJson.has("outputSuono")) {
+			client.unsubscribeTopic("from/"+Antifurto.getMqttTree()+"/gpio/" + client.getNomeOutputSuono());
+			String outputSuono = msgJson.getString("outputSuono");
+			client.setNomeInterruttoreAntifurto(outputSuono);
+			client.addTopicToSubscribe("from/"+Antifurto.getMqttTree()+"/gpio/" + outputSuono);
+		}
+		
+		
+		if(msgJson.has("nomeOutputAntifurto")) {
+			client.unsubscribeTopic("from/"+Antifurto.getMqttTree()+"/gpio/" + client.getNomeOutputAntifurto());
+			String nomeOutputAntifurto = msgJson.getString("nomeOutputAntifurto");
+			client.setNomeInterruttoreAntifurto(nomeOutputAntifurto);
+			client.addTopicToSubscribe("from/"+Antifurto.getMqttTree()+"/gpio/" + nomeOutputAntifurto);
+		}
+		
+		
+		jsResponse.put("interruttore", client.getNomeInterruttoreAntifurto());
+		jsResponse.put("outputSuono", client.getNomeOutputSuono());
+		jsResponse.put("nomeOutputAntifurto",client.getNomeOutputAntifurto());
+
+		
+		JSONObject jsFile = new JSONObject(Helper.leggiFile(Antifurto.CONF_ZONA));
+		jsResponse.put("sensoriMovimento", jsFile.get("sensoriMovimento"));
+		Helper.scriviFile(jsResponse, Antifurto.CONF_ZONA);
+		jsResponse.remove("sensoriMovimento");
+		publisher.aggiungiComando("from/" + Antifurto.getMqttTree() + "/antifurto" , jsResponse.toString());
+		} catch (MqttException | IOException e) {
+			JSONObject jsError = new JSONObject();
+			jsError.put("error", e.getMessage());
+			publisher.aggiungiComando("from/" + Antifurto.getMqttTree() + "/antifurto", jsError.toString());
+		}
+	}
 
 }