예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            Fs            = new EvilFileSystem(this, new EphemeralFileSystemAbstraction());
            UserStoreFile = new File("dbms", "auth");
            RoleStoreFile = new File("dbms", "roles");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.server.security.auth.UserRepository userRepository = new org.neo4j.server.security.auth.FileUserRepository(fs, userStoreFile, logProvider);
            UserRepository userRepository = new FileUserRepository(Fs, UserStoreFile, LogProvider);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final RoleRepository roleRepository = new FileRoleRepository(fs, roleStoreFile, logProvider);
            RoleRepository roleRepository = new FileRoleRepository(Fs, RoleStoreFile, LogProvider);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.server.security.auth.UserRepository initialUserRepository = org.neo4j.server.security.auth.CommunitySecurityModule.getInitialUserRepository(org.neo4j.kernel.configuration.Config.defaults(), logProvider, fs);
            UserRepository initialUserRepository = CommunitySecurityModule.getInitialUserRepository(Config.defaults(), LogProvider, Fs);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.server.security.auth.UserRepository defaultAdminRepository = EnterpriseSecurityModule.getDefaultAdminRepository(org.neo4j.kernel.configuration.Config.defaults(), logProvider, fs);
            UserRepository defaultAdminRepository = EnterpriseSecurityModule.GetDefaultAdminRepository(Config.defaults(), LogProvider, Fs);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.api.security.PasswordPolicy passwordPolicy = new org.neo4j.server.security.auth.BasicPasswordPolicy();
            PasswordPolicy         passwordPolicy         = new BasicPasswordPolicy();
            AuthenticationStrategy authenticationStrategy = new RateLimitedAuthenticationStrategy(Clocks.systemClock(), Config.defaults());

            Realm = new InternalFlatFileRealm(userRepository, roleRepository, passwordPolicy, authenticationStrategy, true, true, JobScheduler, initialUserRepository, defaultAdminRepository);
            Realm.init();
            Realm.start();
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailIfNoRolesFileButManyUsersAndNonExistingDefaultAdmin() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailIfNoRolesFileButManyUsersAndNonExistingDefaultAdmin()
        {
            // Given
            UserRepository defaultAdminRepository = EnterpriseSecurityModule.GetDefaultAdminRepository(Config, NullLogProvider.Instance, FsRule.get());

            defaultAdminRepository.Start();
            defaultAdminRepository.Create((new User.Builder("foo", LegacyCredential.INACCESSIBLE)).withRequiredPasswordChange(false).build());
            defaultAdminRepository.Shutdown();

            Users.create(NewUser("jake", "abc123", false));
            Users.create(NewUser("jane", "123abc", false));

            Expect.expect(typeof(InvalidArgumentsException));
            Expect.expectMessage("No roles defined, and default admin user 'foo' does not exist. " + "Please use `neo4j-admin " + SetDefaultAdminCommand.COMMAND_NAME + "` to select a valid admin.");

            _manager.start();
        }
예제 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private MultiRealmAuthManager createAuthManager(boolean logSuccessfulAuthentications) throws Throwable
        private MultiRealmAuthManager CreateAuthManager(bool logSuccessfulAuthentications)
        {
            Log log = _logProvider.getLog(this.GetType());

            InternalFlatFileRealm internalFlatFileRealm = new InternalFlatFileRealm(Users, new InMemoryRoleRepository(), mock(typeof(PasswordPolicy)), _authStrategy, mock(typeof(JobScheduler)), CommunitySecurityModule.getInitialUserRepository(Config, NullLogProvider.Instance, FsRule.get()), EnterpriseSecurityModule.GetDefaultAdminRepository(Config, NullLogProvider.Instance, FsRule.get()));

            _manager = new MultiRealmAuthManager(internalFlatFileRealm, Collections.singleton(internalFlatFileRealm), new MemoryConstrainedCacheManager(), new SecurityLog(log), logSuccessfulAuthentications, false, Collections.emptyMap());

            _manager.init();
            return(_manager);
        }