There are two halves to the fork lock style ignition switches with the key switch bolted on the top crown. The upper half is all mechanical - if the key turns and locks and comes out normally, the mechanical part is fine. This is good because your seat lock/helmet lock, and on CB650 models with the locking removable gas caps, are all keyed the same, (as on CX500, CBX, DOHC fours, etc).
The bottom part is plastic, and has the switching mechanism and harness connector. These get loose and worn over time. The actual switch contacts are layered inside - the 2 balls visible serve as switch position detents only.
The wiring harness connector is getting tugged constantly, as the switch/steering rotate and the harness wants to stay put, and is the cause of the failure. Honda realized this and made separate kits available with these parts, but they are long discontinued. (You can see it on the CBX parts catalog ignition switch/top clamp page).
Fortunately, they are available for well less than $25 on eBay or Amazon under "Honda ignition switch repair kit". I would recommend staying with the EMGO brand, as their quality is very good.