|
|
@ -49,7 +49,7 @@ public class ExtAppJwtTokenUtils { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public String createToken(Map<String, Object> map, String secret) { |
|
|
private String createToken(Map<String, Object> map, String secret) { |
|
|
return Jwts.builder() |
|
|
return Jwts.builder() |
|
|
.setHeaderParam("typ", "JWT") |
|
|
.setHeaderParam("typ", "JWT") |
|
|
.setClaims(map) |
|
|
.setClaims(map) |
|
|
@ -59,21 +59,7 @@ public class ExtAppJwtTokenUtils { |
|
|
.compact(); |
|
|
.compact(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// /**
|
|
|
public static void genTestToken() { |
|
|
// * token是否过期
|
|
|
|
|
|
// *
|
|
|
|
|
|
// * @return true:过期
|
|
|
|
|
|
// */
|
|
|
|
|
|
// public boolean isTokenExpired(Date expiration) {
|
|
|
|
|
|
// return expiration.before(new Date());
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
genToken(); |
|
|
|
|
|
// getClaim();
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void genToken() { |
|
|
|
|
|
HashMap<String, Object> claim = new HashMap<>(); |
|
|
HashMap<String, Object> claim = new HashMap<>(); |
|
|
//市北
|
|
|
//市北
|
|
|
//String secret = "612d304095c50369c3ef06e490f05779eeb8f19ff16566c73aeafafc5fa01970";
|
|
|
//String secret = "612d304095c50369c3ef06e490f05779eeb8f19ff16566c73aeafafc5fa01970";
|
|
|
@ -89,21 +75,19 @@ public class ExtAppJwtTokenUtils { |
|
|
String appId = "f358d63a89f3670c197c62ca4c3a0366"; |
|
|
String appId = "f358d63a89f3670c197c62ca4c3a0366"; |
|
|
String customrId = "45687aa479955f9d06204d415238f7cc"; |
|
|
String customrId = "45687aa479955f9d06204d415238f7cc"; |
|
|
|
|
|
|
|
|
claim.put("customerId", customrId); |
|
|
|
|
|
claim.put("appId", appId); |
|
|
|
|
|
long ts = System.currentTimeMillis() + 1000 * 60 * 1; |
|
|
long ts = System.currentTimeMillis() + 1000 * 60 * 1; |
|
|
System.out.println("时间戳:" + ts); |
|
|
System.out.println("时间戳:" + ts); |
|
|
claim.put("ts", ts); |
|
|
String token = new ExtAppJwtTokenUtils().genToken(secret, appId, customrId, ts); |
|
|
|
|
|
System.out.println(token); |
|
|
String abc = new ExtAppJwtTokenUtils().createToken(claim, secret); |
|
|
|
|
|
System.out.println(abc); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void getClaim() { |
|
|
public String genToken(String secret, String appId, String customrId, Long ts) { |
|
|
String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJhcHBJZCI6IjEiLCJjdXN0b21lcklkIjoiYzEiLCJpYXQiOjE1OTc3NDI2NTB9.09Vop0Nobg3LENAJoAZaCUKtgAjADAK48BS11ky3YdAp6h-cXYtGeqUxbgvE_4F6239rc7UE2fjxtEvMuWEJuA"; |
|
|
HashMap<String, Object> claim = new HashMap<>(); |
|
|
|
|
|
claim.put("customerId", customrId); |
|
|
|
|
|
claim.put("appId", appId); |
|
|
|
|
|
claim.put("ts", ts); |
|
|
|
|
|
|
|
|
Claims claimByToken = new ExtAppJwtTokenUtils().getClaimByToken(token, "4a762660254c57996343f8ee42fbc0a6"); |
|
|
return createToken(claim, secret); |
|
|
System.out.println(claimByToken); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|