dengzedong
2024-12-31 2e0e42583419225b5dd38e97594de82accd594ad
提交 | 用户 | 时间
e7c126 1 package com.iailab.framework.security.core.aop;
H 2
3 import com.iailab.framework.security.core.annotations.PreAuthenticated;
4 import com.iailab.framework.security.core.util.SecurityFrameworkUtils;
5 import lombok.extern.slf4j.Slf4j;
6 import org.aspectj.lang.ProceedingJoinPoint;
7 import org.aspectj.lang.annotation.Around;
8 import org.aspectj.lang.annotation.Aspect;
9
10 import static com.iailab.framework.common.exception.enums.GlobalErrorCodeConstants.UNAUTHORIZED;
11 import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception;
12
13 @Aspect
14 @Slf4j
15 public class PreAuthenticatedAspect {
16
17     @Around("@annotation(preAuthenticated)")
18     public Object around(ProceedingJoinPoint joinPoint, PreAuthenticated preAuthenticated) throws Throwable {
19         if (SecurityFrameworkUtils.getLoginUser() == null) {
20             throw exception(UNAUTHORIZED);
21         }
22         return joinPoint.proceed();
23     }
24
25 }