A Brooklyn felon convicted of shooting his parole officer delivered a profane tirade at his sentencing today — then was slapped with the maximum 40 years to life in prison.

Robert Morales, 53, was convicted on attempted murder charges last month for shooting parole officer Sam Salters in 2010.

“Not all parole officers are bad, but d—head Salters and his partner don’t deserve that title. They deserve to be here with me in orange,” said Robert Morales, 53, referring to his DOC jumpsuit.

“To Salters and his partner, they can eat a d—k. With that in mind, thank you, your honor.”

Salters spoke before the sentence in a courtroom packed with his fellow parole officers.

“On that day I was in my office doing my job and I was viciously attacked,” said Salters.

“I took an oath and someone tried to take my life for that.”

Brooklyn Supreme Court Justice Alan Marrus said Morales should never again be a free man.

“I’ve been sentencing for 30 years and this is the easiest sentencing decision I’ll ever make,” the judge said.

“Any parole board that would ever parole this man would be committing legal malpractice.”

Morales realized he’d been hit with a heavy sentence.

“I’m f—ed for life,” he said. “I know I ain’t ever going to see the streets again, and I’m okay with that.”

When Morales was escorted out of court he lifted his cuffed hands behind him with both middle fingers raised in an obscene gesture to the gallery.

“He always gives us the finger, but we gave him the finger this time,” a celebrating court officer said outside the courtroom.

“He expresses no regret for his actions,” said assistant district attorney Lew Lieberman.

The high-profile sentencing was even attended by NYS Department of Corrections and Community Supervision commissioner Brian Fischer.

During his trial Morales said he hated Salters because the parole officer was disrespectful and overly strict.

Morales could have faced a lesser sentence but in 1979 he was convicted of setting a fire that killed an eight-year-old boy. He got out on parole in 2002.

“I was doing good for seven years,” Morales said today, referring to his time on parole before he shot Salters. “I wasn’t a problem. He was the problem. I addressed it in an extreme manner, no doubt about that.”

This was the second trial for Morales. The first trial ended in a mistrial last year.