admin管理员组

文章数量:1183716

private static final String SECRET = "cr666N7wIV+KJ2xOQpWtcfAekL4YXd9gbnJMs8SJ9sI=";
private final SecretKey SECRET_KEY = Keys.hmacShaKeyFor(Base64.getDecoder().decode(SECRET));
private final long EXPIRATION_TIME = 1000 * 60 * 60;

public boolean validateToken(String token) {
        try {
            if (token.startsWith("Bearer ")) {
                token = token.substring(7);
            }
            token = token.trim(); 
            System.out.println("After"  + token ) ;
            Jwts.parserBuilder()
                    .setSigningKey(SECRET_KEY)
                    .build()
                    .parseClaimsJws(token); // Parse and validate the token
            return true; // Token is valid
        } catch (Exception e) {
            return false; // Token is invalid or expired
        }
}

this above is my code what to do , i have tried everything

Tried triming Debugged everything by printing

本文标签: