示例#1
0
        public static Account New(string username, HashedPassword password, IEnumerable <AccessPriviledge> priviledges)
        {
            CheckUsernameValidity(username);
            CheckPasswordValidity(password);
            CheckPriviledgesValidity(priviledges);

            return(new Account(null, username, password, priviledges));
        }
示例#2
0
 private Account(
     Identity identity,
     string username,
     HashedPassword password,
     IEnumerable <AccessPriviledge> priviledges)
 {
     Identity     = identity;
     Username     = username;
     Password     = password;
     _Priviledges = priviledges.ToList();
 }
示例#3
0
 private static void CheckPasswordValidity(HashedPassword password)
 {
     if (password == null)
     {
         throw new AccessDomainViolationException("Password is null.");
     }
     if (password.Salt.Length == 0)
     {
         throw new AccessDomainViolationException("Password salt has no value.");
     }
     if (password.Value.Length == 0)
     {
         throw new AccessDomainViolationException("Password has no value.");
     }
 }
示例#4
0
 public void ChangePassword(HashedPassword newPassword)
 {
     CheckPasswordValidity(newPassword);
     Password = newPassword;
 }
示例#5
0
 public static Account Existing(Identity identity, string username, HashedPassword password, IEnumerable <AccessPriviledge> priviledges)
 {
     return(new Account(identity, username, password, priviledges));
 }