These must be non-dog people.
You always offer your hand below the dog’s chin, preferably squatting down if it is a smaller dog, like Barney, so he/she can smell it first. Then, if dog seems content with the sniff-over, you pat the side of the neck.
Towering figures bringing hands down over a dog’s head, to pat the head, are just asking for a good bite. If you were a dog, what would you think?
Furthermore, if Barney was really a nasty dog, they would have needed stitches. Barney’s nips were his way of warning them that they didn’t pass the sniff test.
I own Belgian Malinois, and most people who come to the door know enough not to try to pet them, until they have been well sniffed-over.
Barney’s breed is somewhat similar in temperament, in that they tend to be stand-offish with strangers, and are known to be good protectors of the farm and family. Terriers are a lot more stubborn than Malinois, of course. But neither breed likes to be petted by total strangers.
These are not your lovable doofus labs or goldens! And, I say Barney was entitled. His personal space was being invaded.
Approaching a dog you've never met with your hand over the dog's head or at mouth level is asking for a bite. As I am sure you know, patting a strange dog on top of the head places the dog in a submissive position and can make the animal feel threatened.
Your approach is quite correct. We have pure-breds with AKC obedience titles on both but if they feel threatened, they let you know about it.
If I were Barney, I would have bitten him too.