public void saveToken ( CsrfToken t , HttpServletRequest request , HttpServletResponse response ) { String ident = getIdentifierFromCookie ( request ) ; if ( ident != null ) { String key = ident . concat ( parameterName ) ; CsrfToken token = loadToken ( request ) ; if ( token == null ) { token = generateToken ( null ) ; if ( Config . isCacheEnabled ( ) ) { cache . put ( Config . getRootAppIdentifier ( ) , key , token , ( long ) Config . SESSION_TIMEOUT_SEC ) ; } else { localCache . put ( key , new Object [ ] { token , System . currentTimeMillis ( ) } ) ; } } storeTokenAsCookie ( token , request , response ) ; } }
Saves a CSRF token in cache .