Class SecurityUtils


  • public class SecurityUtils
    extends Object
    Security utilities.
    • Field Detail

      • ALL_PERMISSIONS

        public static final Permissions ALL_PERMISSIONS
        Permissions that contain AllPermission.
    • Method Detail

      • isSecurityCompatibilityMode

        public static boolean isSecurityCompatibilityMode()
        Returns:
        Security compatibility mode flag.
      • serializeVersion

        public static void serializeVersion​(int ver)
        Parameters:
        ver - Serialize version.
      • serializeVersion

        public static int serializeVersion()
        Returns:
        Serialize version.
      • restoreDefaultSerializeVersion

        public static void restoreDefaultSerializeVersion()
        Sets default serialize version DFLT_SERIALIZE_VERSION.
      • nodeSecurityContext

        public static SecurityContext nodeSecurityContext​(Marshaller marsh,
                                                          ClassLoader ldr,
                                                          ClusterNode node)
        Gets the node's security context.
        Parameters:
        marsh - Marshaller.
        ldr - Class loader.
        node - Node.
        Returns:
        Node's security context.
      • securitySubjectId

        public static UUID securitySubjectId​(GridKernalContext ctx)
        Returns:
        Current security subject ID if security is enabled, otherwise null.
      • securitySubjectId

        public static UUID securitySubjectId​(GridCacheContext<?,​?> cctx)
        Returns:
        Current security subject id if security is enabled otherwise null.
      • securitySubjectId

        public static UUID securitySubjectId​(GridCacheSharedContext<?,​?> cctx)
        Returns:
        Current security subject id if security is enabled otherwise null.
      • withRemoteSecurityContext

        public static OperationSecurityContext withRemoteSecurityContext​(GridKernalContext ctx,
                                                                         SecurityContext secCtx)
        Sets specified security context as current if it differs from the null. null means that security context of the local node is specified or security is disabled so no security context change is needed. Note that this method is safe to use only when it is known to be called in the security context of the local node (e.g. in system workers).
        Returns:
        OperationSecurityContext instance if new security context is set, otherwise null.
      • doPrivileged

        public static <T,​E extends Exception> T doPrivileged​(Callable<T> c)
                                                            throws E extends Exception
        Computes a result in a privileged action.
        Type Parameters:
        T - Type of result.
        E - Type of Exception.
        Parameters:
        c - Instance of SandboxCallable.
        Returns:
        Computed result.
        Throws:
        E - if unable to compute a result.
        E extends Exception
      • hasSecurityManager

        public static boolean hasSecurityManager()
        Returns:
        True if SecurityManager is installed.
      • isSystemType

        public static boolean isSystemType​(GridKernalContext ctx,
                                           Object target,
                                           boolean considerWrapperCls)
        Returns:
        True if class of target is a system type.
      • isInIgnitePackage

        public static boolean isInIgnitePackage​(Class<?> cls)
        Parameters:
        cls - Class instance.
        Returns:
        Whether specified class is in Ignite package.
      • isInsideSandbox

        public static boolean isInsideSandbox()
        Returns:
        True if current thread runs inside the Ignite Sandbox.
      • sandboxedProxy

        public static <T> T sandboxedProxy​(GridKernalContext ctx,
                                           Class cls,
                                           T instance)
        Returns:
        Proxy of instance if the sandbox is enabled and class of instance is not a system type otherwise instance.
      • withSecurityContext

        public static Map<String,​Object> withSecurityContext​(SecurityContext secCtx,
                                                                   Map<String,​Object> nodeAttrs,
                                                                   Marshaller marsh)
                                                            throws IgniteCheckedException
        Marshals specified security context and adds it to the node attributes.
        Parameters:
        secCtx - Security context to be added.
        nodeAttrs - Cluster node attributes to which security context attribute is to be added.
        marsh - Marshaller.
        Returns:
        New copy of node attributes with security context attribute added.
        Throws:
        IgniteCheckedException - If security context serialization exception occurs.