master
20918 7 months ago
parent b896a5ba3a
commit 1f82a686a2

3
.gitattributes vendored

@ -0,0 +1,3 @@
*.js linguist-language=java
*.css linguist-language=java
*.html linguist-language=java

4
.gitignore vendored

@ -0,0 +1,4 @@
*.iml
target/
.idea/
~/

@ -0,0 +1,31 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/

@ -0,0 +1,118 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed 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
*
* https://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.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}

Binary file not shown.

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

310
childpassmanage/mvnw vendored

@ -0,0 +1,310 @@
#!/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
#
# https://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.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven 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 Mingw, 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)`"
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
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
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
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
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,182 @@
@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 https://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 Maven 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 keystroke 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 set title of command window
title %0
@REM enable echoing by 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
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%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,105 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.childpassmanage</groupId>
<artifactId>childpassmanage</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>childpassmanage</name>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.68</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.10</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>central</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<layout>default</layout>
<!-- 是否开启发布版构件下载 -->
<releases>
<enabled>true</enabled>
</releases>
<!-- 是否开启快照版构件下载 -->
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>

@ -0,0 +1,15 @@
package com.childpassmanage.net;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import tk.mybatis.spring.annotation.MapperScan;
@SpringBootApplication
@MapperScan("com.childpassmanage.net.dao")
public class ChildpassmanageApplication {
public static void main(String[] args) {
SpringApplication.run(ChildpassmanageApplication.class, args);
}
}

@ -0,0 +1,113 @@
package com.childpassmanage.net.controller;
import com.childpassmanage.net.dao.KeyPassMapper;
import com.childpassmanage.net.pojo.KeyPassPO;
import com.childpassmanage.net.pojo.UserNamePO;
import com.childpassmanage.net.service.KeyPassServie;
import com.childpassmanage.net.service.SM4PubService;
import com.childpassmanage.net.service.UserNameService;
import com.childpassmanage.net.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class LinkUpassServerController {
@Autowired
private UserNameService userNameService;
@Autowired
private KeyPassMapper keyPassMapper;
@Autowired
private SM4PubService sm4PubService;
@RequestMapping(value = "/remote/getSessionKey",method = RequestMethod.POST)
@ResponseBody
public R getUserPublicKey(@RequestParam("username")String username,@RequestParam("password")String password) throws Exception {
boolean userNameIfExist = userNameService.findUserNameIfExist(username);
if (userNameIfExist) {
HashMap<String, String> hashMap = new HashMap<>();
String sessionkey = Sm4Util.generateKey();
hashMap.put("sessionkey", sessionkey);
hashMap.put("username", username);
HttpUtils.post("http://localhost:18088/us-admin/remote/saveUserSM4KEY", hashMap);
return R.ok().put("sessionkey", sessionkey);
} else {
return R.error();
}
}
@RequestMapping("/remote/setUserName/{username}")
public void setUserName(@PathVariable("username")String userName) throws Exception {
PCIKeyPair pciKeyPair = SM2Util.genKeyPair();
String priKey = pciKeyPair.getPriKey();
String pubKey = pciKeyPair.getPubKey();
sm4PubService.insertPubKey(pubKey,userName);
UserNamePO userNamePO = new UserNamePO();
userNamePO.setUserName(userName);
userNamePO.setCreateDate(new Date());
userNamePO.setIfClose(0);
userNamePO.setPriKey(priKey);
userNameService.insertUserName(userNamePO);
}
@RequestMapping("/remote/getSM2Pub/{username}")
@ResponseBody
public R getSM4Pub(@PathVariable("username")String username){
String pubKey =sm4PubService.getSM4PubByUserName(username);
return R.ok().put("pubKey", pubKey);
}
@RequestMapping("/remote/getSM2Pri/{username}")
@ResponseBody
public R getSM4Pri(@PathVariable("username")String username){
String pubKey =userNameService.getSM4PriByUserName(username);
return R.ok().put("priKey", pubKey);
}
@RequestMapping("/remote/savekeypass/{username}")
@ResponseBody
public R saveKeyPass(@PathVariable("username")String username,@RequestParam("keyPass")String keyPass){
KeyPassPO keyPassPO = new KeyPassPO();
Map<String, Long> split = Shamir.split(Integer.parseInt(keyPass));
keyPassPO.setDian0(split.get("dian[0]"));
keyPassPO.setDian1(split.get("dian[1]"));
keyPassPO.setDian2(split.get("dian[2]"));
keyPassPO.setF0(split.get("f[0]"));
keyPassPO.setF1(split.get("f[1]"));
keyPassPO.setF2(split.get("f[2]"));
keyPassPO.setP(split.get("p"));
keyPassPO.setUsername(username);
keyPassMapper.insert(keyPassPO);
return R.ok().put("flag", "true");
}
@RequestMapping("/remote/getKeyPass/{username}")
@ResponseBody
public R getKeyPass(@PathVariable("username")String username){
KeyPassPO keyPassPO = new KeyPassPO();
keyPassPO.setUsername(username);
List<KeyPassPO> select = keyPassMapper.select(keyPassPO);
KeyPassPO keyPassPO1 = select.get(0);
Map<String ,Long> hashMap = new HashMap<>();
hashMap.put("dian[0]", keyPassPO1.getDian0());
hashMap.put("dian[1]", keyPassPO1.getDian1());
hashMap.put("dian[2]", keyPassPO1.getDian2());
hashMap.put("f[0]", keyPassPO1.getF0());
hashMap.put("f[1]", keyPassPO1.getF1());
hashMap.put("f[2]", keyPassPO1.getF2());
hashMap.put("p", keyPassPO1.getP());
long combine = Shamir.combine(hashMap);
String keyByPass = ThroughUserkey.getKeyByPass(combine+"");
return R.ok().put("keyPass",keyByPass);
}
}

@ -0,0 +1,60 @@
package com.childpassmanage.net.controller;
import com.childpassmanage.net.dao.KeyPassMapper;
import com.childpassmanage.net.pojo.KeyPassPO;
import com.childpassmanage.net.service.RandomService;
import com.childpassmanage.net.utils.*;
import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class RandomStringController {
@Autowired
private RandomService randomService;
@Autowired
private KeyPassMapper keyPassMapper;
@RequestMapping(value = "remote/ranstr/{userName}/{keyId}",method = RequestMethod.GET)
@ResponseBody
public R getRandomString(@PathVariable("userName") String userName,@PathVariable("keyId")String keyId) throws Exception {
String sm4Key = Sm4Util.generateKey();
R r = new R();
r.put("random", sm4Key);
KeyPassPO keyPassPO = new KeyPassPO();
keyPassPO.setUsername(userName);
List<KeyPassPO> select = keyPassMapper.select(keyPassPO);
KeyPassPO keyPassPO1 = select.get(0);
Map<String ,Long> hashMap = new HashMap<>();
hashMap.put("dian[0]", keyPassPO1.getDian0());
hashMap.put("dian[1]", keyPassPO1.getDian1());
hashMap.put("dian[2]", keyPassPO1.getDian2());
hashMap.put("f[0]", keyPassPO1.getF0());
hashMap.put("f[1]", keyPassPO1.getF1());
hashMap.put("f[2]", keyPassPO1.getF2());
hashMap.put("p", keyPassPO1.getP());
long combine = Shamir.combine(hashMap);
String keyByPass = ThroughUserkey.getKeyByPass(combine+"");
byte[] encryptSM4key = AESUtil.encrypt(sm4Key, keyByPass);
Boolean flag = randomService.insertRandomStringByUserName(userName,new String(encryptSM4key),keyId);
return flag ? r:R.error();
}
@RequestMapping(value = "remote/ranstr/{keyId}",method = RequestMethod.GET)
@ResponseBody
public R getKeyRanByKeyId(@PathVariable("keyId")String keyId){
String ranStr = randomService.getRandomStringByKeyId(keyId);
return R.ok().put("ranstr",ranStr);
}
}

@ -0,0 +1,9 @@
package com.childpassmanage.net.dao;
import com.childpassmanage.net.pojo.KeyPairPO;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.common.Mapper;
@Component
public interface KeyPairMapper extends Mapper<KeyPairPO> {
}

@ -0,0 +1,9 @@
package com.childpassmanage.net.dao;
import com.childpassmanage.net.pojo.KeyPassPO;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.common.Mapper;
@Component
public interface KeyPassMapper extends Mapper<KeyPassPO> {
}

@ -0,0 +1,9 @@
package com.childpassmanage.net.dao;
import com.childpassmanage.net.pojo.RandomStringPO;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.common.Mapper;
@Component
public interface RandomMapper extends Mapper<RandomStringPO> {
}

@ -0,0 +1,9 @@
package com.childpassmanage.net.dao;
import com.childpassmanage.net.pojo.SM4PubPO;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.common.Mapper;
@Component
public interface SM4PubMapper extends Mapper<SM4PubPO> {
}

@ -0,0 +1,10 @@
package com.childpassmanage.net.dao;
import com.childpassmanage.net.pojo.UserNamePO;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.common.Mapper;
@Component
public interface UserNameMapper extends Mapper<UserNamePO> {
}

@ -0,0 +1,11 @@
package com.childpassmanage.net.pojo;
import lombok.Data;
@Data
public class AdminUser {
private Integer id;
private String username;
private String password;
}

@ -0,0 +1,10 @@
package com.childpassmanage.net.pojo;
import lombok.Data;
@Data
public class KeyPairPO {
private Integer id;
private String userName;
private String pubKey;
}

@ -0,0 +1,19 @@
package com.childpassmanage.net.pojo;
import lombok.Data;
import javax.persistence.Table;
@Data
@Table(name = "p_passdata")
public class KeyPassPO {
private Integer id;
private String username;
private Long dian0;
private Long dian1;
private Long dian2;
private Long f0;
private Long f1;
private Long f2;
private Long p;
}

@ -0,0 +1,15 @@
package com.childpassmanage.net.pojo;
import lombok.Data;
import javax.persistence.Table;
@Data
@Table(name = "p_random")
public class RandomStringPO {
private Integer id;
private String userName;
private String randomStr;
private Integer keyId;
}

@ -0,0 +1,13 @@
package com.childpassmanage.net.pojo;
import lombok.Data;
import javax.persistence.Table;
@Data
@Table(name = "p_sm4pub")
public class SM4PubPO {
private Integer id;
private String pubkey;
private String username;
}

@ -0,0 +1,16 @@
package com.childpassmanage.net.pojo;
import lombok.Data;
import javax.persistence.Table;
import java.util.Date;
@Data
@Table(name = "p_username")
public class UserNamePO {
private Integer id;
private String userName;
private Date createDate;
private Integer ifClose;
private String priKey;
}

@ -0,0 +1,12 @@
package com.childpassmanage.net.service;
import com.childpassmanage.net.pojo.KeyPairPO;
import org.springframework.stereotype.Service;
public interface KeyPairService {
Integer insertKeyPairByUsername(String username, String priKey);
KeyPairPO selectKeyPairByUserName(String username);
}

@ -0,0 +1,4 @@
package com.childpassmanage.net.service;
public interface KeyPassServie {
}

@ -0,0 +1,7 @@
package com.childpassmanage.net.service;
public interface RandomService {
public Boolean insertRandomStringByUserName(String userName ,String randomKey,String keyId);
public Boolean updateRandomStringByUserNameAndKey(String userName, Integer keyId,String randomStr);
public String getRandomStringByKeyId(String keyId);
}

@ -0,0 +1,7 @@
package com.childpassmanage.net.service;
public interface SM4PubService {
String getSM4PubByUserName(String username);
void insertPubKey(String pubKey, String userName);
}

@ -0,0 +1,20 @@
package com.childpassmanage.net.service;
import com.childpassmanage.net.pojo.UserNamePO;
public interface UserNameService {
/**
*
* @param username
* @return
*/
boolean findUserNameIfExist(String username);
/**
*
* @param userNamePO
*/
void insertUserName(UserNamePO userNamePO);
String getSM4PriByUserName(String username);
}

@ -0,0 +1,33 @@
package com.childpassmanage.net.service.impl;
import com.childpassmanage.net.dao.KeyPairMapper;
import com.childpassmanage.net.pojo.KeyPairPO;
import com.childpassmanage.net.service.KeyPairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class KeyPairServiceImpl implements KeyPairService {
@Autowired
private KeyPairMapper keyPairMapper;
@Override
public Integer insertKeyPairByUsername(String username, String priKey) {
KeyPairPO keyPairPO = new KeyPairPO();
keyPairPO.setUserName(username);
keyPairPO.setPubKey(priKey);
int count = keyPairMapper.insert(keyPairPO);
return count;
}
@Override
public KeyPairPO selectKeyPairByUserName(String username) {
KeyPairPO keyPairPO = new KeyPairPO();
keyPairPO.setUserName(username);
KeyPairPO keyPairPOS = keyPairMapper.selectOne(keyPairPO);
return keyPairPOS;
}
}

@ -0,0 +1,8 @@
package com.childpassmanage.net.service.impl;
import com.childpassmanage.net.service.KeyPassServie;
import org.springframework.stereotype.Service;
@Service
public class KeyPassServiceImpl implements KeyPassServie {
}

@ -0,0 +1,47 @@
package com.childpassmanage.net.service.impl;
import com.childpassmanage.net.dao.RandomMapper;
import com.childpassmanage.net.pojo.RandomStringPO;
import com.childpassmanage.net.service.RandomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class RandomServiceImpl implements RandomService {
@Autowired
private RandomMapper randomMapper;
@Override
public Boolean insertRandomStringByUserName(String userName, String randomKey,String keyId) {
RandomStringPO randomStringPO = new RandomStringPO();
randomStringPO.setRandomStr(randomKey);
randomStringPO.setUserName(userName);
randomStringPO.setKeyId(Integer.parseInt(keyId));
int insert = randomMapper.insert(randomStringPO);
return insert == 1;
}
@Override
public Boolean updateRandomStringByUserNameAndKey(String userName, Integer keyId,String randomStr) {
RandomStringPO randomStringPO = new RandomStringPO();
randomStringPO.setUserName(userName);
randomStringPO.setRandomStr(randomStr);
RandomStringPO randomStringPO1 = randomMapper.selectOne(randomStringPO);
if(randomStringPO1!=null){
randomStringPO.setKeyId(keyId);
}
int update = randomMapper.updateByPrimaryKey(randomStringPO1);
return update == 1;
}
@Override
public String getRandomStringByKeyId(String keyId) {
RandomStringPO randomStringPO = new RandomStringPO();
randomStringPO.setKeyId(Integer.parseInt(keyId));
RandomStringPO randomString = randomMapper.selectOne(randomStringPO);
return randomString.getRandomStr();
}
}

@ -0,0 +1,35 @@
package com.childpassmanage.net.service.impl;
import com.childpassmanage.net.dao.SM4PubMapper;
import com.childpassmanage.net.dao.UserNameMapper;
import com.childpassmanage.net.pojo.SM4PubPO;
import com.childpassmanage.net.pojo.UserNamePO;
import com.childpassmanage.net.service.SM4PubService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class SM4PubServiceImpl implements SM4PubService {
@Autowired
private SM4PubMapper sm4PubMapper;
@Override
public String getSM4PubByUserName(String username) {
SM4PubPO sm4PubPO = new SM4PubPO();
sm4PubPO.setUsername(username);
List<SM4PubPO> select = sm4PubMapper.select(sm4PubPO);
return select.get(0).getPubkey();
}
@Override
public void insertPubKey(String pubKey, String userName) {
SM4PubPO sm4PubPO = new SM4PubPO();
sm4PubPO.setUsername(userName);
sm4PubPO.setPubkey(pubKey);
sm4PubMapper.insert(sm4PubPO);
}
}

@ -0,0 +1,42 @@
package com.childpassmanage.net.service.impl;
import com.childpassmanage.net.dao.UserNameMapper;
import com.childpassmanage.net.pojo.UserNamePO;
import com.childpassmanage.net.service.UserNameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional
public class UserNameServiceImpl implements UserNameService {
@Autowired
private UserNameMapper userMapper;
@Override
public boolean findUserNameIfExist(String username) {
UserNamePO userNamePO = new UserNamePO();
userNamePO.setUserName(username);
UserNamePO userNamePO1 = userMapper.selectOne(userNamePO);
if(userNamePO1 != null || userNamePO1.getIfClose() != -1){
return true;
}else{
return false;
}
}
@Override
public void insertUserName(UserNamePO userNamePO) {
userMapper.insert(userNamePO);
}
@Override
public String getSM4PriByUserName(String username) {
UserNamePO userNamePO = new UserNamePO();
userNamePO.setUserName(username);
List<UserNamePO> select = userMapper.select(userNamePO);
return select.get(0).getPriKey();
}
}

