code: public boolean isSessionValid( final String token, long validityPeriod ) {
  
  		boolean valid = false;
  		Long loginTime = null;
  		if( token != null )
  			loginTime = this.tokenToLoginTime.get( token );
  
  		if( validityPeriod < 0 ) {
  			valid = loginTime != null;
  
  		} else if( loginTime != null ) {
  			long now = new Date().getTime();
  			valid = (now - loginTime) <= validityPeriod * 1000;
  
  			// Invalid sessions should be deleted
  			if( ! valid )
  				logout( token );
  		}
  
  		return valid;
  	}
docs: Determines whether a session is valid.
  @param token a token
  @param validityPeriod the validity period for a session (in seconds, < 0 for unbound)
  @return true if the session is valid, false otherwise