PORTLAND, Ore. — A Somali-born teenager who thought he was detonating a car bomb at a packed Christmas tree-lighting ceremony downtown here was arrested by the authorities on Friday night after federal agents said that they had spent nearly six months setting up a sting operation.