At night, after John Gallagher prosecuted gang and drug violence, his sporadic search resumed. The assistant U.S. attorney, based in Philadelphia, scoured the Internet for hints of Val James, the first American-born black man to play in the NHL. There were no interviews, zero traces, and Gallagher suspected that James confronted cruel backlash in his attempt to crack a sport dominated by whites.

A tip buried in the comments beneath video showing James in a hockey fight led Gallagher in 2012 to Great Wolf Lodge, a water park in Niagara Falls, Ontario. James had been living there in obscurity as an aquatics maintenance worker. Gallagher wanted to meet.

"At first," James said, "I couldn't believe it."

The two men combined to write Black Ice: The Val James Story, an autobiography released last month about James' struggle against constant racial insults and taunts.

"As a prosecutor, a big part of our job is to restore a sense of justice to someone who's had it denied," Gallagher, 49, said from his 11th-floor office overlooking Independence Hall. "With the telling of Val's story, I'm hoping that we can repair some of the injustice that he was forced to endure just because he was trying to live his dream of playing hockey."

Gallagher had the idea of finding Valmore James for years. He volunteered as a youth coach for the program Ice Hockey in Harlem soon after becoming a police officer in the neighborhood. He was always a hockey fan, but coaching inner-city kids made Gallagher more curious about the perseverance of black professional players.

"I really fell in love with the kids and the program," said Gallagher, who commuted to coach even after former Police Commissioner John P. Timoney lured him to Philadelphia in 1998 to revamp the department's disciplinary system.

Each time Gallagher searched for James, he hit a dead end. It was not a constant pursuit, but it kept tugging. He heard that James lived in Florida. And Texas. Maybe still in New York. There was one online post that said James had died.

"None of this," Gallagher said, "was true."

The correct tip sent Gallagher to Canada, where he visited James. The two men - both raised on Long Island - discovered a partnership. James had contemplated breaking his silence before. Eight minutes into their first meeting, he knew this was right.

"Just how he talked," James said. "I could tell we would be able to word it the way I wanted to word it."

James, an enforcer known for his fists, played in 11 NHL games for Buffalo and Toronto in the '80s. Willie O'Ree, a Canadian, had broken hockey's racial barrier in 1958. But more than 20 years later, fans and opposing players directed vulgar obscenities at James.

"Since I couldn't act on my fantasy of shoving a hockey puck down the throat of every bigmouthed racist," James wrote, "one acceptable way for me to respond to these attacks was to turn up my physical play."

James did not watch a hockey game for 17 years after his retirement in 1988. The memories conjured up pain that he could not avoid.

"Actually," he said, "I could see the pictures and hear the words. They still sting when you think about it. It was more of a therapeutic thing."

Gallagher and James completed the manuscript for Black Ice six months before Gallagher's day job consumed him. Gallagher, who joined the U.S. Attorney's Office in 2005, was one of three prosecutors in the 2013 trial of drug kingpin Kaboni Savage, the first criminal in modern Philadelphia history to receive a federal death sentence.

Sometime during the trial, a friend sent Gallagher an old clip of a bench-clearing minor-league brawl in Erie. James was in there somewhere, the sender said. Gallagher listened to the local announcers describing the mayhem.

"Boy," one broadcaster said, "referee Pat Meehan sure has his hands tied."

Gallagher was stunned. "It was like a thunderclap," he said.

He called U.S. Rep. Patrick Meehan (R., Pa.), who as the U.S. attorney for the Eastern District of Pennsylvania had hired Gallagher as a federal prosecutor, and explained the fortuitous coincidence. Of course, Meehan said, he remembered James. He could never forget one night in Richmond, Va.

James fought an opponent, and Meehan sent him to the penalty box for five minutes. The referee, just as he was about to drop the puck, heard the crowd roar. Two fans were brandishing a monkey doll on a noose and waving it at James. Meehan delayed the game until the fans were removed.

The book has given James new purpose at 58. He met with Ken Martin, the NHL's vice president for diversity programming, last month to pursue an ambassador role.

He had never harbored animosity. It was just a part of his life he wanted to leave behind.

His attitude evolved.

"It was all because of John," James said. "There is no doubt about that. Once we started telling the story, it just clicked. It was John's doing. I give him all the credit for it. It was perfect."

And, for Gallagher, justice took the form of a 232-page book rather than a judge's verdict.

215-854-2928 @MattGelb