title: signature exception when generate and validating the same token
body: <p>i have coded a jwt creator and when i create the token there is no problem. But when i receive it from header and check it Signature exception occurs what is wrong in the below code?</p>
  <pre><code>@Service
  public class TokenManager {
  
      private static final int validity = 5 * 60 * 1000;
      Key key = Keys.secretKeyFor(SignatureAlgorithm.HS256);
  
      public String generateToken(String afId) {
          return Jwts.builder()
                  .setSubject(afId)
                  .setIssuer(&quot;www.asn.com&quot;)
                  .setIssuedAt(new Date(System.currentTimeMillis()))
                  .setExpiration(new Date(System.currentTimeMillis() + validity))
                  .signWith(key)
                  .compact();
      }
  
      public boolean tokenValidate(String token) {
          return getUsernameToken(token) != null &amp;&amp; !isExpired(token);
      }
  
      public String getUsernameToken(String token) {
          Claims claims = getClaims(token);
          return claims.getSubject();
      }
  
      public boolean isExpired(String token) {
          Claims claims = getClaims(token);
          return claims.getExpiration().before(new Date(System.currentTimeMillis()));
      }
  
      private Claims getClaims(String token) {
          return Jwts.parser().setSigningKey(key).parseClaimsJws(token).getBody(); // SIGNATURE EXCEPTİON occurs
      }
  
  }
  </code></pre>