public class KongHttpUtil {
public static final Logger log = LoggerFactory.getLogger(KongHttpUtil.class);
/**
* 生成JWT
* @return
*/
public static String generateJWT(String secret,String key) throws Exception {
Algorithm algorithm = Algorithm.HMAC256(secret);
String token = JWT.create().withIssuer(key)
.withIssuedAt(new Date())
.withExpiresAt(DateUtils.addHours(new Date(),1))
.sign(algorithm);
log.info("生成的JWT:"+token);
return "Bearer "+token;
}
}