re-factoring the permissions code to handle www and deed.lc urls

Change-Id: Ieb5aba2f17fd4cede43b2acaf5b8db6755305906