@ -0,0 +1,82 @@
package com.childpassmanage.net.utils;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
public class AESUtil {
/**
* AES
*
* @param content
*
* @param password
*
* @return
*/
public static byte[] encrypt(String content, String password) {
try {
KeyGenerator kgen = KeyGenerator.getInstance("AES");// 创建AES的Key生产者
kgen.init(128, new SecureRandom(password.getBytes()));// 利用用户密码作为随机数初始化出
//加密没关系SecureRandom是生成安全随机数序列password.getBytes()是种子只要种子相同序列就一样所以解密只要有password就行
SecretKey secretKey = kgen.generateKey();// 根据用户密码,生成一个密钥
byte[] enCodeFormat = secretKey.getEncoded();// 返回基本编码格式的密钥,如果此密钥不支持编码,则返回
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");// 转换为AES专用密钥
Cipher cipher = Cipher.getInstance("AES");// 创建密码器
byte[] byteContent = content.getBytes("utf-8");
cipher.init(Cipher.ENCRYPT_MODE, key);// 初始化为加密模式的密码器
byte[] result = cipher.doFinal(byteContent);// 加密
return result;
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
return null;
}
/**
* AES
*
* @param content
* AES
* @param password
*
* @return
*/
public static byte[] decrypt(byte[] content, String password) {
try {
KeyGenerator kgen = KeyGenerator.getInstance("AES");// 创建AES的Key生产者
kgen.init(128, new SecureRandom(password.getBytes()));
SecretKey secretKey = kgen.generateKey();// 根据用户密码,生成一个密钥
byte[] enCodeFormat = secretKey.getEncoded();// 返回基本编码格式的密钥
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");// 转换为AES专用密钥
Cipher cipher = Cipher.getInstance("AES");// 创建密码器
cipher.init(Cipher.DECRYPT_MODE, key);// 初始化为解密模式的密码器
byte[] result = cipher.doFinal(content);
return result; // 明文
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
return null;
}
}

@ -0,0 +1,417 @@
package com.childpassmanage.net.utils;
import org.springframework.util.StringUtils;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @ClassName: CommonUtils
* @Description:
* @since: 0.0.1
* @author: dzy
* @date: 2017222 11:46:44
*/
public class CommonUtils {
/**
* @param date
* @param pattern :yyyyMMdd
* @return
* @Title: formatDate
* @Description:
* @since: 0.0.1
*/
public static String formatDate(Date date, String pattern) {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
return formatter.format(date);
}
/**
* @param strDate String
* @param pattern
* @return
* @Title: parseDate
* @Description: StringDate
* @since: 0.0.1
*/
public static Date parseDate(String strDate, String pattern) {
SimpleDateFormat formatter = null;
if (StringUtils.isEmpty(strDate) || strDate.equals("")) {
return null;
}
formatter = new SimpleDateFormat(pattern);
try {
return formatter.parse(strDate);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* @param date
* @param field :,,
* @param amount ()
* @return
* @Title: dateAdd
* @Description:
* @since: 0.0.1
*/
public static Date dateAdd(Date date, int field, int amount) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(field, amount);
return calendar.getTime();
}
/**
* @param source
* @param offset , 0-, source.getBytes().length ,
* @param c
* @param length
* @return
* @Title: fill
* @Description: , ,
* @since: 0.0.1
*/
public static String fill(String source, int offset, char c, int length) throws UnsupportedEncodingException {
if (null == source) {
source = "";
}
if (source.getBytes("utf-8").length == length) {
return source;
}
byte[] buf = new byte[length];
byte[] src = source.getBytes("utf-8");
if (src.length > length) {
System.arraycopy(src, src.length - length, buf, 0, length);
return new String(buf, "utf-8");
}
if (offset > src.length) {
offset = src.length;
} else if (offset < 0) {
offset = 0;
}
int n = length - src.length;
System.arraycopy(src, 0, buf, 0, offset);
for (int i = 0; i < n; i++) {
buf[i + offset] = (byte) c;
}
System.arraycopy(src, offset, buf, offset + n, src.length - offset);
return new String(buf, "utf-8");
}
/**
* @param original
* @param offset , 0-, original.getBytes().length ,
* @param length
* @param c
* @return
* @Title: replace
* @Description: , ,
* @since: 0.0.1
*/
public static String replace(String original, int offset, int length, char c) throws UnsupportedEncodingException {
if (original == null) {
original = "";
}
if (original.getBytes("utf-8").length <= offset) {
return original;
}
if (original.getBytes("utf-8").length < offset + length) {
length = original.getBytes("utf-8").length - offset;
}
byte[] buf = new byte[original.length()];
byte[] src = original.getBytes("utf-8");
System.arraycopy(src, 0, buf, 0, offset);
for (int i = offset; i < offset + length; i++) {
buf[i] = (byte) c;
}
System.arraycopy(src, offset + length, buf, offset + length, src.length - offset - length);
return new String(buf, "utf-8");
}
/**
* @param s 16
* @return
* @Title: hexToByte
* @Description: 16
* @since: 0.0.1
*/
public static byte[] hexToByte(String s) {
byte[] result = null;
try {
int i = s.length();
// if (i % 2 == 1) {
// throw new Exception("字符串长度不是偶数.");
// }
if (i % 2 != 0) {
throw new Exception("字符串长度不是偶数.");
}
result = new byte[i / 2];
for (int j = 0; j < result.length; j++) {
result[j] = (byte) Integer.parseInt(s.substring(j * 2, j * 2 + 2), 16);
}
} catch (Exception e) {
result = null;
e.printStackTrace();
// log.error("16进制字符串转字节数组时出现异常:", e);
}
return result;
}
/**
* @param bytes
* @return
* @Title: byte2hexString
* @Description: 16 //0x33 0xD2 0x00 0x46 转换为 "33d20046" 转换和打印报文用
* @since: 0.0.1
*/
public static String byte2hexString(byte[] bytes) {
StringBuffer buf = new StringBuffer(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
if (((int) bytes[i] & 0xff) < 0x10) {
buf.append("0");
}
buf.append(Long.toString((int) bytes[i] & 0xff, 16));
}
return buf.toString().toUpperCase();
}
/**
* @param hexString 16 :"33d20046" 0x33 0xD2 0x00 0x46
* @return
* @Title: hexString2byte
* @Description: 16
* @since: 0.0.1
*/
public static byte[] hexString2byte(String hexString) {
if (null == hexString || hexString.length() % 2 != 0 || hexString.contains("null")) {
return null;
}
byte[] bytes = new byte[hexString.length() / 2];
for (int i = 0; i < hexString.length(); i += 2) {
bytes[i / 2] = (byte) (Integer.parseInt(hexString.substring(i, i + 2), 16) & 0xff);
}
return bytes;
}
/**
* @param i int
* @return
* @Title: byte1ToBcd2
* @Description: intBCD
* @since: 0.0.1
*/
public static String byte1ToBcd2(int i) {
// return (new Integer(i / 16).toString() + (new Integer(i % 16)).toString());
return Integer.toString(i / 16) + Integer.toString(i % 16);
}
/**
* @param b
* @return
* @Title: byteToHex2
* @Description: 16 For example, byte[] {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF} will be changed to String "0123456789ABCDEF"
* @since: 0.0.1
*/
public static String byteToHex2(byte[] b) {
StringBuffer result = new StringBuffer();
String tmp = "";
for (int i = 0; i < b.length; i++) {
tmp = Integer.toHexString(b[i] & 0xff);
if (tmp.length() == 1) {
result.append("0" + tmp);
} else {
result.append(tmp);
}
}
return result.toString().toUpperCase();
}
/**
* @param num
* @param len
* @return
* @Title: intToHexBytes
* @Description: int16
*/
public static byte[] intToHexBytes(int num, int len) {
byte[] bytes = null;
String hexString = Integer.toHexString(num);
if (len > 0) {
int length = len * 2;
hexString = leftFill(hexString, '0', length);
bytes = CommonUtils.hexString2byte(hexString);
}
return bytes;
}
private static String leftFill(String hexString, char c, int length) {
StringBuilder stringBuilder = new StringBuilder();
if(hexString.length() < length){
for(int count = 0; count <length-hexString.length();count++){
stringBuilder.append(c);
}
}
return stringBuilder.append(hexString).toString();
}
/*public static String byteToHex3(byte[] b) {
String result = "";
String tmp = "";
for (int n = 0; n < b.length; n++) {
tmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
if (tmp.length() == 1) {
result = result + "0" + tmp;
} else {
result = result + tmp;
}
if (n < b.length - 1) {
result = result + "";
}
}
return result.toUpperCase();
}*/
/**
* @param str
* @return
* @Title: iso2Gbk
* @Description: ISO-8859-1GBK
* @since: 0.0.1
*/
public static String iso2Gbk(String str) {
if (null == str) {
return str;
}
try {
return new String(str.getBytes("ISO-8859-1"), "GBK");
} catch (UnsupportedEncodingException e) {
// log.error("不支持的编码异常:", e);
e.printStackTrace();
return str;
}
}
// /**
// * @param message
// * @return
// * @Title: getSubElement
// * @Description: 分解各子域到HashMap
// * @since: 0.0.1
// */
// public static Map<String, String> getSubElement(byte[] message) {
// Map<String, String> map = new HashMap<String, String>();
// String key = null;
// String value = null;
// int len = 0;
// int idx = 0;
// while (idx < message.length) {
// key = new String(message, idx, 2);
// idx += 2; //取了SE id 移2位
// len = Integer.parseInt(new String(message, idx, 2));
// idx += 2; //取了SE id的内容长度 移2位
// value = new String(message, idx, len);
// map.put(key, value);
// idx += len;
// }
// return map;
// }
//byte数组转成long
/**
* @param b long
* @return
*/
public static long byteToLong(byte[] b) {
long s = 0;
long s0 = b[0] & 0xff;// 最低位
long s1 = b[1] & 0xff;
long s2 = b[2] & 0xff;
long s3 = b[3] & 0xff;
long s4 = b[4] & 0xff;// 最低位
long s5 = b[5] & 0xff;
long s6 = b[6] & 0xff;
long s7 = b[7] & 0xff;
// s0不变
s1 <<= 8;
s2 <<= 16;
s3 <<= 24;
s4 <<= 8 * 4;
s5 <<= 8 * 5;
s6 <<= 8 * 6;
s7 <<= 8 * 7;
s = s0 | s1 | s2 | s3 | s4 | s5 | s6 | s7;
return s;
}
/**
* @param b int
* @return
*/
public static int byteToInt(byte[] b) {
int s = 0;
int s0 = b[0] & 0xff;// 最低位
int s1 = b[1] & 0xff;
int s2 = b[2] & 0xff;
int s3 = b[3] & 0xff;
// s0不变
s1 <<= 8;
s2 <<= 16;
s3 <<= 24;
s = s0 | s1 | s2 | s3;
return s;
}
/**
* intbyte
* @param i
* @return
*/
public static byte[] intToLittleBytes(int i) {
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
byteBuffer.asIntBuffer().put(i);
byte[] littleBytes = byteBuffer.array();
return littleBytes;
}
/**
* 10
* @param b
* @return
*/
public static int byteToInt(byte b) {
int value = b & 0xff;
return value;
}
/**
*
* @param bt1 bt1
* @param bt2 bt2
* @return
*/
public static byte[] byteMerger(byte[] bt1, byte[] bt2){
byte[] bt3 = new byte[bt1.length+bt2.length];
System.arraycopy(bt1, 0, bt3, 0, bt1.length);
System.arraycopy(bt2, 0, bt3, bt1.length, bt2.length);
return bt3;
}
}

@ -0,0 +1,68 @@
package com.childpassmanage.net.utils;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.security.NoSuchAlgorithmException;
public class Generatingkey {
/**
AES
* @return
*/
public static String getAESKey() {
String s1;
KeyGenerator kg = null;
try {
kg = KeyGenerator.getInstance("AES");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
kg.init(128);
//要生成多少位只需要修改这里即可128, 192或256
SecretKey sk = kg.generateKey();
byte[] b = sk.getEncoded();
s1 = byteToHexString(b);
// System.out.println("随机生成的密钥长度:"+s1.length()*4);
// System.out.println("密钥:"+s1);
return s1;
}
public static String getDESKey() {
String s1;
KeyGenerator kg = null;
try {
kg = KeyGenerator.getInstance("DES");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
kg.init(56);
//要生成多少位只需要修改这里即可128, 192或256
SecretKey sk = kg.generateKey();
byte[] b = sk.getEncoded();
s1 = byteToHexString(b);
// System.out.println("随机生成的密钥长度:"+s1.length()*4);
// System.out.println("密钥:"+s1);
return s1;
}
/**
byte16
*/
public static String byteToHexString(byte[] bytes) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
String strHex=Integer.toHexString(bytes[i]);
if(strHex.length() > 3) {
sb.append(strHex.substring(6));
} else {
if(strHex.length() < 2) {
sb.append("0" + strHex);
} else {
sb.append(strHex);
}
}
}
return sb.toString();
}
}

@ -0,0 +1,129 @@
package com.childpassmanage.net.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Slf4j
public class HttpUtils {
private static final String ENCODING = "UTF-8";
public static String post(String url, Map<String, String> paramsMap) {
CloseableHttpClient client = HttpClients.createDefault();
String responseText = "";
CloseableHttpResponse response = null;
try {
HttpPost method = new HttpPost(url);
if (paramsMap != null) {
List<NameValuePair> paramList = new ArrayList<NameValuePair>();
for (Map.Entry<String, String> param : paramsMap.entrySet()) {
NameValuePair pair = new BasicNameValuePair(param.getKey(), param.getValue());
paramList.add(pair);
}
method.setEntity(new UrlEncodedFormEntity(paramList, ENCODING));
}
response = client.execute(method);
HttpEntity entity = response.getEntity();
if (entity != null) {
responseText = EntityUtils.toString(entity);
}
} catch (Exception e) {
log.error("http request failed",e);
} finally {
try {
response.close();
} catch (Exception e) {
log.error("",e);
}
}
return responseText;
}
public static String get(String url, Map<String, String> paramsMap) {
CloseableHttpClient client = HttpClients.createDefault();
String responseText = "";
CloseableHttpResponse response = null;
try {
String getUrl = url+"?";
if (paramsMap != null) {
for (Map.Entry<String, String> param : paramsMap.entrySet()) {
getUrl += param.getKey() + "=" + URLEncoder.encode(param.getValue(), ENCODING)+"&";
}
}
HttpGet method = new HttpGet(getUrl);
response = client.execute(method);
HttpEntity entity = response.getEntity();
if (entity != null) {
responseText = EntityUtils.toString(entity);
}
} catch (Exception e) {
log.error("http request failed",e);
} finally {
try {
response.close();
} catch (Exception e) {
log.error("",e);
}
}
return responseText;
}
//post请求参数为json格式
public static String HttpPostWithJson(String url, String json) {
String returnValue = "这是默认返回值,接口调用失败";
CloseableHttpClient httpClient = HttpClients.createDefault();
ResponseHandler<String> responseHandler = new BasicResponseHandler();
try{
//第一步创建HttpClient对象
httpClient = HttpClients.createDefault();
//第二步创建httpPost对象
HttpPost httpPost = new HttpPost(url);
//第三步给httpPost设置JSON格式的参数
StringEntity requestEntity = new StringEntity(json,"utf-8");
requestEntity.setContentEncoding("UTF-8");
httpPost.setHeader("Content-type", "application/json");
httpPost.setEntity(requestEntity);
//第四步发送HttpPost请求获取返回值
returnValue = httpClient.execute(httpPost,responseHandler); //调接口获取返回值时,必须用此方法
}
catch(Exception e)
{
e.printStackTrace();
}
finally {
try {
httpClient.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//第五步:处理返回值
return returnValue;
}
}

@ -0,0 +1,15 @@
package com.childpassmanage.net.utils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PCIKeyPair {
private String priKey; //私钥
private String pubKey; //公钥
}

@ -0,0 +1,49 @@
package com.childpassmanage.net.utils;
import java.util.HashMap;
import java.util.Map;
public class R extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
public R() {
put("code", 200);
}
public static R error() {
return error(500, "未知异常,请联系管理员");
}
public static R error(String msg) {
return error(500, msg);
}
public static R error(int code, String msg) {
R r = new R();
r.put("code", code);
r.put("msg", msg);
return r;
}
public static R ok(String msg) {
R r = new R();
r.put("msg", msg);
return r;
}
public static R ok(Map<String, Object> map) {
R r = new R();
r.putAll(map);
return r;
}
public static R ok() {
return new R();
}
public R put(String key, Object value) {
super.put(key, value);
return this;
}
}

@ -0,0 +1,156 @@
package com.childpassmanage.net.utils;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
/**
* -
*/
public class RandomUtil {
/**
* azlength
*
* @return
*/
public static String getRandomStr(int length) {
String base = "abcdefghijklmnopqrstuvwxyz";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
/**
* int
*
* @return
*/
public static int getRandomRange(int max, int min) {
return (int) (Math.random() * (max - min) + min);
}
/**
*
*
* @param length             base
* @return
*/
public static String getRandomString(int length, String base) { // length表示生成字符串的长度
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
/**
*
*
* @param length
* @return
*/
public static String getRandomString(int length) { // length表示生成字符串的长度
String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
/**
*
*
* @param length
* @return
*/
public static String getRandomNumString(int length) { // length表示生成字符串的长度
String base = "0123456789";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
/**
*
*
* @param start            
* @param end            
* @return
*/
public static int[] getRangRandom(int start, int end) {
return getRangRandom(start, end, end - start + 1);
}
/**
*
*
* @param start
* @param end
* @param num
* @return
*/
public static int[] getRangRandom(int start, int end, int num) {
int length = end - start + 1;
// 参数不合法
if (length < 1 || num > length) {
return null;
} else {
int[] numbers = new int[length];
int[] result = new int[num];
// 循环赋初始值
for (int i = 0; i < length; i++) {
numbers[i] = i + start;
}
Random random = new Random();
// 取randomMax次数
for (int i = 0; i < num; i++) {
// 随机获取取数的位置
int m = random.nextInt(length - i) + i;
result[i] = numbers[m];
// 交换位置
int temp = numbers[m];
numbers[m] = numbers[i];
numbers[i] = temp;
}
return result;
}
}
/*
* 6
*/
public static String code() {
Set<Integer> set = GetRandomNumber();
Iterator<Integer> iterator = set.iterator();
String temp = "";
while (iterator.hasNext()) {
temp += iterator.next();
}
return temp;
}
public static Set<Integer> GetRandomNumber() {
Set<Integer> set = new HashSet<Integer>();
Random random = new Random();
while (set.size() < 6) {
set.add(random.nextInt(10));
}
return set;
}
}

@ -0,0 +1,286 @@
package com.childpassmanage.net.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.codec.binary.Base64;
import org.bouncycastle.asn1.gm.GMNamedCurves;
import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
import org.bouncycastle.crypto.engines.SM2Engine;
import org.bouncycastle.crypto.generators.ECKeyPairGenerator;
import org.bouncycastle.crypto.params.*;
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey;
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
import org.bouncycastle.jce.spec.ECParameterSpec;
import org.bouncycastle.math.ec.ECPoint;
import org.bouncycastle.util.encoders.Hex;
import java.math.BigInteger;
import java.security.*;
import java.util.Map;
import static javax.crypto.Cipher.PRIVATE_KEY;
import static javax.crypto.Cipher.PUBLIC_KEY;
/**
* @Author: dzy
* @Date: 2018/9/28 15:53
* @Describe: SM2
*/
@Slf4j
public class SM2Util {
/**
* SM2
* @return
*/
private static AsymmetricCipherKeyPair genKeyPair0() {
//获取一条SM2曲线参数
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
//构造domain参数
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(),
sm2ECParameters.getG(), sm2ECParameters.getN());
//1.创建密钥生成器
ECKeyPairGenerator keyPairGenerator = new ECKeyPairGenerator();
//2.初始化生成器,带上随机数
try {
keyPairGenerator.init(new ECKeyGenerationParameters(domainParameters, SecureRandom.getInstance("SHA1PRNG")));
} catch (NoSuchAlgorithmException e) {
log.error("生成公私钥对时出现异常:", e);
// e.printStackTrace();
}
//3.生成密钥对
AsymmetricCipherKeyPair asymmetricCipherKeyPair = keyPairGenerator.generateKeyPair();
return asymmetricCipherKeyPair;
}
/**
* ()
* @return
*/
public static PCIKeyPair genKeyPair() {
return genKeyPair(true);
}
/**
*
* @param compressedPubKey
* @return
*/
public static PCIKeyPair genKeyPair(boolean compressedPubKey) {
AsymmetricCipherKeyPair asymmetricCipherKeyPair = genKeyPair0();
//提取公钥点
ECPoint ecPoint = ((ECPublicKeyParameters) asymmetricCipherKeyPair.getPublic()).getQ();
//公钥前面的02或者03表示是压缩公钥,04表示未压缩公钥,04的时候,可以去掉前面的04
String pubKey = Hex.toHexString(ecPoint.getEncoded(compressedPubKey));
BigInteger privatekey = ((ECPrivateKeyParameters) asymmetricCipherKeyPair.getPrivate()).getD();
String priKey = privatekey.toString(16);
PCIKeyPair keyPair = new PCIKeyPair(priKey, pubKey);
return keyPair;
}
/**
* RS
* @param rs
* @return
*/
private static byte[] modifyRSFixedBytes(byte[] rs) {
int length = rs.length;
int fixedLength = 32;
byte[] result = new byte[fixedLength];
if (length < 32) {
System.arraycopy(rs, 0, result, fixedLength - length, length);
} else {
System.arraycopy(rs, length - fixedLength, result, 0, fixedLength);
}
return result;
}
/**
* SM2
* @param publicKey
* @param data
* @return
*/
public static String encrypt(String publicKey, String data){
// 获取一条SM2曲线参数
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
// 构造domain参数
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(),
sm2ECParameters.getG(),
sm2ECParameters.getN());
//提取公钥点
ECPoint pukPoint = sm2ECParameters.getCurve().decodePoint(CommonUtils.hexString2byte(publicKey));
// 公钥前面的02或者03表示是压缩公钥04表示未压缩公钥, 04的时候可以去掉前面的04
ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters);
SM2Engine sm2Engine = new SM2Engine();
sm2Engine.init(true, new ParametersWithRandom(publicKeyParameters, new SecureRandom()));
byte[] arrayOfBytes = null;
try {
byte[] in = data.getBytes("utf-8");
arrayOfBytes = sm2Engine.processBlock(in, 0, in.length);
} catch (Exception e) {
log.error("SM2加密时出现异常:", e);
}
return Hex.toHexString(arrayOfBytes);
}
/**
* SM2
* @param publicKey
* @param data
* @return
*/
public static String encrypt(PublicKey publicKey, String data) {
ECPublicKeyParameters ecPublicKeyParameters = null;
if (publicKey instanceof BCECPublicKey) {
BCECPublicKey bcecPublicKey = (BCECPublicKey) publicKey;
ECParameterSpec ecParameterSpec = bcecPublicKey.getParameters();
ECDomainParameters ecDomainParameters = new ECDomainParameters(ecParameterSpec.getCurve(),
ecParameterSpec.getG(), ecParameterSpec.getN());
ecPublicKeyParameters = new ECPublicKeyParameters(bcecPublicKey.getQ(), ecDomainParameters);
}
SM2Engine sm2Engine = new SM2Engine();
sm2Engine.init(true, new ParametersWithRandom(ecPublicKeyParameters, new SecureRandom()));
byte[] arrayOfBytes = null;
try {
byte[] in = data.getBytes("utf-8");
arrayOfBytes = sm2Engine.processBlock(in,0, in.length);
} catch (Exception e) {
log.error("SM2加密时出现异常:", e);
}
return Hex.toHexString(arrayOfBytes);
}
/**
* SM2
* @param privateKey
* @param cipherData
* @return
*/
public static String decrypt(String privateKey, String cipherData) {
byte[] cipherDataByte = Hex.decode(cipherData);
//获取一条SM2曲线参数
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
//构造domain参数
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(),
sm2ECParameters.getG(), sm2ECParameters.getN());
BigInteger privateKeyD = new BigInteger(privateKey, 16);
ECPrivateKeyParameters privateKeyParameters = new ECPrivateKeyParameters(privateKeyD, domainParameters);
SM2Engine sm2Engine = new SM2Engine();
sm2Engine.init(false, privateKeyParameters);
String result = null;
try {
byte[] arrayOfBytes = sm2Engine.processBlock(cipherDataByte, 0, cipherDataByte.length);
return new String(arrayOfBytes, "utf-8");
} catch (Exception e) {
log.error("SM2解密时出现异常:", e);
}
return result;
}
/**
* SM2
* @param privateKey
* @param cipherData
* @return
*/
public static String decrypt(PrivateKey privateKey, String cipherData) {
byte[] cipherDataByte = Hex.decode(cipherData);
BCECPrivateKey bcecPrivateKey = (BCECPrivateKey) privateKey;
ECParameterSpec ecParameterSpec = bcecPrivateKey.getParameters();
ECDomainParameters ecDomainParameters = new ECDomainParameters(ecParameterSpec.getCurve(),
ecParameterSpec.getG(), ecParameterSpec.getN());
ECPrivateKeyParameters ecPrivateKeyParameters = new ECPrivateKeyParameters(bcecPrivateKey.getD(),
ecDomainParameters);
SM2Engine sm2Engine = new SM2Engine();
sm2Engine.init(false, ecPrivateKeyParameters);
String result = null;
try {
byte[] arrayOfBytes = sm2Engine.processBlock(cipherDataByte, 0, cipherDataByte.length);
return new String(arrayOfBytes, "utf-8");
} catch (Exception e) {
log.error("SM2解密时出现异常:", e);
}
return result;
}
/**
*
* @param pubKey (16,04)
* @return
*/
public static String compressPubKey(String pubKey) {
pubKey = "04"+ pubKey; //将未压缩公钥加上未压缩标识.
// 获取一条SM2曲线参数
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
// 构造domain参数
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(),
sm2ECParameters.getG(),
sm2ECParameters.getN());
//提取公钥点
ECPoint pukPoint = sm2ECParameters.getCurve().decodePoint(CommonUtils.hexString2byte(pubKey));
// 公钥前面的02或者03表示是压缩公钥04表示未压缩公钥, 04的时候可以去掉前面的04
// ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters);
String compressPubKey = Hex.toHexString(pukPoint.getEncoded(Boolean.TRUE));
return compressPubKey;
}
/**
*
* @param compressKey
* @return
*/
public static String unCompressPubKey(String compressKey) {
// 获取一条SM2曲线参数
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
// 构造domain参数
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(),
sm2ECParameters.getG(),
sm2ECParameters.getN());
//提取公钥点
ECPoint pukPoint = sm2ECParameters.getCurve().decodePoint(CommonUtils.hexString2byte(compressKey));
// 公钥前面的02或者03表示是压缩公钥04表示未压缩公钥, 04的时候可以去掉前面的04
// ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters);
String pubKey = Hex.toHexString(pukPoint.getEncoded(Boolean.FALSE));
pubKey = pubKey.substring(2); //去掉前面的04 (04的时候可以去掉前面的04)
return pubKey;
}
/**
*
*/
public static String getKeyStr(Key key) {
return Base64.encodeBase64String(key.getEncoded());
}
}

@ -0,0 +1,226 @@
package com.childpassmanage.net.utils;
import org.apache.commons.lang.math.RandomUtils;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Scanner;
public class Shamir {
public static Map<String, Long> split(int secret) {
//Scanner in = new Scanner(System.in);
long a[] = new long[100];// 放系数
long f[] = new long[100];// 放密钥的值
long dian[] = new long[100];// 放密钥的点
Map<String, Long> hashMap = new HashMap<>();
Random rand = new Random();
int bit_num = rand.nextInt(29) + 2;// 随机2到31位
BigInteger q = BigInteger.probablePrime(bit_num, rand);// 生成一个随机大素数,必须大于输入的随机整数
long p = q.longValue();
while (p < secret) {// 如果不大于输入的数
bit_num = rand.nextInt(29) + 2;
q = BigInteger.probablePrime(bit_num, rand);
p = q.longValue();
}
hashMap.put("p", p);
int k = 2;
int zi_key = 3;
for (int i = 0; i < k - 1; i++) {
a[i] = (long) (Math.random() * p);// 生成伪随机系数
if (a[i] == 0) {// 生成的随机系数不能为0
i--;
}
}
for (int i = 0; i < zi_key; i++) {
dian[i] = (long) (Math.random() * 100);// 生成100以内随机点,不能重复,如果大了,可能在以后的运算中超出数据类型范围,导致错误
if (dian[i] == 0) {// 生成的随机点不能为0
i--;
}
}
for (int i = 0; i < zi_key; i++) {// 计算zi_key个子密钥
f[i] = secret;
for (int j = 0; j < k - 1; j++) {// 一个子密钥
long zhishu = j + 1;
f[i] = Math.floorMod((long) (a[j] * Math.pow(dian[i], zhishu)) + f[i], p);
}
}
hashMap.put("dian[0]", dian[0]);
hashMap.put("dian[1]", dian[1]);
hashMap.put("dian[2]", dian[2]);
hashMap.put("f[0]", f[0]);
hashMap.put("f[1]", f[1]);
hashMap.put("f[2]", f[2]);
return hashMap;
}
public static long combine(Map<String, Long> hashMap) {
long m = (hashMap.get("p"));
int k = 2;
long key_d[] = new long[k];
long key_z[] = new long[k];
long num_x[] = new long[k];
long num_s[] = new long[k];
long s = 0;
int flag = RandomUtil.getRandomRange(3, 1);
if (flag == 1) {
key_d[0] = (hashMap.get("dian[0]"));
key_d[1] = (hashMap.get("dian[1]"));
key_z[0] = (hashMap.get("f[0]"));
key_z[1] = (hashMap.get("f[1]"));
} else if(flag == 2){
key_d[0] = (hashMap.get("dian[0]"));
key_d[1] = (hashMap.get("dian[2]"));
key_z[0] = (hashMap.get("f[0]"));
key_z[1] = (hashMap.get("f[2]"));
}else if(flag == 3){
key_d[0] = (hashMap.get("dian[1]"));
key_d[1] = (hashMap.get("dian[2]"));
key_z[0] = (hashMap.get("f[1]"));
key_z[1] = (hashMap.get("f[2]"));
}
for (int i = 0; i < k; i++) {
num_x[i] = 1;
num_s[i] = 1;
for (int j = 0; j < k; j++) {
if (j == i) {
j++;
}
if (j == k) {
break;
}
num_x[i] = num_x[i] * (key_d[i] - key_d[j]);
num_s[i] = (-key_d[j]) * num_s[i];
}
num_x[i] = qiu_ni(num_x[i], m);
s = num_x[i] * num_s[i] * key_z[i] + s;
}
s = Math.floorMod(s, m);
return s;
}
// 求逆函数
static long qiu_ni(long a, long b) {// 最后s[1]为s即逆元,t[1]为t
long s[] = { 1, 0, 0 };
long t[] = { 0, 1, 0 };
long r1 = a;
long r2 = b;
long tmp;
int i = (int) (r1 / r2);
tmp = r2;
r2 = Math.floorMod(r1, r2);
r1 = tmp;
while (r2 != 0) {
s[2] = s[0] - i * s[1];
t[2] = t[0] - i * t[1];
s[0] = s[1];
s[1] = s[2];
t[0] = t[1];
t[1] = t[2];
if (r2 != 0)
i = (int) (r1 / r2);
tmp = r2;
r2 = Math.floorMod(r1, r2);
r1 = tmp;
}
return s[1];
}
/*
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (true) {
System.out.println("分解秘密请选择1还原秘密选择2, 退出选择3");
int flag = in.nextInt();
if (flag == 1) {
long a[] = new long[100];// 放系数
long f[] = new long[100];// 放密钥的值
long dian[] = new long[100];// 放密钥的点
System.out.println("输入你的秘密");
int secret = in.nextInt();// 输入为一个数小于2,147,483,647
Random rand = new Random();
int bit_num = rand.nextInt(29) + 2;// 随机2到31位
BigInteger q = BigInteger.probablePrime(bit_num, rand);// 生成一个随机大素数,必须大于输入的随机整数
long p = q.longValue();
while (p < secret) {// 如果不大于输入的数
bit_num = rand.nextInt(29) + 2;
q = BigInteger.probablePrime(bit_num, rand);
p = q.longValue();
}
System.out.println("模为 " + p);
//System.out.println("输入门限值");// 门限值小于等于100
int k = 2;
//System.out.println("输入得到几个子密钥");// 子密钥值小于等于100
int zi_key = 3;
for (int i = 0; i < k - 1; i++) {
a[i] = (long) (Math.random() * p);// 生成伪随机系数
if (a[i] == 0) {// 生成的随机系数不能为0
i--;
}
}
for (int i = 0; i < zi_key; i++) {
dian[i] = (long) (Math.random() * 100);// 生成100以内随机点,不能重复,如果大了,可能在以后的运算中超出数据类型范围,导致错误
if (dian[i] == 0) {// 生成的随机点不能为0
i--;
}
}
System.out.println("子密钥为(确保子密钥没有重复,如果有请重新生成) ");
for (int i = 0; i < zi_key; i++) {// 计算zi_key个子密钥
f[i] = secret;
for (int j = 0; j < k - 1; j++) {// 一个子密钥
long zhishu = j + 1;
f[i] = Math.floorMod((long) (a[j] * Math.pow(dian[i], zhishu)) + f[i], p);
}
System.out.print(dian[i] + " ");
System.out.println(f[i]);
}
} else if (flag == 2) {
System.out.println("输入模值");
int m = in.nextInt();
System.out.println("输入门限");
int k = in.nextInt();
long key_d[] = new long[k];
long key_z[] = new long[k];
long num_x[] = new long[k];
long num_s[] = new long[k];
long s = 0;
System.out.println("请输入密钥(先输入所有的点,再输入各点对应的值) ");
for (int i = 0; i < k; i++) {
key_d[i] = in.nextLong();
}
for (int i = 0; i < k; i++) {
key_z[i] = in.nextLong();
}
for (int i = 0; i < k; i++) {
num_x[i] = 1;
num_s[i] = 1;
for (int j = 0; j < k; j++) {
if (j == i) {
j++;
}
if (j == k) {
break;
}
num_x[i] = num_x[i] * (key_d[i] - key_d[j]);
num_s[i] = (-key_d[j]) * num_s[i];
}
num_x[i] = qiu_ni(num_x[i], m);
s = num_x[i] * num_s[i] * key_z[i] + s;
}
s = Math.floorMod(s, m);
System.out.println("秘密为 " + s);
} else {
break;
}
}
}
*/
}

@ -0,0 +1,177 @@
package com.childpassmanage.net.utils;
import org.apache.commons.codec.binary.Hex;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.spec.SecretKeySpec;
import java.security.Key;
import java.security.SecureRandom;
import java.security.Security;
import java.util.Arrays;
public class Sm4Util {
static {
Security.addProvider(new BouncyCastleProvider());
}
private static final String ENCODING = "UTF-8";
public static final String ALGORITHM_NAME = "SM4";
// 加密算法/分组加密模式/分组填充方式
// PKCS5Padding-以8个字节为一组进行分组加密
// 定义分组加密模式使用PKCS5Padding
public static final String ALGORITHM_NAME_ECB_PADDING = "SM4/ECB/PKCS5Padding";
// 128-32位16进制256-64位16进制
public static final int DEFAULT_KEY_SIZE = 128;
/**
*
*
* @return
* @explain
*/
public static String generateKey() throws Exception {
return new String(Hex.encodeHex(generateKey(DEFAULT_KEY_SIZE),false));
}
/**
* @param keySize
* @return
* @throws Exception
* @explain
*/
public static byte[] generateKey(int keySize) throws Exception {
KeyGenerator kg = KeyGenerator.getInstance(ALGORITHM_NAME, BouncyCastleProvider.PROVIDER_NAME);
kg.init(keySize, new SecureRandom());
return kg.generateKey().getEncoded();
}
/**
* ECB
*
* @param algorithmName
* @param mode
* @param key
* @return
* @throws Exception
* @explain ECBElectronic codebook
*/
private static Cipher generateEcbCipher(String algorithmName, int mode, byte[] key) throws Exception {
Cipher cipher = Cipher.getInstance(algorithmName, BouncyCastleProvider.PROVIDER_NAME);
Key sm4Key = new SecretKeySpec(key, ALGORITHM_NAME);
cipher.init(mode, sm4Key);
return cipher;
}
/**
* sm4
*
* @param hexKey 16
* @param paramStr
* @return 16
* @explain ECB
*
*/
public static String encryptEcb(String hexKey, String paramStr) {
try {
String cipherText = "";
// 16进制字符串--&gt;byte[]
byte[] keyData = ByteUtils.fromHexString(hexKey);
// String--&gt;byte[]
byte[] srcData = paramStr.getBytes(ENCODING);
// 加密后的数组
byte[] cipherArray = encrypt_Ecb_Padding(keyData, srcData);
// byte[]--&gt;hexString
cipherText = ByteUtils.toHexString(cipherArray);
return cipherText;
} catch (Exception e) {
return paramStr;
}
}
/**
* Ecb
*
* @param key
* @param data
* @return
* @throws Exception
* @explain
*/
public static byte[] encrypt_Ecb_Padding(byte[] key, byte[] data) throws Exception {
Cipher cipher = generateEcbCipher(ALGORITHM_NAME_ECB_PADDING, Cipher.ENCRYPT_MODE, key);
return cipher.doFinal(data);
}
/**
* sm4
*
* @param hexKey 16
* @param cipherText 16
* @return
* @throws Exception
* @explain ECB
*/
public static String decryptEcb(String hexKey, String cipherText) {
// 用于接收解密后的字符串
String decryptStr = "";
// hexString--&gt;byte[]
byte[] keyData = ByteUtils.fromHexString(hexKey);
// hexString--&gt;byte[]
byte[] cipherData = ByteUtils.fromHexString(cipherText);
// 解密
byte[] srcData = new byte[0];
try {
srcData = decrypt_Ecb_Padding(keyData, cipherData);
// byte[]--&gt;String
decryptStr = new String(srcData, ENCODING);
} catch (Exception e) {
e.printStackTrace();
}
return decryptStr;
}
/**
*
*
* @param key
* @param cipherText
* @return
* @throws Exception
* @explain
*/
public static byte[] decrypt_Ecb_Padding(byte[] key, byte[] cipherText) throws Exception {
Cipher cipher = generateEcbCipher(ALGORITHM_NAME_ECB_PADDING, Cipher.DECRYPT_MODE, key);
return cipher.doFinal(cipherText);
}
/**
*
*
* @param hexKey 16
* @param cipherText 16
* @param paramStr
* @return
* @throws Exception
* @explain
*/
public static boolean verifyEcb(String hexKey, String cipherText, String paramStr) throws Exception {
// 用于接收校验结果
boolean flag = false;
// hexString--&gt;byte[]
byte[] keyData = ByteUtils.fromHexString(hexKey);
// 将16进制字符串转换成数组
byte[] cipherData = ByteUtils.fromHexString(cipherText);
// 解密
byte[] decryptData = decrypt_Ecb_Padding(keyData, cipherData);
// 将原字符串转换成byte[]
byte[] srcData = paramStr.getBytes(ENCODING);
// 判断2个数组是否一致
flag = Arrays.equals(decryptData, srcData);
return flag;
}
}

@ -0,0 +1,96 @@
package com.childpassmanage.net.utils;/*
*/
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
public class ThroughUserkey {
/**
* @return
*/
public static String getAESKey() {
String s1;
KeyGenerator kg = null;
try {
kg = KeyGenerator.getInstance("AES");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
kg.init(128);
//要生成多少位只需要修改这里即可128, 192或256
SecretKey sk = kg.generateKey();
byte[] b = sk.getEncoded();
s1 = byteToHexString(b);
// System.out.println("随机生成的密钥长度:"+s1.length()*4);
// System.out.println("密钥:"+s1);
return s1;
}
public static String getDESKey() {
String s1;
KeyGenerator kg = null;
try {
kg = KeyGenerator.getInstance("DES");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
kg.init(56);
//要生成多少位只需要修改这里即可128, 192或256
SecretKey sk = kg.generateKey();
byte[] b = sk.getEncoded();
s1 = byteToHexString(b);
// System.out.println("随机生成的密钥长度:"+s1.length()*4);
// System.out.println("密钥:"+s1);
return s1;
}
/**
使
* @return
*/
public static String getKeyByPass(String password) {
//生成秘钥
KeyGenerator kg = null;
try {
kg = KeyGenerator.getInstance("AES");
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
//SecureRandom是生成安全随机数序列password.getBytes()是种子,只要种子相同,序列就一样,所以生成的秘钥就一样。
//System.out.println("输入指定字符串生成的密钥的长度:");
//int i=input.nextInt();
kg.init(128, new SecureRandom(password.getBytes()));
SecretKey sk = kg.generateKey();
byte[] b = sk.getEncoded();
String s2 = byteToHexString(b);
// System.out.println("指定字符串生成的密钥长度:"+s2.length()*4);
// System.out.println("密钥:"+s2);
return s2;
}
/**
byte16
*/
public static String byteToHexString(byte[] bytes) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
String strHex=Integer.toHexString(bytes[i]);
if(strHex.length() > 3) {
sb.append(strHex.substring(6));
} else {
if(strHex.length() < 2) {
sb.append("0" + strHex);
} else {
sb.append(strHex);
}
}
}
return sb.toString();
}
}

@ -0,0 +1,104 @@
##本地环境设置 配置注意事项 : 后面紧跟一个空格 然后再配置您的实际值
server:
#tomcat端口 比如http://{ip}:{port}{/context-path}中的{port} 纯数字
port: 18087
Spring:
datasource:
#mysql url连接信息
url: jdbc:mysql://localhost:3306/us?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&userSSL=true&serverTimezone=Hongkong&zeroDateTimeBehavior=CONVERT_TO_NULL
#数据库用户名
username: root
#数据库密码
password: 123456
#mysql8新驱动名称
driverClassName: com.mysql.cj.jdbc.Driver
spring:
thymeleaf:
cache: false
redis:
#所有的redis 缓存都会加入下面的前缀 方便管理
keyPrefix:
# redis地址 单机模式 参见RedisConfig
host: localhost
#redis端口 单机模式
port: 6379
#不允许redis密码为空字符串 可以不设置 您也可以使用"1234"
password: 123456
#集群模式 默认不开启 因为集群模式redis配置复杂演示版只有一个redis
# cluster:
#redis支持集群模式(需要参考文档自行打开) 也支持单机(配置一个即可) 配置规则节点的ip:port,ip:port 逗号分隔多个
# nodes: localhost:6379
# 最大连接时间 具体参考JedisCluster官方文档
# connectionTimeout: 5000
# soTimeout: 5000
# maxAttempts: 3
#druid管理后台 http://localhost:18080/us-admin/druid/ 可以查看数据源的状态 账号/密码admin/123456
monitor:
druid:
userName: admin
password: 123456
allowIps: 127.0.0.1
denyIps: 10.1.1.1
filters: stat,log4j
devtools:
restart:
#是否开启热部署 另外需要配置ide的配置一同生效 参考这篇文章 https://blog.csdn.net/boywcx/article/details/81164411
enabled: false
servlet:
multipart:
#单个文件大小 1G
max-file-size: 1024000000
#总上传的数据大小 1G
max-request-size: 1024000000
#是否开启
enabled: true
magicalcoder:
file:
#文件上传配置useDisk useAliyunOss 如果open都为true 则都使用 returnUrl 默认优先级 useAliyunOss useDisk
upload:
#上传至本地硬盘
useDisk:
#是否开启
open: true
#控制是否采用此模式返回给前端的图片地址
returnUrl: true
#由于spring boot是jar方式执行无法自动映射上传文件访问地址采取单独映射方法
mapping:
#文件要上传到的硬盘路径 例如 windows: /E:/tmp/test/ linux: /home/web/file/upload/ 如果不设置 则会自动查找classpath路径下的upload
uploadDiskFolder:
#虚拟访问映射地址 请尽量不要改动 AdminCommonFileRestController里面有根据这个返回给前端 你可以设置images/magic 前后不要有/ 不能为空
requestPrefix: upload
#实际额外在前面添加其他内容 主要用于跟你自己的项目路径映射 会在实际路径中加入此前缀 不要以http开头 /upload/
fileExtraAddPrefix: upload/
#使用阿里云oss 开通方式参考 doc\upload\阿里云oss文件上传.docx 本配置请改成您自己的阿里云实际参数 因为存储桶要钱购买 所以这里不可能免费使用
useAliyunOss:
#是否开启
open: false
#控制是否采用此模式返回给前端的图片地址
returnUrl: true
#Region请按实际情况填写
endpoint: http://oss-cn-beijing.aliyuncs.com
#oos存储账号
accessKeyId: LTAIGeWoz1iMmX2X
#oos存储密码
accessKeySecret: OywMJpmN5cSqreqgLNYZVrBqtxmE8H
#oos存储桶名称
bucketName: us
#桶的地址前缀 你如果不明白怎么配置 去阿里云oss后台 找个地址看一下 组合是 urlPrefix+上传时候的文件名称
aliyunImgDomain: https://us.oss-cn-beijing.aliyuncs.com/
#超级管理员账号名称 密码默认magicalcoder
superUserName: magicalcoder
cors:
# 跨域 支持哪些同源域名 逗号分隔多个 你可以配置 http://localhost:18088,http://www.magicalcoder.com 跨域demo参考README.md
allowOrigin:
#是否是发布模式 true则加载精简的us-all.min.js us-all.min.css如果您更改了系统js css 注意自行合并 参考YouyabootAllJsCompressTest YouyabootAllCssCompressTest 这样页面加载速度会更快 否则加载其他的crud下面的js 和各个 css
publish: false
settings:
#当启动成功 自动帮助启动浏览器 linux服务端部署方式启动 请设置false
autoStartExplorer: true
#设置默认浏览器的浏览器路径 此处设置chrome为例 您如果未安装chrome 或者不设置此处 则使用默认浏览器
explorerPath: C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe

@ -0,0 +1,35 @@
#全局配置
# tomcat配置
server:
#当前环境上下文 比如http://{ip}:{port}{/context-path}中的{/context-path} 以/开头配置
# context-path: /us-admin
servlet:
context-path: /
#log
logging:
config:
#日志配置读取当前环境下的logback.xml
classpath: logback.xml
spring:
# thymeleaf:
# prefix: classpath:/templates
profiles:
# publish localhost就可以切换不同环境application-xxx的配置
active: localhost
messages:
encoding: UTF-8
http:
encoding:
charset: UTF-8
enabled: true
force: true
application:
#service-name
name: passuser
jackson:
time-zone: GMT+8
mvc:
#这样浏览器小图标就可以加载你自己的favicon.ico了
favicon:
enabled: false

@ -0,0 +1,32 @@
version: v0.0.1
发布日期2018-8-19
/**
*        ┏┓  ┏┓+ +
*       ┏┛┻━━━┛┻┓ + +
*       ┃      ┃  
*       ┃   ━   ┃ ++ + + +
*       ████━████ ┃+
*       ┃       ┃ +
*       ┃   ┻   ┃
*       ┃      ┃ + +
*       ┗━┓   ┏━┛
*         ┃   ┃           
*         ┃   ┃ + + + +
*         ┃   ┃         
*         ┃   ┃ +     
*         ┃   ┃
*         ┃   ┃  +         
*         ┃    ┗━━━┓ + +
*             ┣┓
*              ┏┛
*         ┗┓┓┏━┳┓┏┛ + + + +
*         ┃┫┫ ┃┫┫
*         ┗┻┛ ┗┻┛+ + + +
*
* 神兽保佑 永无BUG
*/
#登录后台
http://localhost:18080/us-admin/ 测试账号 admin/admin
如果启动失败 1 请配置application-publish.yml的数据库和redis 相关信息
druid数据库连接池信息查看http://localhost:18088/us-web/druid admin/123456

@ -0,0 +1,30 @@
<!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->
<configuration scan="true" scanPeriod="3 seconds">
<include resource="org/springframework/boot/logging/logback/base.xml" />
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>~/data/us-servicelog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>~/data/us-%d{yyyyMMdd}.log.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>500MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>100</maxHistory>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n
</Pattern>
</layout>
</appender>
<!--additivity 是否向上传递 true就会打印多次 false只打印1次 INFO改成DEBUG可打印sql日志-->
<logger name="com.passManage" level="DEBUG" additivity="false">
<!--也可以选择其他的ref 来增加新的日志文件-->
<appender-ref ref="INFO_FILE" />
<!--控制台是否打印-->
<appender-ref ref="CONSOLE" />
</logger>
<root level="INFO">
<appender-ref ref="INFO_FILE" />
</root>
</configuration>

@ -0,0 +1,13 @@
package com.childpassmanage.net;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ChildpassmanageApplicationTests {
@Test
void contextLoads() {
}
}

@ -0,0 +1 @@
{"passId":123555,"passType":"SM2","passChildfir":"044783f57ab77198c74a4a8ec2db7c8e64db2164f28feb1910bf2aa0dcd6c344ef23408f526412911e692a880e35deb04768c78b31bf1e9942964ec2f157c71490ec2dd950ed11e8c2e3e6df0b413443d36eef8a522bca930bb055682582b4a6e5a95337890d1107cab6cd10112368a1d0a5c595ce55b68ceb717ce0c195da9de8048a5632cc380f7848a5432c5e1bffb43ddd12dfbd55784c74e74714b50b2dd82520","passChildsec":"046a273ba00d097067d157a282da4c3f849f30248fc7a45737bc7e10c9f22cf60a4ee159c8173a0d3834d08ac4fa3dd1bb20eea3bf87414786bae02f35888c5b4939aab20f259d332e882251a422212a5ee0df2db118e73f2bec07dd236fd3a0a2313e58729da893475567e13ddc5a5c64fa577e3e3caf8fc3d30ec01e6594f628bbdc6a2520cb8f6b10609b990c44c7fd6f3f7de2a4258d455b9fecc758f374a2af04","username":"yg9531"}

@ -0,0 +1,31 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/

@ -0,0 +1,118 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed 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
*
* https://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.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}

Binary file not shown.

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

310
passuser/mvnw vendored

@ -0,0 +1,310 @@
#!/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
#
# https://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.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven 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 Mingw, 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)`"
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
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
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
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
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 "$@"

182
passuser/mvnw.cmd vendored

@ -0,0 +1,182 @@
@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 https://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 Maven 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 keystroke 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 set title of command window
title %0
@REM enable echoing by 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
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%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,201 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.passuser</groupId>
<artifactId>passuser</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>passuser</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.1.3.RELEASE</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.10</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.68</version>
</dependency>
<!-- 生成token -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.31</version>
</dependency>
<dependency>
<groupId>nl.bitwalker</groupId>
<artifactId>UserAgentUtils</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.6</version>
</dependency>
<!-- 添加servlet依赖模块 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- 添加jstl标签库依赖模块 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!--添加tomcat依赖模块.-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- 使用jsp引擎springboot内置tomcat没有此依赖 -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!-- <scope>provided</scope>-->
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.12</version>
</dependency>
<!--jdbc-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>com.dyuproject.protostuff</groupId>
<artifactId>protostuff-core</artifactId>
<version>1.0.12</version>
</dependency>
<dependency>
<groupId>com.dyuproject.protostuff</groupId>
<artifactId>protostuff-runtime</artifactId>
<version>1.0.12</version>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>com.ibeetl</groupId>
<artifactId>beetl</artifactId>
<version>2.9.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
<finalName>net-web</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>

@ -0,0 +1,20 @@
package com.passuser.net.KeyUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PCIKeyPair {
private String priKey; //私钥
private String pubKey; //公钥
private String username; //用户名
public PCIKeyPair(String priKey, String pubKey) {
this.priKey = priKey;
this.pubKey = pubKey;
}
}

@ -0,0 +1,283 @@
package com.passuser.net.KeyUtils;
import com.passuser.net.utils.CommonUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.codec.binary.Base64;
import org.bouncycastle.asn1.gm.GMNamedCurves;
import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
import org.bouncycastle.crypto.engines.SM2Engine;
import org.bouncycastle.crypto.generators.ECKeyPairGenerator;
import org.bouncycastle.crypto.params.*;
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey;
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
import org.bouncycastle.jce.spec.ECParameterSpec;
import org.bouncycastle.math.ec.ECPoint;
import org.bouncycastle.util.encoders.Hex;
import java.math.BigInteger;
import java.security.*;
/**
* @Author: dzy
* @Date: 2018/9/28 15:53
* @Describe: SM2
*/
@Slf4j
public class SM2Util {
/**
* SM2
* @return
*/
private static AsymmetricCipherKeyPair genKeyPair0() {
//获取一条SM2曲线参数
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
//构造domain参数
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(),
sm2ECParameters.getG(), sm2ECParameters.getN());
//1.创建密钥生成器
ECKeyPairGenerator keyPairGenerator = new ECKeyPairGenerator();
//2.初始化生成器,带上随机数
try {
keyPairGenerator.init(new ECKeyGenerationParameters(domainParameters, SecureRandom.getInstance("SHA1PRNG")));
} catch (NoSuchAlgorithmException e) {
log.error("生成公私钥对时出现异常:", e);
// e.printStackTrace();
}
//3.生成密钥对
AsymmetricCipherKeyPair asymmetricCipherKeyPair = keyPairGenerator.generateKeyPair();
return asymmetricCipherKeyPair;
}
/**
* ()
* @return
*/
public static PCIKeyPair genKeyPair() {
return genKeyPair(true);
}
/**
*
* @param compressedPubKey
* @return
*/
public static PCIKeyPair genKeyPair(boolean compressedPubKey) {
AsymmetricCipherKeyPair asymmetricCipherKeyPair = genKeyPair0();
//提取公钥点
ECPoint ecPoint = ((ECPublicKeyParameters) asymmetricCipherKeyPair.getPublic()).getQ();
//公钥前面的02或者03表示是压缩公钥,04表示未压缩公钥,04的时候,可以去掉前面的04
String pubKey = Hex.toHexString(ecPoint.getEncoded(compressedPubKey));
BigInteger privatekey = ((ECPrivateKeyParameters) asymmetricCipherKeyPair.getPrivate()).getD();
String priKey = privatekey.toString(16);
PCIKeyPair keyPair = new PCIKeyPair(priKey, pubKey);
return keyPair;
}
/**
* RS
* @param rs
* @return
*/
private static byte[] modifyRSFixedBytes(byte[] rs) {
int length = rs.length;
int fixedLength = 32;
byte[] result = new byte[fixedLength];
if (length < 32) {
System.arraycopy(rs, 0, result, fixedLength - length, length);
} else {
System.arraycopy(rs, length - fixedLength, result, 0, fixedLength);
}
return result;
}
/**
* SM2
* @param publicKey
* @param data
* @return
*/
public static String encrypt(String publicKey, String data){
// 获取一条SM2曲线参数
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
// 构造domain参数
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(),
sm2ECParameters.getG(),
sm2ECParameters.getN());
//提取公钥点
ECPoint pukPoint = sm2ECParameters.getCurve().decodePoint(CommonUtils.hexString2byte(publicKey));
// 公钥前面的02或者03表示是压缩公钥04表示未压缩公钥, 04的时候可以去掉前面的04
ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters);
SM2Engine sm2Engine = new SM2Engine();
sm2Engine.init(true, new ParametersWithRandom(publicKeyParameters, new SecureRandom()));
byte[] arrayOfBytes = null;
try {
byte[] in = data.getBytes("utf-8");
arrayOfBytes = sm2Engine.processBlock(in, 0, in.length);
} catch (Exception e) {
log.error("SM2加密时出现异常:", e);
}
return Hex.toHexString(arrayOfBytes);
}
/**
* SM2
* @param publicKey
* @param data
* @return
*/
public static String encrypt(PublicKey publicKey, String data) {
ECPublicKeyParameters ecPublicKeyParameters = null;
if (publicKey instanceof BCECPublicKey) {
BCECPublicKey bcecPublicKey = (BCECPublicKey) publicKey;
ECParameterSpec ecParameterSpec = bcecPublicKey.getParameters();
ECDomainParameters ecDomainParameters = new ECDomainParameters(ecParameterSpec.getCurve(),
ecParameterSpec.getG(), ecParameterSpec.getN());
ecPublicKeyParameters = new ECPublicKeyParameters(bcecPublicKey.getQ(), ecDomainParameters);
}
SM2Engine sm2Engine = new SM2Engine();
sm2Engine.init(true, new ParametersWithRandom(ecPublicKeyParameters, new SecureRandom()));
byte[] arrayOfBytes = null;
try {
byte[] in = data.getBytes("utf-8");
arrayOfBytes = sm2Engine.processBlock(in,0, in.length);
} catch (Exception e) {
log.error("SM2加密时出现异常:", e);
}
return Hex.toHexString(arrayOfBytes);
}
/**
* SM2
* @param privateKey
* @param cipherData
* @return
*/
public static String decrypt(String privateKey, String cipherData) {
byte[] cipherDataByte = Hex.decode(cipherData);
//获取一条SM2曲线参数
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
//构造domain参数
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(),
sm2ECParameters.getG(), sm2ECParameters.getN());
BigInteger privateKeyD = new BigInteger(privateKey, 16);
ECPrivateKeyParameters privateKeyParameters = new ECPrivateKeyParameters(privateKeyD, domainParameters);
SM2Engine sm2Engine = new SM2Engine();
sm2Engine.init(false, privateKeyParameters);
String result = null;
try {
byte[] arrayOfBytes = sm2Engine.processBlock(cipherDataByte, 0, cipherDataByte.length);
return new String(arrayOfBytes, "utf-8");
} catch (Exception e) {
log.error("SM2解密时出现异常:", e);
}
return result;
}
/**
* SM2
* @param privateKey
* @param cipherData
* @return
*/
public static String decrypt(PrivateKey privateKey, String cipherData) {
byte[] cipherDataByte = Hex.decode(cipherData);
BCECPrivateKey bcecPrivateKey = (BCECPrivateKey) privateKey;
ECParameterSpec ecParameterSpec = bcecPrivateKey.getParameters();
ECDomainParameters ecDomainParameters = new ECDomainParameters(ecParameterSpec.getCurve(),
ecParameterSpec.getG(), ecParameterSpec.getN());
ECPrivateKeyParameters ecPrivateKeyParameters = new ECPrivateKeyParameters(bcecPrivateKey.getD(),
ecDomainParameters);
SM2Engine sm2Engine = new SM2Engine();
sm2Engine.init(false, ecPrivateKeyParameters);
String result = null;
try {
byte[] arrayOfBytes = sm2Engine.processBlock(cipherDataByte, 0, cipherDataByte.length);
return new String(arrayOfBytes, "utf-8");
} catch (Exception e) {
log.error("SM2解密时出现异常:", e);
}
return result;
}
/**
*
* @param pubKey (16,04)
* @return
*/
public static String compressPubKey(String pubKey) {
pubKey = "04"+ pubKey; //将未压缩公钥加上未压缩标识.
// 获取一条SM2曲线参数
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
// 构造domain参数
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(),
sm2ECParameters.getG(),
sm2ECParameters.getN());
//提取公钥点
ECPoint pukPoint = sm2ECParameters.getCurve().decodePoint(CommonUtils.hexString2byte(pubKey));
// 公钥前面的02或者03表示是压缩公钥04表示未压缩公钥, 04的时候可以去掉前面的04
// ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters);
String compressPubKey = Hex.toHexString(pukPoint.getEncoded(Boolean.TRUE));
return compressPubKey;
}
/**
*
* @param compressKey
* @return
*/
public static String unCompressPubKey(String compressKey) {
// 获取一条SM2曲线参数
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
// 构造domain参数
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(),
sm2ECParameters.getG(),
sm2ECParameters.getN());
//提取公钥点
ECPoint pukPoint = sm2ECParameters.getCurve().decodePoint(CommonUtils.hexString2byte(compressKey));
// 公钥前面的02或者03表示是压缩公钥04表示未压缩公钥, 04的时候可以去掉前面的04
// ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters);
String pubKey = Hex.toHexString(pukPoint.getEncoded(Boolean.FALSE));
pubKey = pubKey.substring(2); //去掉前面的04 (04的时候可以去掉前面的04)
return pubKey;
}
/**
*
*/
public static String getKeyStr(Key key) {
return Base64.encodeBase64String(key.getEncoded());
}
}

