Anthony France, 41, from Watford, is accused of paying an anti-terror police officer at Heathrow Airport for tips.
Mr France said he would never have become involved if he had known it was illegal as he was a "man of good character not involved in crime".
He denies aiding and abetting Pc Timothy Edwards to commit misconduct in a public office.
The trial is part of the Metropolitan Police's Operation Elveden, which is investigating alleged illegal payments to police and officials.
While working as an officer in the Metropolitan Police's Counter Terrorism Command based at Heathrow Airport, Pc Edwards, 49, allegedly sold 38 stories and pieces of information to the journalist in exchange for more than Â£22,000.
Asked what he would have done if he thought talking to Pc Edwards might be illegal, Mr France said: "I would never have got involved with it.
"I would have told him to get lost. I'm a man of good character not involved in crime."
The court heard how Pc Edwards was "given" to Mr France as a source.
After they met at a pub in 2008, he was told by a colleague: "I've spoken to a lawyer and it's fine."
Asked what Pc Edwards' employers might have done if they had found out, Mr France said: "I suspected they might not be happy and might put him through a disciplinary process.
"I thought with the public interest involved that the worst that might happen was he might be sacked. It never came to my mind that anybody considered it criminal."
The court heard while working as the Sun's crime reporter between 2006 and 2010, he had been involved in numerous campaigns involving victims of crime and even worked undercover.
For example, he did a lot of work with the father of young murder victim Damilola Taylor, he said.
But in 2010, Mr France had his title taken away by a boss at the Sun who he described as a "homophobic bully".
He said as a black gay man, it was particularly challenging working for the senior journalist, who cannot be named for legal reasons.
"I could stick up for myself but then there were attempts by him to get me out of the newspaper," he told the court.
Asked by his barrister Adrian Keeling QC why he was determined to stay, Mr France replied: "Because crime reporting is my life."
Mr France is accused of aiding and abetting Pc Edwards to commit misconduct in a public office between March 2008 and July 2011.
The trial continues.
A Sun reporter has told the Old Bailey he never thought paying a source for stories was wrong or against the law.