|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.yxt.anrui.portal.test.controller; |
|
|
|
|
|
|
|
import cn.hutool.core.codec.Base64; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.alibaba.fastjson.annotation.JSONField; |
|
|
@ -14,7 +15,6 @@ import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
import sun.misc.BASE64Encoder; |
|
|
|
|
|
|
|
import javax.crypto.Mac; |
|
|
|
import javax.crypto.spec.SecretKeySpec; |
|
|
@ -218,7 +218,7 @@ public class TestController { |
|
|
|
Key sKey = new SecretKeySpec(secretKey.getBytes("UTF-8"), mac.getAlgorithm()); |
|
|
|
mac.init(sKey); |
|
|
|
byte[] hash = mac.doFinal(signStr.getBytes("UTF-8")); |
|
|
|
String sig = new BASE64Encoder().encode(hash); |
|
|
|
String sig = Base64.encode(hash); |
|
|
|
|
|
|
|
String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"" + sig + "\""; |
|
|
|
return auth; |
|
|
|