Mr. McCain 's campaign has been attacking Mr. Obama for ties to former officials of the mortgage giants , both of which have a long history of cultivating Democratic and Republican allies alike to fend off efforts to restrict their activities .