From 20110a0c8941cd295f4258e14a0e3ff05680383a Mon Sep 17 00:00:00 2001 From: Tang Cheng Date: Wed, 19 Jun 2019 15:06:22 +0800 Subject: [PATCH] =?utf8?q?chore:=20=E4=BF=AE=E6=94=B9=20pointcut=20?= =?utf8?q?=E9=80=9A=E8=BF=87=20securitycontextholder=20=E5=8F=96=E5=87=BA?= =?utf8?q?=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/supwisdom/dlpay/api/advices.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt b/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt index 0f9f3149..092fde81 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt @@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.http.ResponseEntity import org.springframework.security.core.Authentication +import org.springframework.security.core.context.SecurityContextHolder import org.springframework.stereotype.Component import org.springframework.web.bind.annotation.ExceptionHandler import org.springframework.web.bind.annotation.RestControllerAdvice @@ -63,13 +64,16 @@ class RestControllerAspect { fun postmapping() { } - @Around("restcontroller() && postmapping() && args(@RequestBody body, auth, ..)") + @Around("restcontroller() && postmapping() && args(@RequestBody body, ..)") @Throws(Throwable::class) - fun logPostMethods(joinPoint: ProceedingJoinPoint, body: Any, auth: Authentication): Any { + fun logPostMethods(joinPoint: ProceedingJoinPoint, body: Any): Any { return try { if (body is APIRequestParam) { body.checkParam() - if (requestSignCheck && !body.checkSign(commonService.getSecretByAppid(auth.name))) { + + if (requestSignCheck && + !body.checkSign(commonService.getSecretByAppid( + SecurityContextHolder.getContext().authentication.name))) { throw RequestParamCheckException(TradeErrorCode.REQUEST_SIGN_ERROR, "参数签名错误") } } else { -- 2.17.1