| | |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import cn.hutool.crypto.asymmetric.KeyType; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | String headAddress = request.getHeader("address"); |
| | | String key = request.getHeader("key"); |
| | | String path = request.getServletPath().replace("/dapi", ""); |
| | | log.info("进入拦截:{}, {}, {}", headAddress, path, key); |
| | | |
| | | String chain = request.getHeader("chain"); |
| | | if (StrUtil.isBlank(headAddress) || StrUtil.isBlank(key)) { |
| | |
| | | private void responseUnAuth(HttpServletResponse response) throws IOException { |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setContentType("application/json; charset=utf-8"); |
| | | response.getWriter().write(new ObjectMapper().writeValueAsString(new FebsResponse().code(HttpStatus.UNAUTHORIZED))); |
| | | |
| | | FebsResponse code = new FebsResponse().code(HttpStatus.UNAUTHORIZED); |
| | | String encryptBase64 = SecureUtil.rsa(AppContants.RESP_PRIVATE_KEY, AppContants.RESP_PUBLIC_KEY).encryptBase64(JSONObject.toJSONString(code).getBytes(), KeyType.PublicKey); |
| | | response.getWriter().write(new ObjectMapper().writeValueAsString(encryptBase64)); |
| | | } |
| | | |
| | | public static void main(String[] args) { |