@ -0,0 +1,75 @@
package com.passuser.net.KeyUtils;
import java.io.UnsupportedEncodingException;
import java.security.SecureRandom;
import org.apache.commons.codec.binary.Hex;
import org.bouncycastle.crypto.digests.SM3Digest;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.KeyGenerator;
/**
* @author CHENR
* @Title: Sm3Utils
* @ProjectName upds
* @Description: TODO
* @date 2019/9/611:13
*/
public class Sm3Utils {
private final static byte[] hex = "0123456789ABCDEF".getBytes();
// 128-32位16进制256-64位16进制
public static final int DEFAULT_KEY_SIZE = 128;
public static final String ALGORITHM_NAME = "SM3";
/**
* @desc SM3
* @param data
* @return
*/
public static byte[] digest(byte[] data) {
SM3Digest sm3 = new SM3Digest();
byte[] result = null;
try {
sm3.update(data, 0, data.length);
result = new byte[sm3.getDigestSize()];
sm3.doFinal(result, 0);
} catch (Exception e) {
System.out.println("Fail: SM3 byte[] to byte[]" + e);
}
return result;
}
/**
* @desc 16
* @param b
* @return
*/
public static String bytes2HexString(byte[] b) {
byte[] buff = new byte[2 * b.length];
for (int i = 0; i < b.length; i++) {
buff[2 * i] = hex[(b[i] >> 4) & 0x0f];
buff[2 * i + 1] = hex[b[i] & 0x0f];
}
return new String(buff);
}
/**
* @desc 使SM316
* @param msg
* @return 16
*/
public static String encryptBySm3(String msg) {
try {
String encryptedCardNo = bytes2HexString(digest(msg.getBytes("UTF-8")));
return encryptedCardNo;
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "";
}
}
}

