@Test public void generateTokenTest() { JwtToken jwtToken = new JwtToken(); AccountInfo accountInfo = new AccountInfo(); accountInfo.setAccount("admin"); accountInfo.setTeamId(1L); String token = jwtToken.generateToken(accountInfo); }
public String generateToken(AccountInfo accountInfo) { return Jwts.builder() .claim("salt", SALT) .claim("userinfo", JacksonUtil.serialize(accountInfo)) .setSubject(accountInfo.getAccount()) .setExpiration(new Date(System.currentTimeMillis() + EXPIRE)) .signWith(key).compact(); }
JwtToken { public String generateToken(AccountInfo accountInfo) { return Jwts.builder() .claim("salt", SALT) .claim("userinfo", JacksonUtil.serialize(accountInfo)) .setSubject(accountInfo.getAccount()) .setExpiration(new Date(System.currentTimeMillis() + EXPIRE)) .signWith(key).compact(); } }
JwtToken { public String generateToken(AccountInfo accountInfo) { return Jwts.builder() .claim("salt", SALT) .claim("userinfo", JacksonUtil.serialize(accountInfo)) .setSubject(accountInfo.getAccount()) .setExpiration(new Date(System.currentTimeMillis() + EXPIRE)) .signWith(key).compact(); }  }
JwtToken { public String generateToken(AccountInfo accountInfo) { return Jwts.builder() .claim("salt", SALT) .claim("userinfo", JacksonUtil.serialize(accountInfo)) .setSubject(accountInfo.getAccount()) .setExpiration(new Date(System.currentTimeMillis() + EXPIRE)) .signWith(key).compact(); }  String generateToken(AccountInfo accountInfo); Claims parseToken(String token); String parseAccount(String token); }
JwtToken { public String generateToken(AccountInfo accountInfo) { return Jwts.builder() .claim("salt", SALT) .claim("userinfo", JacksonUtil.serialize(accountInfo)) .setSubject(accountInfo.getAccount()) .setExpiration(new Date(System.currentTimeMillis() + EXPIRE)) .signWith(key).compact(); }  String generateToken(AccountInfo accountInfo); Claims parseToken(String token); String parseAccount(String token);  }