Currently, the LockHelper#markAsWOPIUser(Principal principal) and LockHelper#isWOPIUser(Principal principal) methods rely on the principal for synchronization which could be improved since:
- It doesn't protect against other threads that would want to modify the context data, which was not designed to be thread-safe (HashMap).
- It is a hack: what we want to mark is the current request. We could simply use a ThreadLocal, if there's no risk of spawning other threads asynchronously. Indeed, nothing guarantees that the NuxeoPrincipal objects musn't be shared, (we could imagine some cache).