Red gave some really good advice, and that article link is a gem!
In my experience, the most important thing is to never let the dog think you're afraid of him. Rebecca is one of the sweetest, most gentle girls. Yet when she was a puppy, I had her on my lap brushing her. She started to writhe about and snarl and snap. I held her close, said no in a firm voice, and she quieted. I waited a couple of beats while she was good and then praised her and let her down. I warned Rick of her behavior, and sure enough she pulled the same stunt on him that night while he was brushing her. He was ready, though, and reacted just as I had done earlier that day. And that was it. She had tested us, discovered it wouldn't work, and she quit for good.
If we had shrunk from her or let her down immediately, it would have sent a clear message to her that she was alpha in our house.
My first dog was a Rottie who tried to seriously attack the vet as a tiny pup on his very first visit to be checked out. The vet pronounced the pup vicious, and said to take it back. I already loved the little guy...we had picked him out at 4 weeks and took him home at 8 weeks...and I was stubborn and decided the dog could be trained out of his behavior. Well, he lived to 14 and never harmed a soul. It took lots and lots of reading on the topic, much socialization, and some changes in my way of thinking on how dogs should be raised (growing up we'd had poodles!!). But it can be done. Dogs are not vicious, but they can and will use any method they have (teeth, claws) to get their way. My advice is to read all you can on the subject and do what works for your dog.

Rick and Magnus