-
public interface Privilege
Clean interface to thedoPrivileged...
methods onAccessController
.This interface must remain non-exported from
org.postgresql.pljava.internal
.The reason, of course, is that the real methods on
AccessController
end up getting called from these wrappers, and will therefore apply the permissions granted to this module. As long as these methods are only accessible within this module, that isn't a problem.It would be great to develop this into an exportable API so user code could benefit, but that would be a much trickier undertaking, with editing of
AccessControlContext
s to snag the correct caller's context, and not for the faint of heart.Each method here comes in a flavor accepting a
Checked.Supplier
, matching any lambda that returns a reference type, and a flavor accepting aChecked.Runnable
forvoid
lambdas, because the compiler will not match those up withSupplier<Void>
.Fuss no more with
PrivilegedExceptionAction
and catchingPrivilegedActionException
: just pass any of these methods a lambda. If the lambda throws a checked exception, so does the method. If the lambda throws some checked exceptions, the method throws their least common supertype, which is not as nice as throwing their union, and climbs all the way up toException
if they are unrelated. But even so, you can now simply catch it, rather than catching aPrivilegedActionException
and having to unwrap it first.
-
-
Method Summary
-
-
-
Method Detail
-
doPrivileged
static <T,E extends Exception> T doPrivileged(Checked.Supplier<T,E> op) throws E extends Exception
- Throws:
E extends Exception
-
doPrivileged
static <T,E extends Exception> T doPrivileged(Checked.Supplier<T,E> op, AccessControlContext acc) throws E extends Exception
- Throws:
E extends Exception
-
doPrivileged
static <T,E extends Exception> T doPrivileged(Checked.Supplier<T,E> op, AccessControlContext acc, Permission... perms) throws E extends Exception
- Throws:
E extends Exception
-
doPrivilegedWithCombiner
static <T,E extends Exception> T doPrivilegedWithCombiner(Checked.Supplier<T,E> op) throws E extends Exception
- Throws:
E extends Exception
-
doPrivilegedWithCombiner
static <T,E extends Exception> T doPrivilegedWithCombiner(Checked.Supplier<T,E> op, AccessControlContext acc, Permission... perms) throws E extends Exception
- Throws:
E extends Exception
-
doPrivileged
static <E extends Exception> void doPrivileged(Checked.Runnable<E> op) throws E extends Exception
- Throws:
E extends Exception
-
doPrivileged
static <E extends Exception> void doPrivileged(Checked.Runnable<E> op, AccessControlContext acc) throws E extends Exception
- Throws:
E extends Exception
-
doPrivileged
static <E extends Exception> void doPrivileged(Checked.Runnable<E> op, AccessControlContext acc, Permission... perms) throws E extends Exception
- Throws:
E extends Exception
-
doPrivilegedWithCombiner
static <E extends Exception> void doPrivilegedWithCombiner(Checked.Runnable<E> op) throws E extends Exception
- Throws:
E extends Exception
-
doPrivilegedWithCombiner
static <E extends Exception> void doPrivilegedWithCombiner(Checked.Runnable<E> op, AccessControlContext acc, Permission... perms) throws E extends Exception
- Throws:
E extends Exception
-
-