Top Description Fields Constructors Methods
org.eclipse.jetty.util.security

public Class SecurityUtils

extends Object
Class Inheritance
Imports
java.lang.invoke.MethodHandle, .MethodHandles, .MethodType, java.security.Permission, .PrivilegedAction, java.util.concurrent.Callable, .CompletionException, javax.security.auth.Subject

Collections of utility methods to deal with the scheduled removal of the security classes defined by JEP 411.

Field Summary

Modifier and TypeField and Description
private static final MethodHandle
private static final MethodHandle

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static <T> PrivilegedAction<T>
public static void
checkPermission(Permission
the permission to check
permission
)

Checks the given permission, if the security manager is set.

public static <
the type of the result
T
>
T

Returns:

the result of the action
doAs
(Subject
the subject this action runs as
subject
,
Callable<T>
the action to run
action
)

Runs the given action as the given subject.

public static <
the type of the result
T
>
T

Returns:

the result of running the action
doPrivileged
(PrivilegedAction<T>
the action to run
action
)

Runs the given action with the calling context restricted to just the calling frame, not all the frames in the stack.

private static <T> T
doPrivileged(MethodHandle doPrivileged, PrivilegedAction<T> action)

public static Object

Returns:

the current security manager, if available
getSecurityManager
()

Get the current security manager, if available.

private static MethodHandle
private static MethodHandle
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

doAsback to summary
private static final MethodHandle doAs
doPrivilegedback to summary
private static final MethodHandle doPrivileged

Constructor Detail

SecurityUtilsback to summary
private SecurityUtils()

Method Detail

callableToPrivilegedActionback to summary
private static <T> PrivilegedAction<T> callableToPrivilegedAction(Callable<T> callable)
checkPermissionback to summary
public static void checkPermission(Permission permission) throws SecurityException

Checks the given permission, if the security manager is set.

Parameters
permission:Permission

the permission to check

Exceptions
SecurityException:
if the permission check fails
doAsback to summary
public static <T> T doAs(Subject subject, Callable<T> action)

Runs the given action as the given subject.

Parameters
<T>
the type of the result
subject:Subject

the subject this action runs as

action:Callable<T>

the action to run

Returns:T

the result of the action

Annotations
@SuppressWarnings:unchecked
doPrivilegedback to summary
public static <T> T doPrivileged(PrivilegedAction<T> action)

Runs the given action with the calling context restricted to just the calling frame, not all the frames in the stack.

Parameters
<T>
the type of the result
action:PrivilegedAction<T>

the action to run

Returns:T

the result of running the action

doPrivilegedback to summary
private static <T> T doPrivileged(MethodHandle doPrivileged, PrivilegedAction<T> action)
Annotations
@SuppressWarnings:unchecked
getSecurityManagerback to summary
public static Object getSecurityManager()

Get the current security manager, if available.

Returns:Object

the current security manager, if available

lookupDoAsback to summary
private static MethodHandle lookupDoAs()
lookupDoPrivilegedback to summary
private static MethodHandle lookupDoPrivileged()