示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public synchronized void removeUserFromAllRoles(String username) throws org.neo4j.server.security.auth.exception.ConcurrentModificationException, java.io.IOException
        public override void RemoveUserFromAllRoles(string username)
        {
            lock (this)
            {
                ISet <string> roles = _rolesByUsername[username];
                if (roles != null)
                {
                    // Since update() is modifying the set we create a copy for the iteration
                    IList <string> rolesToRemoveFrom = new List <string>(roles);
                    foreach (string roleName in rolesToRemoveFrom)
                    {
                        RoleRecord role    = _rolesByName[roleName];
                        RoleRecord newRole = role.Augment().withoutUser(username).build();
                        Update(role, newRole);
                    }
                }
            }
        }
示例#2
0
		 public override void AddRoleToUser( string roleName, string username )
		 {
			  _roleRepository.assertValidRoleName( roleName );
			  _userRepository.assertValidUsername( username );

			  lock ( this )
			  {
					GetUser( username );
					RoleRecord role = GetRole( roleName );
					RoleRecord newRole = role.Augment().withUser(username).build();
					try
					{
						 _roleRepository.update( role, newRole );
					}
					catch ( ConcurrentModificationException )
					{
						 // Try again
						 AddRoleToUser( roleName, username );
					}
			  }
			  ClearCachedAuthorizationInfoForUser( username );
		 }