Код: Выделить всё
public String generateToken(UserProfile authentication) {
// set the expiration time
Date now = new Date();
Date expiryDate = new Date(now.getTime() + jwtExpirationInMs);
// Generate token and return
return Jwts.builder()
.setSubject(authentication.getUsername())
.claim("roles","user")
.setIssuedAt(new Date())
.setExpiration(expiryDate)
.signWith(SignatureAlgorithm.HS512,jwtSecret)
.compact();
Подробнее здесь: https://stackoverflow.com/questions/521 ... -token-jwt
Мобильная версия