Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zlb-wechat
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhoushaopan
zlb-wechat
Commits
ab2dd9b7
提交
ab2dd9b7
authored
9月 06, 2022
作者:
zhoushaopan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
初始化
上级
隐藏空白字符变更
内嵌
并排
正在显示
25 个修改的文件
包含
1558 行增加
和
0 行删除
+1558
-0
.gitignore
.gitignore
+33
-0
maven-wrapper.jar
.mvn/wrapper/maven-wrapper.jar
+0
-0
maven-wrapper.properties
.mvn/wrapper/maven-wrapper.properties
+2
-0
mvnw
mvnw
+316
-0
mvnw.cmd
mvnw.cmd
+188
-0
pom.xml
pom.xml
+77
-0
ZlbApplication.java
src/main/java/com/tykj/zlb/ZlbApplication.java
+32
-0
ResultObj.java
src/main/java/com/tykj/zlb/base/ResultObj.java
+30
-0
WebMvcConfig.java
src/main/java/com/tykj/zlb/config/WebMvcConfig.java
+32
-0
ZlbConfig.java
src/main/java/com/tykj/zlb/config/ZlbConfig.java
+19
-0
Constants.java
src/main/java/com/tykj/zlb/contants/Constants.java
+64
-0
ApiException.java
src/main/java/com/tykj/zlb/exception/ApiException.java
+35
-0
GlobalExceptionHandler.java
...n/java/com/tykj/zlb/exception/GlobalExceptionHandler.java
+31
-0
ZlbController.java
...n/java/com/tykj/zlb/subject/controller/ZlbController.java
+62
-0
ZlbAuthService.java
...ain/java/com/tykj/zlb/subject/service/ZlbAuthService.java
+26
-0
ZlbAuthServiceImpl.java
...com/tykj/zlb/subject/service/impl/ZlbAuthServiceImpl.java
+74
-0
Swagger2Config.java
src/main/java/com/tykj/zlb/swagger/Swagger2Config.java
+77
-0
HmacAuthUtil.java
src/main/java/com/tykj/zlb/util/HmacAuthUtil.java
+128
-0
IrsSignRes.java
src/main/java/com/tykj/zlb/util/IrsSignRes.java
+15
-0
IrsUtils.java
src/main/java/com/tykj/zlb/util/IrsUtils.java
+78
-0
MD5Util.java
src/main/java/com/tykj/zlb/util/MD5Util.java
+174
-0
UnifiedReturnConfig.java
src/main/java/com/tykj/zlb/util/UnifiedReturnConfig.java
+50
-0
application-dev.properties
src/main/resources/application-dev.properties
+1
-0
application.properties
src/main/resources/application.properties
+1
-0
ZlbApplicationTests.java
src/test/java/com/tykj/zlb/ZlbApplicationTests.java
+13
-0
没有找到文件。
.gitignore
0 → 100644
浏览文件 @
ab2dd9b7
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### 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/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
.mvn/wrapper/maven-wrapper.jar
0 → 100644
浏览文件 @
ab2dd9b7
File added
.mvn/wrapper/maven-wrapper.properties
0 → 100644
浏览文件 @
ab2dd9b7
distributionUrl
=
https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
wrapperUrl
=
https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
mvnw
0 → 100644
浏览文件 @
ab2dd9b7
#!/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
/usr/local/etc/mavenrc
]
;
then
.
/usr/local/etc/mavenrc
fi
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
=
"
`
\\
unset
-f
command
;
\\
command
-v
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
/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
else
jarUrl
=
"https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.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
"
||
rm
-f
"
$wrapperJarPath
"
else
wget
--http-user
=
$MVNW_USERNAME
--http-password
=
$MVNW_PASSWORD
"
$jarUrl
"
-O
"
$wrapperJarPath
"
||
rm
-f
"
$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
\
$MAVEN_DEBUG_OPTS
\
-classpath
"
$MAVEN_PROJECTBASEDIR
/.mvn/wrapper/maven-wrapper.jar"
\
"-Dmaven.home=
${
M2_HOME
}
"
\
"-Dmaven.multiModuleProjectDirectory=
${
MAVEN_PROJECTBASEDIR
}
"
\
${
WRAPPER_LAUNCHER
}
$MAVEN_CONFIG
"
$@
"
mvnw.cmd
0 → 100644
浏览文件 @
ab2dd9b7
@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 "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\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/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
FOR /F "usebackq 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%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.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 "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\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%
cmd /C exit /B %ERROR_CODE%
pom.xml
0 → 100644
浏览文件 @
ab2dd9b7
<?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.4.1
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
com.tykj
</groupId>
<artifactId>
zlb
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
zlb
</name>
<description>
zlb
</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>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.session
</groupId>
<artifactId>
spring-session-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.79
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
2.9.2
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
2.9.2
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
src/main/java/com/tykj/zlb/ZlbApplication.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tykj.zlb.subject.service.ZlbAuthService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
@SpringBootApplication
@Slf4j
public
class
ZlbApplication
{
@Resource
private
ZlbAuthService
zlbAuthService
;
// @PostConstruct
// public void test(){
// log.info("开始初始化");
// String tokenByTicketId = zlbAuthService.getTokenByTicketId("8a1189378293164f0182c9e6426e2ef2-ticket");
// log.info("tokenByTicketId:{}",tokenByTicketId);
// JSONObject userInfoByToken = zlbAuthService.getUserInfoByToken(tokenByTicketId);
//
// }
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
ZlbApplication
.
class
,
args
);
}
}
src/main/java/com/tykj/zlb/base/ResultObj.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
base
;
import
com.fasterxml.jackson.annotation.JsonPropertyOrder
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author dengdiyi
* @description 接口返回统一标准类
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonPropertyOrder
(
value
=
{
"message"
,
"data"
})
public
class
ResultObj
<
T
>
{
private
T
data
;
private
String
message
;
public
ResultObj
(
T
o
)
{
this
.
data
=
o
;
this
.
message
=
"no message"
;
}
public
ResultObj
(
String
m
)
{
this
.
message
=
m
;
}
}
src/main/java/com/tykj/zlb/config/WebMvcConfig.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
/**
* @author zsp
* @version V1.0
* @data 2020/6/11
**/
@Configuration
public
class
WebMvcConfig
{
@Bean
public
WebMvcConfigurer
corsConfigurer
()
{
return
new
WebMvcConfigurer
()
{
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
)
.
allowedOriginPatterns
(
"*"
)
.
allowCredentials
(
true
)
.
allowedMethods
(
"GET"
,
"POST"
,
"DELETE"
,
"PUT"
,
"PATCH"
)
.
maxAge
(
3600
);
}
};
}
}
src/main/java/com/tykj/zlb/config/ZlbConfig.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.client.RestTemplate
;
/**
* @author zsp
* @version 1.0
* @date 2022/8/23 13:42
*/
@Configuration
public
class
ZlbConfig
{
@Bean
public
RestTemplate
getRestTemplate
(){
return
new
RestTemplate
();
}
}
src/main/java/com/tykj/zlb/contants/Constants.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
contants
;
/**
* @author jie.chen
* @date 2022-03-30 15:24
*/
public
interface
Constants
{
/**
* 单点登录(wechat) ticketId换token的地址
*
* 互联网 https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token
* 政府外网 https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token
*/
// String ACCESS_TOKEN_URL = "https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220228000002/sso/servlet/simpleauth/uc/sso/access_token";
// String ACCESS_TOKEN_URL = "https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220228000002/sso/servlet/simpleauth/uc/sso/access_token";
String
ACCESS_TOKEN_URL
=
"https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/access_token"
;
/**
* 单点登录(wechat) token获取用户信息地址
* 互联网 https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo
* 政府外网 https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo
*/
// String GET_USER_INFO_URL = "https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220228000004/sso/servlet/simpleauth/uc/sso/getUserInfo";
// String GET_USER_INFO_URL = "https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220228000004/sso/servlet/simpleauth/uc/sso/getUserInfo";
String
GET_USER_INFO_URL
=
"https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000008/uc/sso/getUserInfo"
;
/**
* IRS请求携带的请求头
*/
String
X_BG_HMAC_ACCESS_KEY
=
"X-BG-HMAC-ACCESS-KEY"
;
String
X_BG_HMAC_SIGNATURE
=
"X-BG-HMAC-SIGNATURE"
;
String
X_BG_HMAC_ALGORITHM
=
"X-BG-HMAC-ALGORITHM"
;
String
X_BG_DATE_TIME
=
"X-BG-DATE-TIME"
;
/**
* IRS签名算法
*/
String
DEFAULT_HMAC_SIGNATURE
=
"hmac-sha256"
;
/**
* 应用ID
*/
String
APP_ID
=
"lm5p4fkv+2002262819+qiyziy"
;
/**
* 微信端固定值为weixin
*/
String
WEIXIN_ENDPOINT_TYPE
=
"weixin"
;
/**
* IRS 申请组件生成的AK
*/
String
IRS_AK
=
"BCDSGA_117d3967fa52d9d62a54f03b2e3bdf8e"
;
/**
* IRS 申请组件生成的SK
*/
String
IRS_SK
=
"BCDSGS_a11b51242885499d4245ad5cd2c3c860"
;
String
TOKEN_SESSION_KEY
=
"sessionAccessToken"
;
String
USER_INFO_KEY
=
"sessionUserInfo"
;
}
src/main/java/com/tykj/zlb/exception/ApiException.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
exception
;
import
com.tykj.zlb.base.ResultObj
;
import
org.springframework.http.ResponseEntity
;
/**
* 全局错误处理类,用于处理一些不容易定义的错误
*
* @author HuangXiahao
**/
public
class
ApiException
extends
RuntimeException
{
private
ResponseEntity
responseEntity
;
public
ApiException
(
ResponseEntity
responseEntity
)
{
this
.
responseEntity
=
responseEntity
;
}
public
ApiException
(
String
message
)
{
this
.
responseEntity
=
ResponseEntity
.
status
(
400
).
body
(
new
ResultObj
(
message
));
}
public
ApiException
(
String
message
,
Object
data
)
{
this
.
responseEntity
=
ResponseEntity
.
status
(
400
).
body
(
new
ResultObj
(
data
,
message
));
}
public
ResponseEntity
getResponseEntity
()
{
return
responseEntity
;
}
public
void
setResponseEntity
(
ResponseEntity
responseEntity
)
{
this
.
responseEntity
=
responseEntity
;
}
}
src/main/java/com/tykj/zlb/exception/GlobalExceptionHandler.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
exception
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Map
;
/**
* 错误处理类
* 所有的报错信息都会通过本层的方法向外界返回
*
* @author HuangXiahao
**/
@RestControllerAdvice
@Slf4j
public
class
GlobalExceptionHandler
{
@ExceptionHandler
(
RuntimeException
.
class
)
public
Map
<
String
,
Object
>
handleRuntimeException
(
RuntimeException
e
)
{
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"code"
,
"error"
);
result
.
put
(
"msg"
,
e
.
getLocalizedMessage
());
return
result
;
}
}
src/main/java/com/tykj/zlb/subject/controller/ZlbController.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
subject
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tykj.zlb.subject.service.ZlbAuthService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpSession
;
import
static
com
.
tykj
.
zlb
.
contants
.
Constants
.
TOKEN_SESSION_KEY
;
import
static
com
.
tykj
.
zlb
.
contants
.
Constants
.
USER_INFO_KEY
;
/**
* @author zsp
* @version 1.0
* @date 2022/8/23 14:19
*/
@RestController
@Api
(
tags
=
"浙里办人员登录模块"
,
description
=
"浙里办人员登录模块"
)
@RequestMapping
(
"/zlbUser"
)
@Slf4j
public
class
ZlbController
{
@Resource
private
ZlbAuthService
zlbAuthService
;
@GetMapping
(
"/getTokenByTicketId"
)
@ApiOperation
(
value
=
"根据票据换取token"
,
notes
=
"根据票据换取token"
)
public
String
getTokenByTicketId
(
String
ticketId
,
HttpServletRequest
request
)
{
HttpSession
session
=
request
.
getSession
();
//1. 通过ticketId 换取 accessToken
String
token
=
zlbAuthService
.
getTokenByTicketId
(
ticketId
);
//2. 保存accessToken
session
.
setAttribute
(
TOKEN_SESSION_KEY
,
token
);
//3. 通过accessToken 获取用户信息
JSONObject
userInfo
=
zlbAuthService
.
getUserInfoByToken
(
token
);
//4. 缓存用户信息
session
.
setAttribute
(
USER_INFO_KEY
,
userInfo
);
log
.
info
(
"session:{}"
,
session
);
return
token
;
}
@GetMapping
(
"/getCurrentUser"
)
@ApiOperation
(
value
=
"获取当前登录的用户信息"
,
notes
=
"获取当前登录的用户信息"
)
public
JSONObject
getCurrentUser
(
HttpServletRequest
request
)
{
HttpSession
session
=
request
.
getSession
();
Object
attribute
=
session
.
getAttribute
(
USER_INFO_KEY
);
if
(
attribute
!=
null
){
log
.
info
(
"attribute:{}"
,
attribute
);
return
(
JSONObject
)
attribute
;
}
else
{
throw
new
RuntimeException
(
"未登录"
);
}
}
}
src/main/java/com/tykj/zlb/subject/service/ZlbAuthService.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
subject
.
service
;
import
com.alibaba.fastjson.JSONObject
;
/**
* @author zsp
* @version 1.0
* @date 2022/8/23 13:46
*/
public
interface
ZlbAuthService
{
/**
* 根据token获取用户信息
* @param accessToken token
* @return 对象
*/
JSONObject
getUserInfoByToken
(
String
accessToken
);
/**
* 根据ticketId获取token
* @param ticketId 票据id
* @return token
*/
String
getTokenByTicketId
(
String
ticketId
);
}
src/main/java/com/tykj/zlb/subject/service/impl/ZlbAuthServiceImpl.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
subject
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tykj.zlb.contants.Constants
;
import
com.tykj.zlb.subject.service.ZlbAuthService
;
import
com.tykj.zlb.util.IrsSignRes
;
import
com.tykj.zlb.util.IrsUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.util.Map
;
/**
* @author zsp
* @version 1.0
* @date 2022/8/23 13:56
*/
@Service
@Slf4j
public
class
ZlbAuthServiceImpl
implements
ZlbAuthService
{
@Resource
private
RestTemplate
restTemplate
;
@Override
public
JSONObject
getUserInfoByToken
(
String
accessToken
)
{
HttpHeaders
headers
=
getHttpHeaders
(
Constants
.
GET_USER_INFO_URL
);
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"token"
,
accessToken
);
HttpEntity
<
Map
<
String
,
Object
>>
request
=
new
HttpEntity
<>(
body
,
headers
);
ResponseEntity
<
String
>
stringResponseEntity
=
restTemplate
.
postForEntity
(
Constants
.
GET_USER_INFO_URL
,
request
,
String
.
class
);
return
checkResponse
(
stringResponseEntity
).
getJSONObject
(
"data"
);
}
@Override
public
String
getTokenByTicketId
(
String
ticketId
)
{
HttpHeaders
headers
=
getHttpHeaders
(
Constants
.
ACCESS_TOKEN_URL
);
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"appId"
,
Constants
.
APP_ID
);
body
.
put
(
"ticketId"
,
ticketId
);
HttpEntity
<
Map
<
String
,
Object
>>
request
=
new
HttpEntity
<>(
body
,
headers
);
ResponseEntity
<
String
>
stringResponseEntity
=
restTemplate
.
postForEntity
(
Constants
.
ACCESS_TOKEN_URL
,
request
,
String
.
class
);
return
checkResponse
(
stringResponseEntity
).
getJSONObject
(
"data"
).
getString
(
"accessToken"
);
}
private
JSONObject
checkResponse
(
ResponseEntity
<
String
>
stringResponseEntity
)
{
if
(!
stringResponseEntity
.
getStatusCode
().
is2xxSuccessful
())
{
//请求失败
throw
new
RuntimeException
(
"status:"
+
stringResponseEntity
.
getStatusCodeValue
()
+
" "
+
stringResponseEntity
.
getBody
());
}
JSONObject
result
=
JSON
.
parseObject
(
stringResponseEntity
.
getBody
());
if
(
result
.
containsKey
(
"errorCode"
)
&&
result
.
getString
(
"errorCode"
)
!=
null
&&
!
result
.
getBooleanValue
(
"success"
))
{
//业务错误
throw
new
RuntimeException
(
result
.
toString
());
}
return
result
;
}
private
HttpHeaders
getHttpHeaders
(
String
url
)
{
IrsSignRes
res
=
IrsUtils
.
sign
(
url
,
"POST"
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
Constants
.
X_BG_HMAC_ACCESS_KEY
,
res
.
getAccessKey
());
headers
.
add
(
Constants
.
X_BG_HMAC_ALGORITHM
,
res
.
getAlgorithm
());
headers
.
add
(
Constants
.
X_BG_HMAC_SIGNATURE
,
res
.
getSignature
());
headers
.
add
(
Constants
.
X_BG_DATE_TIME
,
res
.
getDateTime
());
return
headers
;
}
}
src/main/java/com/tykj/zlb/swagger/Swagger2Config.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
swagger
;
import
com.google.common.base.Predicates
;
import
com.google.common.collect.Sets
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.service.ApiKey
;
import
springfox.documentation.service.AuthorizationScope
;
import
springfox.documentation.service.SecurityReference
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.service.contexts.SecurityContext
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* fusion-platform.
*
* @author : Matrix [xhyrzldf@gmail.com]
* 19-1-10 .
*/
@Configuration
@EnableSwagger2
public
class
Swagger2Config
{
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
produces
(
Sets
.
newHashSet
(
"application/json"
))
.
consumes
(
Sets
.
newHashSet
(
"application/json"
))
.
protocols
(
Sets
.
newHashSet
(
"http"
,
"https"
))
.
apiInfo
(
apiInfo
())
.
forCodeGeneration
(
true
)
.
useDefaultResponseMessages
(
true
)
// .securityContexts(Arrays.asList(securityContext()))
// .securitySchemes(Arrays.asList(apiKey()))
// .globalResponseMessage(RequestMethod.GET, getResMsg())
.
select
()
// 指定controller存放的目录路径
// .apis(RequestHandlerSelectors.withClassAnnotation(AutoDocument.class))
.
paths
(
Predicates
.
not
(
PathSelectors
.
regex
(
"/error.*"
)))
.
paths
(
PathSelectors
.
any
())
.
build
()
;
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
// 文档标题
.
title
(
"浙里办平台接口文档(app)"
)
// 文档描述
.
description
(
"浙里办平台接口文档(app)"
)
.
termsOfServiceUrl
(
"http://192.168.102.30:8010/fusion-group/fusion-platform"
)
.
version
(
"v1"
)
.
build
();
}
// private ApiKey apiKey() {
//
// return new ApiKey("JWT", "Authorization", "header");
//
// }
private
List
<
SecurityReference
>
defaultAuth
()
{
AuthorizationScope
authorizationScope
=
new
AuthorizationScope
(
"global"
,
"accessEverything"
);
AuthorizationScope
[]
authorizationScopes
=
new
AuthorizationScope
[
1
];
authorizationScopes
[
0
]
=
authorizationScope
;
return
Arrays
.
asList
(
new
SecurityReference
(
"JWT"
,
authorizationScopes
));
}
}
src/main/java/com/tykj/zlb/util/HmacAuthUtil.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
util
;
import
javafx.util.Pair
;
import
lombok.extern.slf4j.Slf4j
;
import
javax.crypto.Mac
;
import
javax.crypto.spec.SecretKeySpec
;
import
javax.xml.bind.DatatypeConverter
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URI
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* @author zsp
* @version 1.0
* @date 2022/8/25 15:37
*/
@Slf4j
public
class
HmacAuthUtil
{
/**
* 构造请求 header
* @param urlStr 请求url,全路径格式,比如:https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220228000002/sso/servlet/simpleauth
* @param requestMethod 请求方法,大写格式,如:GET, POST
* @param accessKey 应用的 AK
* @param secretKey 应用的 SK
* @return
*/
public
static
Map
<
String
,
String
>
generateHeader
(
String
urlStr
,
String
requestMethod
,
String
accessKey
,
String
secretKey
)
{
log
.
info
(
"params,urlStr={},requestMethod={},accessKey={},secretKey={}"
,
urlStr
,
requestMethod
,
accessKey
,
secretKey
);
Map
<
String
,
String
>
header
=
new
HashMap
<>();
try
{
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"EEE, dd MMM yyyy HH:mm:ss z"
,
Locale
.
US
);
dateFormat
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"GMT"
));
String
date
=
dateFormat
.
format
(
new
Date
());
URL
url
=
new
URL
(
urlStr
);
URI
uri
=
new
URI
(
url
.
getProtocol
(),
url
.
getHost
(),
url
.
getPath
(),
url
.
getQuery
(),
null
);
String
canonicalQueryString
=
getCanonicalQueryString
(
uri
.
getQuery
());
String
message
=
requestMethod
.
toUpperCase
()
+
"\n"
+
uri
.
getPath
()
+
"\n"
+
canonicalQueryString
+
"\n"
+
accessKey
+
"\n"
+
date
+
"\n"
;
Mac
hasher
=
Mac
.
getInstance
(
"HmacSHA256"
);
hasher
.
init
(
new
SecretKeySpec
(
secretKey
.
getBytes
(),
"HmacSHA256"
));
byte
[]
hash
=
hasher
.
doFinal
(
message
.
getBytes
());
// to lowercase hexits
DatatypeConverter
.
printHexBinary
(
hash
);
// to base64
String
sign
=
DatatypeConverter
.
printBase64Binary
(
hash
);
header
.
put
(
"X-BG-HMAC-SIGNATURE"
,
sign
);
header
.
put
(
"X-BG-HMAC-ALGORITHM"
,
"hmac-sha256"
);
header
.
put
(
"X-BG-HMAC-ACCESS-KEY"
,
accessKey
);
header
.
put
(
"X-BG-DATE-TIME"
,
date
);
}
catch
(
Exception
e
)
{
log
.
error
(
"generate error"
,
e
);
throw
new
RuntimeException
(
"generate header error"
);
}
log
.
info
(
"header info,{}"
,
header
);
return
header
;
}
private
static
String
getCanonicalQueryString
(
String
query
)
{
if
(
query
==
null
||
query
.
trim
().
length
()
==
0
)
{
return
""
;
}
List
<
Pair
<
String
,
String
>>
queryParamList
=
new
ArrayList
<>();
String
[]
params
=
query
.
split
(
"&"
);
for
(
String
param
:
params
)
{
int
eqIndex
=
param
.
indexOf
(
"="
);
String
key
=
param
.
substring
(
0
,
eqIndex
);
String
value
=
param
.
substring
(
eqIndex
+
1
);
Pair
<
String
,
String
>
pair
=
new
Pair
<
String
,
String
>(
key
,
value
);
queryParamList
.
add
(
pair
);
}
List
<
Pair
<
String
,
String
>>
sortedParamList
=
queryParamList
.
stream
().
sorted
(
Comparator
.
comparing
(
param
->
param
.
getKey
()
+
"="
+
Optional
.
ofNullable
(
param
.
getValue
()).
orElse
(
""
))).
collect
(
Collectors
.
toList
());
List
<
Pair
<
String
,
String
>>
encodeParamList
=
new
ArrayList
<>();
sortedParamList
.
stream
().
forEach
(
param
->
{
try
{
String
key
=
URLEncoder
.
encode
(
param
.
getKey
(),
"utf-8"
);
String
value
=
URLEncoder
.
encode
(
Optional
.
ofNullable
(
param
.
getValue
()).
orElse
(
""
),
"utf-8"
)
.
replaceAll
(
"\\%2B"
,
"%20"
)
.
replaceAll
(
"\\+"
,
"%20"
)
.
replaceAll
(
"\\%21"
,
"!"
)
.
replaceAll
(
"\\%27"
,
"'"
)
.
replaceAll
(
"\\%28"
,
"("
)
.
replaceAll
(
"\\%29"
,
")"
)
.
replaceAll
(
"\\%7E"
,
"~"
)
.
replaceAll
(
"\\%25"
,
"%"
)
;
encodeParamList
.
add
(
new
Pair
<>(
key
,
value
));
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
RuntimeException
(
"encoding error"
);
}
});
StringBuilder
queryParamString
=
new
StringBuilder
(
64
);
for
(
Pair
<
String
,
String
>
encodeParam
:
encodeParamList
)
{
queryParamString
.
append
(
encodeParam
.
getKey
()).
append
(
"="
).
append
(
Optional
.
ofNullable
(
encodeParam
.
getValue
()).
orElse
(
""
));
queryParamString
.
append
(
"&"
);
}
return
queryParamString
.
substring
(
0
,
queryParamString
.
length
()
-
1
);
}
public
static
void
main
(
String
[]
args
)
{
Map
<
String
,
String
>
map
=
generateHeader
(
"https://ibcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220228000002/sso/servlet/simpleauth"
,
"POST"
,
"BCDSGA_117d3967fa52d9d62a54f03b2e3bdf8e"
,
"BCDSGS_a11b51242885499d4245ad5cd2c3c860"
);
map
.
forEach
((
k
,
v
)->{
log
.
info
(
"k:{}"
,
k
);
log
.
info
(
"v:{}"
,
v
);
});
String
akString
=
"BCDSGA_117d3967fa52d9d62a54f03b2e3bdf8e"
;
String
skString
=
"BCDSGS_a11b51242885499d4245ad5cd2c3c860"
;
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMddhhmmss"
);
String
format
=
simpleDateFormat
.
format
(
new
Date
());
System
.
out
.
println
(
"format = "
+
format
);
String
md5
=
MD5Util
.
getInstance
().
getMD5
(
akString
+
skString
+
format
);
System
.
out
.
println
(
"md5 = "
+
md5
);
}
}
src/main/java/com/tykj/zlb/util/IrsSignRes.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
util
;
import
lombok.Data
;
/**
* @author jie.chen
* @date 2022-03-30 15:28
*/
@Data
public
class
IrsSignRes
{
private
String
accessKey
;
private
String
signature
;
private
String
algorithm
;
private
String
dateTime
;
}
src/main/java/com/tykj/zlb/util/IrsUtils.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
util
;
import
com.tykj.zlb.contants.Constants
;
import
lombok.SneakyThrows
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.util.UriComponents
;
import
org.springframework.web.util.UriComponentsBuilder
;
import
javax.crypto.Mac
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.nio.charset.StandardCharsets
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* @author jie.chen
* @date 2022-03-30 15:28
*/
public
class
IrsUtils
{
@SneakyThrows
public
static
IrsSignRes
sign
(
String
url
,
String
method
)
{
UriComponents
uriComponents
=
UriComponentsBuilder
.
fromHttpUrl
(
url
).
build
();
uriComponents
=
uriComponents
.
encode
();
List
<
String
>
queryArr
=
new
ArrayList
<>();
MultiValueMap
<
String
,
String
>
queryParams
=
uriComponents
.
getQueryParams
();
for
(
Map
.
Entry
<
String
,
List
<
String
>>
next
:
queryParams
.
entrySet
())
{
for
(
String
va
:
next
.
getValue
())
{
if
(
va
==
null
)
{
queryArr
.
add
(
next
.
getKey
()
+
"="
);
}
else
{
queryArr
.
add
(
next
.
getKey
()
+
"="
+
va
);
}
}
}
//按照字典排序
Collections
.
sort
(
queryArr
);
///Tue, 09 Nov 2021 08:49:20 GMT
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"EEE, dd MMM yyyy HH:mm:ss z"
,
Locale
.
US
);
dateFormat
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"GMT"
));
String
dateTime
=
dateFormat
.
format
(
new
Date
());
String
signStr
=
method
.
toUpperCase
()
+
"\n"
+
//拼接url path
uriComponents
.
getPath
()
+
"\n"
+
//拼接url query
String
.
join
(
"&"
,
queryArr
)
+
"\n"
+
Constants
.
IRS_AK
+
"\n"
+
dateTime
+
"\n"
;
String
sign
=
hmacSha256Base64
(
signStr
,
Constants
.
IRS_SK
);
IrsSignRes
res
=
new
IrsSignRes
();
res
.
setSignature
(
sign
);
res
.
setAccessKey
(
Constants
.
IRS_AK
);
res
.
setDateTime
(
dateTime
);
res
.
setAlgorithm
(
Constants
.
DEFAULT_HMAC_SIGNATURE
);
return
res
;
}
@SneakyThrows
private
static
String
hmacSha256Base64
(
String
content
,
String
key
)
{
Mac
hmacSHA256
=
Mac
.
getInstance
(
"HmacSHA256"
);
SecretKeySpec
secretKey
=
new
SecretKeySpec
(
key
.
getBytes
(
StandardCharsets
.
UTF_8
),
"HmacSHA256"
);
hmacSHA256
.
init
(
secretKey
);
byte
[]
bytes
=
hmacSHA256
.
doFinal
(
content
.
getBytes
(
StandardCharsets
.
UTF_8
));
return
Base64
.
getEncoder
().
encodeToString
(
bytes
);
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
sign
(
"https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220329000007/uc/sso/getUserInfo"
,
"POST"
));
}
}
src/main/java/com/tykj/zlb/util/MD5Util.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
.
util
;
/**
* @author zsp
* @version 1.0
* @date 2022/8/25 15:51
*/
public
class
MD5Util
{
/*
*四个链接变量
*/
private
final
int
A
=
0x67452301
;
private
final
int
B
=
0xefcdab89
;
private
final
int
C
=
0x98badcfe
;
private
final
int
D
=
0x10325476
;
/*
*ABCD的临时变量
*/
private
int
Atemp
,
Btemp
,
Ctemp
,
Dtemp
;
/*
*常量ti
*公式:floor(abs(sin(i+1))×(2pow32)
*/
private
final
int
K
[]={
0xd76aa478
,
0xe8c7b756
,
0x242070db
,
0xc1bdceee
,
0xf57c0faf
,
0x4787c62a
,
0xa8304613
,
0xfd469501
,
0x698098d8
,
0x8b44f7af
,
0xffff5bb1
,
0x895cd7be
,
0x6b901122
,
0xfd987193
,
0xa679438e
,
0x49b40821
,
0xf61e2562
,
0xc040b340
,
0x265e5a51
,
0xe9b6c7aa
,
0xd62f105d
,
0x02441453
,
0xd8a1e681
,
0xe7d3fbc8
,
0x21e1cde6
,
0xc33707d6
,
0xf4d50d87
,
0x455a14ed
,
0xa9e3e905
,
0xfcefa3f8
,
0x676f02d9
,
0x8d2a4c8a
,
0xfffa3942
,
0x8771f681
,
0x6d9d6122
,
0xfde5380c
,
0xa4beea44
,
0x4bdecfa9
,
0xf6bb4b60
,
0xbebfbc70
,
0x289b7ec6
,
0xeaa127fa
,
0xd4ef3085
,
0x04881d05
,
0xd9d4d039
,
0xe6db99e5
,
0x1fa27cf8
,
0xc4ac5665
,
0xf4292244
,
0x432aff97
,
0xab9423a7
,
0xfc93a039
,
0x655b59c3
,
0x8f0ccc92
,
0xffeff47d
,
0x85845dd1
,
0x6fa87e4f
,
0xfe2ce6e0
,
0xa3014314
,
0x4e0811a1
,
0xf7537e82
,
0xbd3af235
,
0x2ad7d2bb
,
0xeb86d391
};
/*
*向左位移数,计算方法未知
*/
private
final
int
s
[]={
7
,
12
,
17
,
22
,
7
,
12
,
17
,
22
,
7
,
12
,
17
,
22
,
7
,
12
,
17
,
22
,
5
,
9
,
14
,
20
,
5
,
9
,
14
,
20
,
5
,
9
,
14
,
20
,
5
,
9
,
14
,
20
,
4
,
11
,
16
,
23
,
4
,
11
,
16
,
23
,
4
,
11
,
16
,
23
,
4
,
11
,
16
,
23
,
6
,
10
,
15
,
21
,
6
,
10
,
15
,
21
,
6
,
10
,
15
,
21
,
6
,
10
,
15
,
21
};
/*
*初始化函数
*/
private
void
init
(){
Atemp
=
A
;
Btemp
=
B
;
Ctemp
=
C
;
Dtemp
=
D
;
}
/*
*移动一定位数
*/
private
int
shift
(
int
a
,
int
s
){
return
(
a
<<
s
)|(
a
>>>(
32
-
s
));
//右移的时候,高位一定要补零,而不是补充符号位
}
/*
*主循环
*/
private
void
MainLoop
(
int
M
[]){
int
F
,
g
;
int
a
=
Atemp
;
int
b
=
Btemp
;
int
c
=
Ctemp
;
int
d
=
Dtemp
;
for
(
int
i
=
0
;
i
<
64
;
i
++){
if
(
i
<
16
){
F
=(
b
&
c
)|((~
b
)&
d
);
g
=
i
;
}
else
if
(
i
<
32
){
F
=(
d
&
b
)|((~
d
)&
c
);
g
=(
5
*
i
+
1
)%
16
;
}
else
if
(
i
<
48
){
F
=
b
^
c
^
d
;
g
=(
3
*
i
+
5
)%
16
;
}
else
{
F
=
c
^(
b
|(~
d
));
g
=(
7
*
i
)%
16
;
}
int
tmp
=
d
;
d
=
c
;
c
=
b
;
b
=
b
+
shift
(
a
+
F
+
K
[
i
]+
M
[
g
],
s
[
i
]);
a
=
tmp
;
}
Atemp
=
a
+
Atemp
;
Btemp
=
b
+
Btemp
;
Ctemp
=
c
+
Ctemp
;
Dtemp
=
d
+
Dtemp
;
}
/*
*填充函数
*处理后应满足bits≡448(mod512),字节就是bytes≡56(mode64)
*填充方式为先加一个0,其它位补零
*最后加上64位的原来长度
*/
private
int
[]
add
(
String
str
){
int
num
=((
str
.
length
()+
8
)/
64
)+
1
;
//以512位,64个字节为一组
int
strByte
[]=
new
int
[
num
*
16
];
//64/4=16,所以有16个整数
for
(
int
i
=
0
;
i
<
num
*
16
;
i
++){
//全部初始化0
strByte
[
i
]=
0
;
}
int
i
;
for
(
i
=
0
;
i
<
str
.
length
();
i
++){
strByte
[
i
>>
2
]|=
str
.
charAt
(
i
)<<((
i
%
4
)*
8
);
//一个整数存储四个字节,小端序
}
strByte
[
i
>>
2
]|=
0x80
<<((
i
%
4
)*
8
);
//尾部添加1
/*
*添加原长度,长度指位的长度,所以要乘8,然后是小端序,所以放在倒数第二个,这里长度只用了32位
*/
strByte
[
num
*
16
-
2
]=
str
.
length
()*
8
;
return
strByte
;
}
/*
*调用函数
*/
public
String
getMD5
(
String
source
){
init
();
int
strByte
[]=
add
(
source
);
for
(
int
i
=
0
;
i
<
strByte
.
length
/
16
;
i
++){
int
num
[]=
new
int
[
16
];
for
(
int
j
=
0
;
j
<
16
;
j
++){
num
[
j
]=
strByte
[
i
*
16
+
j
];
}
MainLoop
(
num
);
}
return
changeHex
(
Atemp
)+
changeHex
(
Btemp
)+
changeHex
(
Ctemp
)+
changeHex
(
Dtemp
);
}
/*
*整数变成16进制字符串
*/
private
String
changeHex
(
int
a
){
String
str
=
""
;
for
(
int
i
=
0
;
i
<
4
;
i
++){
str
+=
String
.
format
(
"%2s"
,
Integer
.
toHexString
(((
a
>>
i
*
8
)%(
1
<<
8
))&
0xff
)).
replace
(
' '
,
'0'
);
}
return
str
;
}
/*
*单例
*/
private
static
MD5Util
instance
;
public
static
MD5Util
getInstance
(){
if
(
instance
==
null
){
instance
=
new
MD5Util
();
}
return
instance
;
}
public
static
void
main
(
String
[]
args
){
Boolean
isMD5
=
true
;
do
{
System
.
out
.
println
(
"输入加密的字符串:"
);
java
.
util
.
Scanner
scanner
=
new
java
.
util
.
Scanner
(
System
.
in
);
String
md5String
=
scanner
.
next
(
);
String
str
=
MD5Util
.
getInstance
().
getMD5
(
md5String
);
System
.
out
.
println
(
"MD5加密:"
+
str
);
System
.
out
.
println
(
"MD5加密后长度:"
+
str
.
length
(
));
System
.
out
.
println
(
"是否继续加密:"
);
char
md5char
=
scanner
.
next
(
).
charAt
(
0
);
isMD5
=
true
;
if
(
md5char
==
'n'
||
md5char
==
'N'
)
isMD5
=
false
;
}
while
(
isMD5
);
}
}
src/main/java/com/tykj/zlb/util/UnifiedReturnConfig.java
0 → 100644
浏览文件 @
ab2dd9b7
//package com.tykj.zlb.util;
//
//import com.fasterxml.jackson.core.JsonProcessingException;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.tykj.zlb.base.ResultObj;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.MethodParameter;
//import org.springframework.http.MediaType;
//import org.springframework.http.converter.HttpMessageConverter;
//import org.springframework.http.server.ServerHttpRequest;
//import org.springframework.http.server.ServerHttpResponse;
//import org.springframework.web.bind.annotation.RestControllerAdvice;
//import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
//
///**
// * UnifiedReturnConfig.
// *
// * @author zsp <xhyrzldf@gmail.com>
// * @since 2020/10/9 at 3:17 下午
// */
//@Configuration
//@RestControllerAdvice("com.tykj.zlb")
//public class UnifiedReturnConfig implements ResponseBodyAdvice<Object> {
//
// private ObjectMapper objectMapper = new ObjectMapper();
//
// @Override
// public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
// return true;
// }
//
// @Override
// public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
// Class<? extends HttpMessageConverter<?>> selectedConverterType,
// ServerHttpRequest request, ServerHttpResponse response) {
// // String类型不能直接包装
// if (returnType.getGenericParameterType().equals(String.class)) {
// try {
// // 将数据包装在ResultObj里后转换为json串进行返回
// return objectMapper.writeValueAsString(new ResultObj<>(body));
// } catch (JsonProcessingException e) {
// e.getMessage();
// }
// }
// // 否则直接包装成ResultVo返回
// return new ResultObj<>(body);
//
// }
//}
//
src/main/resources/application-dev.properties
0 → 100644
浏览文件 @
ab2dd9b7
server.port
=
8010
src/main/resources/application.properties
0 → 100644
浏览文件 @
ab2dd9b7
src/test/java/com/tykj/zlb/ZlbApplicationTests.java
0 → 100644
浏览文件 @
ab2dd9b7
package
com
.
tykj
.
zlb
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
class
ZlbApplicationTests
{
@Test
void
contextLoads
()
{
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论