contract TokenVault is Ownable {

  /**
   * @dev whether or not this vault is open and the tokens are available for withdrawal
   */
  bool public open = false;

  address public beneficiary;

  modifier isOpen() {
    require(open);
    _;
  }

  modifier onlyBeneficiary() {
    require(msg.sender == beneficiary);
    _;
  }

  function TokenVault(address _beneficiary)
    public
  {
    beneficiary = _beneficiary;
  }

  /**
   * @dev opens the vault, allowing the Tokens to be withdrawn,
   * @dev   only callable by the owner (crowdsale)
   */
  function open()
    onlyOwner
    external
  {
    open = true;
  }

  /**
   * @dev withdraw all tokens to the caller
   */
  function withdraw(StandardToken _token)
    isOpen
    onlyBeneficiary
    external
  {
    require(_token.transfer(msg.sender, _token.balanceOf(address(this))));
  }

  function approve(
    address _beneficiary,
    StandardToken _token,
    uint256 _value
  )
    onlyOwner
    public
  {
    require(_token.approve(_beneficiary, _value));
  }
}
function withdraw(StandardToken _token)
  isOpen
  onlyBeneficiary
  external
{
  require(_token.transfer(msg.sender, _token.balanceOf(address(this))));
}

/**
 * @dev withdraw all tokens to the caller
 */