@ -0,0 +1,176 @@
package com.passuser.net.KeyUtils;
import org.apache.commons.codec.binary.Hex;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.spec.SecretKeySpec;
import java.security.Key;
import java.security.SecureRandom;
import java.security.Security;
import java.util.Arrays;
public class Sm4Util {
static {
Security.addProvider(new BouncyCastleProvider());
}
private static final String ENCODING = "UTF-8";
public static final String ALGORITHM_NAME = "SM4";
// 加密算法/分组加密模式/分组填充方式
// PKCS5Padding-以8个字节为一组进行分组加密
// 定义分组加密模式使用PKCS5Padding
public static final String ALGORITHM_NAME_ECB_PADDING = "SM4/ECB/PKCS5Padding";
// 128-32位16进制256-64位16进制
public static final int DEFAULT_KEY_SIZE = 128;
/**
*
*
* @return
* @explain
*/
public static String generateKey() throws Exception {
return new String(Hex.encodeHex(generateKey(DEFAULT_KEY_SIZE),false));
}
/**
* @param keySize
* @return
* @throws Exception
* @explain
*/
public static byte[] generateKey(int keySize) throws Exception {
KeyGenerator kg = KeyGenerator.getInstance(ALGORITHM_NAME, BouncyCastleProvider.PROVIDER_NAME);
kg.init(keySize, new SecureRandom());
return kg.generateKey().getEncoded();
}
/**
* ECB
*
* @param algorithmName
* @param mode
* @param key
* @return
* @throws Exception
* @explain ECBElectronic codebook
*/
private static Cipher generateEcbCipher(String algorithmName, int mode, byte[] key) throws Exception {
Cipher cipher = Cipher.getInstance(algorithmName, BouncyCastleProvider.PROVIDER_NAME);
Key sm4Key = new SecretKeySpec(key, ALGORITHM_NAME);
cipher.init(mode, sm4Key);
return cipher;
}
/**
* sm4
*
* @param hexKey 16
* @param paramStr
* @return 16
* @explain ECB
*
*/
public static String encryptEcb(String hexKey, String paramStr) {
try {
String cipherText = "";
// 16进制字符串--&gt;byte[]
byte[] keyData = ByteUtils.fromHexString(hexKey);
// String--&gt;byte[]
byte[] srcData = paramStr.getBytes(ENCODING);
// 加密后的数组
byte[] cipherArray = encrypt_Ecb_Padding(keyData, srcData);
// byte[]--&gt;hexString
cipherText = ByteUtils.toHexString(cipherArray);
return cipherText;
} catch (Exception e) {
return paramStr;
}
}
/**
* Ecb
*
* @param key
* @param data
* @return
* @throws Exception
* @explain
*/
public static byte[] encrypt_Ecb_Padding(byte[] key, byte[] data) throws Exception {
Cipher cipher = generateEcbCipher(ALGORITHM_NAME_ECB_PADDING, Cipher.ENCRYPT_MODE, key);
return cipher.doFinal(data);
}
/**
* sm4
*
* @param hexKey 16
* @param cipherText 16
* @return
* @throws Exception
* @explain ECB
*/
public static String decryptEcb(String hexKey, String cipherText) {
// 用于接收解密后的字符串
String decryptStr = "";
// hexString--&gt;byte[]
byte[] keyData = ByteUtils.fromHexString(hexKey);
// hexString--&gt;byte[]
byte[] cipherData = ByteUtils.fromHexString(cipherText);
// 解密
byte[] srcData = new byte[0];
try {
srcData = decrypt_Ecb_Padding(keyData, cipherData);
// byte[]--&gt;String
decryptStr = new String(srcData, ENCODING);
} catch (Exception e) {
e.printStackTrace();
}
return decryptStr;
}
/**
*
*
* @param key
* @param cipherText
* @return
* @throws Exception
* @explain
*/
public static byte[] decrypt_Ecb_Padding(byte[] key, byte[] cipherText) throws Exception {
Cipher cipher = generateEcbCipher(ALGORITHM_NAME_ECB_PADDING, Cipher.DECRYPT_MODE, key);
return cipher.doFinal(cipherText);
}
/**
*
*
* @param hexKey 16
* @param cipherText 16
* @param paramStr
* @return
* @throws Exception
* @explain
*/
public static boolean verifyEcb(String hexKey, String cipherText, String paramStr) throws Exception {
// 用于接收校验结果
boolean flag = false;
// hexString--&gt;byte[]
byte[] keyData = ByteUtils.fromHexString(hexKey);
// 将16进制字符串转换成数组
byte[] cipherData = ByteUtils.fromHexString(cipherText);
// 解密
byte[] decryptData = decrypt_Ecb_Padding(keyData, cipherData);
// 将原字符串转换成byte[]
byte[] srcData = paramStr.getBytes(ENCODING);
// 判断2个数组是否一致
flag = Arrays.equals(decryptData, srcData);
return flag;
}
}

@ -0,0 +1,91 @@
package com.passuser.net.KeyUtils;
import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* (xor)/
*
* @author xietansheng
*/
public class XORUtils {
/**
* /
*
* @param data /
* @param key
* @return /
*/
public static byte[] encrypt(byte[] data, byte[] key) {
if (data == null || data.length == 0 || key == null || key.length == 0) {
return data;
}
byte[] result = new byte[data.length];
// 使用密钥字节数组循环加密或解密
for (int i = 0; i < data.length; i++) {
// 数据与密钥异或, 再与循环变量的低8位异或增加复杂度
result[i] = (byte) (data[i] ^ key[i % key.length] ^ (i & 0xFF));
}
return result;
}
/**
* /
*
* @param inFile /
* @param outFile
* @param key
*/
public static void encryptFile(File inFile, File outFile, byte[] key) throws Exception {
InputStream in = null;
OutputStream out = null;
try {
// 文件输入流
in = new FileInputStream(inFile);
// 结果输出流, 异或运算时, 字节是一个一个读取和写入, 这里必须使用缓冲流包装,
// 等缓冲到一定数量的字节10240字节后再写入磁盘否则写磁盘次数太多, 速度会非常慢)
out = new BufferedOutputStream(new FileOutputStream(outFile), 10240);
int b = -1;
long i = 0;
// 每次循环读取文件的一个字节, 使用密钥字节数组循环加密或解密
while ((b = in.read()) != -1) {
// 数据与密钥异或, 再与循环变量的低8位异或增加复杂度
b = (b ^ key[(int) (i % key.length)] ^ (int) (i & 0xFF));
// 写入一个加密/解密后的字节
out.write(b);
// 循环变量递增
i++;
}
out.flush();
} finally {
close(in);
close(out);
}
}
private static void close(Closeable c) {
if (c != null) {
try {
c.close();
} catch (IOException e) {
// nothing
}
}
}
}

@ -0,0 +1,13 @@
package com.passuser.net;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class PassuserApplication {
public static void main(String[] args) {
SpringApplication.run(PassuserApplication.class, args);
}
}

@ -0,0 +1,19 @@
package com.passuser.net.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author Think
* @Title: AuthToken
* @ProjectName token-authentication
* @Description: TODO
* @date 2019/1/1815:52
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface AuthToken {
}

@ -0,0 +1,62 @@
package com.passuser.net.configuration;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.passuser.net.interceptor.AuthorizationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author cailei.lu
* @description
* @date 2018/8/3
*/
@Configuration
public class WebAppConfiguration implements WebMvcConfigurer {
@Bean
public AuthorizationInterceptor getAuthorizationInterceptor(){
return new AuthorizationInterceptor();
}
/**
* redisTemplate 使jdkSerializeable, ,
* @param redisConnectionFactory
* @return
*/
@Bean
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
// 使用Jackson2JsonRedisSerialize 替换默认序列化
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
// 设置value的序列化规则和 key的序列化规则
redisTemplate.setValueSerializer(new StringRedisSerializer());
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(getAuthorizationInterceptor()).addPathPatterns("/**");
}
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//将所有/static/** 访问都映射到classpath:/static/ 目录下
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
}
}

