@ -1,22 +1,25 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
*/target/*
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
@ -0,0 +1,25 @@
|
||||
/target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/build/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
@ -0,0 +1 @@
|
||||
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
|
@ -0,0 +1,225 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Migwn, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
@ -0,0 +1,143 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
|
||||
<groupId>cn.zifangsky</groupId>
|
||||
<artifactId>clientdemo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ClientDemo</name>
|
||||
<description>Demo project for License</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.0.3.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<!-- 打包时忽略测试代码 -->
|
||||
<skipTests>true</skipTests>
|
||||
<!-- JUnit单元测试 -->
|
||||
<junit>4.12</junit>
|
||||
<!-- Apache Commons系列公共库 -->
|
||||
<commons-lang3>3.7</commons-lang3>
|
||||
<commons-io>2.6</commons-io>
|
||||
<commons-codec>1.11</commons-codec>
|
||||
<!-- Apache HttpClient -->
|
||||
<httpclient>4.5.5</httpclient>
|
||||
<!-- Fastjson -->
|
||||
<fastjson>1.2.47</fastjson>
|
||||
<!-- Java Servlet API -->
|
||||
<javax.servlet-api>4.0.1</javax.servlet-api>
|
||||
<!-- License -->
|
||||
<truelicense>1.33</truelicense>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Junit -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Commons -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>${commons-codec}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache HttpClient -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${httpclient}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Java Servlet API -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>${javax.servlet-api}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson对自动解析JSON和XML格式的支持 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SLF4J和LogBack -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- License -->
|
||||
<dependency>
|
||||
<groupId>de.schlichtherle.truelicense</groupId>
|
||||
<artifactId>truelicense-core</artifactId>
|
||||
<version>${truelicense}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.nekohtml</groupId>
|
||||
<artifactId>nekohtml</artifactId>
|
||||
<version>1.9.22</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.tld</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,19 @@
|
||||
package cn.zifangsky;
|
||||
|
||||
import org.springframework.boot.Banner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication
|
||||
@ServletComponentScan
|
||||
@PropertySource({"license-config.properties"}) //加载额外的配置
|
||||
public class ClientDemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication application = new SpringApplication(ClientDemoApplication.class);
|
||||
application.setBannerMode(Banner.Mode.CONSOLE);
|
||||
application.run(args);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.zifangsky.config;
|
||||
|
||||
import cn.zifangsky.license.LicenseCheckInterceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Web相关配置
|
||||
* @author zifangsky
|
||||
* @date 2018/7/9
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 视图控制器
|
||||
*/
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addViewController("/index").setViewName("index");
|
||||
registry.addViewController("/login").setViewName("login");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加拦截器
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new LicenseCheckInterceptor()).addPathPatterns("/check");
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package cn.zifangsky.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @author zifangsky
|
||||
* @date 2018/7/9
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Controller
|
||||
public class LoginController {
|
||||
|
||||
/**
|
||||
* 模拟登录验证
|
||||
* @author zifangsky
|
||||
* @date 2018/7/9 17:09
|
||||
* @since 1.0.0
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @return java.util.Map<java.lang.String,java.lang.Object>
|
||||
*/
|
||||
@PostMapping("/check")
|
||||
@ResponseBody
|
||||
public Map<String,Object> test(@RequestParam(required = true) String username, @RequestParam(required = true) String password){
|
||||
Map<String,Object> result = new HashMap<>(1);
|
||||
System.out.println(MessageFormat.format("用户名:{0},密码:{1}",username,password));
|
||||
|
||||
//模拟登录
|
||||
System.out.println("模拟登录流程");
|
||||
result.put("code",200);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户首页
|
||||
* @author zifangsky
|
||||
* @date 2018/7/9 17:10
|
||||
* @since 1.0.0
|
||||
* @return java.lang.String
|
||||
*/
|
||||
@RequestMapping("/userIndex")
|
||||
public String userIndex(){
|
||||
return "userIndex";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* LicenseCheckInterceptor
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/25
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LicenseCheckInterceptor extends HandlerInterceptorAdapter{
|
||||
private static Logger logger = LogManager.getLogger(LicenseCheckInterceptor.class);
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
LicenseVerify licenseVerify = new LicenseVerify();
|
||||
|
||||
//校验证书是否有效
|
||||
boolean verifyResult = licenseVerify.verify();
|
||||
|
||||
if(verifyResult){
|
||||
return true;
|
||||
}else{
|
||||
response.setCharacterEncoding("utf-8");
|
||||
Map<String,String> result = new HashMap<>(1);
|
||||
result.put("result","您的证书无效,请核查服务器是否取得授权或重新申请证书!");
|
||||
|
||||
response.getWriter().write(JSON.toJSONString(result));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 在项目启动时安装证书
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/24
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Component
|
||||
public class LicenseCheckListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||
private static Logger logger = LogManager.getLogger(LicenseCheckListener.class);
|
||||
|
||||
/**
|
||||
* 证书subject
|
||||
*/
|
||||
@Value("${license.subject}")
|
||||
private String subject;
|
||||
|
||||
/**
|
||||
* 公钥别称
|
||||
*/
|
||||
@Value("${license.publicAlias}")
|
||||
private String publicAlias;
|
||||
|
||||
/**
|
||||
* 访问公钥库的密码
|
||||
*/
|
||||
@Value("${license.storePass}")
|
||||
private String storePass;
|
||||
|
||||
/**
|
||||
* 证书生成路径
|
||||
*/
|
||||
@Value("${license.licensePath}")
|
||||
private String licensePath;
|
||||
|
||||
/**
|
||||
* 密钥库存储路径
|
||||
*/
|
||||
@Value("${license.publicKeysStorePath}")
|
||||
private String publicKeysStorePath;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
//root application context 没有parent
|
||||
ApplicationContext context = event.getApplicationContext().getParent();
|
||||
if(context == null){
|
||||
if(StringUtils.isNotBlank(licensePath)){
|
||||
logger.info("++++++++ 开始安装证书 ++++++++");
|
||||
|
||||
LicenseVerifyParam param = new LicenseVerifyParam();
|
||||
param.setSubject(subject);
|
||||
param.setPublicAlias(publicAlias);
|
||||
param.setStorePass(storePass);
|
||||
param.setLicensePath(licensePath);
|
||||
param.setPublicKeysStorePath(publicKeysStorePath);
|
||||
|
||||
LicenseVerify licenseVerify = new LicenseVerify();
|
||||
//安装证书
|
||||
licenseVerify.install(param);
|
||||
|
||||
logger.info("++++++++ 证书安装结束 ++++++++");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自定义需要校验的License参数
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/23
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LicenseCheckModel implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 8600137500316662317L;
|
||||
/**
|
||||
* 可被允许的IP地址
|
||||
*/
|
||||
private List<String> ipAddress;
|
||||
|
||||
/**
|
||||
* 可被允许的MAC地址
|
||||
*/
|
||||
private List<String> macAddress;
|
||||
|
||||
/**
|
||||
* 可被允许的CPU序列号
|
||||
*/
|
||||
private String cpuSerial;
|
||||
|
||||
/**
|
||||
* 可被允许的主板序列号
|
||||
*/
|
||||
private String mainBoardSerial;
|
||||
|
||||
public List<String> getIpAddress() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
public void setIpAddress(List<String> ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
|
||||
public List<String> getMacAddress() {
|
||||
return macAddress;
|
||||
}
|
||||
|
||||
public void setMacAddress(List<String> macAddress) {
|
||||
this.macAddress = macAddress;
|
||||
}
|
||||
|
||||
public String getCpuSerial() {
|
||||
return cpuSerial;
|
||||
}
|
||||
|
||||
public void setCpuSerial(String cpuSerial) {
|
||||
this.cpuSerial = cpuSerial;
|
||||
}
|
||||
|
||||
public String getMainBoardSerial() {
|
||||
return mainBoardSerial;
|
||||
}
|
||||
|
||||
public void setMainBoardSerial(String mainBoardSerial) {
|
||||
this.mainBoardSerial = mainBoardSerial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LicenseCheckModel{" +
|
||||
"ipAddress=" + ipAddress +
|
||||
", macAddress=" + macAddress +
|
||||
", cpuSerial='" + cpuSerial + '\'' +
|
||||
", mainBoardSerial='" + mainBoardSerial + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
import de.schlichtherle.license.LicenseManager;
|
||||
import de.schlichtherle.license.LicenseParam;
|
||||
|
||||
/**
|
||||
* de.schlichtherle.license.LicenseManager的单例
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/19
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LicenseManagerHolder {
|
||||
|
||||
private static volatile LicenseManager LICENSE_MANAGER;
|
||||
|
||||
public static LicenseManager getInstance(LicenseParam param){
|
||||
if(LICENSE_MANAGER == null){
|
||||
synchronized (LicenseManagerHolder.class){
|
||||
if(LICENSE_MANAGER == null){
|
||||
LICENSE_MANAGER = new CustomLicenseManager(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return LICENSE_MANAGER;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
import de.schlichtherle.license.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* License校验类
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/20
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LicenseVerify {
|
||||
private static Logger logger = LogManager.getLogger(LicenseVerify.class);
|
||||
|
||||
/**
|
||||
* 安装License证书
|
||||
* @author zifangsky
|
||||
* @date 2018/4/20 16:26
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public synchronized LicenseContent install(LicenseVerifyParam param){
|
||||
LicenseContent result = null;
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
//1. 安装证书
|
||||
try{
|
||||
LicenseManager licenseManager = LicenseManagerHolder.getInstance(initLicenseParam(param));
|
||||
licenseManager.uninstall();
|
||||
|
||||
result = licenseManager.install(new File(param.getLicensePath()));
|
||||
logger.info(MessageFormat.format("证书安装成功,证书有效期:{0} - {1}",format.format(result.getNotBefore()),format.format(result.getNotAfter())));
|
||||
}catch (Exception e){
|
||||
logger.error("证书安装失败!",e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验License证书
|
||||
* @author zifangsky
|
||||
* @date 2018/4/20 16:26
|
||||
* @since 1.0.0
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean verify(){
|
||||
LicenseManager licenseManager = LicenseManagerHolder.getInstance(null);
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
//2. 校验证书
|
||||
try {
|
||||
LicenseContent licenseContent = licenseManager.verify();
|
||||
// System.out.println(licenseContent.getSubject());
|
||||
|
||||
logger.info(MessageFormat.format("证书校验通过,证书有效期:{0} - {1}",format.format(licenseContent.getNotBefore()),format.format(licenseContent.getNotAfter())));
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
logger.error("证书校验失败!",e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化证书生成参数
|
||||
* @author zifangsky
|
||||
* @date 2018/4/20 10:56
|
||||
* @since 1.0.0
|
||||
* @param param License校验类需要的参数
|
||||
* @return de.schlichtherle.license.LicenseParam
|
||||
*/
|
||||
private LicenseParam initLicenseParam(LicenseVerifyParam param){
|
||||
Preferences preferences = Preferences.userNodeForPackage(LicenseVerify.class);
|
||||
|
||||
CipherParam cipherParam = new DefaultCipherParam(param.getStorePass());
|
||||
|
||||
KeyStoreParam publicStoreParam = new CustomKeyStoreParam(LicenseVerify.class
|
||||
,param.getPublicKeysStorePath()
|
||||
,param.getPublicAlias()
|
||||
,param.getStorePass()
|
||||
,null);
|
||||
|
||||
return new DefaultLicenseParam(param.getSubject()
|
||||
,preferences
|
||||
,publicStoreParam
|
||||
,cipherParam);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
/**
|
||||
* License校验类需要的参数
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/20
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LicenseVerifyParam {
|
||||
|
||||
/**
|
||||
* 证书subject
|
||||
*/
|
||||
private String subject;
|
||||
|
||||
/**
|
||||
* 公钥别称
|
||||
*/
|
||||
private String publicAlias;
|
||||
|
||||
/**
|
||||
* 访问公钥库的密码
|
||||
*/
|
||||
private String storePass;
|
||||
|
||||
/**
|
||||
* 证书生成路径
|
||||
*/
|
||||
private String licensePath;
|
||||
|
||||
/**
|
||||
* 密钥库存储路径
|
||||
*/
|
||||
private String publicKeysStorePath;
|
||||
|
||||
public LicenseVerifyParam() {
|
||||
|
||||
}
|
||||
|
||||
public LicenseVerifyParam(String subject, String publicAlias, String storePass, String licensePath, String publicKeysStorePath) {
|
||||
this.subject = subject;
|
||||
this.publicAlias = publicAlias;
|
||||
this.storePass = storePass;
|
||||
this.licensePath = licensePath;
|
||||
this.publicKeysStorePath = publicKeysStorePath;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public String getPublicAlias() {
|
||||
return publicAlias;
|
||||
}
|
||||
|
||||
public void setPublicAlias(String publicAlias) {
|
||||
this.publicAlias = publicAlias;
|
||||
}
|
||||
|
||||
public String getStorePass() {
|
||||
return storePass;
|
||||
}
|
||||
|
||||
public void setStorePass(String storePass) {
|
||||
this.storePass = storePass;
|
||||
}
|
||||
|
||||
public String getLicensePath() {
|
||||
return licensePath;
|
||||
}
|
||||
|
||||
public void setLicensePath(String licensePath) {
|
||||
this.licensePath = licensePath;
|
||||
}
|
||||
|
||||
public String getPublicKeysStorePath() {
|
||||
return publicKeysStorePath;
|
||||
}
|
||||
|
||||
public void setPublicKeysStorePath(String publicKeysStorePath) {
|
||||
this.publicKeysStorePath = publicKeysStorePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LicenseVerifyParam{" +
|
||||
"subject='" + subject + '\'' +
|
||||
", publicAlias='" + publicAlias + '\'' +
|
||||
", storePass='" + storePass + '\'' +
|
||||
", licensePath='" + licensePath + '\'' +
|
||||
", publicKeysStorePath='" + publicKeysStorePath + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用于获取客户Linux服务器的基本信息
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/23
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LinuxServerInfos extends AbstractServerInfos{
|
||||
|
||||
@Override
|
||||
protected List<String> getIpAddress() throws Exception {
|
||||
List<String> result = null;
|
||||
|
||||
//获取所有网络接口
|
||||
List<InetAddress> inetAddresses = getLocalAllInetAddress();
|
||||
|
||||
if(inetAddresses != null && inetAddresses.size() > 0){
|
||||
result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getMacAddress() throws Exception {
|
||||
List<String> result = null;
|
||||
|
||||
//1. 获取所有网络接口
|
||||
List<InetAddress> inetAddresses = getLocalAllInetAddress();
|
||||
|
||||
if(inetAddresses != null && inetAddresses.size() > 0){
|
||||
//2. 获取所有网络接口的Mac地址
|
||||
result = inetAddresses.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCPUSerial() throws Exception {
|
||||
//序列号
|
||||
String serialNumber = "";
|
||||
|
||||
//使用dmidecode命令获取CPU序列号
|
||||
String[] shell = {"/bin/bash","-c","dmidecode -t processor | grep 'ID' | awk -F ':' '{print $2}' | head -n 1"};
|
||||
Process process = Runtime.getRuntime().exec(shell);
|
||||
process.getOutputStream().close();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
|
||||
String line = reader.readLine().trim();
|
||||
if(StringUtils.isNotBlank(line)){
|
||||
serialNumber = line;
|
||||
}
|
||||
|
||||
reader.close();
|
||||
return serialNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMainBoardSerial() throws Exception {
|
||||
//序列号
|
||||
String serialNumber = "";
|
||||
|
||||
//使用dmidecode命令获取主板序列号
|
||||
String[] shell = {"/bin/bash","-c","dmidecode | grep 'Serial Number' | awk -F ':' '{print $2}' | head -n 1"};
|
||||
Process process = Runtime.getRuntime().exec(shell);
|
||||
process.getOutputStream().close();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
|
||||
String line = reader.readLine().trim();
|
||||
if(StringUtils.isNotBlank(line)){
|
||||
serialNumber = line;
|
||||
}
|
||||
|
||||
reader.close();
|
||||
return serialNumber;
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用于获取客户Windows服务器的基本信息
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/23
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class WindowsServerInfos extends AbstractServerInfos{
|
||||
|
||||
@Override
|
||||
protected List<String> getIpAddress() throws Exception {
|
||||
List<String> result = null;
|
||||
|
||||
//获取所有网络接口
|
||||
List<InetAddress> inetAddresses = getLocalAllInetAddress();
|
||||
|
||||
if(inetAddresses != null && inetAddresses.size() > 0){
|
||||
result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getMacAddress() throws Exception {
|
||||
List<String> result = null;
|
||||
|
||||
//1. 获取所有网络接口
|
||||
List<InetAddress> inetAddresses = getLocalAllInetAddress();
|
||||
|
||||
if(inetAddresses != null && inetAddresses.size() > 0){
|
||||
//2. 获取所有网络接口的Mac地址
|
||||
result = inetAddresses.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCPUSerial() throws Exception {
|
||||
//序列号
|
||||
String serialNumber = "";
|
||||
|
||||
//使用WMIC获取CPU序列号
|
||||
Process process = Runtime.getRuntime().exec("wmic cpu get processorid");
|
||||
process.getOutputStream().close();
|
||||
Scanner scanner = new Scanner(process.getInputStream());
|
||||
|
||||
if(scanner != null && scanner.hasNext()){
|
||||
scanner.next();
|
||||
}
|
||||
|
||||
if(scanner.hasNext()){
|
||||
serialNumber = scanner.next().trim();
|
||||
}
|
||||
|
||||
scanner.close();
|
||||
return serialNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMainBoardSerial() throws Exception {
|
||||
//序列号
|
||||
String serialNumber = "";
|
||||
|
||||
//使用WMIC获取主板序列号
|
||||
Process process = Runtime.getRuntime().exec("wmic baseboard get serialnumber");
|
||||
process.getOutputStream().close();
|
||||
Scanner scanner = new Scanner(process.getInputStream());
|
||||
|
||||
if(scanner != null && scanner.hasNext()){
|
||||
scanner.next();
|
||||
}
|
||||
|
||||
if(scanner.hasNext()){
|
||||
serialNumber = scanner.next().trim();
|
||||
}
|
||||
|
||||
scanner.close();
|
||||
return serialNumber;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
server.port=7080
|
||||
|
||||
#session超时时间
|
||||
server.servlet.session.timeout=300
|
||||
|
||||
#是否启用debug模式
|
||||
#debug=true
|
||||
|
||||
logging.level.org.springframework.web=DEBUG
|
||||
#logging.file=D:/runtime/test.log
|
||||
|
||||
#thymeleaf start
|
||||
spring.thymeleaf.mode=LEGACYHTML5
|
||||
spring.thymeleaf.prefix=classpath:/templates/
|
||||
spring.thymeleaf.suffix=.html
|
||||
spring.thymeleaf.template-resolver-order=0
|
||||
spring.thymeleaf.cache=false
|
||||
#thymeleaf end
|
@ -0,0 +1 @@
|
||||
server.port=8080
|
@ -0,0 +1,2 @@
|
||||
#使用哪个环境的配置
|
||||
spring.profiles.active=dev
|
@ -0,0 +1,22 @@
|
||||
${AnsiColor.BLUE}
|
||||
_ooOoo_
|
||||
o8888888o
|
||||
88" . "88
|
||||
(| ^_^ |)
|
||||
O\ = /O
|
||||
____/`---'\____
|
||||
.' \\| | `.
|
||||
/ \\||| : ||| \
|
||||
/ _||||| -:- |||||- \
|
||||
| | \\\ - / | |
|
||||
| \_| ''\---/'' | |
|
||||
\ .-\__ `-` ___/-. /
|
||||
___`. .' /--.--\ `. . ___
|
||||
."" '< `.___\_<|>_/___.' >'"".
|
||||
| | : `- \`.;`\ _ /`;.`/ - ` : | |
|
||||
\ \ `-. \_ __\ /__ _/ .-` / /
|
||||
========`-.____`-.___\_____/___.-`____.-'========
|
||||
`=---='
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
佛祖保佑 永无BUG
|
||||
|
@ -0,0 +1,6 @@
|
||||
#License相关配置
|
||||
license.subject=license_demo
|
||||
license.publicAlias=publicCert
|
||||
license.storePass=public_password1234
|
||||
license.licensePath=C:/Users/zifangsky/Desktop/license_demo/license.lic
|
||||
license.publicKeysStorePath=C:/Users/zifangsky/Desktop/license_demo/publicCerts.keystore
|
@ -0,0 +1,24 @@
|
||||
body{
|
||||
background: url("../img/3.jpg");
|
||||
animation-name:myfirst;
|
||||
animation-duration:20s;
|
||||
/*变换时间*/
|
||||
animation-delay:5s;
|
||||
/*动画开始时间*/
|
||||
animation-iteration-count:infinite;
|
||||
/*下一周期循环播放*/
|
||||
animation-play-state:running;
|
||||
/*动画开始运行*/
|
||||
}
|
||||
@keyframes myfirst
|
||||
{
|
||||
0% {background:url("../img/3.jpg");}
|
||||
34% {background:url("../img/2.jpg");}
|
||||
67% {background:url("../img/1.jpg");}
|
||||
100% {background:url("../img/3.jpg");}
|
||||
}
|
||||
.form{background: rgba(255,255,255,0.2);width:400px;margin:120px auto;}
|
||||
/*阴影*/
|
||||
.fa{display: inline-block;top: 27px;left: 6px;position: relative;color: #ccc;}
|
||||
input[type="text"],input[type="password"]{padding-left:26px;}
|
||||
.errMsg{color: red;}
|
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 166 KiB |
After Width: | Height: | Size: 339 KiB |
After Width: | Height: | Size: 338 KiB |
After Width: | Height: | Size: 339 KiB |
After Width: | Height: | Size: 328 KiB |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 339 KiB |
@ -0,0 +1,46 @@
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta content="text/html;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>首页</title>
|
||||
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
|
||||
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||
<style>
|
||||
body{
|
||||
background: url("/img/4.jpg");
|
||||
}
|
||||
/*.container{
|
||||
display:table;
|
||||
height:100%;
|
||||
}
|
||||
|
||||
.row{
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.row-centered {
|
||||
text-align:center;
|
||||
}
|
||||
.col-centered {
|
||||
display:inline-block;
|
||||
float:none;
|
||||
text-align:left;
|
||||
margin-right:-4px;
|
||||
}*/
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!--<div class="container">
|
||||
<div class="row clearfix">
|
||||
<div class="col-md-12 column">
|
||||
<h2 class="text-center">
|
||||
欢迎访问首页
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,93 @@
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta content="text/html;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>登录页面</title>
|
||||
<
|
||||
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
|
||||
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||
<link rel="stylesheet" th:href="@{/css/style.css}"/>
|
||||
|
||||
<script>
|
||||
//回车登录
|
||||
function enterlogin(e) {
|
||||
var key = window.event ? e.keyCode : e.which;
|
||||
if (key === 13) {
|
||||
userLogin();
|
||||
}
|
||||
}
|
||||
|
||||
//用户密码登录
|
||||
function userLogin() {
|
||||
//获取用户名、密码
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
|
||||
if (username == null || username === "") {
|
||||
$("#errMsg").text("请输入登陆用户名!");
|
||||
$("#errMsg").attr("style", "display:block");
|
||||
return;
|
||||
}
|
||||
if (password == null || password === "") {
|
||||
$("#errMsg").text("请输入登陆密码!");
|
||||
$("#errMsg").attr("style", "display:block");
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/check",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
"username": username,
|
||||
"password": password
|
||||
},
|
||||
success: function (data) {
|
||||
if (data.code == "200") {
|
||||
$("#errMsg").attr("style", "display:none");
|
||||
window.location.href = '/userIndex';
|
||||
} else if (data.result != null) {
|
||||
$("#errMsg").text(data.result);
|
||||
$("#errMsg").attr("style", "display:block");
|
||||
} else {
|
||||
$("#errMsg").text(data.msg);
|
||||
$("#errMsg").attr("style", "display:block");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onkeydown="enterlogin(event);">
|
||||
<div class="container">
|
||||
<div class="form row">
|
||||
<div class="form-horizontal col-md-offset-3" id="login_form">
|
||||
<h3 class="form-title">LOGIN</h3>
|
||||
<div class="col-md-9">
|
||||
<div class="form-group">
|
||||
<i class="fa fa-user fa-lg"></i>
|
||||
<input class="form-control required" type="text" placeholder="Username" id="username"
|
||||
name="username" autofocus="autofocus" maxlength="20"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<i class="fa fa-lock fa-lg"></i>
|
||||
<input class="form-control required" type="password" placeholder="Password" id="password"
|
||||
name="password" maxlength="8"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<span class="errMsg" id="errMsg" style="display: none">错误提示</span>
|
||||
</div>
|
||||
<div class="form-group col-md-offset-9">
|
||||
<button type="submit" class="btn btn-success pull-right" name="submit" onclick="userLogin()">登录
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,19 @@
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta content="text/html;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>用户首页</title>
|
||||
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
|
||||
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||
<style>
|
||||
body{
|
||||
background: url("/img/5.jpg");
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,16 @@
|
||||
package cn.zifangsky;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class ClientDemoApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/build/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
@ -0,0 +1 @@
|
||||
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
|
@ -0,0 +1,225 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Migwn, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
@ -0,0 +1,143 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
|
||||
<groupId>cn.zifangsky</groupId>
|
||||
<artifactId>serverdemo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ServerDemo</name>
|
||||
<description>Demo project for License</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.0.3.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<!-- 打包时忽略测试代码 -->
|
||||
<skipTests>true</skipTests>
|
||||
<!-- JUnit单元测试 -->
|
||||
<junit>4.12</junit>
|
||||
<!-- Apache Commons系列公共库 -->
|
||||
<commons-lang3>3.7</commons-lang3>
|
||||
<commons-io>2.6</commons-io>
|
||||
<commons-codec>1.11</commons-codec>
|
||||
<!-- Apache HttpClient -->
|
||||
<httpclient>4.5.5</httpclient>
|
||||
<!-- Fastjson -->
|
||||
<fastjson>1.2.47</fastjson>
|
||||
<!-- Java Servlet API -->
|
||||
<javax.servlet-api>4.0.1</javax.servlet-api>
|
||||
<!-- License -->
|
||||
<truelicense>1.33</truelicense>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Junit -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Commons -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>${commons-codec}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache HttpClient -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${httpclient}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Java Servlet API -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>${javax.servlet-api}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson对自动解析JSON和XML格式的支持 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SLF4J和LogBack -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- License -->
|
||||
<dependency>
|
||||
<groupId>de.schlichtherle.truelicense</groupId>
|
||||
<artifactId>truelicense-core</artifactId>
|
||||
<version>${truelicense}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.nekohtml</groupId>
|
||||
<artifactId>nekohtml</artifactId>
|
||||
<version>1.9.22</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.tld</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,16 @@
|
||||
package cn.zifangsky;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication
|
||||
@ServletComponentScan
|
||||
@PropertySource({"license-config.properties"}) //加载额外的配置
|
||||
public class ServerDemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServerDemoApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package cn.zifangsky.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Web相关配置
|
||||
* @author zifangsky
|
||||
* @date 2018/7/9
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 视图控制器
|
||||
*/
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addViewController("/index").setViewName("index");
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自定义需要校验的License参数
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/23
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LicenseCheckModel implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 8600137500316662317L;
|
||||
/**
|
||||
* 可被允许的IP地址
|
||||
*/
|
||||
private List<String> ipAddress;
|
||||
|
||||
/**
|
||||
* 可被允许的MAC地址
|
||||
*/
|
||||
private List<String> macAddress;
|
||||
|
||||
/**
|
||||
* 可被允许的CPU序列号
|
||||
*/
|
||||
private String cpuSerial;
|
||||
|
||||
/**
|
||||
* 可被允许的主板序列号
|
||||
*/
|
||||
private String mainBoardSerial;
|
||||
|
||||
public List<String> getIpAddress() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
public void setIpAddress(List<String> ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
|
||||
public List<String> getMacAddress() {
|
||||
return macAddress;
|
||||
}
|
||||
|
||||
public void setMacAddress(List<String> macAddress) {
|
||||
this.macAddress = macAddress;
|
||||
}
|
||||
|
||||
public String getCpuSerial() {
|
||||
return cpuSerial;
|
||||
}
|
||||
|
||||
public void setCpuSerial(String cpuSerial) {
|
||||
this.cpuSerial = cpuSerial;
|
||||
}
|
||||
|
||||
public String getMainBoardSerial() {
|
||||
return mainBoardSerial;
|
||||
}
|
||||
|
||||
public void setMainBoardSerial(String mainBoardSerial) {
|
||||
this.mainBoardSerial = mainBoardSerial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LicenseCheckModel{" +
|
||||
"ipAddress=" + ipAddress +
|
||||
", macAddress=" + macAddress +
|
||||
", cpuSerial='" + cpuSerial + '\'' +
|
||||
", mainBoardSerial='" + mainBoardSerial + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
import de.schlichtherle.license.CipherParam;
|
||||
import de.schlichtherle.license.DefaultCipherParam;
|
||||
import de.schlichtherle.license.DefaultLicenseParam;
|
||||
import de.schlichtherle.license.KeyStoreParam;
|
||||
import de.schlichtherle.license.LicenseContent;
|
||||
import de.schlichtherle.license.LicenseManager;
|
||||
import de.schlichtherle.license.LicenseParam;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* License生成类
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/19
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LicenseCreator {
|
||||
private static Logger logger = LogManager.getLogger(LicenseCreator.class);
|
||||
private final static X500Principal DEFAULT_HOLDER_AND_ISSUER = new X500Principal("CN=localhost, OU=localhost, O=localhost, L=SH, ST=SH, C=CN");
|
||||
private LicenseCreatorParam param;
|
||||
|
||||
public LicenseCreator(LicenseCreatorParam param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成License证书
|
||||
* @author zifangsky
|
||||
* @date 2018/4/20 10:58
|
||||
* @since 1.0.0
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean generateLicense(){
|
||||
try {
|
||||
LicenseManager licenseManager = new CustomLicenseManager(initLicenseParam());
|
||||
LicenseContent licenseContent = initLicenseContent();
|
||||
|
||||
licenseManager.store(licenseContent,new File(param.getLicensePath()));
|
||||
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
logger.error(MessageFormat.format("证书生成失败:{0}",param),e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化证书生成参数
|
||||
* @author zifangsky
|
||||
* @date 2018/4/20 10:56
|
||||
* @since 1.0.0
|
||||
* @return de.schlichtherle.license.LicenseParam
|
||||
*/
|
||||
private LicenseParam initLicenseParam(){
|
||||
Preferences preferences = Preferences.userNodeForPackage(LicenseCreator.class);
|
||||
|
||||
//设置对证书内容加密的秘钥
|
||||
CipherParam cipherParam = new DefaultCipherParam(param.getStorePass());
|
||||
|
||||
KeyStoreParam privateStoreParam = new CustomKeyStoreParam(LicenseCreator.class
|
||||
,param.getPrivateKeysStorePath()
|
||||
,param.getPrivateAlias()
|
||||
,param.getStorePass()
|
||||
,param.getKeyPass());
|
||||
|
||||
LicenseParam licenseParam = new DefaultLicenseParam(param.getSubject()
|
||||
,preferences
|
||||
,privateStoreParam
|
||||
,cipherParam);
|
||||
|
||||
return licenseParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置证书生成正文信息
|
||||
* @author zifangsky
|
||||
* @date 2018/4/20 10:57
|
||||
* @since 1.0.0
|
||||
* @return de.schlichtherle.license.LicenseContent
|
||||
*/
|
||||
private LicenseContent initLicenseContent(){
|
||||
LicenseContent licenseContent = new LicenseContent();
|
||||
licenseContent.setHolder(DEFAULT_HOLDER_AND_ISSUER);
|
||||
licenseContent.setIssuer(DEFAULT_HOLDER_AND_ISSUER);
|
||||
|
||||
licenseContent.setSubject(param.getSubject());
|
||||
licenseContent.setIssued(param.getIssuedTime());
|
||||
licenseContent.setNotBefore(param.getIssuedTime());
|
||||
licenseContent.setNotAfter(param.getExpiryTime());
|
||||
licenseContent.setConsumerType(param.getConsumerType());
|
||||
licenseContent.setConsumerAmount(param.getConsumerAmount());
|
||||
licenseContent.setInfo(param.getDescription());
|
||||
|
||||
//扩展校验服务器硬件信息
|
||||
licenseContent.setExtra(param.getLicenseCheckModel());
|
||||
|
||||
return licenseContent;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用于获取客户Linux服务器的基本信息
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/23
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LinuxServerInfos extends AbstractServerInfos {
|
||||
|
||||
@Override
|
||||
protected List<String> getIpAddress() throws Exception {
|
||||
List<String> result = null;
|
||||
|
||||
//获取所有网络接口
|
||||
List<InetAddress> inetAddresses = getLocalAllInetAddress();
|
||||
|
||||
if(inetAddresses != null && inetAddresses.size() > 0){
|
||||
result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getMacAddress() throws Exception {
|
||||
List<String> result = null;
|
||||
|
||||
//1. 获取所有网络接口
|
||||
List<InetAddress> inetAddresses = getLocalAllInetAddress();
|
||||
|
||||
if(inetAddresses != null && inetAddresses.size() > 0){
|
||||
//2. 获取所有网络接口的Mac地址
|
||||
result = inetAddresses.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCPUSerial() throws Exception {
|
||||
//序列号
|
||||
String serialNumber = "";
|
||||
|
||||
//使用dmidecode命令获取CPU序列号
|
||||
String[] shell = {"/bin/bash","-c","dmidecode -t processor | grep 'ID' | awk -F ':' '{print $2}' | head -n 1"};
|
||||
Process process = Runtime.getRuntime().exec(shell);
|
||||
process.getOutputStream().close();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
|
||||
String line = reader.readLine().trim();
|
||||
if(StringUtils.isNotBlank(line)){
|
||||
serialNumber = line;
|
||||
}
|
||||
|
||||
reader.close();
|
||||
return serialNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMainBoardSerial() throws Exception {
|
||||
//序列号
|
||||
String serialNumber = "";
|
||||
|
||||
//使用dmidecode命令获取主板序列号
|
||||
String[] shell = {"/bin/bash","-c","dmidecode | grep 'Serial Number' | awk -F ':' '{print $2}' | head -n 1"};
|
||||
Process process = Runtime.getRuntime().exec(shell);
|
||||
process.getOutputStream().close();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
|
||||
String line = reader.readLine().trim();
|
||||
if(StringUtils.isNotBlank(line)){
|
||||
serialNumber = line;
|
||||
}
|
||||
|
||||
reader.close();
|
||||
return serialNumber;
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package cn.zifangsky.license;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用于获取客户Windows服务器的基本信息
|
||||
*
|
||||
* @author zifangsky
|
||||
* @date 2018/4/23
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class WindowsServerInfos extends AbstractServerInfos {
|
||||
|
||||
@Override
|
||||
protected List<String> getIpAddress() throws Exception {
|
||||
List<String> result = null;
|
||||
|
||||
//获取所有网络接口
|
||||
List<InetAddress> inetAddresses = getLocalAllInetAddress();
|
||||
|
||||
if(inetAddresses != null && inetAddresses.size() > 0){
|
||||
result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getMacAddress() throws Exception {
|
||||
List<String> result = null;
|
||||
|
||||
//1. 获取所有网络接口
|
||||
List<InetAddress> inetAddresses = getLocalAllInetAddress();
|
||||
|
||||
if(inetAddresses != null && inetAddresses.size() > 0){
|
||||
//2. 获取所有网络接口的Mac地址
|
||||
result = inetAddresses.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCPUSerial() throws Exception {
|
||||
//序列号
|
||||
String serialNumber = "";
|
||||
|
||||
//使用WMIC获取CPU序列号
|
||||
Process process = Runtime.getRuntime().exec("wmic cpu get processorid");
|
||||
process.getOutputStream().close();
|
||||
Scanner scanner = new Scanner(process.getInputStream());
|
||||
|
||||
if(scanner.hasNext()){
|
||||
scanner.next();
|
||||
}
|
||||
|
||||
if(scanner.hasNext()){
|
||||
serialNumber = scanner.next().trim();
|
||||
}
|
||||
|
||||
scanner.close();
|
||||
return serialNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMainBoardSerial() throws Exception {
|
||||
//序列号
|
||||
String serialNumber = "";
|
||||
|
||||
//使用WMIC获取主板序列号
|
||||
Process process = Runtime.getRuntime().exec("wmic baseboard get serialnumber");
|
||||
process.getOutputStream().close();
|
||||
Scanner scanner = new Scanner(process.getInputStream());
|
||||
|
||||
if(scanner.hasNext()){
|
||||
scanner.next();
|
||||
}
|
||||
|
||||
if(scanner.hasNext()){
|
||||
serialNumber = scanner.next().trim();
|
||||
}
|
||||
|
||||
scanner.close();
|
||||
return serialNumber;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
server.port=7000
|
||||
|
||||
#session超时时间
|
||||
server.servlet.session.timeout=300
|
||||
|
||||
#是否启用debug模式
|
||||
#debug=true
|
||||
|
||||
logging.level.org.springframework.web=DEBUG
|
||||
#logging.file=D:/runtime/test.log
|
||||
|
||||
#thymeleaf start
|
||||
spring.thymeleaf.mode=LEGACYHTML5
|
||||
spring.thymeleaf.prefix=classpath:/templates/
|
||||
spring.thymeleaf.suffix=.html
|
||||
spring.thymeleaf.template-resolver-order=0
|
||||
spring.thymeleaf.cache=false
|
||||
#thymeleaf end
|
@ -0,0 +1 @@
|
||||
server.port=8000
|
@ -0,0 +1,2 @@
|
||||
#使用哪个环境的配置
|
||||
spring.profiles.active=dev
|
@ -0,0 +1,22 @@
|
||||
${AnsiColor.BLUE}
|
||||
_ooOoo_
|
||||
o8888888o
|
||||
88" . "88
|
||||
(| ^_^ |)
|
||||
O\ = /O
|
||||
____/`---'\____
|
||||
.' \\| | `.
|
||||
/ \\||| : ||| \
|
||||
/ _||||| -:- |||||- \
|
||||
| | \\\ - / | |
|
||||
| \_| ''\---/'' | |
|
||||
\ .-\__ `-` ___/-. /
|
||||
___`. .' /--.--\ `. . ___
|
||||
."" '< `.___\_<|>_/___.' >'"".
|
||||
| | : `- \`.;`\ _ /`;.`/ - ` : | |
|
||||
\ \ `-. \_ __\ /__ _/ .-` / /
|
||||
========`-.____`-.___\_____/___.-`____.-'========
|
||||
`=---='
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
佛祖保佑 永无BUG
|
||||
|
@ -0,0 +1,2 @@
|
||||
#License相关配置
|
||||
license.licensePath=C:/Users/zifangsky/Desktop/license_demo/license.lic
|
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 166 KiB |
After Width: | Height: | Size: 339 KiB |
After Width: | Height: | Size: 338 KiB |
After Width: | Height: | Size: 339 KiB |
After Width: | Height: | Size: 328 KiB |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 339 KiB |
@ -0,0 +1,46 @@
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta content="text/html;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>首页</title>
|
||||
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
|
||||
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||
<style>
|
||||
body{
|
||||
background: url("/img/6.jpg");
|
||||
}
|
||||
/*.container{
|
||||
display:table;
|
||||
height:100%;
|
||||
}
|
||||
|
||||
.row{
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.row-centered {
|
||||
text-align:center;
|
||||
}
|
||||
.col-centered {
|
||||
display:inline-block;
|
||||
float:none;
|
||||
text-align:left;
|
||||
margin-right:-4px;
|
||||
}*/
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!--<div class="container">
|
||||
<div class="row clearfix">
|
||||
<div class="col-md-12 column">
|
||||
<h2 class="text-center">
|
||||
欢迎访问首页
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,16 @@
|
||||
package cn.zifangsky;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class ServerDemoApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|