Esempio n. 1
0
        private DokuAuthUser _UserAdd(DokuAuthUser user)
        {
            DokuAuthUser userexist = this._userList.SingleOrDefault(o => o.Login.Equals(user.Login));

            if (userexist == null)
            {
                if (
                    (string.IsNullOrWhiteSpace(user.Password)) &&
                    (string.IsNullOrWhiteSpace(user.PasswdHash))
                    )
                {
                    return(default(DokuAuthUser));
                }
                user.PasswdHash = ((string.IsNullOrWhiteSpace(user.PasswdHash)) ? CryptUtils.Crypt(user.Password) : user.Password);
                user.Group      = ((string.IsNullOrWhiteSpace(user.Group)) ?
                                   ((string.IsNullOrWhiteSpace(this._group)) ? groupDefault : this._group) : user.Group
                                   );
                this._userList.Add(user);
                userexist = user;
            }
            else
            {
                userexist.Name       = user.Name;
                userexist.Email      = user.Email;
                userexist.Group      = ((string.IsNullOrWhiteSpace(user.Group)) ? userexist.Group : user.Group);
                userexist.PasswdHash =
                    ((string.IsNullOrWhiteSpace(user.PasswdHash)) ?
                     ((string.IsNullOrWhiteSpace(user.Password)) ? userexist.PasswdHash : CryptUtils.Crypt(user.Password)) :
                     user.PasswdHash
                    );
            }
            this._isChanged = true;
            return(userexist);
        }
Esempio n. 2
0
 public void DokuWikiAuthAdd(DokuAuthUser dauin)
 {
     if (
         (dauin == null) ||
         (this._cocDWAuth == null)
         )
     {
         return;
     }
     try
     {
         DokuAuthUser dau = this._cocDWAuth.UserAdd(dauin);
     }
     catch (Exception e)
     {
         this.DokuWikiAuthException(e);
     }
 }
Esempio n. 3
0
 public void DokuWikiAuthAdd(string tag, string login, string passwd, string name, string group)
 {
     if (
         (this._cocDWAuth == null) ||
         (string.IsNullOrWhiteSpace(login)) ||
         (string.IsNullOrWhiteSpace(passwd))
         )
     {
         return;
     }
     try
     {
         DokuAuthUser dau = this._cocDWAuth.UserAdd(login, passwd, name, group);
     }
     catch (Exception e)
     {
         this.DokuWikiAuthException(e);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// (Doku Manager) Delete user from auth table
 /// </summary>
 /// <code>
 /// List&lt;DokuAuthUser&gt; udel = new List&lt;DokuAuthUser&gt;()
 /// {
 ///     new DokuAuthUser() { Login = "******" },
 ///     new DokuAuthUser() { ... },
 /// };
 /// dam.UserDelete(udel);
 /// dam.AuthSave();
 /// </code>
 /// <param name="userlst"></param>
 public void UserDelete(List <DokuAuthUser> userlst)
 {
     if (!this._CheckMethodParam(userlst))
     {
         return;
     }
     lock (_lockAuthFile)
     {
         foreach (var user in userlst)
         {
             DokuAuthUser userdel = this._userList.SingleOrDefault(o => o.Login.Equals(user.Login));
             if (userdel == null)
             {
                 continue;
             }
             this._userList.Remove(userdel);
             this._isChanged = true;
         }
     }
 }
Esempio n. 5
0
        private void _GetDokuAuth()
        {
            try
            {
                this._CheckDokuAuth();

                lock (_lockAuthFile)
                {
                    string[] lines = File.ReadAllLines(this._path, Encoding.UTF8);
                    if (lines == null)
                    {
                        throw new RpcXmlException(
                                  string.Format(
                                      Properties.ResourceCodeError.rpcErrorIntFormat,
                                      className,
                                      "DokuWiki auth file is empty.."
                                      ),
                                  5082
                                  );
                    }

                    this._userList.Clear();

                    for (int i = 0; i < lines.Length; i++)
                    {
                        if (
                            (string.IsNullOrWhiteSpace(lines[i])) ||
                            (lines[i].StartsWith("#"))
                            )
                        {
                            continue;
                        }
                        string[] items = lines[i].Split(':');
                        if (
                            (items == null) ||
                            (items.Length != 5)
                            )
                        {
                            continue;
                        }
                        DokuAuthUser dau = new DokuAuthUser()
                        {
                            Login      = items[0],
                            PasswdHash = items[1],
                            Name       = items[2],
                            Email      = items[3],
                            Group      = items[4],
                            Password   = String.Empty
                        };
                        this._userList.Add(dau);
                    }
                }
            }
            catch (RpcXmlException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new RpcXmlException(
                          className + e.Message,
                          5083
                          );
            }
        }
Esempio n. 6
0
 /// <summary>
 /// (Doku Manager) Add users to auth table (input DokuAuthUser)
 /// </summary>
 /// <code>
 /// dam.UserAdd(
 ///   new DokuAuthUser()
 ///   {
 ///      Login = "******",
 ///      Password = "******",
 ///      Name = "Nikolas",
 ///      Email = "*****@*****.**",
 ///      Group = "personalGroup"
 ///   }
 /// );
 /// dam.AuthSave();
 /// </code>
 /// <param name="user">Class <see cref="Data.DokuAuthUser"/>DokuAuthUser</param>
 /// <returns>Class <see cref="Data.DokuAuthUser"/>DokuAuthUser</returns>
 public DokuAuthUser UserAdd(DokuAuthUser user)
 {
     return(this._UserAdd(user));
 }