@ -0,0 +1,461 @@
package com.passuser.net.controller.key;
import ch.qos.logback.core.encoder.ByteArrayUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.passuser.net.KeyUtils.*;
import com.passuser.net.annotation.AuthToken;
import com.passuser.net.entity.PpassInstant;
import com.passuser.net.utils.*;
import lombok.SneakyThrows;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.http.cookie.SM;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
@Controller
@RequestMapping("/passInstant")
public class KeyController {
@Resource
private RedisTemplate<String, String> redisTemplate;
@Autowired
private ResolveResponUtils resolveResponUtils;
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
private String PREFIX = "/PassInstant/passInstant/";
/**
*
*/
@RequestMapping("")
public String index() {
return PREFIX + "passInstant.html";
}
@RequestMapping("passInstant_upload")
public String uploadPpass(){return PREFIX + "passInstant_upload.html";}
/**
*
*/
@RequestMapping("/passInstant_add")
public String passInstantAdd() {
return PREFIX + "passInstant_add.html";
}
@RequestMapping("/list")
@AuthToken
@ResponseBody
public String getKeyList(HttpServletRequest request) throws Exception {
String token = CookieUtils.getCookieValue(request, "Authorization");
String username = redisTemplate.opsForValue().get(token);
List<String> strList = new ArrayList<>();
strList.add("encryptData");
Map<String, String> encryptData = resolveResponUtils.getGetResponseDecryptData("http://localhost:18088/us-admin/remote/getKeyList/" + username, null, strList);
Gson gson = new Gson();
List<PpassInstant> nowPassInstant = gson.fromJson(encryptData.get("encryptData"), new TypeToken<List<PpassInstant>>() {
}.getType());
Map<String, Object> hashMap = new HashMap<>();
hashMap.put("code", "0");
hashMap.put("data", nowPassInstant);
String postJSON = gson.toJson(hashMap);
return postJSON;
}
@RequestMapping("/add")
@AuthToken
public String generateKeyAndUpload(PpassInstant ppassInstant, HttpServletRequest request) throws Exception {
String passType = ppassInstant.getPassType();
ppassInstant.setPassCreatetime(DateFormatUtils.format(new Date(), "yyyy-MM-dd hh:mm:ss"));
return addNewKeyByData(ppassInstant, request, passType);
}
private String addNewKeyByData(PpassInstant ppassInstant, HttpServletRequest request, String passType) throws Exception {
switch (passType) {
case "SM4":
Map<String, String> SM4flag = generateSM4Key(ppassInstant, request);
SM4flag.put("keyId", ppassInstant.getPassId() + "");
return SM4flag.get("flag").equals("true") ? PREFIX + "passInstant.html" : "404.html";
case "SM2":
Map<String, String> SM2flag = generateSM2key(ppassInstant, request);
SM2flag.put("keyId", ppassInstant.getPassId() + "");
return SM2flag.get("flag").equals("true") ? PREFIX + "passInstant.html" : "404.html";
case ("AES"):
Map<String, String> AESflag = generateAESKey(ppassInstant, request);
AESflag.put("keyId", ppassInstant.getPassId() + "");
return AESflag.get("flag").equals("true") ? PREFIX + "passInstant.html" : "404.html";
case ("DES"):
Map<String, String> DESflag = generateDESKey(ppassInstant, request);
DESflag.put("keyId", ppassInstant.getPassId() + "");
return DESflag.get("flag").equals("true") ? PREFIX + "passInstant.html" : "404.html";
case ("RSA"):
Map<String, String> RSAflag = generateRSAkey(ppassInstant, request);
RSAflag.put("keyId", ppassInstant.getPassId() + "");
return RSAflag.get("flag").equals("true") ? PREFIX + "passInstant.html" : "404.html";
default:
return "404.html";
}
}
private Map<String, String> generateSM2key(PpassInstant ppassInstant, HttpServletRequest request) throws Exception {
Map<String, String> sm2key = getSM2KeyPairToJSON();
return resolveSetPpassInstant(ppassInstant, request, sm2key);
}
private Map<String, String> generateSM4Key(PpassInstant ppassInstant, HttpServletRequest request) throws Exception {
String sm4key = Sm4Util.generateKey();
return resolveSetPpassInstant(ppassInstant, request, sm4key);
}
@RequestMapping("updateKey/{keyId}")
@AuthToken
public String updateKeyAndUpload(@PathVariable("keyId") String keyId, @ModelAttribute PpassInstant ppassInstant, Model model, HttpServletRequest request) throws Exception {
return UpdateKeyAndUpload(keyId, ppassInstant, request);
}
private String UpdateKeyAndUpload(@PathVariable("keyId") String keyId, @ModelAttribute PpassInstant ppassInstant, HttpServletRequest request) throws Exception {
String passType = ppassInstant.getPassType();
switch (passType) {
case ("SM4"):
String sm4key = Sm4Util.generateKey();
Map<String, String> SM4flag = resolveSetPpassInstantById(keyId, ppassInstant, request, sm4key);
return SM4flag.get("flag").equals("true") ? PREFIX + "passInstant.html" : "404.html";
case ("SM2"):
Map<String, String> sm2key = getSM2KeyPairToJSON();
Map<String, String> SM2flag = resolveSetSM2PpassInstantById(keyId, ppassInstant, request, sm2key);
return SM2flag.get("flag").equals("true") ? PREFIX + "passInstant.html" : "404.html";
case ("AES"):
Map<String, String> AESflag = generateAESKey(ppassInstant, request);
AESflag.put("keyId", ppassInstant.getPassId() + "");
return AESflag.get("flag").equals("true") ? PREFIX + "passInstant.html" : "404.html";
case ("DES"):
Map<String, String> DESflag = generateDESKey(ppassInstant, request);
DESflag.put("keyId", ppassInstant.getPassId() + "");
return DESflag.get("flag").equals("true") ? PREFIX + "passInstant.html" : "404.html";
case ("RSA"):
Map<String, String> RSAflag = generateRSAkey(ppassInstant, request);
RSAflag.put("keyId", ppassInstant.getPassId() + "");
return RSAflag.get("flag").equals("true") ? PREFIX + "passInstant.html" : "404.html";
default:
return "404.html";
}
}
@RequestMapping("download/{keyId}")
@AuthToken
@ResponseBody
public String download(@PathVariable("keyId") String keyId, Model model, HttpServletRequest request, HttpServletResponse response,@RequestParam("username")String qianyiUser) throws Exception {
String token = CookieUtils.getCookieValue(request, "Authorization");
String username = redisTemplate.opsForValue().get(token);
String key = downloadKeyByKeyId(keyId, username, qianyiUser);
// 以流的形式下载文件。
InputStream fis = new BufferedInputStream(new ByteArrayInputStream(key.getBytes("utf-8")));
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
fis.close();
// 清空response
response.reset();
// 设置response的Header
response.addHeader("Content-Disposition", "attachment;filename=" + new String("key.txt".getBytes()));
response.addHeader("Content-Length", "" + key.length());
OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/octet-stream");
toClient.write(buffer);
toClient.flush();
toClient.close();
return "下载成功";
}
@RequestMapping("update/{keyId}")
@AuthToken
@ResponseBody
public String updateKey(@PathVariable("keyId") String keyId, HttpServletRequest request) throws Exception {
String token = CookieUtils.getCookieValue(request, "Authorization");
String username = redisTemplate.opsForValue().get(token);
Map<String, String> keyDataMap = getKeyDataMap(keyId, username);
String keytype = keyDataMap.get("keytype");
deleteByKeyId(keyId,username);
PpassInstant ppassInstant = new PpassInstant();
ppassInstant.setPassType(keytype);
ppassInstant.setPassId(Integer.parseInt(keyId)+1);
ppassInstant.setPassName(keyId+" update key");
ppassInstant.setPassExpiry(DateFormatUtils.format(DateUtils.rollMon(new Date(),1),"yyyy-MM-dd"));
ppassInstant.setPassCreatetime(DateFormatUtils.format(new Date(), "yyyy-MM-dd hh:mm:ss"));
return generateKeyAndUpload(ppassInstant,request);
}
@RequestMapping("delete/{keyId}")
@AuthToken
@ResponseBody
public String deleteKey(@PathVariable("keyId") String keyId, HttpServletRequest request) throws Exception {
String token = CookieUtils.getCookieValue(request, "Authorization");
String username = redisTemplate.opsForValue().get(token);
String flag = deleteByKeyId(keyId, username);
return flag.equals("true") ? "/passInstant" : "404.html";
}
/**
*
*/
@RequestMapping(value = "/upload",method= RequestMethod.POST)
@ResponseBody
public String handleFileUpload(HttpServletRequest request, @RequestParam("file") MultipartFile file) throws Exception {
if (!file.isEmpty()) {
try {
BufferedOutputStream out = new BufferedOutputStream(
new FileOutputStream(new File(
file.getOriginalFilename())));
System.out.println(file.getName());
out.write(file.getBytes());
out.flush();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
return "上传失败," + e.getMessage();
} catch (IOException e) {
e.printStackTrace();
return "上传失败," + e.getMessage();
}
//上传文件路径
String path = request.getServletContext().getRealPath("/systemFiles/");
//上传文件名
String filename = file.getOriginalFilename();
File filepath = new File(path, filename);
//判断路径是否存在,如果不存在就创建一个
if (!filepath.getParentFile().exists()) {
filepath.getParentFile().mkdirs();
} //将上传文件保存到一个目标文件当中
file.transferTo(new File(path + File.separator + filename));
File readTxt = new File(path + File.separator + filename);
BufferedReader reader = null;
String tempString = null;
StringBuffer sb = new StringBuffer();
try {
// System.out.println("以行为单位读取文件内容,一次读一整行:");
reader = new BufferedReader(new InputStreamReader(new FileInputStream(readTxt),"UTF-8"));
while ((tempString = reader.readLine()) != null) {
sb.append(tempString);
}
reader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
if(reader != null){
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
String keyStr = sb.toString();
Gson gson = new Gson();
PpassInstant ppassInstant = gson.fromJson(keyStr, PpassInstant.class);
String priKey = resolveResponUtils.getGetResponseData("http://localhost:18087/remote/getSM2Pri/" + ppassInstant.getUsername(), null, "priKey");
String fir = SM2Util.decrypt(priKey, ppassInstant.getPassChildfir());
ppassInstant.setPassChildfir(fir);
if(ppassInstant.getPassChildsec()!=null){
String sec = SM2Util.decrypt(priKey, ppassInstant.getPassChildsec());
ppassInstant.setPassChildsec(sec);
Map<String,String> hashMap = new HashMap<>();
hashMap.put("priKey",ppassInstant.getPassChildfir());
hashMap.put("pubKey",ppassInstant.getPassChildsec());
ppassInstant.setPassId(ppassInstant.getPassId() + 1 );
Map<String, String> SM2flag = resolveSetPpassInstant(ppassInstant, request, hashMap);
return SM2flag.get("flag").equals("true") ? "上传成功" : "404.html";
}
ppassInstant.setPassId(ppassInstant.getPassId() + 1 );
Map<String, String> uploadKeyflag = resolveSetPpassInstant(ppassInstant, request,fir);
return uploadKeyflag.get("flag").equals("true") ? "上传成功" : "404.html";
} else {
return "404.html";
}
}
@RequestMapping("/passInstant_download/{ppassId}")
public String passInstant_download(@PathVariable("ppassId")String ppassId,Model model){
model.addAttribute("ppassId",ppassId);
return PREFIX + "passInstant_download.html";
}
private String deleteByKeyId(String keyId, String username) throws Exception {
List<String> flagList = new ArrayList<>();
flagList.add("flag");
Map<String, String> flagMap = resolveResponUtils.getGetResponseDecryptData("http://localhost:18088/us-admin/remote/deleteKey/" + keyId + "/" + username, null, flagList);
String flag = flagMap.get("flag");
return flag;
}
private String updateByKeyId(String keyId, String username) throws Exception {
List<String> flagList = new ArrayList<>();
flagList.add("flag");
Map<String, String> flagMap = resolveResponUtils.getGetResponseDecryptData("http://localhost:18088/us-admin/remote/updateKey/" + keyId + "/" + username, null, flagList);
String flag = flagMap.get("flag");
return flag;
}
private String downloadKeyByKeyId(String keyId, String username,String qianyiUser) throws Exception {
String keyPass = resolveResponUtils.getGetResponseData("http://localhost:18087/remote/getKeyPass/" + username , null, "keyPass");
Map<String, String> getKeyData = getKeyDataMap(keyId, username);
String keydata = getKeyData.get("keydata");
if (keydata.contains("pubKey:")) {
String[] split = keydata.split("pubKey:");
String[] split1 = split[1].split("priKey:");
String pubKeyStr = new String(split1[0].getBytes());
String priKeyStr = new String(split1[1].getBytes());
String keyPubKey = resolveResponUtils.getGetResponseData("http://localhost:18087/remote/getSM2Pub/" + qianyiUser, null, "pubKey");
String pubKey = Sm4Util.decryptEcb(keyPass, pubKeyStr);
String priKey = Sm4Util.decryptEcb(keyPass, priKeyStr);
String pubKeyEnc = SM2Util.encrypt(keyPubKey, pubKey);
String priKeyEnc = SM2Util.encrypt(keyPubKey, priKey);
PpassInstant ppassInstant = new PpassInstant();
ppassInstant.setPassChildfir(pubKeyEnc);
ppassInstant.setPassChildsec(priKeyEnc);
ppassInstant.setPassType(getKeyData.get("keytype"));
ppassInstant.setUsername(qianyiUser);
ppassInstant.setPassId(Integer.parseInt(getKeyData.get("keyId")));
Gson gson = new Gson();
String keyJson = gson.toJson(ppassInstant);
return keyJson;
}
String keyPubKey = resolveResponUtils.getGetResponseData("http://localhost:18087/remote/getSM2Pub/" + username, null, "pubKey");
String keyEnc = Sm4Util.decryptEcb(keyPass,keydata);
String encryptKey = SM2Util.encrypt(keyPubKey, keyEnc);
PpassInstant ppassInstant = new PpassInstant();
ppassInstant.setPassChildfir(encryptKey);
ppassInstant.setPassType(getKeyData.get("keytype"));
ppassInstant.setPassId(Integer.parseInt(getKeyData.get("keyId")));
ppassInstant.setUsername(qianyiUser);
Gson gson = new Gson();
String keyJson = gson.toJson(ppassInstant);
return keyJson;
}
private Map<String, String> getKeyDataMap(String keyId, String username) throws Exception {
List<String> keyStr = new ArrayList<>();
keyStr.add("keydata");
keyStr.add("keytype");
keyStr.add("keyId");
return resolveResponUtils.getGetResponseDecryptData("http://localhost:18088/us-admin/remote/getKeyById/" + keyId + "/" + username, null, keyStr);
}
private Map<String, String> resolveSetSM2PpassInstantById(String keyId, PpassInstant ppassInstant, HttpServletRequest request, Map<String, String> key) throws Exception {
String token = CookieUtils.getCookieValue(request, "Authorization");
String userName = redisTemplate.opsForValue().get(token);
String postJson = getKeyPostBody(ppassInstant, key, userName,token);
List<String> strList = new ArrayList<>();
strList.add("flag");
return resolveResponUtils.getPostJsonResponseDecryptData("http://localhost:18088/us-admin/remote/keyUploadJson/" + keyId + "/" + userName, postJson, strList);
}
private Map<String, String> resolveSetPpassInstantById(String keyId, PpassInstant ppassInstant, HttpServletRequest request, String key) throws Exception {
String token = CookieUtils.getCookieValue(request, "Authorization");
String userName = redisTemplate.opsForValue().get(token);
String postJson = getKeyPostBody(ppassInstant, key, userName, token);
List<String> strList = new ArrayList<>();
strList.add("flag");
return resolveResponUtils.getPostJsonResponseDecryptData("http://localhost:18088/us-admin/remote/keyUploadJson/" + keyId + "/" + userName, postJson, strList);
}
private String getKeyPostBody(PpassInstant ppassInstant, Map<String, String> key, String userName, String token) throws Exception {
String keyPass = resolveResponUtils.getGetResponseData("http://localhost:18087/remote/getKeyPass/" + userName , null, "keyPass");
String privateKey = Sm4Util.encryptEcb(keyPass, key.get("priKey"));
String publicKey = Sm4Util.encryptEcb(keyPass, key.get("pubKey"));
key.put("priKey",privateKey);
key.put("pubKey",publicKey);
ppassInstant.setPassCreatetime(DateFormatUtils.format(new Date(), "yyyy-MM-dd hh:mm:ss"));
ppassInstant.setPassExpiry(DateFormatUtils.format(DateUtils.rollDay(new Date(), 31), "yyyy-MM-dd"));
ppassInstant.setPassLength(new String(privateKey).length());
ppassInstant.setPassChildfir(privateKey);
ppassInstant.setPassChildsec(publicKey);
Gson gson = new Gson();
return gson.toJson(ppassInstant);
}
private String getKeyPostBody(PpassInstant ppassInstant, String key, String userName, String token) throws Exception {
String keyPass = resolveResponUtils.getGetResponseData("http://localhost:18087/remote/getKeyPass/" + userName , null, "keyPass");
String priKeyStr = Sm4Util.encryptEcb(keyPass, key);
ppassInstant.setPassCreatetime(DateFormatUtils.format(new Date(), "yyyy-MM-dd hh:mm:ss"));
ppassInstant.setPassExpiry(DateFormatUtils.format(DateUtils.rollDay(new Date(), 31), "yyyy-MM-dd"));
ppassInstant.setPassLength(key.length());
ppassInstant.setPassChildfir(priKeyStr);
Gson gson = new Gson();
return gson.toJson(ppassInstant);
}
private Map<String, String> getSM2KeyPairToJSON() {
PCIKeyPair pciKeyPair = SM2Util.genKeyPair();
String priKey = pciKeyPair.getPriKey();
String pubKey = pciKeyPair.getPubKey();
Map<String, String> hashMap = new HashMap<>();
hashMap.put("priKey", priKey);
hashMap.put("pubKey", pubKey);
return hashMap;
}
private Map<String, String> resolveSetPpassInstant(@ModelAttribute PpassInstant ppassInstant, HttpServletRequest request, String key) throws Exception {
String token = CookieUtils.getCookieValue(request, "Authorization");
String userName = redisTemplate.opsForValue().get(token);
String postJson = getKeyPostBody(ppassInstant, key, userName, token);
List<String> strList = new ArrayList<>();
strList.add("flag");
strList.add("keyId");
Map<String, String> postList = resolveResponUtils.getPostJsonResponseDecryptData("http://localhost:18088/us-admin/remote/keySaveJson/" + userName, postJson, strList);
return postList;
}
private Map<String, String> resolveSetPpassInstant(@ModelAttribute PpassInstant ppassInstant, HttpServletRequest request, Map<String, String> key) throws Exception {
String token = CookieUtils.getCookieValue(request, "Authorization");
String userName = redisTemplate.opsForValue().get(token);
String postJson = getKeyPostBody(ppassInstant, key, userName,token);
List<String> strList = new ArrayList<>();
strList.add("flag");
strList.add("keyId");
Map<String, String> postList = resolveResponUtils.getPostJsonResponseDecryptData("http://localhost:18088/us-admin/remote/keySaveJson/" + userName, postJson, strList);
return postList;
}
private Map<String, String> generateAESKey(PpassInstant ppassInstant, HttpServletRequest request) throws Exception {
String AESkey = Generatingkey.getAESKey();
return resolveSetPpassInstant(ppassInstant, request, AESkey);
}
private Map<String, String> generateDESKey(PpassInstant ppassInstant, HttpServletRequest request) throws Exception {
String DESkey = Generatingkey.getDESKey();
return resolveSetPpassInstant(ppassInstant, request, DESkey);
}
private Map<String, String> getRSAKeyPairToJSON() throws Exception {
PCIKeyPair pciKeyPair = SM2Util.genKeyPair();
String priKey = RSAUtils.getPriKey();
String pubKey = RSAUtils.getPubKey();
Map<String, String> hashMap = new HashMap<>();
hashMap.put("priKey", priKey);
hashMap.put("pubKey", pubKey);
return hashMap;
}
private Map<String, String> generateRSAkey(PpassInstant ppassInstant, HttpServletRequest request) throws Exception {
Map<String, String> RSAkey = getRSAKeyPairToJSON();
return resolveSetPpassInstant(ppassInstant, request, RSAkey);
}
}

@ -0,0 +1,30 @@
package com.passuser.net.controller.notice;
import com.passuser.net.annotation.AuthToken;
import com.passuser.net.utils.R;
import com.passuser.net.utils.ResolveResponUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Map;
@Controller
public class NoticeController {
@Autowired
private ResolveResponUtils resolveResponUtils;
@RequestMapping("notice")
@AuthToken
@ResponseBody
public R getUserNotice(HttpServletRequest request) throws Exception {
String user = (String)request.getAttribute("user");
Map<String ,String> noticelist = resolveResponUtils.getGetResponseDecryptData("http://localhost:18088/notice/" + user, null, Arrays.asList("noticelist"));
return new R().put("noticelist",noticelist.get("noticelist"));
}
}

@ -0,0 +1,157 @@
package com.passuser.net.controller.user;
import com.google.gson.Gson;
import com.mysql.cj.util.StringUtils;
import com.passuser.net.KeyUtils.Sm4Util;
import com.passuser.net.annotation.AuthToken;
import com.passuser.net.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
@Controller
public class UserController {
// 注入Md5TokenGenerator
@Resource
Md5TokenGenerator tokenGenerator;
// 注入ResolveResponUtils
@Autowired
private ResolveResponUtils resolveResponUtils;
// 注入RedisTemplate
@Resource
private RedisTemplate<String, String> redisTemplate;
// 登录接口
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String loginUserBySM4(@RequestParam("username") String username, @RequestParam("password") String password, HttpServletRequest request, HttpServletResponse response) throws Exception {
HashMap<String, String> hashMap = new HashMap<>();
Gson gson = new Gson();
hashMap.put("username", username);
hashMap.put("password", password);
// 发送post请求获取sessionkey
String post = HttpUtils.post("http://localhost:18087/remote/getSessionKey", hashMap);
Map<String ,Object> map = new HashMap<>();
Map<String ,Object> publicKey = gson.fromJson(post, map.getClass());
String sessionkey = (String) publicKey.get("sessionkey");
// 将sessionkey存入redis
redisTemplate.opsForValue().set("sessionkey", sessionkey);
// 将用户信息加密
String jsonUserName = gson.toJson(hashMap);
String userEncrypt = Sm4Util.encryptEcb(sessionkey, jsonUserName);
HashMap<String, String> userInfos = new HashMap<>();
userInfos.put("username", username);
userInfos.put("userEncrypt", userEncrypt);
// 发送post请求进行认证
String userPost = HttpUtils.post("http://localhost:18088/us-admin/remote/remoteauth", userInfos);
Map<String ,Object> r = gson.fromJson(userPost, map.getClass());
Boolean auth = (Boolean) r.get("auth");
if (Boolean.TRUE.equals(auth)) {
// 获取keyPass
String keyPass = resolveResponUtils.getGetResponseData("http://localhost:18087/remote/getKeyPass/" + username, null, "keyPass");
// 生成token
String token = tokenGenerator.generate(username, password);
// 设置cookie和header
CookieUtils.setCookie(request,response,"Authorization", token);
response.setHeader("Authorization", token);
// 将token和用户名存入redis
redisTemplate.opsForValue().set(token, username);
redisTemplate.opsForValue().set(token+username,System.currentTimeMillis()+"");
}
if (Boolean.TRUE.equals(auth)) {
return "/PassInstant/passInstant/passInstant.html";
} else {
return "login.html";
}
}
// 获取登录页面
@RequestMapping(value = {"/login", "/"}, method = RequestMethod.GET)
public String getLoginPage(HttpServletRequest request,HttpServletResponse response) {
String token = CookieUtils.getCookieValue(request, "Authorization");
if (!StringUtils.isNullOrEmpty(token) && redisTemplate.opsForValue().get(token) != null) {
return "/PassInstant/passInstant/passInstant.html";
}
return "/login.html";
}
// 登出接口
@RequestMapping("logout")
public String logout(HttpServletRequest request,HttpServletResponse response){
// 删除cookie
CookieUtils.deleteCookie(request,response,"Authorization");
// 清除session
Enumeration em = request.getSession().getAttributeNames();
while(em.hasMoreElements()){
request.getSession().removeAttribute(em.nextElement().toString());
}
return "login.html";
}
// 获取用户注册页面
@RequestMapping("/user_userAdd")
public String getUserRegister(){
return "/system/user/user_teacherAdd.html";
}
// 获取修改密码页面
@RequestMapping("/changePassword")
public String changPassword(){
return "/system/user/user_changPwd";
}
/**
*
*/
@RequestMapping(value = "/changPassword",method = RequestMethod.POST)
@AuthToken
public String addUser(@RequestParam("oldpassword") String oldpassword, @RequestParam("firpassword") String firpassword, @RequestParam("secpassword") String secpassword, HttpServletRequest request, HttpServletResponse response) throws Exception {
HashMap<String, String> hashMap = new HashMap<>();
String token = CookieUtils.getCookieValue(request, "Authorization");
String username = redisTemplate.opsForValue().get(token);
if (!firpassword.equals(secpassword)) {
return "404.html";
}
Gson gson = new Gson();
hashMap.put("oldpassword", oldpassword);
hashMap.put("newpassword", firpassword);
hashMap.put("username", username);
String hashMapJson = gson.toJson(hashMap);
String sessionkey = redisTemplate.opsForValue().get("sessionkey");
String userEncrypt = Sm4Util.encryptEcb(sessionkey, hashMapJson);
R r = R.ok().put("encryptData", userEncrypt);
String postJson = gson.toJson(r);
// 发送post请求修改密码
String flag = resolveResponUtils.getPostJsonResponseData("http://localhost:18088/us-admin/remote/changpwd/" + username, postJson, "flag");
return flag.equals("true")?"redirect:/passInstant":"404.html";
}
/**
*
*/
@RequestMapping(value = "register",method = RequestMethod.POST)
public String register(@RequestParam("username")String username,@RequestParam("password")String password,@RequestParam("keypass")String keypass) throws Exception {
Map<String,String> hashMap = new HashMap<>();
hashMap.put("username",username);
hashMap.put("password",password);
Map<String,String> keyPass = new HashMap<>();
keyPass.put("keyPass",keypass);
// 发送post请求注册用户
String flag = resolveResponUtils.getPostResponseData("http://localhost:18088/us-admin/remote/register/", hashMap, "flag");
// 发送post请求保存keyPass
resolveResponUtils.getPostResponseData("http://localhost:18087/remote/savekeypass/"+username, keyPass, "flag");
return flag.equals("true")?"redirect:/login":"404.html";
}
}

@ -0,0 +1,102 @@
package com.passuser.net.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* Created by www.magicalcoder.com
* qq:709876443
* read
* QQ:648595928
*/
@Data
public class PpassInstant implements Serializable{
private Integer passId;//密钥UUID
private String passName;//密钥名称
private Integer passLength;//密钥长度
private String passType;//密钥类型
private String passChildfir;//第一子密钥
private String passChildsec;//第二子密钥
private String passChildthi;//第三子密钥
private String passExpiry;//密钥有效期
@DateTimeFormat( pattern = "yyyy-MM-dd HH:mm:ss" )
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
private String passCreatetime;//密钥上传时间
private Integer passUserid;//密钥使用者
private String username;
public Integer getPassId(){
return passId;
}
public void setPassId(Integer passId){
this.passId = passId;
}
public String getPassName(){
return passName;
}
public void setPassName(String passName){
this.passName = passName;
}
public Integer getPassLength(){
return passLength;
}
public void setPassLength(Integer passLength){
this.passLength = passLength;
}
public String getPassType(){
return passType;
}
public void setPassType(String passType){
this.passType = passType;
}
public String getPassChildfir(){
return passChildfir;
}
public void setPassChildfir(String passChildfir){
this.passChildfir = passChildfir;
}
public String getPassChildsec(){
return passChildsec;
}
public void setPassChildsec(String passChildsec){
this.passChildsec = passChildsec;
}
public String getPassChildthi(){
return passChildthi;
}
public void setPassChildthi(String passChildthi){
this.passChildthi = passChildthi;
}
public String getPassExpiry(){
return passExpiry;
}
public void setPassExpiry(String passExpiry){
this.passExpiry = passExpiry;
}
public String getPassCreatetime(){
return passCreatetime;
}
public void setPassCreatetime(String passCreatetime){
this.passCreatetime = passCreatetime;
}
public Integer getPassUserid(){
return passUserid;
}
public void setPassUserid(Integer passUserid){
this.passUserid = passUserid;
}
}

@ -0,0 +1,22 @@
package com.passuser.net.entity;
import lombok.Data;
/**
* @Description: Token
* @author: Yangxf
* @date: 2019/4/14 12:53
*/
@Data
public class TokenEntity {
/* 用户ID */
private Long userName;
/* 刷新时间 */
private int buildTime;
/* token */
private String token;
}

@ -0,0 +1,131 @@
package com.passuser.net.interceptor;
import com.alibaba.fastjson.JSONObject;
import com.passuser.net.annotation.AuthToken;
import com.passuser.net.utils.ConstantKit;
import com.passuser.net.utils.CookieUtils;
import com.passuser.net.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;
/**
* @author Think
* @Title: AuthorizationInterceptor
* @ProjectName token-authentication
* @Description: TODO
* @date 2019/1/1815:50
*/
@Slf4j
@Component
public class AuthorizationInterceptor implements HandlerInterceptor {
@Autowired
private RedisTemplate<String, String> redisTemplate;
//存放鉴权信息的Header名称默认是Authorization
private String httpHeaderName = "Authorization";
//鉴权失败后返回的错误信息默认为401 unauthorized
private String unauthorizedErrorMessage = "401 unauthorized";
//鉴权失败后返回的HTTP错误码默认为401
private int unauthorizedErrorCode = HttpServletResponse.SC_UNAUTHORIZED;
/**
* KeyRequest Key
*/
public static final String REQUEST_CURRENT_KEY = "REQUEST_CURRENT_KEY";
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler){
if (!(handler instanceof HandlerMethod)) {
return true;
}
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
// 如果打上了AuthToken注解则需要验证token
if (method.getAnnotation(AuthToken.class) != null || handlerMethod.getBeanType().getAnnotation(AuthToken.class) != null) {
String token = CookieUtils.getCookieValue(request, httpHeaderName);
// String token = request.getHeader(httpHeaderName);
// String token = request.getParameter(httpHeaderName);
log.info("Get token from request is {} ", token);
String username = "";
if (token != null && token.length() != 0) {
username = redisTemplate.opsForValue().get(token);
log.info("Get username from Redis is {}", username);
}
if (username != null && !username.trim().equals("")) {
//log.info("token birth time is: {}",jedis.get(username+token));
Long tokeBirthTime = Long.valueOf(redisTemplate.opsForValue().get(token + username));
log.info("token Birth time is: {}", tokeBirthTime);
Long diff = System.currentTimeMillis() - tokeBirthTime;
log.info("token is exist : {} ms", diff);
//重新设置Redis中的token过期时间
if (diff > ConstantKit.TOKEN_RESET_TIME) {
redisTemplate.expire(username, ConstantKit.TOKEN_EXPIRE_TIME, TimeUnit.MINUTES);
redisTemplate.expire(token, ConstantKit.TOKEN_EXPIRE_TIME, TimeUnit.MINUTES);
log.info("Reset expire time success!");
Long newBirthTime = System.currentTimeMillis();
redisTemplate.opsForValue().set(token + username, newBirthTime.toString());
}
//用完关闭
request.setAttribute(REQUEST_CURRENT_KEY, username);
return true;
} else {
JSONObject jsonObject = new JSONObject();
PrintWriter out = null;
try {
response.setStatus(unauthorizedErrorCode);
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
jsonObject.put("code", ((HttpServletResponse) response).getStatus());
jsonObject.put("message", HttpStatus.UNAUTHORIZED);
out = response.getWriter();
out.println(jsonObject);
return false;
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != out) {
out.flush();
out.close();
}
}
}
}
request.setAttribute(REQUEST_CURRENT_KEY, null);
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
}
}

