The federal ruling could affect President Obama’s efforts to close the detention site at Guantánamo Bay, Cuba.