(before I start, standard caveats: I am not a lawyer yet, and even if I was, this isn't legal advice.)
What state are they in?
Here in WI, a man is presumed to be the father of a child born or conceived during his marriage. This presumption is rebuttable, by DNA or other evidence, if it would be in the best interest of the child. Needless to say, I know of no judge or court commissioner (and I've worked with quite a few recently) that would take a 5-year-old's father away, genetics or not. (I've seen the presumption rebutted for an infant conceived while a couple was separated or divorcing, but still technically married. NEVER in a case where a man has raised a child as his own and then had this dumped in his lap. I suppose anything can happen, but it would be rare.)
That said, it would be pretty simple for the mother to have the boyfriend and child DNA tested privately, and some judges might establish some visitation for the biological father (who, if he's living with the woman and children, is already spending time with the child). But I couldn't imagine him gaining any parental rights. The husband will, in all likelihood (though again, I can't guarantee anything), get the same custody he'd be entitled to, either way. (Here, there's a presumption of joint legal custody, and as much time with each parent as practicable, assuming both are fit parents. In many cases, it's 50/50. Depending on the state, the wife's infidelity and seeming abandonment of her older son can be a factor.)
Your friend (the husband) should get a lawyer for the divorce and custody battle that he's likely in for, whether he's his son's genetic father or not. He is that boy's dad.