added a convenience method
added a convenience method.
[JENKINS-20064]

Jenkins now remembers the authorities (read group memberships) that the user had carried when he/she last time interactively logged in.
This information is exposed via User.impersonate(), which is used when using Jenkins SSH, Jenkins CLI, or access via API tokens.

Previously this was impossible for a subset of SecurityRealms that does not allow us to read group membership information without
successful login (such as Active Directory, OpenID, etc.)

For security reasons, if the backend determines that the user does not exist (as opposed to the backend who cannot tell if the user
exists or not), then the impersonation will fail.

I need to check AD plugin is reporting a failure correctly in this case, before marking as JENKINS-20064 fixed.
Using latest and greatest (take 2
User.impersonate() now does the loadUserDetailsByName call.

So ApiTokenFilter no longer needs to do that.
Moving impersonation logic once again.

I think the cleanest place to do this is as a filter of UserDetailsService.

The problem is that SecurityRealm defines loadUserByName method, which AbstractPasswordBasedSecurityRealm overrides
Doing impersonation here as well.

See javadoc for discussion why this possibly redundant use is desirable
NPE fix
added another test for the basic remember-me flow
Merge branch 'master' of github.com:jenkinsci/jenkins