|
|
@@ -29,10 +29,10 @@ public class AuthCodeManage { |
|
|
|
private final CachePlusOps cachePlusOps; |
|
|
|
private final AuthCodeProperties authCodeProperties; |
|
|
|
|
|
|
|
private String generateAuthCode(String userId, boolean checkSign, String sign) { |
|
|
|
private String generateAuthCode(String userId, boolean checkSign, Long timestamp, String sign) { |
|
|
|
if (checkSign) { |
|
|
|
HMac hmacMd5 = SecureUtil.hmacMd5(authCodeProperties.getSecretKey()); |
|
|
|
String digestHex = hmacMd5.digestHex(userId); |
|
|
|
String digestHex = hmacMd5.digestHex(userId + "#" + timestamp); |
|
|
|
if (!digestHex.equals(sign)) { |
|
|
|
throw BizException.wrap("获取授权码失败:签名错误"); |
|
|
|
} |
|
|
@@ -44,12 +44,12 @@ public class AuthCodeManage { |
|
|
|
return authCode; |
|
|
|
} |
|
|
|
|
|
|
|
public String generateAuthCode(String userId, String sign) { |
|
|
|
return generateAuthCode(userId, true, sign); |
|
|
|
public String generateAuthCode(String userId, Long timestamp, String sign) { |
|
|
|
return generateAuthCode(userId, true, timestamp, sign); |
|
|
|
} |
|
|
|
|
|
|
|
public String generateAuthCode(String userId) { |
|
|
|
return generateAuthCode(userId, false, null); |
|
|
|
return generateAuthCode(userId, false, null, null); |
|
|
|
} |
|
|
|
|
|
|
|
public boolean authCodeCheck(String userId, String authCode) { |
|
|
|