src/main/java/com/property/manager/security/token/JwtTokenProvider.java
public boolean validateToken(String token) throws CustomException {
        CustomException illegalCustomException = new CustomException(CustomError.EXPIRED_TOKEN);
        CustomException forbiddenCustomException = new CustomException(CustomError.ACCESS_DENIED);
        try {
            Jws<Claims> claims = Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token);
            if (claims.getBody().getExpiration().before(new Date())) {
                throw forbiddenCustomException;
            }
            return true;
        } catch (JwtException | IllegalArgumentException | CustomException e) {
            try {
                if (JWT.decode(token).getExpiresAt().before(new Date()))
                    throw forbiddenCustomException;
                return true;
            } catch (Exception ex) {
                throw illegalCustomException;
            }
        }
    }
/**
     * checks if the access token has valid pattern
     *
     * @param token
     * @return CustomException EXPIRED_TOKEN or ACCESS_DENIED message
     */
checks if the access token has valid pattern
@param token
@return CustomException EXPIRED_TOKEN or ACCESS_DENIED message
checks if the access token has valid pattern @param token @return CustomException EXPIRED_TOKEN or ACCESS_DENIED message
public boolean validateToken(String token) throws CustomException {
        CustomException illegalCustomException = new CustomException(CustomError.EXPIRED_TOKEN);
        CustomException forbiddenCustomException = new CustomException(CustomError.ACCESS_DENIED);
        try {
            Jws<Claims> claims = Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token);
            if (claims.getBody().getExpiration().before(new Date())) {
                throw forbiddenCustomException;
            }
            return true;
        } catch (JwtException | IllegalArgumentException | CustomException e) {
            try {
                if (JWT.decode(token).getExpiresAt().before(new Date()))
                    throw forbiddenCustomException;
                return true;
            } catch (Exception ex) {
                throw illegalCustomException;
            }
        }
    }
public boolean validateToken ( String token ) throws CustomException { CustomException illegalCustomException = new CustomException ( CustomError . EXPIRED_TOKEN ) ; CustomException forbiddenCustomException = new CustomException ( CustomError . ACCESS_DENIED ) ; try { Jws < Claims > claims = Jwts . parser ( ) . setSigningKey ( secretKey ) . parseClaimsJws ( token ) ; if ( claims . getBody ( ) . getExpiration ( ) . before ( new Date ( ) ) ) { throw forbiddenCustomException ; } return true ; } catch ( JwtException | IllegalArgumentException | CustomException e ) { try { if ( JWT . decode ( token ) . getExpiresAt ( ) . before ( new Date ( ) ) ) throw forbiddenCustomException ; return true ; } catch ( Exception ex ) { throw illegalCustomException ; } } }
checks if the access token has valid pattern
 @param token
 @return CustomException EXPIRED_TOKEN or ACCESS_DENIED message
checks if the access token has valid pattern @param token @return CustomException EXPIRED_TOKEN or ACCESS_DENIED message