Explorar el Código

合并 jetbrains_merge 分支到 master, 并修改 README.md

backflow hace 8 años
padre
commit
84de6d1994
Se han modificado 3 ficheros con 119 adiciones y 89 borrados
  1. 5 3
      README.md
  2. 81 82
      pom.xml
  3. 33 4
      src/main/java/com/vvvtimes/server/MainServer.java

+ 5 - 3
README.md

@@ -1,6 +1,6 @@
-# Jrebel License Server for Java
+# Jrebel & Jet Brains License Server for Java
 
-A license server for Jrebel products, it also support JRebel for Android and XRebel.
+A license server for Jrebel & JetBrains products, it also support JRebel for Android and XRebel.
 
 ***
 Thank ilanyu
@@ -20,7 +20,7 @@ mvn package
 ```
 then
 ```
-java -jar JrebelLicenseServerforJava-1.0-SNAPSHOT-jar-with-dependencies.jar -p 8081
+java -jar JrebelBrainsLicenseServerforJava-1.0-SNAPSHOT-jar-with-dependencies.jar -p 8081
 ```
 default port is 8081.
 
@@ -32,6 +32,8 @@ JRebel for Android
 
 XRebel
 
+JetBrains Products
+
 ## Feedback
 
 + issue: https://gitee.com/gsls200808/JrebelLicenseServerforJava/issues

+ 81 - 82
pom.xml

@@ -2,99 +2,98 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
+  <modelVersion>4.0.0</modelVersion>
 
-    <groupId>com.vvvtimes.com</groupId>
-    <artifactId>JrebelBrainsLicenseServerforJava</artifactId>
-    <version>1.0-SNAPSHOT</version>
+  <groupId>com.vvvtimes.com</groupId>
+  <artifactId>JrebelBrainsLicenseServerforJava</artifactId>
+  <version>1.0-SNAPSHOT</version>
 
-    <properties>  
-         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
-    </properties>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <!-- 与Servlet版本对应 -->
-                <version>3.1</version>
-                <configuration>
-                    <source>1.6</source>
-                    <target>1.6</target>
-                    <encoding>utf8</encoding>
-                </configuration>
-            </plugin>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-assembly-plugin</artifactId>
-            <version>3.1.0</version>
-            <configuration>
-              <archive>
-                <manifest>
-                  <mainClass>com.vvvtimes.server.MainServer</mainClass>
-                </manifest>
-              </archive>
-              <descriptorRefs>
-                <descriptorRef>jar-with-dependencies</descriptorRef>
-              </descriptorRefs>
-            </configuration>
-            <executions>
-              <execution>
-                <id>make-assembly</id>
-                <phase>package</phase>
-                <goals>
-                  <goal>single</goal>
-                </goals>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <!-- 与Servlet版本对应 -->
+        <version>3.1</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+          <encoding>utf8</encoding>
+        </configuration>
+      </plugin>
 
-  <dependencies>
-
-        <dependency>
-            <groupId>org.eclipse.jetty.aggregate</groupId>
-            <artifactId>jetty-all</artifactId>
-            <version>8.1.2.v20120308</version>
-        </dependency>
+      <!-- 打包可运行jar包 -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>3.1.0</version>
+        <configuration>
+          <archive>
+            <manifest>
+              <mainClass>com.vvvtimes.server.MainServer</mainClass>
+            </manifest>
+          </archive>
+          <descriptorRefs>
+            <descriptorRef>jar-with-dependencies</descriptorRef>
+          </descriptorRefs>
+        </configuration>
+        <executions>
+          <execution>
+            <id>make-assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
 
+  <dependencies>
 
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>javax.servlet-api</artifactId>
-            <version>3.0.1</version>
-            <scope>provided</scope>
-        </dependency>
-
+    <dependency>
+      <groupId>org.eclipse.jetty.aggregate</groupId>
+      <artifactId>jetty-all</artifactId>
+      <version>8.1.2.v20120308</version>
+    </dependency>
 
-        <dependency>
-            <groupId>org.bouncycastle</groupId>
-            <artifactId>bcprov-jdk15on</artifactId>
-            <version>1.58</version>
-        </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>javax.servlet-api</artifactId>
+      <version>3.0.1</version>
+      <scope>provided</scope>
+    </dependency>
 
-        <dependency>
-            <groupId>commons-codec</groupId>
-            <artifactId>commons-codec</artifactId>
-            <version>1.10</version>
-        </dependency>
+    <dependency>
+      <groupId>org.bouncycastle</groupId>
+      <artifactId>bcprov-jdk15on</artifactId>
+      <version>1.58</version>
+    </dependency>
 
-        <dependency>
-            <groupId>net.sf.json-lib</groupId>
-            <artifactId>json-lib</artifactId>
-            <version>2.4</version>
-            <classifier>jdk15</classifier>
-        </dependency>
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>1.10</version>
+    </dependency>
 
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.1</version>
-        </dependency>
+    <dependency>
+      <groupId>net.sf.json-lib</groupId>
+      <artifactId>json-lib</artifactId>
+      <version>2.4</version>
+      <classifier>jdk15</classifier>
+    </dependency>
 
-    </dependencies>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>3.1</version>
+    </dependency>
 
+  </dependencies>
 
 </project>

+ 33 - 4
src/main/java/com/vvvtimes/server/MainServer.java

@@ -7,7 +7,9 @@ import net.sf.json.JSONObject;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.Locale;
+import java.util.Map;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -19,13 +21,43 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
 
 public class MainServer extends AbstractHandler {
 
+    public static Map<String, String> parseArguments(String[] args) {
+        Map<String, String> params = new HashMap<String, String>();
+
+        String option = null;
+        for (final String arg : args) {
+            if (arg.charAt(0) == '-') {
+                if (arg.length() < 2) {
+                    throw new IllegalArgumentException("Error at argument " + arg);
+                }
+                option = arg.substring(1);
+            } else {
+                params.put(option, arg);
+            }
+        }
+        return params;
+    }
+
     public static void main(String[] args) throws Exception {
-        Server server = new Server(8081);
+        Map<String, String> arguments = parseArguments(args);
+        String port = arguments.get("p");
+
+        if (port == null || !port.matches("\\d+")) {
+            port = "8081";
+        }
+
+        Server server = new Server(Integer.parseInt(port));
         server.setHandler(new MainServer());
         server.start();
+
+        System.out.println("License Server started at http://localhost:" + port);
+        System.out.println("JetBrains Activation address was: http://localhost:" + port + "/{tokenname}, with any email.");
+        System.out.println("JRebel Activation address was: http://localhost:" + port + "/{tokenname}, with any email.");
+
         server.join();
     }
 
+
     public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
             throws IOException, ServletException {
         System.out.println(target);
@@ -48,7 +80,6 @@ public class MainServer extends AbstractHandler {
         } else {
             response.setStatus(HttpServletResponse.SC_FORBIDDEN);
         }
-
     }
 
     private void jrebelLeases1Handler(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException {
@@ -163,8 +194,6 @@ public class MainServer extends AbstractHandler {
             String body = "<!-- " + xmlSignature + " -->\n" + xmlContent;
             response.getWriter().print(body);
         }
-
-
     }
 
     private void pingHandler ( String target , Request baseRequest , HttpServletRequest request , HttpServletResponse response ) throws IOException