Refactor JWT generation to reduce code duplication (bug 979551)

- Split JWT creation and testing into their own modules
- Create 'product' abstraction layer
- Single JWT producing code, conencts to webapp and inapp through product interface layer