Yes, the congress can enact whatever law they want, but any law so passed needs to be within the limit set by the constitution.
They can sue the government and claim the law is unconsitutional. I think they have pretty decent arguments based on freedom to contract, property rights, due process etc., although this doesn't seem to be a good move from the PR perspective.
Obama used to teach constitution law in law school, that's why he anticipated there are possible grounds to challenge the law.