예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void setup(Dependencies dependencies) throws org.neo4j.internal.kernel.api.exceptions.KernelException
        public override void Setup(Dependencies dependencies)
        {
            Config                config           = dependencies.Config();
            Procedures            procedures       = dependencies.Procedures();
            LogProvider           logProvider      = dependencies.LogService().UserLogProvider;
            JobScheduler          jobScheduler     = dependencies.Scheduler();
            FileSystemAbstraction fileSystem       = dependencies.FileSystem();
            AccessCapability      accessCapability = dependencies.AccessCapability();

            SecurityLog securityLog = SecurityLog.create(config, dependencies.LogService().getInternalLog(typeof(GraphDatabaseFacade)), fileSystem, jobScheduler);

            Life.add(securityLog);

            _authManager = NewAuthManager(config, logProvider, securityLog, fileSystem, jobScheduler, accessCapability);
            Life.add(dependencies.DependencySatisfier().satisfyDependency(_authManager));

            // Register procedures
            procedures.RegisterComponent(typeof(SecurityLog), ctx => securityLog, false);
            procedures.RegisterComponent(typeof(EnterpriseAuthManager), ctx => _authManager, false);
            procedures.RegisterComponent(typeof(EnterpriseSecurityContext), ctx => AsEnterprise(ctx.get(SECURITY_CONTEXT)), true);

            if (SecurityConfig.nativeAuthEnabled)
            {
                procedures.RegisterComponent(typeof(EnterpriseUserManager), ctx => _authManager.getUserManager(ctx.get(SECURITY_CONTEXT).subject(), ctx.get(SECURITY_CONTEXT).Admin), true);
                if (config.Get(SecuritySettings.auth_providers).Count > 1)
                {
                    procedures.RegisterProcedure(typeof(UserManagementProcedures), true, "%s only applies to native users.");
                }
                else
                {
                    procedures.RegisterProcedure(typeof(UserManagementProcedures), true);
                }
            }
            else
            {
                procedures.RegisterComponent(typeof(EnterpriseUserManager), ctx => EnterpriseUserManager.NOOP, true);
            }

            procedures.RegisterProcedure(typeof(SecurityProcedures), true);
        }