Package org.infinispan.security
Class Security
java.lang.Object
org.infinispan.security.Security
Security. A simple class to implement caller privileges without a security manager and a much faster implementations
of the
Subject.doAs(Subject, PrivilegedAction)
and Subject.doAs(Subject, PrivilegedExceptionAction)
when interaction with the AccessControlContext
is not needed.
N.B. this uses the caller's Package
, this can easily be subverted by placing the calling code within the
org.infinispan hierarchy. However for most purposes this is ok.
- Since:
- 7.0
- Author:
- Tristan Tarrant
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkPermission
(CachePermission permission) static void
static <T> T
doAs
(Subject subject, PrivilegedAction<T> action) A "lightweight" implementation ofSubject.doAs(Subject, PrivilegedAction)
which uses a ThreadLocalSubject
instead of modifying the currentAccessControlContext
.static <T> T
doAs
(Subject subject, PrivilegedExceptionAction<T> action) A "lightweight" implementation ofSubject.doAs(Subject, PrivilegedExceptionAction)
which uses a ThreadLocalSubject
instead of modifying the currentAccessControlContext
.static <T,
U, R> R doAs
(Subject subject, BiFunction<T, U, R> function, T t, U u) static <T,
R> R static <T> T
doPrivileged
(PrivilegedAction<T> action) static <T> T
doPrivileged
(PrivilegedExceptionAction<T> action) static Subject
If usingdoAs(Subject, PrivilegedAction)
ordoAs(Subject, PrivilegedExceptionAction)
, returns theSubject
associated with the current thread otherwise it returns theSubject
associated with the currentAccessControlContext
static Principal
Returns the first principal of a subjectstatic boolean
static String
A simplified version of Subject.toString() with the following advantages: only lists principals, ignoring credentials uses a compact, single-line format does not use synchronization does not use i18n messages
-
Constructor Details
-
Security
public Security()
-
-
Method Details
-
doPrivileged
-
doPrivileged
public static <T> T doPrivileged(PrivilegedExceptionAction<T> action) throws PrivilegedActionException - Throws:
PrivilegedActionException
-
doAs
-
doAs
-
doAs
-
doAs
A "lightweight" implementation ofSubject.doAs(Subject, PrivilegedAction)
which uses a ThreadLocalSubject
instead of modifying the currentAccessControlContext
.- See Also:
-
doAs
public static <T> T doAs(Subject subject, PrivilegedExceptionAction<T> action) throws PrivilegedActionException A "lightweight" implementation ofSubject.doAs(Subject, PrivilegedExceptionAction)
which uses a ThreadLocalSubject
instead of modifying the currentAccessControlContext
.- Throws:
PrivilegedActionException
- See Also:
-
checkPermission
- Throws:
AccessControlException
-
isPrivileged
public static boolean isPrivileged() -
getSubject
If usingdoAs(Subject, PrivilegedAction)
ordoAs(Subject, PrivilegedExceptionAction)
, returns theSubject
associated with the current thread otherwise it returns theSubject
associated with the currentAccessControlContext
-
getSubjectUserPrincipal
Returns the first principal of a subject -
toString
A simplified version of Subject.toString() with the following advantages:- only lists principals, ignoring credentials
- uses a compact, single-line format
- does not use synchronization
- does not use i18n messages
- Parameters:
subject
-- Returns:
-