public static < ReturnType > ReturnType executeWithSystemPermissions ( Callable < ReturnType > task ) throws ExecutionException { ContextAwareCallable < ReturnType > contextAwareCallable = new ContextAwareCallable < ReturnType > ( task ) ; Subject newsubject = new Subject . Builder ( ) . buildSubject ( ) ; newsubject . login ( new RootAuthenticationToken ( ) ) ; try { return newsubject . execute ( contextAwareCallable ) ; } finally { newsubject . logout ( ) ; } }
Executes the given task with root - permissions . Use with care .