| | |
| | | import cn.hutool.crypto.asymmetric.KeyType; |
| | | import cn.hutool.crypto.asymmetric.RSA; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.core.MethodParameter; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.core.annotation.Order; |
| | |
| | | * @author wzy |
| | | * @date 2022-06-14 |
| | | **/ |
| | | @Slf4j |
| | | @ControllerAdvice |
| | | public class MyResponseBodyAdvise implements ResponseBodyAdvice { |
| | | @Override |
| | |
| | | if (!AppContants.ENCRYPT_METHOD.contains(methodParameter.getMethod().getName())) { |
| | | return o; |
| | | } |
| | | |
| | | RSA rsa = new RSA(AppContants.RESP_PRIVATE_KEY, AppContants.RESP_PUBLIC_KEY); |
| | | return rsa.encryptBase64(JSONObject.toJSONString(o), KeyType.PublicKey); |
| | | } |