|
|
|
@ -20,11 +20,13 @@ import java.security.interfaces.RSAPrivateKey; |
|
|
|
import java.security.interfaces.RSAPublicKey; |
|
|
|
import java.security.spec.PKCS8EncodedKeySpec; |
|
|
|
import java.security.spec.X509EncodedKeySpec; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 远程请求签名工具 |
|
|
|
*/ |
|
|
|
@ -123,6 +125,11 @@ public class SignUtils { |
|
|
|
Calendar cal = Calendar.getInstance(); |
|
|
|
cal.add(Calendar.SECOND,(int)exp); |
|
|
|
Date expireDate = cal.getTime(); |
|
|
|
// 格式化时间
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
// String iatStr= sdf.format(new Date());
|
|
|
|
String iatStr= String.valueOf(System.currentTimeMillis()/1000l); |
|
|
|
|
|
|
|
|
|
|
|
// 证书信息
|
|
|
|
Map xmap = getTypeMap(type); |
|
|
|
@ -131,7 +138,7 @@ public class SignUtils { |
|
|
|
Map<String,String> payload= new HashMap<>(); |
|
|
|
payload.put("iss",(String)xmap.get("pem_token")); |
|
|
|
payload.put("exp",expireDate.toString()); //过期
|
|
|
|
payload.put("iat",expireDate.toString());//发行日期
|
|
|
|
payload.put("iat",iatStr);//发行日期
|
|
|
|
|
|
|
|
// 如果是用户
|
|
|
|
if("user_real".equals(type)){ |
|
|
|
@ -149,9 +156,7 @@ public class SignUtils { |
|
|
|
RSAPublicKey rsaPublicKey = getPublicKey(ChConstant.WORK_DIR + "/" +pub_key_path); |
|
|
|
|
|
|
|
JWTCreator.Builder builder = JWT.create(); |
|
|
|
// 头部信息
|
|
|
|
Map<String,Object> a = new HashMap<>(payload); |
|
|
|
// builder.withHeader(a);
|
|
|
|
|
|
|
|
// 构建payload
|
|
|
|
// stream 流式
|
|
|
|
payload.forEach((k,v)->builder.withClaim(k,v)); |
|
|
|
|