JWT Token verification with Java
<p>I am facing a issue that whenever I am signing a token also I parse it and it is not throwing any signature exception.</p>

<p>You can see the key are different still it giving me the proper response.</p>

<pre><code>public class JwtUtil {

 public String parseToken(String token) {
    try {
       Jws&lt;Claims&gt; jwt = Jwts.parser()                  
                .setSigningKey("Test@12")                    
                .parseClaimsJws(token);


        System.out.println(jwt.getBody().getSubject());
        return "Valid";

    } catch (SignatureException jwtException) {
        jwtException.printStackTrace();
        return null;
     }
 }


public String generateToken() {

    Claims claim = Jwts.claims();
    claim.put("GivenName", "Johnny");
    claim.put("Surname", "Rocket");
    claim.put("Email", "jrocket@example.com");      

    return Jwts.builder().setHeaderParam("typ", "JWT").setClaims(claim)
            .setIssuer("Online JWT Builder")
            .setAudience("www.example.com").setSubject("jrocket@example.com")
            .signWith(SignatureAlgorithm.HS256, "Test@123").compact();


}

public static void main(String[] args) {
    JwtUtil jwtUtil = new JwtUtil();        
    String token = jwtUtil.generateToken();
    System.out.println(token);  

    JwtUtil jwtUtil1 = new JwtUtil();
    jwtUtil1.parseToken(token);
 }
}
</code></pre>