From a 2006 interview with British journalist James Rubin:

RUBIN: "Do you think that American diplomats should be operating the way they have in the past, working with the Palestinian government if Hamas is now in charge?"

McCAIN: "They're the government; sooner or later we are going to have to deal with them, one way or another, and I understand why this administration and previous administrations had such antipathy towards Hamas because of their dedication to violence and the things that they not only espouse but practice, so . . . but it's a new reality in the Middle East. I think the lesson is people want security and a decent life and decent future, that they want democracy. Fatah was not giving them that."

NYT:

[I]n a fund-raising letter sent out in April, a spokesman for Mr. McCain wrote: “We need change in America, but not the kind of change that wins kind words from Hamas, surrenders in Iraq and will hold unconditional talks with Iranian President Ahmadinejad.”

In particular, the McCain campaign has explicitly linked Mr. Yousef’s statements to Mr. Obama’s repeatedly stated willingness to talk to so-called “rogue states” like Iran, North Korea and Cuba.

“Well, Iran is obviously an important supporter of Hamas,” Mr. McCain said Friday.

Rubin has an editorial in today's Washington Post where he accused McCain of hypocrisy. I think that's a bit harsh. Senator Out O'Touch probably just doesn't remember what he said.