Implementation of a more generic authenticator 

This pull request addresses issues #49 and #96. This is a work in progress to get some suggestions from @fernandoacorreia and @dnephin.