| | |
| | | package com.doumee.config.interfaceencryption; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.config.annotation.EncryptionResp; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.utils.AESUtils; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.MethodParameter; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.converter.HttpMessageConverter; |
| | |
| | | import org.springframework.web.bind.annotation.ControllerAdvice; |
| | | import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.Random; |
| | | |
| | |
| | | ApiResponse apiResponse = (ApiResponse) body; |
| | | //对响应内容进行加密 |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); |
| | | String aesEncryptData = AESUtils.encrypt(objectMapper.writeValueAsString(apiResponse.getData()), str); |
| | | apiResponse.setData(aesEncryptData); |
| | | String aesEncryptMessage = AESUtils.encrypt(objectMapper.writeValueAsString(apiResponse.getMessage()), str); |
| | |
| | | char randomChar = (char) (random.nextInt(26) + 'a'); |
| | | sb.append(randomChar); |
| | | } |
| | | |
| | | return sb.toString(); |
| | | } |
| | | } |