re-factoring the permissions code to handle http & https and to be case-insensitive

Change-Id: I80f918efeddc613b13e5edc17bff9c8e72718199