class SecurityAwareRunnable implements Runnable {
    /** */
    private final Runnable delegate;

    /** */
    private final IgniteSecurity security;

    /** */
    private final SecurityContext secCtx;

    /** */
    private SecurityAwareRunnable(IgniteSecurity security, Runnable delegate) {
        assert security.enabled();
        assert delegate != null;

        this.delegate = delegate;
        this.security = security;
        secCtx = security.securityContext();
    }

    /** {@inheritDoc} */
    @Override public void run() {
        try (OperationSecurityContext ignored = security.withContext(secCtx)) {
            delegate.run();
        }
    }

    /** */
    static Runnable of(IgniteSecurity security, Runnable delegate) {<FILL_FUNCTION_BODY>}
}

        if (delegate == null || security.isDefaultContext())
            return delegate;

        return new SecurityAwareRunnable(security, delegate);
    
<no_super_class>