Package org.infinispan.security
Class Security
- java.lang.Object
-
- org.infinispan.security.Security
-
public final class Security extends Object
Security. A simple class to implement caller privileges without a security manager and a much faster implementations of theSubject.doAs(Subject, PrivilegedAction)andSubject.doAs(Subject, PrivilegedExceptionAction)when interaction with theAccessControlContextis 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
Constructors Constructor Description Security()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckPermission(CachePermission permission)static voiddoAs(Subject subject, Runnable action)static <T> TdoAs(Subject subject, PrivilegedAction<T> action)A "lightweight" implementation ofSubject.doAs(Subject, PrivilegedAction)which uses a ThreadLocalSubjectinstead of modifying the currentAccessControlContext.static <T> TdoAs(Subject subject, PrivilegedExceptionAction<T> action)A "lightweight" implementation ofSubject.doAs(Subject, PrivilegedExceptionAction)which uses a ThreadLocalSubjectinstead of modifying the currentAccessControlContext.static <T,U,R>
RdoAs(Subject subject, BiFunction<T,U,R> function, T t, U u)static <T,R>
RdoAs(Subject subject, Function<T,R> function, T t)static <T> TdoPrivileged(PrivilegedAction<T> action)static <T> TdoPrivileged(PrivilegedExceptionAction<T> action)static SubjectgetSubject()If usingdoAs(Subject, PrivilegedAction)ordoAs(Subject, PrivilegedExceptionAction), returns theSubjectassociated with the current thread otherwise it returns theSubjectassociated with the currentAccessControlContextstatic PrincipalgetSubjectUserPrincipal(Subject s)Returns the first principal of a subjectstatic booleanisPrivileged()static StringtoString(Subject subject)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
-
-
-
Method Detail
-
doPrivileged
public static <T> T doPrivileged(PrivilegedAction<T> action)
-
doPrivileged
public static <T> T doPrivileged(PrivilegedExceptionAction<T> action) throws PrivilegedActionException
- Throws:
PrivilegedActionException
-
doAs
public static <T,U,R> R doAs(Subject subject, BiFunction<T,U,R> function, T t, U u)
-
doAs
public static <T> T doAs(Subject subject, PrivilegedAction<T> action)
A "lightweight" implementation ofSubject.doAs(Subject, PrivilegedAction)which uses a ThreadLocalSubjectinstead of modifying the currentAccessControlContext.- See Also:
Subject.doAs(Subject, PrivilegedAction)
-
doAs
public static <T> T doAs(Subject subject, PrivilegedExceptionAction<T> action) throws PrivilegedActionException
A "lightweight" implementation ofSubject.doAs(Subject, PrivilegedExceptionAction)which uses a ThreadLocalSubjectinstead of modifying the currentAccessControlContext.- Throws:
PrivilegedActionException- See Also:
Subject.doAs(Subject, PrivilegedExceptionAction)
-
checkPermission
public static void checkPermission(CachePermission permission) throws AccessControlException
- Throws:
AccessControlException
-
isPrivileged
public static boolean isPrivileged()
-
getSubject
public static Subject getSubject()
If usingdoAs(Subject, PrivilegedAction)ordoAs(Subject, PrivilegedExceptionAction), returns theSubjectassociated with the current thread otherwise it returns theSubjectassociated with the currentAccessControlContext
-
getSubjectUserPrincipal
public static Principal getSubjectUserPrincipal(Subject s)
Returns the first principal of a subject
-
-