President Obama decried a recent spike in military assaults -- and appeared to criticize turmoil at the IRS -- as he delivered the commencement speech Friday at the US Naval Academy in Annapolis.

As he lauded the grads for their service, Obama called on them to uphold the honor of their service, as he talked about how the "actions of a few" have eroded public confidence in government.

"We need your honor, that inner compass that guides you, not when the path is easy and obvious, but it's hard and uncertain, that tells you the difference between that which is right and that which is wrong," he told the graduates in their white dress uniforms.

He said that those who commit sexual assaults are not only committing a crime, "they threaten the trust and discipline that makes our military strong. That's why we have to be determined to stop these crimes. Because they've got no place in the greatest military on Earth."

Obama opened his remarks on the scandal by noting that in recent decades, Americans have lost confidence in government, and that "we've seen how the actions of a few can undermine the integrity of those institutions."

He brought up mortgage companies and banks, saying they "put families in new homes and help students go to college."

But, he added, the "misdeeds of some, wild risk-taking or putting profits before people, sparked a financial crisis and deepened the recession that cost millions of Americans their jobs."

And he charged that politics where "compromise is rejected as a dirty word" and policies are "driven by special interests" have served to breed "cynicism that threatens our democracy."

He noted that civil servants do their jobs daily, "with professionalism," but said "it only takes the misconduct of a few to further erode the people's trust in their government."

He lauded the military for serving as "one American team," but added, "we must acknowledge that even here, even in our military, we've seen how the misconduct of some can have effects that ripple far and wide."

He likened the damage caused by sexual assaults seemingly to the pictures of soliders degrading detainees at the Abu Ghraib prison camp, saying that "a single image from the battlefield of troops falling short of their standards can go viral and endanger our forces and undermine our efforts to achieve security and peace."

He told the graduates he was telling them because they are "about to assume the burden of leadership. As officers, you'll be trusted with the most awesome of responsibilities, the lives of the men and women under your command. And when your service is complete, many of you will go on to help lead your communities, America's companies. You will lead this country.

"And if we want to restore the trust that the American people deserve to have in their institutions, all of us have to do our part. And those of us in leadership, myself included, have to constantly strive to remain worthy of the public trust."