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
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.
An unexpected failure in processing remember me cookie should be handled
gracefully. In particular, possibly problematic cookie should be
removed, or else the browser will keep bombarding the server with the
same cookie, and will never be able to get through.
It's much better to just drop the cookie.
This is already handled by ListView.Listener (other kinds of views are now responsible for their own listeners).
And handled better—if there are no actual changes
(because you have no such views, or they do not mention this job), there is no need to save.
Also moving the actual saving in those remaining cases out of the lock on the ListView itself, just in case.
(Util.createSymlink is partly to blame for not throwing a descriptive IOException when it fails to create a link,
but this is its historical behavior needed for compatibility.
copyRecursiveTo also continues to suppress error text from this method because there is nowhere for it to go.
Perhaps need a new variant of createSymlink that is guaranteed to either have created the link or throw an exception.)
... based on Tyler's discovery at https://gist.github.com/rtyler/9195510
testRemoting(hudson.util.ProcessTreeTest) Time elapsed: 0.097 sec <<< ERROR!
java.util.NoSuchElementException: null
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:897)
at java.util.HashMap$ValueIterator.next(HashMap.java:922)
at hudson.util.ProcessTreeTest$MyCallable.call(ProcessTreeTest.java:42)
at hudson.util.ProcessTreeTest$MyCallable.call(ProcessTreeTest.java:38)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
He runs this on FreeBSD.
The problem was masked by a blind assumption that an InvocationTargetException was in fact wrapping a ClassNotFoundException.
Many thanks to @gotwarlost for demonstrating how to reproduce the problem and diagnosing the cause.
In order to maintain backwards compatibility we need to keep IOUtils the
same as in commons-io 1.4. This code is backwards compatible, however
most of the methods have been deprecated and should instead use the
org.apache.commons.io.IOUtils version instead.