robe-auth/src/main/java/io/robe/auth/token/jersey/TokenBasedAuthResponseFilter.java
@Override
    public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
        String authToken = extractAuthTokenFromCookieList(requestContext.getHeaders().getFirst("Cookie"));
        if (authToken != null && authToken.length() != 0) {
            try {
                BasicToken token = new BasicToken(authToken);
                if (token.isExpired()) {
                    LOGGER.debug("ExpireDate : " + token.getExpirationDate().toString());
                    LOGGER.debug("Now: " + DateTime.now().toDate().toString());
                    responseContext.getHeaders().putSingle("Set-Cookie", getTokenSentence(null));
                    responseContext.setStatusInfo(Response.Status.UNAUTHORIZED);
                    responseContext.setEntity("Token expired. Please login again.");
                    LOGGER.info("Token expired. Please login again.");
                } else {
                    token.setExpiration(token.getMaxAge());
                    if (!logoutPath.equals(requestContext.getUriInfo().getPath())) {
                        String cookie = getTokenSentence(token);
                        responseContext.getHeaders().putSingle("Set-Cookie", cookie);
                    }
                }

            } catch (Exception e) {
                LOGGER.error("Token re-creation failed", e.getMessage());
                responseContext.setStatusInfo(Response.Status.UNAUTHORIZED);

            }
        }
    }
@Override
    public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
        String authToken = extractAuthTokenFromCookieList(requestContext.getHeaders().getFirst("Cookie"));
        if (authToken != null && authToken.length() != 0) {
            try {
                BasicToken token = new BasicToken(authToken);
                if (token.isExpired()) {
                    LOGGER.debug("ExpireDate : " + token.getExpirationDate().toString());
                    LOGGER.debug("Now: " + DateTime.now().toDate().toString());
                    responseContext.getHeaders().putSingle("Set-Cookie", getTokenSentence(null));
                    responseContext.setStatusInfo(Response.Status.UNAUTHORIZED);
                    responseContext.setEntity("Token expired. Please login again.");
                    LOGGER.info("Token expired. Please login again.");
                } else {
                    token.setExpiration(token.getMaxAge());
                    if (!logoutPath.equals(requestContext.getUriInfo().getPath())) {
                        String cookie = getTokenSentence(token);
                        responseContext.getHeaders().putSingle("Set-Cookie", cookie);
                    }
                }

            } catch (Exception e) {
                LOGGER.error("Token re-creation failed", e.getMessage());
                responseContext.setStatusInfo(Response.Status.UNAUTHORIZED);

            }
        }
    }
@ Override public void filter ( ContainerRequestContext requestContext , ContainerResponseContext responseContext ) throws IOException { String authToken = extractAuthTokenFromCookieList ( requestContext . getHeaders ( ) . getFirst ( "Cookie" ) ) ; if ( authToken != null && authToken . length ( ) != 0 ) { try { BasicToken token = new BasicToken ( authToken ) ; if ( token . isExpired ( ) ) { LOGGER . debug ( "ExpireDate : " + token . getExpirationDate ( ) . toString ( ) ) ; LOGGER . debug ( "Now: " + DateTime . now ( ) . toDate ( ) . toString ( ) ) ; responseContext . getHeaders ( ) . putSingle ( "Set-Cookie" , getTokenSentence ( null ) ) ; responseContext . setStatusInfo ( Response . Status . UNAUTHORIZED ) ; responseContext . setEntity ( "Token expired. Please login again." ) ; LOGGER . info ( "Token expired. Please login again." ) ; } else { token . setExpiration ( token . getMaxAge ( ) ) ; if ( ! logoutPath . equals ( requestContext . getUriInfo ( ) . getPath ( ) ) ) { String cookie = getTokenSentence ( token ) ; responseContext . getHeaders ( ) . putSingle ( "Set-Cookie" , cookie ) ; } } } catch ( Exception e ) { LOGGER . error ( "Token re-creation failed" , e . getMessage ( ) ) ; responseContext . setStatusInfo ( Response . Status . UNAUTHORIZED ) ; } } }
Checks the expiration date of token.
Renews and puts at header of response.

@param requestContext
@param responseContext
@return
Checks the expiration date of token . Renews and puts at header of response .