Support for Security Token Service

**Work in progress**

This PR adds support for Security Token Service. Take 2.

This time I have looked a bit more carefully into the coding style.