When creating various web services such as a REST service authentication tends to become relevant sooner or later. In some cases you want to integrate into existing services such as Google+ using OAuth in other cases – like here – you would rather have your own security schemes.
In searching for ways to do this I ran into a lot of older articles, which although being useful, often provided slightly outdated information or only half examples. This aims to provide a fully working basic example, with a complete source code for assistance. Basic example here means just enough to prove and show the concepts and enough to be used as a start for more advanced code.