/// <summary> /// Internal Class constructor. /// </summary> /// <param name="name"></param> /// <param name="password"></param> /// <param name="admin"></param> /// <param name="pub"></param> internal User(string name, string password, bool admin, User pub) { _right = new Hashtable(); _name = name; Password = password; _administrator = admin; _public = pub; }
/// <summary> /// Access Class constructor. /// Creates a new ArrayList to contain the User object instances, as well /// as creating an initial PUBLIC user, with no password. /// </summary> public Access() { uUser = new ArrayList(); uPublic = CreateUser("PUBLIC", null, false); }
/// <summary> /// CreateUser method declaration. /// This method is used to create a new user. The collection of users /// is first checked for a duplicate name, and an exception will be thrown /// if a user of the same name already exists. /// </summary> /// <param name="name">User login</param> /// <param name="password">Plaintext password</param> /// <param name="admin">Is this a database admin user?</param> /// <returns>An instance of the newly created User object</returns> public User CreateUser(string name, string password, bool admin) { for (int i = 0; i < uUser.Count; i++) { User u = (User)uUser[i]; if (u != null && u.Name.Equals(name)) { throw TracingHelper.Error(TracingHelper.USER_ALREADY_EXISTS, name); } } User unew = new User(name, password, admin, uPublic); uUser.Add(unew); return unew; }
/// <summary> /// Builds a channel based on an existing one. /// </summary> /// <param name="channel"></param> /// <param name="id"></param> public Channel(Channel channel, int id) : this() { _id = id; _database = channel._database; _user = channel._user; _autoCommit = true; _readOnly = channel._readOnly; }
/// <summary> /// Sets the current user for the channel. /// </summary> /// <param name="user"></param> internal void SetUser(User user) { TracingHelper.Check(!_closed, TracingHelper.CONNECTION_IS_CLOSED); _user = user; }
/// <summary> /// Disconnects the current channel from database. /// </summary> public void Disconnect() { if (_closed) { return; } Rollback(); _user = null; _database = null; _transaction = null; _closed = true; }
/// <summary> /// Builds a new channel. /// </summary> /// <param name="db"></param> /// <param name="user"></param> /// <param name="autoCommit"></param> /// <param name="readOnly"></param> /// <param name="id"></param> public Channel(Database db, User user, bool autoCommit, bool readOnly, int id) : this() { _id = id; _database = db; _user = user; _autoCommit = autoCommit; _readOnly = readOnly; }