From 2821f9fab40713c47bfd9bd553d47c5dc0756a66 Mon Sep 17 00:00:00 2001 From: Alfredo Chissotti <20033498@studenti.uniupo.it> Date: Thu, 15 Sep 2022 09:53:23 +0200 Subject: [PATCH] wss inizio --- domainManager/Domain/DBPissirDomain.db | Bin 77824 -> 77824 bytes domainManager/Domain/bin/code/Domain.class | Bin 4469 -> 4476 bytes .../Domain/bin/code/ServicesHandler.class | Bin 1965 -> 1951 bytes domainManager/Domain/src/code/Domain.java | 2 +- .../Domain/src/code/ServicesHandler.java | 4 +- keycloak-19.0.1/data/h2/keycloakdb.trace.db | 31 +++++++ webapp/public/css/style.css | 4 + webapp/public/index.html | 12 ++- webapp/public/js/mqtt/mqtthat.js | 2 + webapp/public/js/scriptIndex.js | 84 ++++++++++-------- 10 files changed, 93 insertions(+), 46 deletions(-) diff --git a/domainManager/Domain/DBPissirDomain.db b/domainManager/Domain/DBPissirDomain.db index 67fd95713eba1c06f1ad515715a22437def76f14..dbeb8858400454bbff0580994bf4151500f2f4f4 100644 GIT binary patch delta 2522 zcmcImU2Icj82(PrY1bCkZ{2CPoweK94^S9%>sWs_B_bFXf0ppO=oM1B(iKKKyRjH0 zc9LLBM5BC|h)Ti*(GW@anTZ$^lrSz>yJaLqj2Z$40(yZ#7cRKb=R4=@bd?J(j5*2E z?|t5%^L+35emZ_b8owcZ;1lkA=zm7Ib7uQ-Dn=X!SjG1#$?>V<z=XR>cC>jSR-(wt zj^xl#d~p5x&K)~a!|7~wn6qA!?c1A3Pn^2kZxbV~NmenNl3Y`+NmSVEVzbvJdn95N z1tA=sn7tkn&W400g%BdrON8F1KhsNeukqw)4oTbShIf@+*};rnAEEoy;dCY&&y1#b z?#+#6!R!k10FxO>Bs1|`8jei?9y$a;rqd&`Gp~5odMu(hz_ZGnm4fKiUN)S|j>S8j zny`z6{sd_k={5SL_8g=KA#4lHx4?f$D2a2x-Y=A?vxCZNA*KRDUIje;T5y>JE3J{d zfk$~!qstUq`SdLl_p@?SwLtIl{;|>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kc(|B zgp+0d?8TV9aUeq<HJOu&MS?}1i&g$EZ}5zNzJ_CNN?TGPs!Zcc1YyqXq|jS|1*vrF Oyx`R9-#~kkH1`Mor$5O6 diff --git a/domainManager/Domain/bin/code/Domain.class b/domainManager/Domain/bin/code/Domain.class index d16ed102ae0246ca342220f09fc2d349244a5684..4eaaa810bd027dd436456bb3b41b6ae53c2b05e5 100644 GIT binary patch delta 42 wcmeyW^harf7>}&FOMY%*W}X5NB^D>==al3t6qhPwl#~=$>FaOS;qhbz08E<>X#fBK delta 35 pcmeyP^i^qt7>}5OOMY%*W}X5NB^D>==al3t6qhP&Hs<kU1pw&A3<>}M diff --git a/domainManager/Domain/bin/code/ServicesHandler.class b/domainManager/Domain/bin/code/ServicesHandler.class index dfc99fc528af6cb09f2e5cf5ebcb63f1592a225a..e2272c0dc4eec585dd87c5711b7d282d8e28c8c6 100644 GIT binary patch delta 363 zcmZ9I&nrYx6vscqym#kOG-FB+CBragm>DH>5tF1biu?$Xjci0&Ses;{Y=*a+nr5Rc zq$u7z*;oyGe~%xB*r<E@-g7>uPq%y1SZ=(n7}guL)Bz99v(cV^p*|7xoqO1Kp-%1Z zbBSuhr%l_a((>JT#I>?jDEUabhG)Xs><<mOG!@x+Vr0F77H(GQ^67wWdW=e_P{t0p zOs!r~r!CuZ$z9RrvGAXze&DjLTvoI{5#-hOd#v5b8}~Wln3><qQlLo5DVWiGgbsR% z5GP8K9tMdqER!*rOp{=V6q}^kVSrts`$7&G7hgt<6Pz%~scfE!y+BsHbCj5+OpZ(D txn_}jF>K2(?P0yss_0gP8$O6h)Jw_vq#w&UP|ePk3i|$T0p~)segVn1NlpL& delta 387 zcmZ9IOG^S_6owzG@taXXGzq4J=wg|d(uj($!X%=sponf_(4tM7qMb_#qD>UU?1D(z zxGHipPPB1l{f+)dw=b+k!Qs4|^Bx{v&W-QR_fXZ0SDNtxj#bmTiaFWxj5p?YT{@VR zK(Ex|Heu;@NnyI{bbL<^QK_4HVCa!#6E%WTBm!eLZCB)<n8;O;$`^I|T+%Rw!=w^D zkTDIL*{w1j=`lSvOJzb1tAD(aUvu5mZ8oG9^YdbA4%-zK^N3?knE%l%7T1)lb9cBH zrkglDBnXpYfN>&721yfTff$<%vrCeF<sLAq2vZc8R=kWNra5JXGv>HZbc?LwE>mKW zTb3xZ!aZwL*<nvTs(|rMr=VXDe8aE$M~H}$Mt!Of9zkB9H*Ty$(Qf61(fWUz`T_;+ BO7Q>y diff --git a/domainManager/Domain/src/code/Domain.java b/domainManager/Domain/src/code/Domain.java index b921fb8..d6d11b7 100644 --- a/domainManager/Domain/src/code/Domain.java +++ b/domainManager/Domain/src/code/Domain.java @@ -137,7 +137,7 @@ public class Domain { server.createContext("/secured/priviledges", new PriviledgesHandler()); server.start(); - System.out.println("Domain in ascolto su localhost:"+port); + System.out.println("Domain in ascolto su http://localhost:"+port); } } diff --git a/domainManager/Domain/src/code/ServicesHandler.java b/domainManager/Domain/src/code/ServicesHandler.java index f316339..107459c 100644 --- a/domainManager/Domain/src/code/ServicesHandler.java +++ b/domainManager/Domain/src/code/ServicesHandler.java @@ -28,8 +28,8 @@ public class ServicesHandler implements HttpHandler{ return; } - String user; - if((user = Helper.checkTokenGetUser(he)) == null) { + + if(Helper.checkTokenGetUser(he) == null) { Helper.sendCors(he, 401); return; } diff --git a/keycloak-19.0.1/data/h2/keycloakdb.trace.db b/keycloak-19.0.1/data/h2/keycloakdb.trace.db index de54447..de93876 100644 --- a/keycloak-19.0.1/data/h2/keycloakdb.trace.db +++ b/keycloak-19.0.1/data/h2/keycloakdb.trace.db @@ -1345,3 +1345,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-14 19:40:43 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/css/style.css b/webapp/public/css/style.css index da1bc45..08f6827 100644 --- a/webapp/public/css/style.css +++ b/webapp/public/css/style.css @@ -51,4 +51,8 @@ .no-padding-left { padding-left: 0; +} + +#no-services { + box-shadow: 0px 0px 10px; } \ No newline at end of file diff --git a/webapp/public/index.html b/webapp/public/index.html index d5a07db..6dbe9f2 100644 --- a/webapp/public/index.html +++ b/webapp/public/index.html @@ -33,7 +33,7 @@ </head> <body id="body-id"> - <h1>Pissir SmartHome ${nomeCasa o nomeProprio}</h1> + <h1>Pissir SmartHome</h1> <div id="alert-message" role="alert" class="alert invisible"> <!-- <div class="d-flex justify-content-around container-fluid"> <i class="fa-solid fa-exclamation-circle fa-4x" aria-hidden="true"></i> @@ -46,17 +46,21 @@ <!-- alert-danger --> <!-- alert-success --> </div> + <div id="no-services" class="invisible d-col position-absolute top-50 start-50 translate-middle"> + <h1 style="width: 50%; margin: 0 auto;">Non hai servizi</h1> + <h3 style="width: 90%; margin: 10px auto;">Non hai scelto nessun nostro servizio attivo. Questa pagina rimane vuota.</h3> + </div> <button class="btn btn-primary position-absolute bottom-0 end-0" id="button-logout">Logout</button> <!-- container of the top buttons to change what is seen --> <div id="mainButtonContainer" class="d-flex flex-row justify-content-around"> - <button class="btn-12 btn btn-dark" id="luci-btn"> + <button class="btn-12 btn btn-dark invisible" id="luci-btn"> <span>Luci</span> </button> - <button class="btn-12 btn btn-dark" id="scenari-btn"> + <button class="btn-12 btn btn-dark invisible" id="scenari-btn"> <span>Scenari</span> </button> - <button class="btn-12 btn btn-dark" id="antifurto-btn"> + <button class="btn-12 btn btn-dark invisible" id="antifurto-btn"> <span>Antifurto</span> </button> </div> diff --git a/webapp/public/js/mqtt/mqtthat.js b/webapp/public/js/mqtt/mqtthat.js index f5b25b8..c188125 100644 --- a/webapp/public/js/mqtt/mqtthat.js +++ b/webapp/public/js/mqtt/mqtthat.js @@ -24,6 +24,8 @@ client.connect({ onSuccess: onConnect, userName: "gruppo2", password: "funziona", + useSSL: true, + cleanSession: false, }); let isConnected = false; diff --git a/webapp/public/js/scriptIndex.js b/webapp/public/js/scriptIndex.js index 6895400..a4576b8 100644 --- a/webapp/public/js/scriptIndex.js +++ b/webapp/public/js/scriptIndex.js @@ -1,11 +1,11 @@ "use strict"; import { logoutKeycloak } from './authentication/script.js';//qui lo script si prende il token import RequestToDomain from './authentication/requests-to-domain.js'; -import Sensori from './sensori.js'; -import Antifurto from "./antifurto.js"; -import Scenari from "./scenari.js"; -import Luci from './luci.js'; -import Admin from './adminControls.js'; +// import Sensori from './sensori.js'; +// import Antifurto from "./antifurto.js"; +// import Scenari from "./scenari.js"; +// import Luci from './luci.js'; +// import Admin from './adminControls.js'; const logout = document.getElementById("button-logout"); logout.addEventListener('click', () => { @@ -13,12 +13,12 @@ logout.addEventListener('click', () => { }); // ask domain to know which service should be used -const domain = sessionStorage.getItem('domain') +const domain = sessionStorage.getItem('domain'); +document.querySelector('body > h1').innerHTML = `Pissir SmartHome @${domain}`; // map all elements in servicesArray to be lower case const servicesArray = (await RequestToDomain.getUsedServices(domain)).map(s => s.toLowerCase());// ["luci", "antifurto", ...] const userPriviledges = await RequestToDomain.getUserPriviledges(domain);// "admin" or "user" -new Sensori(); const boolArray = [false, false, false]; let atLeastOneOfOurServices = false; for (const service of servicesArray) { @@ -35,41 +35,47 @@ for (const service of servicesArray) { atLeastOneOfOurServices = true; } } -if (!atLeastOneOfOurServices) { - document.getElementById('no-services').classList.remove('invisible');//TODO creare questo elemento -} -// launch each class -const antifurtobtn = document.getElementById("antifurto-btn"); -if (boolArray[0]) - new Antifurto(); -else { - antifurtobtn.classList.add('invisible'); -} +const antifurtoBtn = document.getElementById("antifurto-btn"); +const scenariBtn = document.getElementById("scenari-btn"); +const luciBtn = document.getElementById("luci-btn"); +if (!atLeastOneOfOurServices) { + document.getElementById('no-services').classList.remove('invisible'); +} else { + const sensori = await import('./sensori.js'); + new sensori.default(); -const scenariBtn = document.getElementById("scenari-btn"); -if (boolArray[1]) - new Scenari(); -else { - scenariBtn.classList.add('invisible'); -} + // launch each class + if (boolArray[0]){ + const antifurto = await import("./antifurto.js"); + new antifurto.default(); + antifurtoBtn.classList.remove('invisible'); + } -const luciBtn = document.getElementById("luci-btn"); -if (boolArray[2]) - new Luci(); -else { - luciBtn.classList.add('invisible'); -} + if (boolArray[1]){ + const scenari = await import("./scenari.js"); + new scenari.default(); + scenariBtn.classList.remove('invisible'); + } -// if there is only one service, click the related button -// search if there's only one true in the boolArray -if (servicesArray.length === 1) { - const btn = document.getElementById(`${servicesArray[0]}-btn`); - btn.click(); - // btn.classList.add('invisible'); -} + if (boolArray[2]){ + const luci = await import('./luci.js'); + new luci.default(); + luciBtn.classList.remove('invisible'); + } + + // if there is only one service, click the related button + // search if there's only one true in the boolArray + if (servicesArray.length === 1) { + const btn = document.getElementById(`${servicesArray[0]}-btn`); + btn.click(); + // btn.classList.add('invisible'); + } -// if the user is an admin, show the admin panel -if (userPriviledges.toLowerCase() === 'admin') - new Admin(); \ No newline at end of file + // if the user is an admin, show the admin panel + if (userPriviledges.toLowerCase() === 'admin'){ + const admin = await import('./adminControls.js'); + new admin.default(); + } +} \ No newline at end of file -- GitLab