There is one problem with the entirely justified if self-interested media squawking about the Justice Department snooping into the phone records of multiple Associated Press reporters and Fox News' James Rosen.

The problem is that what the AP reporters and Rosen did arguably violates the letter of the law.

The search warrant in the Rosen case cites Section 793(d) of Title 18 of the U.S. Code.

Section 793(d) says that a person lawfully in possession of information that the government has classified as secret who turns it over to someone not lawfully entitled to possess it has committed a crime. That might cover Rosen's source.

Section 793(g) is a conspiracy count that says that anyone who conspires to help the source do that has committed the same crime. That would be the reporter.

It sounds like this law criminalizes a lot of journalism. You might wonder how such a law ever got passed and why, for the last 90 years, it has very seldom produced prosecutions and investigations of journalists.

The answer: This is the Espionage Act of 1917, passed two months after the United States entered World War I. In his 1998 book "Secrecy," the late Sen. Daniel Patrick Moynihan tells the story of how the law came into being.

Congress was responding to incidents of German espionage before the declaration of war. In July 1916, German agents blew up the Black Tom munitions dump in New York Harbor. The explosion was loud enough to be heard from Connecticut to Maryland.

The Espionage Act was passed with bipartisan support in a Democratic Congress and strongly supported by Democratic President Woodrow Wilson.

Wilson wanted even more. "Authority to exercise censorship over the press is absolutely necessary," he wrote a senator. He got that authority in May 1918 when Congress passed the Sedition Act criminalizing, among other things, "abusive language" about the government.

Wilson's Justice Department successfully prosecuted Eugene Debs, the Socialist candidate who received 900,000 votes for president in 1912, for making statements opposing the war.

The Wilson administration barred socialist newspapers from the mails, jailed a filmmaker for making a movie about the Revolutionary War (don't rile our British allies) and prosecuted a minister who claimed Jesus was a pacifist.

German-language books were removed from libraries, German-language newspapers forced out of business and one state banned speaking German outdoors.

It was an ugly period in our history. It's also a reminder that big government liberals can be as much inclined to suppress civil liberties as small government conservatives -- or more so.

Fortunately, things changed after Wilson left office. A Republican Congress allowed the Sedition Act to expire in 1921.

Debs, who received 915,000 votes for president in 1920 while in Atlanta federal prison, was pardoned by Republican President Warren Harding (a former journalist) and invited to the White House.

The Espionage Act of 1917 remained on the books and was amended to cover news media. But it was used sparingly.

Franklin Roosevelt, who served in the Wilson administration, didn't use it in World War II. When his attorney general urged him to prosecute the Chicago Tribune for a story three days before Pearl Harbor detailing military plans for a possible world war, he brushed the recommendation aside.

That despite the fact that New Deal Democrats were as paranoid about the Republican and isolationist Tribune as conservatives have been in recent times about the New York Times.

Roosevelt did order the internment of West Coast Japanese-Americans in 1942. But an act apologizing for that and providing restitution was passed with bipartisan majorities and signed by Ronald Reagan in 1988.

Presidents and attorneys general of both parties have been reluctant to use the Espionage Act when secret information has been leaked to the press because they have recognized that it is overbroad.

They have understood, as Moynihan argues in "Secrecy," that government classifies far too many things as secrets, even as it has often failed to protect information that truly needs to stay secret.

Barack Obama and his Justice Department seem to be of a different mind. They have used the Espionage Act of 1917 six times to bring cases against government officials for leaks to the media six times -- twice as many as all their predecessors combined.

"Gradually, over time," Moynihan writes, "American government became careful about liberties." Now, suddenly, it seems to be moving in the other direction.

Michael Barone, The Washington Examiner's senior political analyst, can be contacted at mbarone@washingtonexaminer.com. His column appears Wednesday and Sunday, and his stories and blog posts appear on washingtonexaminer.com.