之前的版本:http://blog.csdn.net/h996666/article/details/78207031
不说了,直接贴代码
package com.life.app.token;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.util.encoders.Base64;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
/**
* Json web token 签发
*
*/
public class JWT {
// 密钥key
private static final String SECRET_KEY = "xxxxxxx";
/**
* 构造密钥
*
* @return
*/
private static SecretKey generalKey() {
byte[] encodeKey = Base64.decode(SECRET_KEY);
return new SecretKeySpec(encodeKey, 0, encodeKey.length, "AES&