Browse Source

add HTTPS supported.

Shentar 3 years ago
parent
commit
81ec713d23

+ 3 - 1
asmblefiles.xml

@@ -23,6 +23,7 @@
         <include name="dedup.db"/>
         <include name="favicon.ico"/>
         <include name="jalbum.xml"/>
+        <include name="keystore"/>
         <include name="log4j.xml"/>
       </fileset>
       <fileset dir="${scripts.dir}">
@@ -48,13 +49,14 @@
       <fileset dir="${dedup.dir}">
         <include name="jalbum.xml"/>
         <include name="log4j.xml"/>
+        <include name="keystore"/>
       </fileset>
     </copy>
     <fixcrlf srcdir="${distribute.dir}/relase_tmp" includes="**/*.xml" eol="crlf"/>
     <zip destfile="jAlbum_release.zip">
       <zipfileset dir="${distribute.dir}" excludes=".svn/**, thumbnail/**, log/**, relase_tmp/**, dedup.db, log4j.xml, jalbum.xml"/>
       <zipfileset dir="${dedup.dir}" includes="dedup.db"/>
-      <zipfileset dir="${distribute.dir}/relase_tmp" includes="log4j.xml, jalbum.xml"/>
+      <zipfileset dir="${distribute.dir}/relase_tmp" includes="log4j.xml, jalbum.xml, keystore"/>
     </zip>
     <delete dir="${distribute.dir}/relase_tmp"/>
   </target>

+ 3 - 1
build.xml

@@ -25,6 +25,7 @@
         <include name="dedup.db"/>
         <include name="favicon.ico"/>
         <include name="jalbum.xml"/>
+        <include name="keystore"/>
         <include name="log4j.xml"/>
       </fileset>
       <fileset dir="${scripts.dir}">
@@ -54,13 +55,14 @@
       <fileset dir="${dedup.dir}">
         <include name="jalbum.xml"/>
         <include name="log4j.xml"/>
+        <include name="keystore"/>
       </fileset>
     </copy>
     <fixcrlf srcdir="${distribute.dir}/relase_tmp" includes="**/*.xml" eol="crlf"/>
     <zip destfile="jAlbum_release.zip">
       <zipfileset dir="${distribute.dir}" excludes=".svn/**, thumbnail/**, log/**, relase_tmp/**, dedup.db, log4j.xml, jalbum.xml"/>
       <zipfileset dir="${dedup.dir}" includes="dedup.db"/>
-      <zipfileset dir="${distribute.dir}/relase_tmp" includes="log4j.xml, jalbum.xml"/>
+      <zipfileset dir="${distribute.dir}/relase_tmp" includes="log4j.xml, jalbum.xml, keystore"/>
     </zip>
     <delete dir="${distribute.dir}/relase_tmp"/>
   </target>

+ 1 - 0
build_for_Raspberry3.xml

@@ -30,6 +30,7 @@
         <include name="favicon.ico"/>
         <include name="jalbum.xml"/>
         <include name="log4j.xml"/>
+        <include name="keystore"/>		
       </fileset>
       <fileset dir="${scripts.dir}">
         <include name="jalbum_for_Raspberry3.sh"/>

BIN
dedup/keystore


+ 19 - 3
dedup/src/main/java/com/shentar/frontend/FrontMain.java

@@ -1,16 +1,19 @@
 package com.shentar.frontend;
 
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.http.HttpVersion;
+import org.eclipse.jetty.server.*;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.util.thread.QueuedThreadPool;
 import org.eclipse.jetty.webapp.WebAppContext;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
 
 public class FrontMain
 {
-    public static final int DEFAULT_PORT = 2148;
+    private static final int DEFAULT_PORT = 2148;
 
     public static void main(String[] args) throws Exception
     {
@@ -71,6 +74,19 @@ public class FrontMain
         // connector.setSoLingerTime(5000);
         server.addConnector(connector);
 
+        SslContextFactory sslContextFactory = new SslContextFactory();
+        sslContextFactory.setKeyStorePath("keystore");
+        sslContextFactory.setKeyStorePassword("123456");
+        sslContextFactory.setKeyManagerPassword("123456");
+        SslConnectionFactory scf =
+                new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString());
+
+        connector = new ServerConnector(server, scf, new HttpConnectionFactory());
+        connector.setAcceptQueueSize(4);
+        connector.setIdleTimeout(5000);
+        connector.setPort(5443);
+        server.addConnector(connector);
+
         /**
          * SignalHandler sig = new SignalHandler() {
          *