public static void executeWithSystemPermissions ( Runnable task ) { ContextAwareRunnable contextAwaretask = new ContextAwareRunnable ( task ) ; Subject newsubject = new Subject . Builder ( ) . buildSubject ( ) ; newsubject . login ( new RootAuthenticationToken ( ) ) ; try { newsubject . execute ( contextAwaretask ) ; } finally { newsubject . logout ( ) ; } }
wraps an existing ExecutorService to handle context - and security - related threadlocal variables