Jessica Durando

USA TODAY

A Kenyan court ruled Thursday the use of anal examinations to determine a suspect’s sexual orientation is legal, despite arguments that the procedure is a form of torture.

Mombasa High Court Judge Mathew Emukule said, “I find no violation of human dignity, right to privacy and right to freedom of the petitioners," the Associated Press reported.

The court in Mombasa made the decision after reviewing the case of two men who were arrested in a bar near Ukunda along Kenya's Indian Ocean coast in Feburary 2015 on suspicion of having sex.

In Kenya, gay sex is a criminal offense and can bring prison sentences of up to 14 years.

The two men were forced to have anal examinations and HIV and Hepatitis B tests, and they petitioned that they were being "subjected to torture and degrading treatment," the AP reported.

A judge dismissed their petition Thursday. The men still face charges.

Cameroon, Egypt, Tunisia, Turkmenistan, Uganda and Zambia are other countries that still use anal exams to determine homosexuality, the Washington Post reported.