4 import java.lang.Thread;
5 import java.security.*;
6 import java.security.cert.*;
7 import javax.net.ssl.*;
9 import java.nio.file.FileSystems;
10 import java.nio.file.Path;
15 public static void main(String[] args) {
16 String ksName = global.home + global.keyStoreName;
17 char ksPass[] = global.keyStorePass.toCharArray();
18 char ctPass[] = global.keyStorePass.toCharArray();
19 global.request=new dbConnect();
20 //thread di controllo directory esercizi
21 Path pathToWatch = FileSystems.getDefault().getPath(global.locationEsercizi);
22 DirectoryWatcher dirWatcher = new DirectoryWatcher(pathToWatch);
23 Thread dirWatcherThread = new Thread(dirWatcher);
24 dirWatcherThread.start();
26 //thread che si occupa del lato http
27 httpget regServer = new httpget();
28 Thread httpServer = new Thread(regServer);
30 SSLServerSocket s = null;
32 KeyStore ks = KeyStore.getInstance("JKS");
33 ks.load(new FileInputStream(ksName), ksPass);
34 KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
36 SSLContext sc = SSLContext.getInstance("TLS");
37 sc.init(kmf.getKeyManagers(), null, null);
38 SSLServerSocketFactory ssf = sc.getServerSocketFactory();
39 s = (SSLServerSocket) ssf.createServerSocket(global.portaServer);
40 } catch (CertificateException e) {
42 } catch (UnrecoverableKeyException e) {
44 } catch (NoSuchAlgorithmException e) {
46 } catch (KeyStoreException e) {
48 } catch (KeyManagementException e) {
50 } catch (FileNotFoundException e) {
52 } catch (IOException e) {
56 System.out.println("Server started:");
59 SSLSocket c = (SSLSocket) s.accept();
60 guestServer guest = new guestServer(c);
61 Thread t = new Thread(guest);
63 } catch (IOException e) {
68 System.out.println("Server die!");