| 
														
															@@ -6,9 +6,9 @@ import javax.servlet.Filter; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.chelvc.framework.base.interceptor.StandardUnifiedResponseWrapper; 
														 | 
														
														 | 
														
															 import com.chelvc.framework.base.interceptor.StandardUnifiedResponseWrapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.chelvc.framework.base.interceptor.UnifiedResponseWrapper; 
														 | 
														
														 | 
														
															 import com.chelvc.framework.base.interceptor.UnifiedResponseWrapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.chelvc.framework.base.util.StringUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.chelvc.framework.security.annotation.Encrypt; 
														 | 
														
														 | 
														
															 import com.chelvc.framework.security.annotation.Encrypt; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.chelvc.framework.security.context.SecurityContextHolder; 
														 | 
														
														 | 
														
															 import com.chelvc.framework.security.context.SecurityContextHolder; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import lombok.extern.slf4j.Slf4j; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.aopalliance.intercept.MethodInvocation; 
														 | 
														
														 | 
														
															 import org.aopalliance.intercept.MethodInvocation; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.boot.web.servlet.FilterRegistrationBean; 
														 | 
														
														 | 
														
															 import org.springframework.boot.web.servlet.FilterRegistrationBean; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.context.annotation.Bean; 
														 | 
														
														 | 
														
															 import org.springframework.context.annotation.Bean; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -35,7 +35,6 @@ import org.springframework.web.filter.CorsFilter; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * @author Woody 
														 | 
														
														 | 
														
															  * @author Woody 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * @date 2023/4/5 
														 | 
														
														 | 
														
															  * @date 2023/4/5 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  */ 
														 | 
														
														 | 
														
															  */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-@Slf4j 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 @Configuration 
														 | 
														
														 | 
														
															 @Configuration 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 @EnableGlobalMethodSecurity(prePostEnabled = true) 
														 | 
														
														 | 
														
															 @EnableGlobalMethodSecurity(prePostEnabled = true) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 public class SecurityConfigurer extends GlobalMethodSecurityConfiguration { 
														 | 
														
														 | 
														
															 public class SecurityConfigurer extends GlobalMethodSecurityConfiguration { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -70,13 +69,9 @@ public class SecurityConfigurer extends GlobalMethodSecurityConfiguration { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             public Object wrap(NativeWebRequest request, MethodParameter method, Object value) { 
														 | 
														
														 | 
														
															             public Object wrap(NativeWebRequest request, MethodParameter method, Object value) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 // 判断方法返回值是否需要加密 
														 | 
														
														 | 
														
															                 // 判断方法返回值是否需要加密 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 Method target = Objects.requireNonNull(method.getMethod()); 
														 | 
														
														 | 
														
															                 Method target = Objects.requireNonNull(method.getMethod()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                if (target.getReturnType() == String.class && target.isAnnotationPresent(Encrypt.class)) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    try { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        value = SecurityContextHolder.encrypt((String) value); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    } catch (Exception e) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        // 如果加密失败则回退到明文传输 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        log.error("Data encrypt failed: {}", e.getMessage()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if (target.getReturnType() == String.class && target.isAnnotationPresent(Encrypt.class) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        && StringUtils.nonEmpty(value)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    value = SecurityContextHolder.encrypt((String) value, true); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } 
														 | 
														
														 | 
														
															                 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 return super.wrap(request, method, value); 
														 | 
														
														 | 
														
															                 return super.wrap(request, method, value); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 |