4 import java.lang.Thread;
5 import java.security.*;
6 import javax.net.ssl.*;
8 import java.nio.file.FileSystems;
9 import java.nio.file.Path;
14 public static void main(String[] args) {
15 String ksName = global.home + global.keyStoreName;
16 char ksPass[] = global.keyStorePass.toCharArray();
17 char ctPass[] = global.keyStorePass.toCharArray();
18 global.request=new dbConnect();
19 //thread di controllo directory esercizi
20 Path pathToWatch = FileSystems.getDefault().getPath(global.locationEsercizi);
21 DirectoryWatcher dirWatcher = new DirectoryWatcher(pathToWatch);
22 Thread dirWatcherThread = new Thread(dirWatcher);
23 dirWatcherThread.start();
25 //thread che si occupa del lato http
26 httpget regServer = new httpget();
27 Thread httpServer = new Thread(regServer);
29 SSLServerSocket s = null;
31 KeyStore ks = KeyStore.getInstance("JKS");
32 ks.load(new FileInputStream(ksName), ksPass);
33 KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
35 SSLContext sc = SSLContext.getInstance("TLS");
36 sc.init(kmf.getKeyManagers(), null, null);
37 SSLServerSocketFactory ssf = sc.getServerSocketFactory();
38 s = (SSLServerSocket) ssf.createServerSocket(global.portaServer);
39 } catch (CertificateException e) {
41 } catch (UnrecoverableKeyException e) {
43 } catch (NoSuchAlgorithmException e) {
45 } catch (KeyStoreException e) {
47 } catch (KeyManagementException e) {
49 } catch (FileNotFoundException e) {
51 } catch (IOException e) {
55 System.out.println("Server started:");
58 SSLSocket c = (SSLSocket) s.accept();
59 guestServer guest = new guestServer(c);
60 Thread t = new Thread(guest);
62 } catch (IOException e) {
67 System.out.println("Server die!");