ISPN-4405 & ISPN-4406

I think we'd better use a PrivilegedAction here, based on the same framework introduce by my PR https://github.com/infinispan/infinispan/pull/2629