@ -0,0 +1,17 @@
package com.scorpios.tokenauthentication.model;
import lombok.Builder;
import lombok.Data;
@Builder
@Data
public class ResponseTemplate {
public Integer code;
public String message;
public Object data;
}

@ -0,0 +1,82 @@
package com.passuser.net.utils;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
public class AESUtil {
/**
* AES
*
* @param content
*
* @param password
*
* @return
*/
public static byte[] encrypt(String content, String password) {
try {
KeyGenerator kgen = KeyGenerator.getInstance("AES");// 创建AES的Key生产者
kgen.init(128, new SecureRandom(password.getBytes()));// 利用用户密码作为随机数初始化出
//加密没关系SecureRandom是生成安全随机数序列password.getBytes()是种子只要种子相同序列就一样所以解密只要有password就行
SecretKey secretKey = kgen.generateKey();// 根据用户密码,生成一个密钥
byte[] enCodeFormat = secretKey.getEncoded();// 返回基本编码格式的密钥,如果此密钥不支持编码,则返回
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");// 转换为AES专用密钥
Cipher cipher = Cipher.getInstance("AES");// 创建密码器
byte[] byteContent = content.getBytes("utf-8");
cipher.init(Cipher.ENCRYPT_MODE, key);// 初始化为加密模式的密码器
byte[] result = cipher.doFinal(byteContent);// 加密
return result;
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
return null;
}
/**
* AES
*
* @param content
* AES
* @param password
*
* @return
*/
public static byte[] decrypt(byte[] content, String password) {
try {
KeyGenerator kgen = KeyGenerator.getInstance("AES");// 创建AES的Key生产者
kgen.init(128, new SecureRandom(password.getBytes()));
SecretKey secretKey = kgen.generateKey();// 根据用户密码,生成一个密钥
byte[] enCodeFormat = secretKey.getEncoded();// 返回基本编码格式的密钥
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");// 转换为AES专用密钥
Cipher cipher = Cipher.getInstance("AES");// 创建密码器
cipher.init(Cipher.DECRYPT_MODE, key);// 初始化为解密模式的密码器
byte[] result = cipher.doFinal(content);
return result; // 明文
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
return null;
}
}

@ -0,0 +1,417 @@
package com.passuser.net.utils;
import org.springframework.util.StringUtils;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @ClassName: CommonUtils
* @Description:
* @since: 0.0.1
* @author: dzy
* @date: 2017222 11:46:44
*/
public class CommonUtils {
/**
* @param date
* @param pattern :yyyyMMdd
* @return
* @Title: formatDate
* @Description:
* @since: 0.0.1
*/
public static String formatDate(Date date, String pattern) {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
return formatter.format(date);
}
/**
* @param strDate String
* @param pattern
* @return
* @Title: parseDate
* @Description: StringDate
* @since: 0.0.1
*/
public static Date parseDate(String strDate, String pattern) {
SimpleDateFormat formatter = null;
if (StringUtils.isEmpty(strDate) || strDate.equals("")) {
return null;
}
formatter = new SimpleDateFormat(pattern);
try {
return formatter.parse(strDate);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* @param date
* @param field :,,
* @param amount ()
* @return
* @Title: dateAdd
* @Description:
* @since: 0.0.1
*/
public static Date dateAdd(Date date, int field, int amount) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(field, amount);
return calendar.getTime();
}
/**
* @param source
* @param offset , 0-, source.getBytes().length ,
* @param c
* @param length
* @return
* @Title: fill
* @Description: , ,
* @since: 0.0.1
*/
public static String fill(String source, int offset, char c, int length) throws UnsupportedEncodingException {
if (null == source) {
source = "";
}
if (source.getBytes("utf-8").length == length) {
return source;
}
byte[] buf = new byte[length];
byte[] src = source.getBytes("utf-8");
if (src.length > length) {
System.arraycopy(src, src.length - length, buf, 0, length);
return new String(buf, "utf-8");
}
if (offset > src.length) {
offset = src.length;
} else if (offset < 0) {
offset = 0;
}
int n = length - src.length;
System.arraycopy(src, 0, buf, 0, offset);
for (int i = 0; i < n; i++) {
buf[i + offset] = (byte) c;
}
System.arraycopy(src, offset, buf, offset + n, src.length - offset);
return new String(buf, "utf-8");
}
/**
* @param original
* @param offset , 0-, original.getBytes().length ,
* @param length
* @param c
* @return
* @Title: replace
* @Description: , ,
* @since: 0.0.1
*/
public static String replace(String original, int offset, int length, char c) throws UnsupportedEncodingException {
if (original == null) {
original = "";
}
if (original.getBytes("utf-8").length <= offset) {
return original;
}
if (original.getBytes("utf-8").length < offset + length) {
length = original.getBytes("utf-8").length - offset;
}
byte[] buf = new byte[original.length()];
byte[] src = original.getBytes("utf-8");
System.arraycopy(src, 0, buf, 0, offset);
for (int i = offset; i < offset + length; i++) {
buf[i] = (byte) c;
}
System.arraycopy(src, offset + length, buf, offset + length, src.length - offset - length);
return new String(buf, "utf-8");
}
/**
* @param s 16
* @return
* @Title: hexToByte
* @Description: 16
* @since: 0.0.1
*/
public static byte[] hexToByte(String s) {
byte[] result = null;
try {
int i = s.length();
// if (i % 2 == 1) {
// throw new Exception("字符串长度不是偶数.");
// }
if (i % 2 != 0) {
throw new Exception("字符串长度不是偶数.");
}
result = new byte[i / 2];
for (int j = 0; j < result.length; j++) {
result[j] = (byte) Integer.parseInt(s.substring(j * 2, j * 2 + 2), 16);
}
} catch (Exception e) {
result = null;
e.printStackTrace();
// log.error("16进制字符串转字节数组时出现异常:", e);
}
return result;
}
/**
* @param bytes
* @return
* @Title: byte2hexString
* @Description: 16 //0x33 0xD2 0x00 0x46 转换为 "33d20046" 转换和打印报文用
* @since: 0.0.1
*/
public static String byte2hexString(byte[] bytes) {
StringBuffer buf = new StringBuffer(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
if (((int) bytes[i] & 0xff) < 0x10) {
buf.append("0");
}
buf.append(Long.toString((int) bytes[i] & 0xff, 16));
}
return buf.toString().toUpperCase();
}
/**
* @param hexString 16 :"33d20046" 0x33 0xD2 0x00 0x46
* @return
* @Title: hexString2byte
* @Description: 16
* @since: 0.0.1
*/
public static byte[] hexString2byte(String hexString) {
if (null == hexString || hexString.length() % 2 != 0 || hexString.contains("null")) {
return null;
}
byte[] bytes = new byte[hexString.length() / 2];
for (int i = 0; i < hexString.length(); i += 2) {
bytes[i / 2] = (byte) (Integer.parseInt(hexString.substring(i, i + 2), 16) & 0xff);
}
return bytes;
}
/**
* @param i int
* @return
* @Title: byte1ToBcd2
* @Description: intBCD
* @since: 0.0.1
*/
public static String byte1ToBcd2(int i) {
// return (new Integer(i / 16).toString() + (new Integer(i % 16)).toString());
return Integer.toString(i / 16) + Integer.toString(i % 16);
}
/**
* @param b
* @return
* @Title: byteToHex2
* @Description: 16 For example, byte[] {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF} will be changed to String "0123456789ABCDEF"
* @since: 0.0.1
*/
public static String byteToHex2(byte[] b) {
StringBuffer result = new StringBuffer();
String tmp = "";
for (int i = 0; i < b.length; i++) {
tmp = Integer.toHexString(b[i] & 0xff);
if (tmp.length() == 1) {
result.append("0" + tmp);
} else {
result.append(tmp);
}
}
return result.toString().toUpperCase();
}
/**
* @param num
* @param len
* @return
* @Title: intToHexBytes
* @Description: int16
*/
public static byte[] intToHexBytes(int num, int len) {
byte[] bytes = null;
String hexString = Integer.toHexString(num);
if (len > 0) {
int length = len * 2;
hexString = leftFill(hexString, '0', length);
bytes = CommonUtils.hexString2byte(hexString);
}
return bytes;
}
private static String leftFill(String hexString, char c, int length) {
StringBuilder stringBuilder = new StringBuilder();
if(hexString.length() < length){
for(int count = 0; count <length-hexString.length();count++){
stringBuilder.append(c);
}
}
return stringBuilder.append(hexString).toString();
}
/*public static String byteToHex3(byte[] b) {
String result = "";
String tmp = "";
for (int n = 0; n < b.length; n++) {
tmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
if (tmp.length() == 1) {
result = result + "0" + tmp;
} else {
result = result + tmp;
}
if (n < b.length - 1) {
result = result + "";
}
}
return result.toUpperCase();
}*/
/**
* @param str
* @return
* @Title: iso2Gbk
* @Description: ISO-8859-1GBK
* @since: 0.0.1
*/
public static String iso2Gbk(String str) {
if (null == str) {
return str;
}
try {
return new String(str.getBytes("ISO-8859-1"), "GBK");
} catch (UnsupportedEncodingException e) {
// log.error("不支持的编码异常:", e);
e.printStackTrace();
return str;
}
}
// /**
// * @param message
// * @return
// * @Title: getSubElement
// * @Description: 分解各子域到HashMap
// * @since: 0.0.1
// */
// public static Map<String, String> getSubElement(byte[] message) {
// Map<String, String> map = new HashMap<String, String>();
// String key = null;
// String value = null;
// int len = 0;
// int idx = 0;
// while (idx < message.length) {
// key = new String(message, idx, 2);
// idx += 2; //取了SE id 移2位
// len = Integer.parseInt(new String(message, idx, 2));
// idx += 2; //取了SE id的内容长度 移2位
// value = new String(message, idx, len);
// map.put(key, value);
// idx += len;
// }
// return map;
// }
//byte数组转成long
/**
* @param b long
* @return
*/
public static long byteToLong(byte[] b) {
long s = 0;
long s0 = b[0] & 0xff;// 最低位
long s1 = b[1] & 0xff;
long s2 = b[2] & 0xff;
long s3 = b[3] & 0xff;
long s4 = b[4] & 0xff;// 最低位
long s5 = b[5] & 0xff;
long s6 = b[6] & 0xff;
long s7 = b[7] & 0xff;
// s0不变
s1 <<= 8;
s2 <<= 16;
s3 <<= 24;
s4 <<= 8 * 4;
s5 <<= 8 * 5;
s6 <<= 8 * 6;
s7 <<= 8 * 7;
s = s0 | s1 | s2 | s3 | s4 | s5 | s6 | s7;
return s;
}
/**
* @param b int
* @return
*/
public static int byteToInt(byte[] b) {
int s = 0;
int s0 = b[0] & 0xff;// 最低位
int s1 = b[1] & 0xff;
int s2 = b[2] & 0xff;
int s3 = b[3] & 0xff;
// s0不变
s1 <<= 8;
s2 <<= 16;
s3 <<= 24;
s = s0 | s1 | s2 | s3;
return s;
}
/**
* intbyte
* @param i
* @return
*/
public static byte[] intToLittleBytes(int i) {
ByteBuffer byteBuffer = ByteBuffer.allocate(4);
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
byteBuffer.asIntBuffer().put(i);
byte[] littleBytes = byteBuffer.array();
return littleBytes;
}
/**
* 10
* @param b
* @return
*/
public static int byteToInt(byte b) {
int value = b & 0xff;
return value;
}
/**
*
* @param bt1 bt1
* @param bt2 bt2
* @return
*/
public static byte[] byteMerger(byte[] bt1, byte[] bt2){
byte[] bt3 = new byte[bt1.length+bt2.length];
System.arraycopy(bt1, 0, bt3, 0, bt1.length);
System.arraycopy(bt2, 0, bt3, bt1.length, bt2.length);
return bt3;
}
}

@ -0,0 +1,27 @@
package com.passuser.net.utils;
public final class ConstantKit {
/**
*
*/
public static final Integer DEL_FLAG_TRUE = 1;
/**
*
*/
public static final Integer DEL_FLAG_FALSE = 0;
/**
* redistoken10
*/
public static final Integer TOKEN_EXPIRE_TIME = 60 * 10;
/**
* token
*/
public static final Integer TOKEN_RESET_TIME = 1000 * 100;
}

@ -0,0 +1,326 @@
package com.passuser.net.utils;
import org.slf4j.Logger;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* Cookie
*
*/
public final class CookieUtils {
/**
* Cookie,
*
* @param request
* @param cookieName
* @return
*/
public static String getCookieValue(HttpServletRequest request, String cookieName) {
return getCookieValue(request, cookieName, false);
}
/**
* Cookie,
*
* @param request
* @param cookieName
* @return
*/
public static String getCookieValue(HttpServletRequest request, String cookieName, boolean isDecoder) {
Cookie[] cookieList = request.getCookies();
if (cookieList == null || cookieName == null) {
return null;
}
String retValue = null;
try {
for (int i = 0; i < cookieList.length; i++) {
if (cookieList[i].getName().equals(cookieName)) {
if (isDecoder) {
retValue = URLDecoder.decode(cookieList[i].getValue(), "UTF-8");
} else {
retValue = cookieList[i].getValue();
}
break;
}
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
// e.printStackTrace();
}
return retValue;
}
/**
* Cookie,
*
* @param request
* @param cookieName
* @return
*/
public static String getCookieValue(HttpServletRequest request, String cookieName, String encodeString) {
Cookie[] cookieList = request.getCookies();
if (cookieList == null || cookieName == null) {
return null;
}
String retValue = null;
try {
for (int i = 0; i < cookieList.length; i++) {
if (cookieList[i].getName().equals(cookieName)) {
retValue = URLDecoder.decode(cookieList[i].getValue(), encodeString);
break;
}
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
// e.printStackTrace();
}
return retValue;
}
/**
* Cookie ,
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,
String cookieValue) {
setCookie(request, response, cookieName, cookieValue, -1);
}
/**
* Cookie ,
*/
public static void setCookieTwo(String domian, HttpServletResponse response, String cookieName,
String cookieValue) {
setCookieTwo(domian, response, cookieName, cookieValue, -1);
}
/**
* Cookie ,
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,
String cookieValue, int cookieMaxage) {
setCookie(request, response, cookieName, cookieValue, cookieMaxage, false);
}
/**
* Cookie ,
*/
public static void setCookieTwo(String domain, HttpServletResponse response, String cookieName,
String cookieValue, int cookieMaxage) {
setCookieTwo(domain, response, cookieName, cookieValue, cookieMaxage, false);
}
/**
* Cookie ,
*/
public static void setCookieTwo(String domain, HttpServletResponse response, String cookieName,
String cookieValue, int cookieMaxage, boolean isEncode) {
doSetCookieTwo(domain, response, cookieName, cookieValue, cookieMaxage, isEncode);
}
/**
* Cookie使
*
* @param cookieMaxage cookie
*/
private static final void doSetCookieTwo(String domain, HttpServletResponse response,
String cookieName, String cookieValue, int cookieMaxage, boolean isEncode) {
try {
if (cookieValue == null) {
cookieValue = "";
} else if (isEncode) {
cookieValue = URLEncoder.encode(cookieValue, "utf-8");
}
Cookie cookie = new Cookie(cookieName, cookieValue);
if (cookieMaxage > 0)
cookie.setMaxAge(cookieMaxage);
String domainName = getDomainNameByUrl(domain);
if (!"localhost".equals(domainName)) {
cookie.setDomain(domainName);
}
cookie.setPath("/");
cookie.setHttpOnly(true);
response.addCookie(cookie);
} catch (Exception e) {
// logger.error("doSetCookie错误信息:{}",e);
throw new RuntimeException(e);
// e.printStackTrace();
}
}
/**
* cookie
*/
public static final String getDomainNameByUrl(String domain) {
String domainName = null;
String serverName = domain;
if (serverName == null || serverName.equals("")) {
domainName = "";
} else {
// serverName = serverName.toLowerCase();
// serverName = serverName.substring(7);
// final int end = serverName.indexOf("/");
serverName = domain;
final String[] domains = serverName.split("\\.");
int len = domains.length;
if (len > 3) {
// www.xxx.com.cn
domainName = "." + domains[len - 3] + "." + domains[len - 2] + "." + domains[len - 1];
} else if (len <= 3 && len > 1) {
// xxx.com or xxx.cn
domainName = "."+domains[len - 2] + "." + domains[len - 1];
} else {
domainName = serverName;
}
}
if (domainName != null && domainName.indexOf(":") > 0) {
String[] ary = domainName.split("\\:");
domainName = ary[0];
}
return domainName;
}
/**
* Cookie ,
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,
String cookieValue, boolean isEncode) {
setCookie(request, response, cookieName, cookieValue, -1, isEncode);
}
/**
* Cookie ,
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,
String cookieValue, int cookieMaxage, boolean isEncode) {
doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, isEncode);
}
/**
* Cookie , ()
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,
String cookieValue, int cookieMaxage, String encodeString) {
doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, encodeString);
}
/**
* Cookiecookie
*/
public static void deleteCookie(HttpServletRequest request, HttpServletResponse response,
String cookieName) {
doSetCookie(request, response, cookieName, "", -1, false);
}
/**
* Cookie使
*
* @param cookieMaxage cookie
*/
private static final void doSetCookie(HttpServletRequest request, HttpServletResponse response,
String cookieName, String cookieValue, int cookieMaxage, boolean isEncode) {
try {
if (cookieValue == null) {
cookieValue = "";
} else if (isEncode) {
cookieValue = URLEncoder.encode(cookieValue, "utf-8");
}
Cookie cookie = new Cookie(cookieName, cookieValue);
if (cookieMaxage > 0)
cookie.setMaxAge(cookieMaxage);
if (null != request) {// 设置域名的cookie
String domainName = getDomainName(request);
if (!"localhost".equals(domainName)) {
cookie.setDomain(domainName);
}
}
cookie.setPath("/");
cookie.setHttpOnly(true);
response.addCookie(cookie);
} catch (Exception e) {
// logger.error("doSetCookie错误信息:{}",e);
throw new RuntimeException(e);
// e.printStackTrace();
}
}
/**
* Cookie使
*
* @param cookieMaxage cookie
*/
private static final void doSetCookie(HttpServletRequest request, HttpServletResponse response,
String cookieName, String cookieValue, int cookieMaxage, String encodeString) {
try {
if (cookieValue == null) {
cookieValue = "";
} else {
cookieValue = URLEncoder.encode(cookieValue, encodeString);
}
Cookie cookie = new Cookie(cookieName, cookieValue);
if (cookieMaxage > 0)
cookie.setMaxAge(cookieMaxage);
if (null != request) {// 设置域名的cookie
String domainName = getDomainName(request);
System.out.println(domainName);
if (!"localhost".equals(domainName)) {
cookie.setDomain(domainName);
}
}
cookie.setPath("/");
response.addCookie(cookie);
} catch (Exception e) {
// logger.error("doSetCookie错误信息:{}",e);
throw new RuntimeException(e);
// e.printStackTrace();
}
}
/**
* cookie
*/
public static final String getDomainName(HttpServletRequest request) {
String domainName = null;
String serverName = request.getRequestURL().toString();
if (serverName == null || serverName.equals("")) {
domainName = "";
} else {
serverName = serverName.toLowerCase();
serverName = serverName.substring(7);
final int end = serverName.indexOf("/");
serverName = serverName.substring(0, end);
final String[] domains = serverName.split("\\.");
int len = domains.length;
if (len > 3) {
// www.xxx.com.cn
domainName = domains[len - 3] + "." + domains[len - 2] + "." + domains[len - 1];
} else if (len <= 3 && len > 1) {
// xxx.com or xxx.cn
domainName = domains[len - 2] + "." + domains[len - 1];
} else {
domainName = serverName;
}
}
if (domainName != null && domainName.indexOf(":") > 0) {
String[] ary = domainName.split("\\:");
domainName = ary[0];
}
return domainName;
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,69 @@
package com.passuser.net.utils;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.security.NoSuchAlgorithmException;
import java.util.Scanner;
public class Generatingkey {
/**
AES
* @return
*/
public static String getAESKey() {
String s1;
KeyGenerator kg = null;
try {
kg = KeyGenerator.getInstance("AES");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
kg.init(128);
//要生成多少位只需要修改这里即可128, 192或256
SecretKey sk = kg.generateKey();
byte[] b = sk.getEncoded();
s1 = byteToHexString(b);
// System.out.println("随机生成的密钥长度:"+s1.length()*4);
// System.out.println("密钥:"+s1);
return s1;
}
public static String getDESKey() {
String s1;
KeyGenerator kg = null;
try {
kg = KeyGenerator.getInstance("DES");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
kg.init(56);
//要生成多少位只需要修改这里即可128, 192或256
SecretKey sk = kg.generateKey();
byte[] b = sk.getEncoded();
s1 = byteToHexString(b);
// System.out.println("随机生成的密钥长度:"+s1.length()*4);
// System.out.println("密钥:"+s1);
return s1;
}
/**
byte16
*/
public static String byteToHexString(byte[] bytes) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
String strHex=Integer.toHexString(bytes[i]);
if(strHex.length() > 3) {
sb.append(strHex.substring(6));
} else {
if(strHex.length() < 2) {
sb.append("0" + strHex);
} else {
sb.append(strHex);
}
}
}
return sb.toString();
}
}

@ -0,0 +1,129 @@
package com.passuser.net.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Slf4j
public class HttpUtils {
private static final String ENCODING = "UTF-8";
public static String post(String url, Map<String, String> paramsMap) {
CloseableHttpClient client = HttpClients.createDefault();
String responseText = "";
CloseableHttpResponse response = null;
try {
HttpPost method = new HttpPost(url);
if (paramsMap != null) {
List<NameValuePair> paramList = new ArrayList<NameValuePair>();
for (Map.Entry<String, String> param : paramsMap.entrySet()) {
NameValuePair pair = new BasicNameValuePair(param.getKey(), param.getValue());
paramList.add(pair);
}
method.setEntity(new UrlEncodedFormEntity(paramList, ENCODING));
}
response = client.execute(method);
HttpEntity entity = response.getEntity();
if (entity != null) {
responseText = EntityUtils.toString(entity);
}
} catch (Exception e) {
log.error("http request failed",e);
} finally {
try {
response.close();
} catch (Exception e) {
log.error("",e);
}
}
return responseText;
}
public static String get(String url, Map<String, String> paramsMap) {
CloseableHttpClient client = HttpClients.createDefault();
String responseText = "";
CloseableHttpResponse response = null;
try {
String getUrl = url+"?";
if (paramsMap != null) {
for (Map.Entry<String, String> param : paramsMap.entrySet()) {
getUrl += param.getKey() + "=" + URLEncoder.encode(param.getValue(), ENCODING)+"&";
}
}
HttpGet method = new HttpGet(getUrl);
response = client.execute(method);
HttpEntity entity = response.getEntity();
if (entity != null) {
responseText = EntityUtils.toString(entity);
}
} catch (Exception e) {
log.error("http request failed",e);
} finally {
try {
response.close();
} catch (Exception e) {
log.error("",e);
}
}
return responseText;
}
//post请求参数为json格式
public static String HttpPostWithJson(String url, String json) {
String returnValue = "这是默认返回值,接口调用失败";
CloseableHttpClient httpClient = HttpClients.createDefault();
ResponseHandler<String> responseHandler = new BasicResponseHandler();
try{
//第一步创建HttpClient对象
httpClient = HttpClients.createDefault();
//第二步创建httpPost对象
HttpPost httpPost = new HttpPost(url);
//第三步给httpPost设置JSON格式的参数
StringEntity requestEntity = new StringEntity(json,"utf-8");
requestEntity.setContentEncoding("UTF-8");
httpPost.setHeader("Content-type", "application/json");
httpPost.setEntity(requestEntity);
//第四步发送HttpPost请求获取返回值
returnValue = httpClient.execute(httpPost,responseHandler); //调接口获取返回值时,必须用此方法
}
catch(Exception e)
{
e.printStackTrace();
}
finally {
try {
httpClient.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//第五步:处理返回值
return returnValue;
}
}

@ -0,0 +1,21 @@
package com.passuser.net.utils;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
@Component
public class Md5TokenGenerator implements TokenGenerator {
@Override
public String generate(String... strings) {
long timestamp = System.currentTimeMillis();
String tokenMeta = "";
for (String s : strings) {
tokenMeta = tokenMeta + s;
}
tokenMeta = tokenMeta + timestamp;
String token = DigestUtils.md5DigestAsHex(tokenMeta.getBytes());
return token;
}
}

@ -0,0 +1,49 @@
package com.passuser.net.utils;
import java.util.HashMap;
import java.util.Map;
public class R extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
public R() {
put("code", 200);
}
public static R error() {
return error(500, "未知异常,请联系管理员");
}
public static R error(String msg) {
return error(500, msg);
}
public static R error(int code, String msg) {
R r = new R();
r.put("code", code);
r.put("msg", msg);
return r;
}
public static R ok(String msg) {
R r = new R();
r.put("msg", msg);
return r;
}
public static R ok(Map<String, Object> map) {
R r = new R();
r.putAll(map);
return r;
}
public static R ok() {
return new R();
}
public R put(String key, Object value) {
super.put(key, value);
return this;
}
}

@ -0,0 +1,111 @@
package com.passuser.net.utils;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.util.HashMap;
import java.util.Map;
public class RSAUtils {
public class Keys {
}
public static final String KEY_ALGORITHM = "RSA";
//public static final String SIGNATURE_ALGORITHM = "MD5withRSA";
private static final String PUBLIC_KEY = "RSAPublicKey";
private static final String PRIVATE_KEY = "RSAPrivateKey";
//获得公钥
public static String getPublicKey(Map<String, Object> keyMap) throws Exception {
//获得map中的公钥对象 转为key对象
Key key = (Key) keyMap.get(PUBLIC_KEY);
//byte[] publicKey = key.getEncoded();
//编码返回字符串
return encryptBASE64(key.getEncoded());
}
//获得私钥
public static String getPrivateKey(Map<String, Object> keyMap) throws Exception {
//获得map中的私钥对象 转为key对象
Key key = (Key) keyMap.get(PRIVATE_KEY);
//byte[] privateKey = key.getEncoded();
//编码返回字符串
return encryptBASE64(key.getEncoded());
}
//解码返回byte
public static byte[] decryptBASE64(String key) throws Exception {
return (new BASE64Decoder()).decodeBuffer(key);
}
//编码返回字符串
public static String encryptBASE64(byte[] key) throws Exception {
return (new BASE64Encoder()).encodeBuffer(key);
}
//map对象中存放公私钥
public static Map<String, Object> initKey() throws Exception {
//获得对象 KeyPairGenerator 参数 RSA 1024个字节
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM);
keyPairGen.initialize(1024);
//通过对象 KeyPairGenerator 获取对象KeyPair
KeyPair keyPair = keyPairGen.generateKeyPair();
//通过对象 KeyPair 获取RSA公私钥对象RSAPublicKey RSAPrivateKey
RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
//公私钥对象存入map中
Map<String, Object> keyMap = new HashMap<String, Object>(2);
keyMap.put(PUBLIC_KEY, publicKey);
keyMap.put(PRIVATE_KEY, privateKey);
return keyMap;
}
public static String getPriKey() throws Exception {
Map<String, Object> keyMap;
keyMap = initKey();
//String publicKey = getPublicKey(keyMap);
//System.out.println(publicKey);
String privateKey = getPrivateKey(keyMap);
//System.out.println(privateKey);
//return privateKey;
return privateKey;
}
public static String getPubKey() throws Exception {
Map<String, Object> keyMap;
keyMap = initKey();
String publicKey = getPublicKey(keyMap);
//System.out.println(publicKey);
//String privateKey = getPrivateKey(keyMap);
//System.out.println(privateKey);
return publicKey;
}
/*
public static void main(String[] args) {
try {
String privateKey =getPriKey();
String publicKey =getPubKey();
System.out.println(publicKey);
System.out.println(privateKey);
} catch (Exception e) {
e.printStackTrace();
}
}
*/
}

@ -0,0 +1,29 @@
package com.passuser.net.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.concurrent.TimeUnit;
public class RedisTokenUtil {
@Autowired
Md5TokenGenerator tokenGenerator;
@Autowired
private static RedisTemplate<String,String> redisUtil;
public String returnToken(String username,String password){
String token = tokenGenerator.generate(username, password);
redisUtil.opsForValue().set(username, token);
//设置key生存时间当key过期时它会被自动删除时间是秒
redisUtil.expire(username, ConstantKit.TOKEN_EXPIRE_TIME, TimeUnit.MINUTES);
redisUtil.opsForValue().set(token, username);
redisUtil.expire(token, ConstantKit.TOKEN_EXPIRE_TIME,TimeUnit.MINUTES);
Long currentTime = System.currentTimeMillis();
redisUtil.opsForValue().set(token + username, currentTime.toString());
//用完关闭
return token;
}
}

@ -0,0 +1,231 @@
package com.passuser.net.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Component
public class RedisUtils {
private RedisUtils() {
}
@Autowired
private static RedisTemplate<String, String> redisTemplate;
/**
*
*
* @param key Redis
* @param timeout
* @return true=false=
*/
public static boolean expire(final String key, final long timeout) {
return expire(key, timeout, TimeUnit.SECONDS);
}
/**
*
*
* @param key Redis
* @param timeout
* @param unit
* @return true=false=
*/
public static boolean expire(final String key, final long timeout, final TimeUnit unit) {
Boolean ret = redisTemplate.expire(key, timeout, unit);
return ret != null && ret;
}
/**
* key
*
* @param key
* @return true=false=
*/
public static boolean del(final String key) {
Boolean ret = redisTemplate.delete(key);
return ret != null && ret;
}
/**
* key
*
* @param keys
* @return
*/
public static long del(final Collection<String> keys) {
Long ret = redisTemplate.delete(keys);
return ret == null ? 0 : ret;
}
/**
*
*
* @param key Redis
* @param value
*/
public static void set(final String key, final String value) {
redisTemplate.opsForValue().set(key, value, 1, TimeUnit.MINUTES);
}
// 存储普通对象操作
/**
*
*
* @param key
* @param value
* @param timeout
*/
public static void set(final String key, final String value, final long timeout) {
redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.SECONDS);
}
/**
*
*
* @param key
* @return
*/
public static String get(final String key) {
return redisTemplate.opsForValue().get(key);
}
// 存储Hash操作
/**
* Hash
*
* @param key Redis
* @param hKey Hash
* @param value
*/
public static void hPut(final String key, final String hKey, final Object value) {
redisTemplate.opsForHash().put(key, hKey, value);
}
/**
* Hash
*
* @param key Redis
* @param values Hash
*/
public static void hPutAll(final String key, final Map<String, Object> values) {
redisTemplate.opsForHash().putAll(key, values);
}
/**
* Hash
*
* @param key Redis
* @param hKey Hash
* @return Hash
*/
public static Object hGet(final String key, final String hKey) {
return redisTemplate.opsForHash().get(key, hKey);
}
/**
* Hash
*
* @param key Redis
* @param hKeys Hash
* @return Hash
*/
public static List<Object> hMultiGet(final String key, final Collection<Object> hKeys) {
return redisTemplate.opsForHash().multiGet(key, hKeys);
}
// 存储Set相关操作
/**
* Set
*
* @param key Redis
* @param values
* @return
*/
public static long sSet(final String key, final String... values) {
Long count = redisTemplate.opsForSet().add(key, values);
return count == null ? 0 : count;
}
/**
* Set
*
* @param key Redis
* @param values
* @return
*/
public static long sDel(final String key, final String... values) {
Long count = redisTemplate.opsForSet().remove(key, values);
return count == null ? 0 : count;
}
// 存储List相关操作
/**
* List
*
* @param key Redis
* @param value
* @return
*/
public static long lPush(final String key, final String value) {
Long count = redisTemplate.opsForList().rightPush(key, value);
return count == null ? 0 : count;
}
/**
* List
*
* @param key Redis
* @param values
* @return
*/
public static long lPushAll(final String key, final Collection<String> values) {
Long count = redisTemplate.opsForList().rightPushAll(key, values);
return count == null ? 0 : count;
}
/**
* List
*
* @param key Redis
* @param values
* @return
*/
public static long lPushAll(final String key, final String... values) {
Long count = redisTemplate.opsForList().rightPushAll(key, values);
return count == null ? 0 : count;
}
/**
* Listbeginend
*
* @param key Redis
* @param start
* @param end start=0end=-1
* @return List
*/
public static List<String> lGet(final String key, final int start, final int end) {
return redisTemplate.opsForList().range(key, start, end);
}
}

@ -0,0 +1,111 @@
package com.passuser.net.utils;
import com.google.gson.Gson;
import com.passuser.net.KeyUtils.Sm4Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class ResolveResponUtils {
@Autowired
private RedisTemplate<String,String> redisTemplate;
@Autowired
private Map<String ,Object> map = new HashMap<>();
public Map<String ,Object> resolveGetRespons(String url, Map<String, String> paramsMap){
String getRanStr = HttpUtils.get(url, paramsMap);
return getResponse(getRanStr);
}
public Map<String ,Object> resolvePostRespons(String url, Map<String, String> paramsMap){
String getRanStr = HttpUtils.post(url, paramsMap);
return getResponse(getRanStr);
}
public Map<String ,Object> resolvePostJsonRespons(String url, String postJson){
String getRanStr = HttpUtils.HttpPostWithJson(url, postJson);
return getResponse(getRanStr);
}
public String getGetResponseData(String url,Map<String, String> paramsMap, String dataKey) throws Exception {
String getRanStr = HttpUtils.get(url, paramsMap);
return dealGetResponseData(dataKey, getRanStr);
}
public String getPostJsonResponseData(String url,String postJson, String dataKey) throws Exception {
String getRanStr = HttpUtils.HttpPostWithJson(url, postJson);
return dealGetResponseData(dataKey, getRanStr);
}
public String getPostResponseData(String url,Map<String, String> paramsMap, String dataKey) throws Exception {
String getRanStr = HttpUtils.post(url, paramsMap);
return dealGetResponseData(dataKey, getRanStr);
}
public Map<String ,String> getGetResponseDecryptData(String url,Map<String, String> paramsMap, List<String> dataKey) throws Exception {
String getRanStr = HttpUtils.get(url, paramsMap);
return dealResponseDecryptData(getRanStr,dataKey);
}
public Map<String ,String> getPostResponseDecryptData(String url,Map<String, String> paramsMap, List<String> dataKey) throws Exception {
String getRanStr = HttpUtils.post(url, paramsMap);
return dealResponseDecryptData( getRanStr,dataKey);
}
public Map<String ,String> getPostJsonResponseDecryptData(String url, String postjson, List<String> dataKey) throws Exception {
String getRanStr = HttpUtils.HttpPostWithJson(url, postjson);
return dealResponseDecryptData( getRanStr,dataKey);
}
private Map<String ,String> dealResponseDecryptData(String getRanStr, List<String> dataKey) throws Exception {
String sessionkey = redisTemplate.opsForValue().get("sessionkey");
Map<String ,Object> response = getResponse(getRanStr);
Map<String ,String> perDatas = new HashMap<>();
if(response!= null){
for (String key : dataKey) {
perDatas.put(key,Sm4Util.decryptEcb(sessionkey, response.get(key).toString()));
}
}else{
throw new Exception("Response is not defined");
}
return perDatas;
}
private String dealResponseListDecryptData(String dataKey, String getRanStr) throws Exception {
String sessionkey = redisTemplate.opsForValue().get("sessionkey");
Map<String ,Object> response = getResponse(getRanStr);
String perData = "";
if(response!= null){
perData = Sm4Util.decryptEcb(sessionkey, response.get(dataKey).toString());
}else{
throw new Exception("Response is not defined");
}
return perData;
}
private String dealGetResponseData(String dataKey, String getRanStr) {
Map<String, Object> response = getResponse(getRanStr);
String perData;
if (response != null) {
perData = response.get(dataKey).toString();
} else {
throw new NullPointerException("Response is not defined");
}
return perData;
}
private Map<String ,Object> getResponse(String getRanStr) {
Gson gson = new Gson();
return gson.fromJson(getRanStr, map.getClass());
}
}

@ -0,0 +1,111 @@
package com.passuser.net.utils;/*
*/
import java.security.NoSuchAlgorithmException;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.util.Scanner;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.security.Key;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.KeyGenerator;
public class ThroughUserkey {
/**
* @return
*/
public static String getAESKey() {
String s1;
KeyGenerator kg = null;
try {
kg = KeyGenerator.getInstance("AES");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
kg.init(128);
//要生成多少位只需要修改这里即可128, 192或256
SecretKey sk = kg.generateKey();
byte[] b = sk.getEncoded();
s1 = byteToHexString(b);
// System.out.println("随机生成的密钥长度:"+s1.length()*4);
// System.out.println("密钥:"+s1);
return s1;
}
public static String getDESKey() {
String s1;
KeyGenerator kg = null;
try {
kg = KeyGenerator.getInstance("DES");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
kg.init(56);
//要生成多少位只需要修改这里即可128, 192或256
SecretKey sk = kg.generateKey();
byte[] b = sk.getEncoded();
s1 = byteToHexString(b);
// System.out.println("随机生成的密钥长度:"+s1.length()*4);
// System.out.println("密钥:"+s1);
return s1;
}
/**
使
* @return
*/
public static String getKeyByPass(String password) {
//生成秘钥
KeyGenerator kg = null;
try {
kg = KeyGenerator.getInstance("AES");
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
//SecureRandom是生成安全随机数序列password.getBytes()是种子,只要种子相同,序列就一样,所以生成的秘钥就一样。
//System.out.println("输入指定字符串生成的密钥的长度:");
//int i=input.nextInt();
kg.init(128, new SecureRandom(password.getBytes()));
SecretKey sk = kg.generateKey();
byte[] b = sk.getEncoded();
String s2 = byteToHexString(b);
// System.out.println("指定字符串生成的密钥长度:"+s2.length()*4);
// System.out.println("密钥:"+s2);
return s2;
}
/**
byte16
*/
public static String byteToHexString(byte[] bytes) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
String strHex=Integer.toHexString(bytes[i]);
if(strHex.length() > 3) {
sb.append(strHex.substring(6));
} else {
if(strHex.length() < 2) {
sb.append("0" + strHex);
} else {
sb.append(strHex);
}
}
}
return sb.toString();
}
}

@ -0,0 +1,10 @@
package com.passuser.net.utils;
import org.springframework.stereotype.Component;
@Component
public interface TokenGenerator {
public String generate(String... strings);
}

@ -0,0 +1,37 @@
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5></h5>
</div>
<div class="ibox-content">
<div class="row row-lg">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3">
<#NameCon id="condition" name="名称" />
</div>
<div class="col-sm-3">
<#button name="搜索" icon="fa-search" clickFun="PassInstant.search()"/>
</div>
</div>
<div class="hidden-xs" id="PassInstantTableToolbar" role="group">
@if(shiro.hasPermission("/passInstant/add")){
<#button name="添加" icon="fa-plus" clickFun="PassInstant.openAddPassInstant()"/>
@}
@if(shiro.hasPermission("/passInstant/update")){
<#button name="修改" icon="fa-edit" clickFun="PassInstant.openPassInstantDetail()" space="true"/>
@}
@if(shiro.hasPermission("/passInstant/delete")){
<#button name="删除" icon="fa-remove" clickFun="PassInstant.delete()" space="true"/>
@}
</div>
<#table id="PassInstantTable"/>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="${ctxPath}/static/modular/PassInstant/passInstant/passInstant.js"></script>
@}

@ -0,0 +1,35 @@
@layout("/common/_container.html"){
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="form-horizontal">
<div class="row">
<div class="col-sm-6 b-r">
<#input id="passId" name="密钥UUID" underline="true"/>
<#input id="passName" name="密钥名称" underline="true"/>
<#input id="passLength" name="密钥长度" underline="true"/>
<#input id="passType" name="密钥类型" underline="true"/>
<#input id="passChildfir" name="第一子密钥"/>
</div>
<div class="col-sm-6">
<#input id="passChildsec" name="第二子密钥" underline="true"/>
<#input id="passChildthi" name="第三子密钥" underline="true"/>
<#input id="passExpiry" name="密钥有效期" underline="true"/>
<#input id="passCreatetime" name="密钥上传时间" underline="true"/>
<#input id="passUserid" name="密钥用户" underline="true"/>
</div>
</div>
<div class="row btn-group-m-t">
<div class="col-sm-10">
<#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="PassInstantInfoDlg.addSubmit()"/>
<#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="PassInstantInfoDlg.close()"/>
</div>
</div>
</div>
</div>
</div>
<script src="${ctxPath}/static/modular/PassInstant/passInstant/passInstant_info.js"></script>
@}

@ -0,0 +1,35 @@
@layout("/common/_container.html"){
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="form-horizontal">
<div class="row">
<div class="col-sm-6 b-r">
<#input id="passId" name="密钥UUID" value="${item.passId}" underline="true"/>
<#input id="passName" name="密钥名称" value="${item.passName}" underline="true"/>
<#input id="passLength" name="密钥长度" value="${item.passLength}" underline="true"/>
<#input id="passType" name="密钥类型" value="${item.passType}" underline="true"/>
<#input id="passChildfir" name="第一子密钥" value="${item.passChildfir}" />
</div>
<div class="col-sm-6">
<#input id="passChildsec" name="第二子密钥" value="${item.passChildsec}" underline="true"/>
<#input id="passChildthi" name="第三子密钥" value="${item.passChildthi}" underline="true"/>
<#input id="passExpiry" name="密钥有效期" value="${item.passExpiry}" underline="true"/>
<#input id="passCreatetime" name="密钥上传时间" value="${item.passCreatetime}" underline="true"/>
<#input id="passUserid" name="密钥用户" value="${item.passUserid}" />
</div>
</div>
<div class="row btn-group-m-t">
<div class="col-sm-10">
<#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="PassInstantInfoDlg.editSubmit()"/>
<#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="PassInstantInfoDlg.close()"/>
</div>
</div>
</div>
</div>
</div>
<script src="${ctxPath}/static/modular/PassInstant/passInstant/passInstant_info.js"></script>
@}

@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> - </title>
<link rel="shortcut icon" href="${ctxPath}/static/favicon.ico">
<link href="${ctxPath}/static/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="${ctxPath}/static/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="${ctxPath}/static/css/style.css?v=4.1.0" rel="stylesheet">
<script>if (window.top !== window.self) {
window.top.location = window.location;
}</script>
<script src="${ctxPath}/static/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctxPath}/static/js/bootstrap.min.js?v=3.3.6"></script>
</head>
<body class="gray-bg">
<div class="middle-box text-center loginscreen">
<div style="padding: 100px 0px;">
<div>
<h2>使</h2>
<!--<h1 class="logo-name"></h1>-->
</div>
<h3></h3>
<!--<h3>使</h3>-->
<br/>
<h4 style="color: red;">${tips!}</h4>
<form class="m-t" role="form" action="${ctxPath}/login" method="post">
<div class="form-group">
<input type="text" name="username" class="form-control" placeholder="用户名" required="">
</div>
<div class="form-group">
<input type="password" name="password" class="form-control" placeholder="密码" required="">
</div>
<div class="form-group" style="float: left;">
<div class="checkbox" style="text-align: left">
<label>
<input type="checkbox" name="remember" style="margin-top: 2px;">
</label>
</div>
</div>
<button type="submit" class="btn btn-primary block full-width m-b"> </button>
</p>
</form>
</div>
</div>
<script>
$(function () {
$("#kaptcha").on('click', function () {
$("#kaptcha").attr('src', '${ctxPath}/kaptcha?' + Math.floor(Math.random() * 100)).fadeIn();
});
});
</script>
</body>
</html>

@ -0,0 +1,587 @@
/*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
.btn-default,
.btn-primary,
.btn-success,
.btn-info,
.btn-warning,
.btn-danger {
text-shadow: 0 -1px 0 rgba(0, 0, 0, .2);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);
}
.btn-default:active,
.btn-primary:active,
.btn-success:active,
.btn-info:active,
.btn-warning:active,
.btn-danger:active,
.btn-default.active,
.btn-primary.active,
.btn-success.active,
.btn-info.active,
.btn-warning.active,
.btn-danger.active {
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
}
.btn-default.disabled,
.btn-primary.disabled,
.btn-success.disabled,
.btn-info.disabled,
.btn-warning.disabled,
.btn-danger.disabled,
.btn-default[disabled],
.btn-primary[disabled],
.btn-success[disabled],
.btn-info[disabled],
.btn-warning[disabled],
.btn-danger[disabled],
fieldset[disabled] .btn-default,
fieldset[disabled] .btn-primary,
fieldset[disabled] .btn-success,
fieldset[disabled] .btn-info,
fieldset[disabled] .btn-warning,
fieldset[disabled] .btn-danger {
-webkit-box-shadow: none;
box-shadow: none;
}
.btn-default .badge,
.btn-primary .badge,
.btn-success .badge,
.btn-info .badge,
.btn-warning .badge,
.btn-danger .badge {
text-shadow: none;
}
.btn:active,
.btn.active {
background-image: none;
}
.btn-default {
text-shadow: 0 1px 0 #fff;
background-image: -webkit-linear-gradient(top, #fff 0%, #e0e0e0 100%);
background-image: -o-linear-gradient(top, #fff 0%, #e0e0e0 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#e0e0e0));
background-image: linear-gradient(to bottom, #fff 0%, #e0e0e0 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
background-repeat: repeat-x;
border-color: #dbdbdb;
border-color: #ccc;
}
.btn-default:hover,
.btn-default:focus {
background-color: #e0e0e0;
background-position: 0 -15px;
}
.btn-default:active,
.btn-default.active {
background-color: #e0e0e0;
border-color: #dbdbdb;
}
.btn-default.disabled,
.btn-default[disabled],
fieldset[disabled] .btn-default,
.btn-default.disabled:hover,
.btn-default[disabled]:hover,
fieldset[disabled] .btn-default:hover,
.btn-default.disabled:focus,
.btn-default[disabled]:focus,
fieldset[disabled] .btn-default:focus,
.btn-default.disabled.focus,
.btn-default[disabled].focus,
fieldset[disabled] .btn-default.focus,
.btn-default.disabled:active,
.btn-default[disabled]:active,
fieldset[disabled] .btn-default:active,
.btn-default.disabled.active,
.btn-default[disabled].active,
fieldset[disabled] .btn-default.active {
background-color: #e0e0e0;
background-image: none;
}
.btn-primary {
background-image: -webkit-linear-gradient(top, #337ab7 0%, #265a88 100%);
background-image: -o-linear-gradient(top, #337ab7 0%, #265a88 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#265a88));
background-image: linear-gradient(to bottom, #337ab7 0%, #265a88 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff265a88', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
background-repeat: repeat-x;
border-color: #245580;
}
.btn-primary:hover,
.btn-primary:focus {
background-color: #265a88;
background-position: 0 -15px;
}
.btn-primary:active,
.btn-primary.active {
background-color: #265a88;
border-color: #245580;
}
.btn-primary.disabled,
.btn-primary[disabled],
fieldset[disabled] .btn-primary,
.btn-primary.disabled:hover,
.btn-primary[disabled]:hover,
fieldset[disabled] .btn-primary:hover,
.btn-primary.disabled:focus,
.btn-primary[disabled]:focus,
fieldset[disabled] .btn-primary:focus,
.btn-primary.disabled.focus,
.btn-primary[disabled].focus,
fieldset[disabled] .btn-primary.focus,
.btn-primary.disabled:active,
.btn-primary[disabled]:active,
fieldset[disabled] .btn-primary:active,
.btn-primary.disabled.active,
.btn-primary[disabled].active,
fieldset[disabled] .btn-primary.active {
background-color: #265a88;
background-image: none;
}
.btn-success {
background-image: -webkit-linear-gradient(top, #5cb85c 0%, #419641 100%);
background-image: -o-linear-gradient(top, #5cb85c 0%, #419641 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#5cb85c), to(#419641));
background-image: linear-gradient(to bottom, #5cb85c 0%, #419641 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff419641', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
background-repeat: repeat-x;
border-color: #3e8f3e;
}
.btn-success:hover,
.btn-success:focus {
background-color: #419641;
background-position: 0 -15px;
}
.btn-success:active,
.btn-success.active {
background-color: #419641;
border-color: #3e8f3e;
}
.btn-success.disabled,
.btn-success[disabled],
fieldset[disabled] .btn-success,
.btn-success.disabled:hover,
.btn-success[disabled]:hover,
fieldset[disabled] .btn-success:hover,
.btn-success.disabled:focus,
.btn-success[disabled]:focus,
fieldset[disabled] .btn-success:focus,
.btn-success.disabled.focus,
.btn-success[disabled].focus,
fieldset[disabled] .btn-success.focus,
.btn-success.disabled:active,
.btn-success[disabled]:active,
fieldset[disabled] .btn-success:active,
.btn-success.disabled.active,
.btn-success[disabled].active,
fieldset[disabled] .btn-success.active {
background-color: #419641;
background-image: none;
}
.btn-info {
background-image: -webkit-linear-gradient(top, #5bc0de 0%, #2aabd2 100%);
background-image: -o-linear-gradient(top, #5bc0de 0%, #2aabd2 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#5bc0de), to(#2aabd2));
background-image: linear-gradient(to bottom, #5bc0de 0%, #2aabd2 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2aabd2', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
background-repeat: repeat-x;
border-color: #28a4c9;
}
.btn-info:hover,
.btn-info:focus {
background-color: #2aabd2;
background-position: 0 -15px;
}
.btn-info:active,
.btn-info.active {
background-color: #2aabd2;
border-color: #28a4c9;
}
.btn-info.disabled,
.btn-info[disabled],
fieldset[disabled] .btn-info,
.btn-info.disabled:hover,
.btn-info[disabled]:hover,
fieldset[disabled] .btn-info:hover,
.btn-info.disabled:focus,
.btn-info[disabled]:focus,
fieldset[disabled] .btn-info:focus,
.btn-info.disabled.focus,
.btn-info[disabled].focus,
fieldset[disabled] .btn-info.focus,
.btn-info.disabled:active,
.btn-info[disabled]:active,
fieldset[disabled] .btn-info:active,
.btn-info.disabled.active,
.btn-info[disabled].active,
fieldset[disabled] .btn-info.active {
background-color: #2aabd2;
background-image: none;
}
.btn-warning {
background-image: -webkit-linear-gradient(top, #f0ad4e 0%, #eb9316 100%);
background-image: -o-linear-gradient(top, #f0ad4e 0%, #eb9316 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#f0ad4e), to(#eb9316));
background-image: linear-gradient(to bottom, #f0ad4e 0%, #eb9316 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffeb9316', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
background-repeat: repeat-x;
border-color: #e38d13;
}
.btn-warning:hover,
.btn-warning:focus {
background-color: #eb9316;
background-position: 0 -15px;
}
.btn-warning:active,
.btn-warning.active {
background-color: #eb9316;
border-color: #e38d13;
}
.btn-warning.disabled,
.btn-warning[disabled],
fieldset[disabled] .btn-warning,
.btn-warning.disabled:hover,
.btn-warning[disabled]:hover,
fieldset[disabled] .btn-warning:hover,
.btn-warning.disabled:focus,
.btn-warning[disabled]:focus,
fieldset[disabled] .btn-warning:focus,
.btn-warning.disabled.focus,
.btn-warning[disabled].focus,
fieldset[disabled] .btn-warning.focus,
.btn-warning.disabled:active,
.btn-warning[disabled]:active,
fieldset[disabled] .btn-warning:active,
.btn-warning.disabled.active,
.btn-warning[disabled].active,
fieldset[disabled] .btn-warning.active {
background-color: #eb9316;
background-image: none;
}
.btn-danger {
background-image: -webkit-linear-gradient(top, #d9534f 0%, #c12e2a 100%);
background-image: -o-linear-gradient(top, #d9534f 0%, #c12e2a 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#d9534f), to(#c12e2a));
background-image: linear-gradient(to bottom, #d9534f 0%, #c12e2a 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc12e2a', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
background-repeat: repeat-x;
border-color: #b92c28;
}
.btn-danger:hover,
.btn-danger:focus {
background-color: #c12e2a;
background-position: 0 -15px;
}
.btn-danger:active,
.btn-danger.active {
background-color: #c12e2a;
border-color: #b92c28;
}
.btn-danger.disabled,
.btn-danger[disabled],
fieldset[disabled] .btn-danger,
.btn-danger.disabled:hover,
.btn-danger[disabled]:hover,
fieldset[disabled] .btn-danger:hover,
.btn-danger.disabled:focus,
.btn-danger[disabled]:focus,
fieldset[disabled] .btn-danger:focus,
.btn-danger.disabled.focus,
.btn-danger[disabled].focus,
fieldset[disabled] .btn-danger.focus,
.btn-danger.disabled:active,
.btn-danger[disabled]:active,
fieldset[disabled] .btn-danger:active,
.btn-danger.disabled.active,
.btn-danger[disabled].active,
fieldset[disabled] .btn-danger.active {
background-color: #c12e2a;
background-image: none;
}
.thumbnail,
.img-thumbnail {
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
}
.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus {
background-color: #e8e8e8;
background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
background-image: -o-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e8e8e8));
background-image: linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);
background-repeat: repeat-x;
}
.dropdown-menu > .active > a,
.dropdown-menu > .active > a:hover,
.dropdown-menu > .active > a:focus {
background-color: #2e6da4;
background-image: -webkit-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
background-image: -o-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2e6da4));
background-image: linear-gradient(to bottom, #337ab7 0%, #2e6da4 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);
background-repeat: repeat-x;
}
.navbar-default {
background-image: -webkit-linear-gradient(top, #fff 0%, #f8f8f8 100%);
background-image: -o-linear-gradient(top, #fff 0%, #f8f8f8 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#f8f8f8));
background-image: linear-gradient(to bottom, #fff 0%, #f8f8f8 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff8f8f8', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
background-repeat: repeat-x;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 5px rgba(0, 0, 0, .075);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 5px rgba(0, 0, 0, .075);
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .active > a {
background-image: -webkit-linear-gradient(top, #dbdbdb 0%, #e2e2e2 100%);
background-image: -o-linear-gradient(top, #dbdbdb 0%, #e2e2e2 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#dbdbdb), to(#e2e2e2));
background-image: linear-gradient(to bottom, #dbdbdb 0%, #e2e2e2 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdbdbdb', endColorstr='#ffe2e2e2', GradientType=0);
background-repeat: repeat-x;
-webkit-box-shadow: inset 0 3px 9px rgba(0, 0, 0, .075);
box-shadow: inset 0 3px 9px rgba(0, 0, 0, .075);
}
.navbar-brand,
.navbar-nav > li > a {
text-shadow: 0 1px 0 rgba(255, 255, 255, .25);
}
.navbar-inverse {
background-image: -webkit-linear-gradient(top, #3c3c3c 0%, #222 100%);
background-image: -o-linear-gradient(top, #3c3c3c 0%, #222 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#3c3c3c), to(#222));
background-image: linear-gradient(to bottom, #3c3c3c 0%, #222 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c3c3c', endColorstr='#ff222222', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
background-repeat: repeat-x;
border-radius: 4px;
}
.navbar-inverse .navbar-nav > .open > a,
.navbar-inverse .navbar-nav > .active > a {
background-image: -webkit-linear-gradient(top, #080808 0%, #0f0f0f 100%);
background-image: -o-linear-gradient(top, #080808 0%, #0f0f0f 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#080808), to(#0f0f0f));
background-image: linear-gradient(to bottom, #080808 0%, #0f0f0f 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff080808', endColorstr='#ff0f0f0f', GradientType=0);
background-repeat: repeat-x;
-webkit-box-shadow: inset 0 3px 9px rgba(0, 0, 0, .25);
box-shadow: inset 0 3px 9px rgba(0, 0, 0, .25);
}
.navbar-inverse .navbar-brand,
.navbar-inverse .navbar-nav > li > a {
text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
}
.navbar-static-top,
.navbar-fixed-top,
.navbar-fixed-bottom {
border-radius: 0;
}
@media (max-width: 767px) {
.navbar .navbar-nav .open .dropdown-menu > .active > a,
.navbar .navbar-nav .open .dropdown-menu > .active > a:hover,
.navbar .navbar-nav .open .dropdown-menu > .active > a:focus {
color: #fff;
background-image: -webkit-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
background-image: -o-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2e6da4));
background-image: linear-gradient(to bottom, #337ab7 0%, #2e6da4 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);
background-repeat: repeat-x;
}
}
.alert {
text-shadow: 0 1px 0 rgba(255, 255, 255, .2);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .05);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .05);
}
.alert-success {
background-image: -webkit-linear-gradient(top, #dff0d8 0%, #c8e5bc 100%);
background-image: -o-linear-gradient(top, #dff0d8 0%, #c8e5bc 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#dff0d8), to(#c8e5bc));
background-image: linear-gradient(to bottom, #dff0d8 0%, #c8e5bc 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0);
background-repeat: repeat-x;
border-color: #b2dba1;
}
.alert-info {
background-image: -webkit-linear-gradient(top, #d9edf7 0%, #b9def0 100%);
background-image: -o-linear-gradient(top, #d9edf7 0%, #b9def0 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#d9edf7), to(#b9def0));
background-image: linear-gradient(to bottom, #d9edf7 0%, #b9def0 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0);
background-repeat: repeat-x;
border-color: #9acfea;
}
.alert-warning {
background-image: -webkit-linear-gradient(top, #fcf8e3 0%, #f8efc0 100%);
background-image: -o-linear-gradient(top, #fcf8e3 0%, #f8efc0 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#fcf8e3), to(#f8efc0));
background-image: linear-gradient(to bottom, #fcf8e3 0%, #f8efc0 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0);
background-repeat: repeat-x;
border-color: #f5e79e;
}
.alert-danger {
background-image: -webkit-linear-gradient(top, #f2dede 0%, #e7c3c3 100%);
background-image: -o-linear-gradient(top, #f2dede 0%, #e7c3c3 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#f2dede), to(#e7c3c3));
background-image: linear-gradient(to bottom, #f2dede 0%, #e7c3c3 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0);
background-repeat: repeat-x;
border-color: #dca7a7;
}
.progress {
background-image: -webkit-linear-gradient(top, #ebebeb 0%, #f5f5f5 100%);
background-image: -o-linear-gradient(top, #ebebeb 0%, #f5f5f5 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#ebebeb), to(#f5f5f5));
background-image: linear-gradient(to bottom, #ebebeb 0%, #f5f5f5 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff5f5f5', GradientType=0);
background-repeat: repeat-x;
}
.progress-bar {
background-image: -webkit-linear-gradient(top, #337ab7 0%, #286090 100%);
background-image: -o-linear-gradient(top, #337ab7 0%, #286090 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#286090));
background-image: linear-gradient(to bottom, #337ab7 0%, #286090 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff286090', GradientType=0);
background-repeat: repeat-x;
}
.progress-bar-success {
background-image: -webkit-linear-gradient(top, #5cb85c 0%, #449d44 100%);
background-image: -o-linear-gradient(top, #5cb85c 0%, #449d44 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#5cb85c), to(#449d44));
background-image: linear-gradient(to bottom, #5cb85c 0%, #449d44 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0);
background-repeat: repeat-x;
}
.progress-bar-info {
background-image: -webkit-linear-gradient(top, #5bc0de 0%, #31b0d5 100%);
background-image: -o-linear-gradient(top, #5bc0de 0%, #31b0d5 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#5bc0de), to(#31b0d5));
background-image: linear-gradient(to bottom, #5bc0de 0%, #31b0d5 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0);
background-repeat: repeat-x;
}
.progress-bar-warning {
background-image: -webkit-linear-gradient(top, #f0ad4e 0%, #ec971f 100%);
background-image: -o-linear-gradient(top, #f0ad4e 0%, #ec971f 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#f0ad4e), to(#ec971f));
background-image: linear-gradient(to bottom, #f0ad4e 0%, #ec971f 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0);
background-repeat: repeat-x;
}
.progress-bar-danger {
background-image: -webkit-linear-gradient(top, #d9534f 0%, #c9302c 100%);
background-image: -o-linear-gradient(top, #d9534f 0%, #c9302c 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#d9534f), to(#c9302c));
background-image: linear-gradient(to bottom, #d9534f 0%, #c9302c 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0);
background-repeat: repeat-x;
}
.progress-bar-striped {
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
}
.list-group {
border-radius: 4px;
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
box-shadow: 0 1px 2px rgba(0, 0, 0, .075);
}
.list-group-item.active,
.list-group-item.active:hover,
.list-group-item.active:focus {
text-shadow: 0 -1px 0 #286090;
background-image: -webkit-linear-gradient(top, #337ab7 0%, #2b669a 100%);
background-image: -o-linear-gradient(top, #337ab7 0%, #2b669a 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2b669a));
background-image: linear-gradient(to bottom, #337ab7 0%, #2b669a 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2b669a', GradientType=0);
background-repeat: repeat-x;
border-color: #2b669a;
}
.list-group-item.active .badge,
.list-group-item.active:hover .badge,
.list-group-item.active:focus .badge {
text-shadow: none;
}
.panel {
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
.panel-default > .panel-heading {
background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
background-image: -o-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e8e8e8));
background-image: linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);
background-repeat: repeat-x;
}
.panel-primary > .panel-heading {
background-image: -webkit-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
background-image: -o-linear-gradient(top, #337ab7 0%, #2e6da4 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2e6da4));
background-image: linear-gradient(to bottom, #337ab7 0%, #2e6da4 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);
background-repeat: repeat-x;
}
.panel-success > .panel-heading {
background-image: -webkit-linear-gradient(top, #dff0d8 0%, #d0e9c6 100%);
background-image: -o-linear-gradient(top, #dff0d8 0%, #d0e9c6 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#dff0d8), to(#d0e9c6));
background-image: linear-gradient(to bottom, #dff0d8 0%, #d0e9c6 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffd0e9c6', GradientType=0);
background-repeat: repeat-x;
}
.panel-info > .panel-heading {
background-image: -webkit-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%);
background-image: -o-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#d9edf7), to(#c4e3f3));
background-image: linear-gradient(to bottom, #d9edf7 0%, #c4e3f3 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffc4e3f3', GradientType=0);
background-repeat: repeat-x;
}
.panel-warning > .panel-heading {
background-image: -webkit-linear-gradient(top, #fcf8e3 0%, #faf2cc 100%);
background-image: -o-linear-gradient(top, #fcf8e3 0%, #faf2cc 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#fcf8e3), to(#faf2cc));
background-image: linear-gradient(to bottom, #fcf8e3 0%, #faf2cc 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fffaf2cc', GradientType=0);
background-repeat: repeat-x;
}
.panel-danger > .panel-heading {
background-image: -webkit-linear-gradient(top, #f2dede 0%, #ebcccc 100%);
background-image: -o-linear-gradient(top, #f2dede 0%, #ebcccc 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#f2dede), to(#ebcccc));
background-image: linear-gradient(to bottom, #f2dede 0%, #ebcccc 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffebcccc', GradientType=0);
background-repeat: repeat-x;
}
.well {
background-image: -webkit-linear-gradient(top, #e8e8e8 0%, #f5f5f5 100%);
background-image: -o-linear-gradient(top, #e8e8e8 0%, #f5f5f5 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#e8e8e8), to(#f5f5f5));
background-image: linear-gradient(to bottom, #e8e8e8 0%, #f5f5f5 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8', endColorstr='#fff5f5f5', GradientType=0);
background-repeat: repeat-x;
border-color: #dcdcdc;
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05), 0 1px 0 rgba(255, 255, 255, .1);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05), 0 1px 0 rgba(255, 255, 255, .1);
}
/*# sourceMappingURL=bootstrap-theme.css.map */

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save