diff --git a/CloudAppManagerSimple/cloudappman-1662645313991-pub-tcplocalhost/.lck b/CloudAppManagerSimple/cloudappman-1662645313991-pub-tcplocalhost/.lck
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/CloudAppManagerSimple/cloudappman-1662914323537-pub-tcplocalhost/.lck b/CloudAppManagerSimple/cloudappman-1662914323537-pub-tcplocalhost/.lck
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/domainManager/Domain/DBPissirDomain.db b/domainManager/Domain/DBPissirDomain.db
index e27540bec3200d4443d31e21adddb1a49ddff6ba..8aaa11a97117f42adda2c898ea0cff59f0d995b1 100644
Binary files a/domainManager/Domain/DBPissirDomain.db and b/domainManager/Domain/DBPissirDomain.db differ
diff --git a/domainManager/Domain/bin/code/Domain.class b/domainManager/Domain/bin/code/Domain.class
index 68b95bda3e01e680fb4909a6aa527d8149f49dfa..eedeb15fb66100b70a314a813037ae2695aa40e6 100644
Binary files a/domainManager/Domain/bin/code/Domain.class and b/domainManager/Domain/bin/code/Domain.class differ
diff --git a/domainManager/Domain/bin/code/HttpHandler.class b/domainManager/Domain/bin/code/HttpHandler.class
new file mode 100644
index 0000000000000000000000000000000000000000..4a6a9b82d8a5d1a3ec638bdad9db2dbed57d7ada
Binary files /dev/null and b/domainManager/Domain/bin/code/HttpHandler.class differ
diff --git a/domainManager/Domain/bin/code/InstallHandler.class b/domainManager/Domain/bin/code/InstallHandler.class
index 1b54f35bb7723894ee46e1aa9a76cfa068f0af62..5395b0904b004b261427440880dfe886794c30fb 100644
Binary files a/domainManager/Domain/bin/code/InstallHandler.class and b/domainManager/Domain/bin/code/InstallHandler.class differ
diff --git a/domainManager/Domain/bin/code/PriviledgesHandler.class b/domainManager/Domain/bin/code/PriviledgesHandler.class
new file mode 100644
index 0000000000000000000000000000000000000000..a6866baf7c437ae816a336ab5e3d6f4dcb981fbf
Binary files /dev/null and b/domainManager/Domain/bin/code/PriviledgesHandler.class differ
diff --git a/domainManager/Domain/bin/code/ServicesHandler.class b/domainManager/Domain/bin/code/ServicesHandler.class
index 3822c7bc1a99de9b5b92d03965b4938991fb25a3..3f798031f337570998de6dc2d6c8f4fa03a72342 100644
Binary files a/domainManager/Domain/bin/code/ServicesHandler.class and b/domainManager/Domain/bin/code/ServicesHandler.class differ
diff --git a/domainManager/Domain/bin/code/TokenHandler.class b/domainManager/Domain/bin/code/TokenHandler.class
index 7dc3505d7acc16e9d4500fab19bc464cf102e8a2..49b518ba2376362ddd5d2df47c588022ac6c8a0e 100644
Binary files a/domainManager/Domain/bin/code/TokenHandler.class and b/domainManager/Domain/bin/code/TokenHandler.class differ
diff --git a/domainManager/Domain/bin/db/DBC.class b/domainManager/Domain/bin/db/DBC.class
index b265e5430c2e59c4925b317595ff7cd0f8bb5f59..f8305150768da8c3c2314a876187a9646a9cad89 100644
Binary files a/domainManager/Domain/bin/db/DBC.class and b/domainManager/Domain/bin/db/DBC.class differ
diff --git a/domainManager/Domain/bin/db/Dominio.class b/domainManager/Domain/bin/db/Dominio.class
index 30e929d158f18f6285ca6adc238f99ed5ba73dae..a4294eecca1c19482f9797ed337bddc548398f5c 100644
Binary files a/domainManager/Domain/bin/db/Dominio.class and b/domainManager/Domain/bin/db/Dominio.class differ
diff --git a/domainManager/Domain/src/code/Domain.java b/domainManager/Domain/src/code/Domain.java
index 97fa282693cd9903e8a8c3d321d2b9f8f798dccc..a341688b11a90a82cd1ba9a1f01e629c8d746970 100644
--- a/domainManager/Domain/src/code/Domain.java
+++ b/domainManager/Domain/src/code/Domain.java
@@ -134,7 +134,8 @@ public class Domain {
 		server.createContext("/stop/", new StopHandler());
 		server.createContext("/delete/", new DeleteHandler());
 		server.createContext("/secured/domains/", new TokenHandler());
-		server.createContext("/secured/services/", new ServicesHandler());
+		server.createContext("/secured/services", new ServicesHandler());
+		server.createContext("/secured/priviledges", new PriviledgesHandler());//TODO
 
 		server.start();
 		System.out.println("Domain in ascolto su localhost:"+port);
diff --git a/domainManager/Domain/src/code/HttpHandler.java b/domainManager/Domain/src/code/HttpHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..97dfe3289ec018d977d2eac8d3b35ff2aab5a018
--- /dev/null
+++ b/domainManager/Domain/src/code/HttpHandler.java
@@ -0,0 +1,5 @@
+package code;
+
+public interface HttpHandler {
+
+}
diff --git a/domainManager/Domain/src/code/InstallHandler.java b/domainManager/Domain/src/code/InstallHandler.java
index 128b61e7539f4c8fb0301c34c3ef3fd605cdd9c4..f64df14d8f2d54f25d876b6d8206ba2f170b9aff 100644
--- a/domainManager/Domain/src/code/InstallHandler.java
+++ b/domainManager/Domain/src/code/InstallHandler.java
@@ -10,6 +10,8 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.security.NoSuchAlgorithmException;
 import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
 
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -30,7 +32,8 @@ public class InstallHandler implements HttpHandler {
 		String requestMethod = he.getRequestMethod();
 
 		if (requestMethod.compareToIgnoreCase("options") == 0) {
-			he.getResponseHeaders().add("Access-Control-Allow-Origin", "*");// se non mettiamo *, viene errore CORS //http://localhost:3001/secured/domains
+			he.getResponseHeaders().add("Access-Control-Allow-Origin", "*");// se non mettiamo *, viene errore CORS
+																			// //http://localhost:3001/secured/domains
 			he.getResponseHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
 			he.getResponseHeaders().add("Access-Control-Allow-Headers", "Content-Type,Authorization");
 			he.sendResponseHeaders(200, -1);
@@ -42,40 +45,36 @@ public class InstallHandler implements HttpHandler {
 		// String query = requestedUri.getRawQuery();
 		String body = readBody(he.getRequestBody());
 
-		 //he.getRequestHeaders().get("user").get(0);
+		// he.getRequestHeaders().get("user").get(0);
 
 		String user;
 
-
-
 		try {
-			String token=he.getRequestHeaders().get("Authorization").get(0).substring(7);
-			//JSONObject tok=new JSONObject(token);
-			//String accessToken=tok.getString("access_token");
-			String[] tokSplit=token.split("[.]");
-			if(tokSplit.length!=3)return;//controllo che il token abbia header,body e signature(abbia 2 punti :s)
-			//int scnddot=accessToken.lastIndexOf(".");//dopo questo indice è tutta signature
-			String signature=tokSplit[2];
-			user=TokenHandler.verificaToken(token,signature);
-			if(user == null){
+			String token = he.getRequestHeaders().get("Authorization").get(0).substring(7);
+			// JSONObject tok=new JSONObject(token);
+			// String accessToken=tok.getString("access_token");
+			String[] tokSplit = token.split("[.]");
+			if (tokSplit.length != 3)
+				return;// controllo che il token abbia header,body e signature(abbia 2 punti :s)
+			// int scnddot=accessToken.lastIndexOf(".");//dopo questo indice è tutta
+			// signature
+			String signature = tokSplit[2];
+			user = TokenHandler.verificaToken(token, signature);
+			if (user == null) {
 				he.sendResponseHeaders(401, -1);
-				he.getResponseHeaders().add("Access-Control-Allow-Origin", "*");//http://localhost:3001/secured/domains
-				he.getResponseHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");//non c'era POST
+				he.getResponseHeaders().add("Access-Control-Allow-Origin", "*");// http://localhost:3001/secured/domains
+				he.getResponseHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");// non c'era POST
 				he.getResponseHeaders().add("Access-Control-Allow-Headers", "Content-Type,Authorization");
 				// questa parte sopra serve anche qui, non solo quando si chiama con OPTIONS
 				return;
 			}
 
-
 		} catch (NoSuchAlgorithmException | IOException | JSONException e2) {
 			e2.printStackTrace();
 			return;
 		}
 
-
-
-
-		//verifica user
+		// verifica user
 
 		if (requestMethod.compareToIgnoreCase("POST") == 0) {
 
@@ -84,30 +83,102 @@ public class InstallHandler implements HttpHandler {
 				j = new JSONObject(body);
 				String dm = j.getString("domain");
 
-				//try {
-
-					Dominio d = DBC.getDom(dm);
-					if (d != null) {
-
-						// String response = "DOMINIO GIA' IN USO";
-						OutputStream os = he.getResponseBody();
-						he.getResponseHeaders().add("Access-Control-Allow-Origin", "*");//http://localhost:3001/secured/domains
-						he.getResponseHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");//non c'era POST
-						he.getResponseHeaders().add("Access-Control-Allow-Headers", "Content-Type,Authorization");
-						// questa parte sopra serve anche qui, non solo quando si chiama con OPTIONS
-						he.sendResponseHeaders(403, -1);// response.getBytes().length);
-						// os.write(response.getBytes());
-						os.close();
-						return;
-					}
-
-
+				// try {
+
+				Dominio d = DBC.getDom(dm);
+				if (d != null) {
+
+					// String response = "DOMINIO GIA' IN USO";
+					OutputStream os = he.getResponseBody();
+					he.getResponseHeaders().add("Access-Control-Allow-Origin", "*");// http://localhost:3001/secured/domains
+					he.getResponseHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");// non c'era POST
+					he.getResponseHeaders().add("Access-Control-Allow-Headers", "Content-Type,Authorization");
+					// questa parte sopra serve anche qui, non solo quando si chiama con OPTIONS
+					he.sendResponseHeaders(403, -1);// response.getBytes().length);
+					// os.write(response.getBytes());
+					os.close();
+					return;
+				}
 
 			} catch (JSONException | SQLException e) {
 				e.printStackTrace();
 				return;
 			}
 
+			// inserisco i dati nel DB
+
+			// String s = user + "-A";
+			try {
+
+				// qui leggo e parsifico i json nel body, inserisco tutti i campi nel db
+
+				String domain = j.getString("domain");
+				DBC.insertDom(domain);
+				// questa chiamata serve ad assicurarsi che l'utente che ha effettuato la
+				// chiamata sia anche amministratore del dominio
+				DBC.insertAmministra(user, domain);
+
+				JSONArray arrUsers = j.getJSONArray("users");
+				for (int i = 0; i < arrUsers.length(); i++) {
+					JSONObject userObj = arrUsers.getJSONObject(i);
+					String usr = userObj.getString("user");
+					if (user.equals(usr))
+						continue;
+					if (userObj.getString("role").equals("A")) {
+						DBC.insertAmministra(usr, domain);
+					} else if (userObj.getString("role").equals("U")) {
+						DBC.insertUsa(usr, domain);
+					} else
+						System.err.println(userObj.toString());
+				}
+
+				JSONArray arrServ = j.getJSONArray("services");//array con solo il nome dei servizi da installare
+				ArrayList<String> moduleHosts = new ArrayList<String>();
+				for (int i = 0; i < arrServ.length(); i++) {
+
+					// String modul=((JSONObject) arrUsers.get(i)).getString("service");
+					// String host=((JSONObject) arrUsers.get(i)).getString("host");
+					// DBC.insertService(domain,host,modul);
+					String modul = arrServ.getString(i);
+					moduleHosts.addAll(DBC.insertService(domain, modul));
+				}
+				// divido gli host in base al loro module
+				HashMap<String, ArrayList<String>> hostsMap = new HashMap<String, ArrayList<String>>();
+				for (String mh : moduleHosts) {
+					String[] mhSplit = mh.split("---");
+					String module = mhSplit[0];
+					String host = mhSplit[1];
+					ArrayList<String> hostsList;
+					if (hostsMap.containsKey(module)) {
+						hostsList = hostsMap.get(module);
+					} else {
+						hostsList = new ArrayList<String>();
+						hostsMap.put(module, hostsList);
+					}
+					hostsList.add(host);
+				}
+				// imposta correttamente l'array dei servizi
+				JSONArray arrServiziFinale = new JSONArray();
+				for(int i=0; i < arrServ.length(); i++) {
+					JSONObject row = new JSONObject();
+					String mod = arrServ.getString(i);
+					ArrayList<String> ho = hostsMap.get(mod);
+					for(String h : ho) {
+						row.put("host", h);
+						row.put("service", mod);
+						row.put("uri", DBC.getURI(mod));
+						arrServiziFinale.put(row);
+					}
+				}
+				j.put("services", arrServiziFinale);
+				System.out.println("about to send: " + j.toString());
+				// non ci sono controlli!!!!
+
+			} catch (SQLException | JSONException e) {
+				e.printStackTrace();
+			}
+
+			// ora bisogna fare la chiamata al CloudApp, non prima!
 			// effettuo chiamata a CloudAppManager
 			// preso da https://www.baeldung.com/java-http-request
 
@@ -128,15 +199,14 @@ public class InstallHandler implements HttpHandler {
 			URL url = new URL("http://127.0.0.1:3002/install");// maybe, se CloudAppe è in localhost porta 8080
 			HttpURLConnection con = (HttpURLConnection) url.openConnection();
 
-
-
 			con.setRequestMethod("POST");
 			con.setRequestProperty("Content-Type", "application/json");
 			con.setRequestProperty("Accept", "application/json");
 			con.setDoOutput(true);
 			con.setConnectTimeout(5000);
 			con.setReadTimeout(5000);
-			DataOutputStream outForCloudApp = new DataOutputStream(con.getOutputStream());// inserimento param in call
+			DataOutputStream outForCloudApp = new DataOutputStream(con.getOutputStream());// inserimento param
+																							// in call
 			outForCloudApp.writeBytes(j.toString());
 			outForCloudApp.flush();
 			outForCloudApp.close();
@@ -157,64 +227,19 @@ public class InstallHandler implements HttpHandler {
 			// finita chiamata a CloudApp
 
 			// f.close();
+			//risposta alla webapp
 			OutputStream os = he.getResponseBody();
-			he.getResponseHeaders().add("Access-Control-Allow-Origin", "*");//http://localhost:3001/secured/domains
-			he.getResponseHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");//non c'era POST
-	        he.getResponseHeaders().add("Access-Control-Allow-Headers", "Content-Type,Authorization");
+			he.getResponseHeaders().add("Access-Control-Allow-Origin", "*");// http://localhost:3001/secured/domains
+			he.getResponseHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");// non c'era POST
+			he.getResponseHeaders().add("Access-Control-Allow-Headers", "Content-Type,Authorization");
 			// questa parte sopra serve anche qui, non solo quando si chiama con OPTIONS
-			String response = content.toString();//{"result":"done"}
-			he.sendResponseHeaders(status, -1);//response.getBytes().length);
+			// String response = content.toString();// {"result":"done"}
+			he.sendResponseHeaders(status, -1);// response.getBytes().length);
 			// os.write(response.getBytes());
 
 			// he.sendResponseHeaders(status, response.length());//status
 			// os.write(response.getBytes());
 			os.close();
-
-
-			// inserisco i dati nel DB
-			if (status==200) {
-				//String s = user + "-A";
-				try {
-
-
-					//qui leggo e parsifico i json nel body, inserisco tutti i campi nel db
-
-
-					String domain=j.getString("domain");
-					DBC.insertDom(domain);
-					// questa chiamata serve ad assicurarsi che l'utente che ha effettuato la chiamata sia anche amministratore del dominio
-					DBC.insertAmministra(user, domain);
-
-					JSONArray arrUsers = j.getJSONArray("users");
-					for(int i=0;i<arrUsers.length();i++) {
-						JSONObject userObj = arrUsers.getJSONObject(i);
-						String usr=userObj.getString("user");
-						if(user.equals(usr)) continue;
-						if(userObj.getString("role").equals("A")) {
-							DBC.insertAmministra(usr, domain);
-						}
-						else if(userObj.getString("role").equals("U")) {
-							DBC.insertUsa(usr, domain);
-						} else System.err.println(userObj.toString());
-					}
-
-					JSONArray arrServ = j.getJSONArray("services");
-					for(int i=0;i<arrServ.length();i++) {
-
-						// String modul=((JSONObject) arrUsers.get(i)).getString("service");
-						// String host=((JSONObject) arrUsers.get(i)).getString("host");
-						// DBC.insertService(domain,host,modul);
-						String modul = arrServ.get(i).toString();
-						DBC.insertService(domain,modul);//FIXME da questo ricavare gli host
-					}
-
-					//non ci sono controlli!!!!
-
-
-				} catch (SQLException | JSONException e) {
-					e.printStackTrace();
-				}
-			}
 		}
 	}
 
diff --git a/domainManager/Domain/src/code/PriviledgesHandler.java b/domainManager/Domain/src/code/PriviledgesHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..94c9a157b80bb229b7e670c74869df95744a229e
--- /dev/null
+++ b/domainManager/Domain/src/code/PriviledgesHandler.java
@@ -0,0 +1,23 @@
+package code;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+
+public class PriviledgesHandler implements HttpHandler{
+
+	public void handle(HttpExchange he) throws IOException {
+		// TODO
+
+		he.getResponseHeaders().add("Access-Control-Allow-Origin", "*");// se non mettiamo *, viene errore CORS //http://localhost:3001/secured/domains
+		he.getResponseHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
+		he.getResponseHeaders().add("Access-Control-Allow-Headers", "Content-Type,Authorization");
+		byte[] response = "{\"priviledges\":\"admin\"}".getBytes();
+		he.sendResponseHeaders(200, response.length);
+		OutputStream os = he.getResponseBody();
+		os.write(response);
+		os.close();
+	}
+
+}
diff --git a/domainManager/Domain/src/code/ServicesHandler.java b/domainManager/Domain/src/code/ServicesHandler.java
index c32adea7cba6c84127d650e9c8dd4898709e81a0..6e15c16036dc8ac9ecb02fdb31b71220ca5ee77a 100644
--- a/domainManager/Domain/src/code/ServicesHandler.java
+++ b/domainManager/Domain/src/code/ServicesHandler.java
@@ -98,9 +98,9 @@ public class ServicesHandler implements HttpHandler{
 					//	rs.put(k);
 					rs= DBC.getServicesInUseByDomain(domain);
 					res.put("response", rs);
+					System.out.println("ciao! "+res.toString());
 
 				} catch (SQLException | JSONException e) {
-					// TODO Auto-generated catch block
 					e.printStackTrace();
 				}
 
@@ -112,19 +112,18 @@ public class ServicesHandler implements HttpHandler{
 				try {
 					res.put("response",rs);
 				} catch (JSONException e) {
-					// TODO Auto-generated catch block
 					e.printStackTrace();
 				}
 
 			}
 			response = res.toString();
 
-			he.getResponseHeaders().add("Access-Control-Allow-Origin", "*");//http://localhost:3001/secured/domains
-			he.getResponseHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");//non c'era POST
-	        he.getResponseHeaders().add("Access-Control-Allow-Headers", "Content-Type,Authorization");
 			// questa parte sopra serve anche qui, non solo quando si chiama con OPTIONS
 
 			OutputStream os = he.getResponseBody();
+			he.getResponseHeaders().add("Access-Control-Allow-Origin", "*");//http://localhost:3001/secured/domains
+			he.getResponseHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");//non c'era POST
+	        he.getResponseHeaders().add("Access-Control-Allow-Headers", "Content-Type,Authorization");
 			he.sendResponseHeaders(200, response.getBytes().length);
 			os.write(response.getBytes());
 			// he.sendResponseHeaders(status, response.length());//status
diff --git a/domainManager/Domain/src/db/DBC.java b/domainManager/Domain/src/db/DBC.java
index b8d8ae15b1abbe57281dff392b0f16389b78e5d3..f0020b2d07d81cb09484725286ac309085f5832b 100644
--- a/domainManager/Domain/src/db/DBC.java
+++ b/domainManager/Domain/src/db/DBC.java
@@ -8,6 +8,8 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -665,7 +667,7 @@ public class DBC {
 	/**
 	 * finds the host from the database and calls insertService(domain,host,service) to insert the data into the database
 	 */
-	public static void insertService(String domain, String module) throws JSONException {//FIXME aspettare Alessandro
+	public static ArrayList<String> insertService(String domain, String module) throws JSONException {
 		// find the host from the database
 		Connection conn = null;
 		try {
@@ -702,9 +704,12 @@ public class DBC {
 				}
 			}
 			conn.close();
+			ArrayList<String> result = new ArrayList<String>();
 			for (String host : hosts) {
 				insertService(domain, host, module);
+				result.add(module+"---"+host);
 			}
+			return result;
 
 		} catch (SQLException e) {
 			e.printStackTrace();
@@ -717,6 +722,7 @@ public class DBC {
 				ex.printStackTrace();
 			}
 		}
+		return null;
 	}
 
 	public static JSONArray getServicesInUseByDomain(String domain) throws SQLException, JSONException {
@@ -740,18 +746,19 @@ public class DBC {
 
 			//ArrayList<String> res=new ArrayList<String>();
 			//JSONArray jsnarr=new JSONArray();
-			ArrayList<String> arr=new ArrayList<String>();
+			ArrayList<String> arr=new ArrayList<String>();//serve per il contains
 			JSONArray res=new JSONArray();
 			while (result.next()) {
 				System.out.println("GETSERVICESWHILE");
 				//JSONObject j= result;
+				String module=result.getString("Module");
+				if(!arr.contains(module)) {
 
-				if(!arr.contains(result.getString("Module"))) {
-					arr.add(result.getString("Module"));
-					res.put(result.getString("Module"));
+					arr.add(module);
+					res.put(module);
 					}
 
-				System.out.println(result.getString("Module"));
+				System.out.println(module);
 				//String dom = result.getString("Domain");
 				//String desc= result.getString("Desc");
 				//Integer state = result.getInt("State");
@@ -870,4 +877,36 @@ public class DBC {
 		}
 		return 0;
 	}
+
+	public static String getURI(String module){
+		Connection conn = null;
+		try {
+			// db parameters
+			String url = "jdbc:sqlite:../DBPissirDomain.db";
+			// create a connection to the database
+			conn = DriverManager.getConnection(url);
+
+			System.out.println("Connection to SQLite has been established: getURI");
+
+			PreparedStatement prepared = conn.prepareStatement("SELECT Path FROM Moduli WHERE Module = ?");
+			prepared.setString(2, module);
+			ResultSet result = prepared.executeQuery();
+
+			if(result.next()) {
+				return "iotlabgw.edu-al.unipmn.it/lib/"+result.getString("URI");
+			}
+
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				if (conn != null) {
+					conn.close();
+				}
+			} catch (SQLException ex) {
+				ex.printStackTrace();
+			}
+		}
+		return null;
+	}
 }
diff --git a/keycloak-19.0.1/data/h2/keycloakdb.trace.db b/keycloak-19.0.1/data/h2/keycloakdb.trace.db
index f7b106aa429486b0407e223aba6beb2129bae908..daa46cbcff8b3dc58ed45ec9eeb50b7ea95aabd0 100644
--- a/keycloak-19.0.1/data/h2/keycloakdb.trace.db
+++ b/keycloak-19.0.1/data/h2/keycloakdb.trace.db
@@ -1217,3 +1217,34 @@ org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic c
 	at io.quarkus.runtime.Application.stop(Application.java:203)
 	at io.quarkus.runtime.Application.stop(Application.java:155)
 	at io.quarkus.runtime.ApplicationLifecycleManager$ShutdownHookThread.run(ApplicationLifecycleManager.java:420)
+2022-09-07 18:10:24 jdbc[3]: exception
+org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-197]
+	at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
+	at org.h2.message.DbException.get(DbException.java:179)
+	at org.h2.message.DbException.get(DbException.java:155)
+	at org.h2.message.DbException.get(DbException.java:144)
+	at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1526)
+	at org.h2.jdbcx.JdbcXAConnection$PooledJdbcConnection.checkClosed(JdbcXAConnection.java:470)
+	at org.h2.jdbc.JdbcConnection.checkClosedForWrite(JdbcConnection.java:1512)
+	at org.h2.jdbc.JdbcConnection.rollback(JdbcConnection.java:516)
+	at org.h2.jdbcx.JdbcXAConnection$PooledJdbcConnection.close(JdbcXAConnection.java:450)
+	at org.h2.jdbcx.JdbcXAConnection.close(JdbcXAConnection.java:78)
+	at io.agroal.pool.ConnectionHandler.closeConnection(ConnectionHandler.java:185)
+	at io.agroal.pool.ConnectionPool$DestroyConnectionTask.run(ConnectionPool.java:768)
+	at io.agroal.pool.ConnectionPool.close(ConnectionPool.java:189)
+	at io.agroal.pool.DataSource.close(DataSource.java:79)
+	at io.quarkus.agroal.runtime.DataSources.stop(DataSources.java:381)
+	at io.quarkus.agroal.runtime.DataSources_Bean.destroy(Unknown Source)
+	at io.quarkus.agroal.runtime.DataSources_Bean.destroy(Unknown Source)
+	at io.quarkus.arc.impl.AbstractInstanceHandle.destroyInternal(AbstractInstanceHandle.java:80)
+	at io.quarkus.arc.impl.ContextInstanceHandleImpl.destroy(ContextInstanceHandleImpl.java:20)
+	at io.quarkus.arc.impl.AbstractSharedContext.destroy(AbstractSharedContext.java:94)
+	at io.quarkus.arc.impl.ArcContainerImpl.shutdown(ArcContainerImpl.java:369)
+	at io.quarkus.arc.Arc.shutdown(Arc.java:52)
+	at io.quarkus.arc.runtime.ArcRecorder$1.run(ArcRecorder.java:44)
+	at io.quarkus.runtime.StartupContext.runAllInReverseOrder(StartupContext.java:84)
+	at io.quarkus.runtime.StartupContext.close(StartupContext.java:73)
+	at io.quarkus.runner.ApplicationImpl.doStop(Unknown Source)
+	at io.quarkus.runtime.Application.stop(Application.java:203)
+	at io.quarkus.runtime.Application.stop(Application.java:155)
+	at io.quarkus.runtime.ApplicationLifecycleManager$ShutdownHookThread.run(ApplicationLifecycleManager.java:420)
diff --git a/webapp/public/js/authentication/app.js b/webapp/public/js/authentication/app.js
index 6cbd01b867ec096088b2d8e50b570f3133fbb60e..6c2e49ada27356ec76a5ef797a87927611b8a294 100644
--- a/webapp/public/js/authentication/app.js
+++ b/webapp/public/js/authentication/app.js
@@ -40,6 +40,11 @@ class App {
                 }
             });
         }
+        tr.querySelector('th > h4 > a').addEventListener('click', (event) => {
+            event.preventDefault();
+            sessionStorage.setItem('domain', domainObject.nome);
+            window.location.href = '/secured/home/';
+        });
     }
 
 
diff --git a/webapp/public/js/mqtt/mqtthat.js b/webapp/public/js/mqtt/mqtthat.js
index 6612179adb1785ebd9c2e9a1c63d95781c2a5401..f7b18c7ac1a5980d88135d56151e90e0aa9f77d3 100644
--- a/webapp/public/js/mqtt/mqtthat.js
+++ b/webapp/public/js/mqtt/mqtthat.js
@@ -150,7 +150,8 @@ function onMessageArrived(message) {
             Api.overlayAntifurtoAntifurto(rawValue == 'true');
         else if (from === 'antifurto')
             // dopo rpc per descrizione
-            Api.sendWebGetAntifurto(JSON.parse(message.payloadString));
+            if(message.payloadJSON.antifurto != null)
+                Api.sendWebGetAntifurto(JSON.parse(message.payloadString));
         else if (from === 'valore')
             Api.setAntifurtoAttenzione(valueInt);
         else if (from === 'allarme')
diff --git a/webapp/public/js/scriptIndex.js b/webapp/public/js/scriptIndex.js
index e5f9536ad5fc525fee2581d7cc8aa72c8b54d521..bf99932768a6bccb48875d61ef65ad638bc750de 100644
--- a/webapp/public/js/scriptIndex.js
+++ b/webapp/public/js/scriptIndex.js
@@ -13,7 +13,7 @@ logout.addEventListener('click', () => {
 });
 
 // ask domain to know which service should be used
-const servicesArray = await RequestToDomain.getUsedServices();
+const servicesArray = await RequestToDomain.getUsedServices(sessionStorage.getItem('domain'));
 const userPriviledges = await RequestToDomain.getUserPriviledges();
 
 new Sensori();