示例#1
0
        public Authentication Authenticate(SignatureDate signatureDate)
        {
            if (signatureDate.ID == Authentication.SystemID)
            {
                Authentication.System.SignatureDate = signatureDate;
                return(Authentication.System);
            }

            var user = this.Users[signatureDate.ID];

            if (user != null)
            {
                user.Authentication.SignatureDate = signatureDate;
                return(user.Authentication);
            }

            if (this.customAuthentications.ContainsKey(signatureDate.ID) == false)
            {
                this.customAuthentications.Add(signatureDate.ID, new Authentication(new AuthenticationProvider(signatureDate.ID)));
            }

            var authentication = this.customAuthentications[signatureDate.ID];

            authentication.SignatureDate = signatureDate;
            return(authentication);
        }
示例#2
0
        public User AddNew(Authentication authentication, string userID, string categoryPath, SecureString password, string userName, Authority authority)
        {
            this.ValidateUserCreate(authentication, userID, categoryPath, password);
            this.Sign(authentication);
            var designedInfo = new SignatureDate(authentication.ID, DateTime.UtcNow);
            var userInfo     = new UserSerializationInfo()
            {
                ID               = userID,
                Password         = UserContext.SecureStringToString(password).Encrypt(),
                Name             = userName,
                Authority        = authority,
                CategoryPath     = categoryPath,
                CreationInfo     = designedInfo,
                ModificationInfo = designedInfo,
            };

            this.InvokeUserCreate(authentication, userInfo);

            var user = this.BaseAddNew(userID, categoryPath, null);

            user.Initialize((UserInfo)userInfo, BanInfo.Empty);
            user.Password = UserContext.StringToSecureString(userInfo.Password);
            this.InvokeUsersCreatedEvent(authentication, new User[] { user });
            return(user);
        }
示例#3
0
        public void Commit(Authentication authentication, IEnumerable <LogPropertyInfo> properties, string comment, string eventLog)
        {
            var propList = new List <LogPropertyInfo>
            {
                new LogPropertyInfo()
                {
                    Key = LogPropertyInfo.EventLogKey, Value = eventLog
                },
                new LogPropertyInfo()
                {
                    Key = LogPropertyInfo.VersionKey, Value = AppUtility.ProductVersion
                },
                new LogPropertyInfo()
                {
                    Key = LogPropertyInfo.UserIDKey, Value = authentication.ID
                }
            };

            if (properties != null)
            {
                propList.AddRange(properties);
            }

            var dateTime = this.dispatcher.Invoke(() => this.repository.Commit(this.path, comment, propList));

            this.revision      = this.repository.Revision;
            this.signatureDate = new SignatureDate(authentication.ID, dateTime);
            this.OnChanged(EventArgs.Empty);
        }
示例#4
0
 public DomainEventArgs(Authentication authentication, IDomain domain)
 {
     this.domain = domain;
     this.domainInfo = domain.DomainInfo;
     this.domainState = domain.DomainState;
     this.signatureDate = authentication.SignatureDate;
 }
示例#5
0
        internal void Set(SignatureDate signatureDate, string memberID, AccessType accessType)
        {
            if (this.Contains(memberID) == false)
            {
                throw new ArgumentException();
            }

            var ownerID = this.OwnerID;

            for (var i = 0; i < this.Members.Length; i++)
            {
                if (this.Members[i].ID == memberID)
                {
                    this.Members[i].AccessType    = accessType;
                    this.Members[i].SignatureDate = new SignatureDate(memberID, signatureDate.DateTime);
                    break;
                }
            }

            if (accessType != AccessType.Owner || ownerID == memberID)
            {
                return;
            }

            for (var i = 0; i < this.Members.Length; i++)
            {
                if (this.Members[i].ID == ownerID)
                {
                    this.Members[i].AccessType    = AccessType.Master;
                    this.Members[i].SignatureDate = new SignatureDate(ownerID, signatureDate.DateTime);
                    break;
                }
            }
        }
示例#6
0
 internal void SetPrivate(string path, SignatureDate signatureDate)
 {
     this.SignatureDate = signatureDate;
     this.Path          = path;
     this.ParentPath    = string.Empty;
     this.Add(signatureDate, signatureDate.ID, AccessType.Owner);
 }
示例#7
0
        public InternalDataTable(CremaDataTable target, string name, string categoryPath)
            : base(name, categoryPath)
        {
            this.childList2 = new ReadOnlyObservableCollection <InternalDataTable>(this.childList);
            if (base.ChildItems is INotifyCollectionChanged childTables)
            {
                childTables.CollectionChanged += ChildTables_CollectionChanged;
            }

            this.attributeTag = new InternalAttribute(CremaSchema.Tags, typeof(string))
            {
                AllowDBNull  = false,
                DefaultValue = TagInfo.All.ToString(),
            };
            this.Columns.Add(this.attributeTag);

            this.attributeEnable = new InternalAttribute(CremaSchema.Enable, typeof(bool))
            {
                AllowDBNull  = false,
                DefaultValue = true,
            };
            this.Columns.Add(this.attributeEnable);

            base.Target = target ?? new CremaDataTable(this);
            this.Columns.CollectionChanged     += Columns_CollectionChanged;
            this.Constraints.CollectionChanged += Constraints_CollectionChanged;
            this.creationInfo = this.modificationInfo = this.SignatureDateProvider.Provide();
        }
示例#8
0
        void IDataBaseCollectionServiceCallback.OnDataBasesLockChanged(SignatureDate signatureDate, LockChangeType changeType, LockInfo[] lockInfos, string[] comments)
        {
            this.InvokeAsync(() =>
            {
                var authentication = this.userContext.Authenticate(signatureDate);
                var dataBases      = new DataBase[lockInfos.Length];
                for (var i = 0; i < lockInfos.Length; i++)
                {
                    var lockInfo = lockInfos[i];
                    var dataBase = this[lockInfo.Path];
                    dataBase.SetLockInfo(changeType, lockInfo);
                    dataBases[i] = dataBase;
                }
                switch (changeType)
                {
                case LockChangeType.Lock:
                    this.InvokeItemsLockedEvent(authentication, dataBases, comments);
                    break;

                case LockChangeType.Unlock:
                    this.InvokeItemsUnlockedEvent(authentication, dataBases);
                    break;
                }
            }, nameof(IDataBaseCollectionServiceCallback.OnDataBasesLockChanged));
        }
示例#9
0
        void IUserServiceCallback.OnUsersBanChanged(SignatureDate signatureDate, BanInfo[] banInfos, BanChangeType changeType, string[] comments)
        {
            this.InvokeAsync(() =>
            {
                var authentication = this.Authenticate(signatureDate);
                var users          = new User[banInfos.Length];
                for (var i = 0; i < banInfos.Length; i++)
                {
                    var banInfo = banInfos[i];
                    var user    = this[banInfo.Path] as User;
                    user.SetBanInfo(changeType, banInfo);
                    users[i] = user;
                }

                switch (changeType)
                {
                case BanChangeType.Ban:
                    this.Users.InvokeUsersBannedEvent(authentication, users, comments);
                    break;

                case BanChangeType.Unban:
                    this.Users.InvokeUsersUnbannedEvent(authentication, users);
                    break;
                }
            }, nameof(IUserServiceCallback.OnUsersBanChanged));
        }
示例#10
0
 void IUserServiceCallback.OnMessageReceived(SignatureDate signatureDate, string[] userIDs, string message, MessageType messageType)
 {
     this.InvokeAsync(() =>
     {
         var authentication = this.Authenticate(signatureDate);
         if (messageType == MessageType.None)
         {
             foreach (var item in userIDs)
             {
                 var user = this.Users[item];
                 this.Users.InvokeSendMessageEvent(authentication, user, message);
             }
         }
         else if (messageType == MessageType.Notification)
         {
             var users = new User[userIDs.Length];
             for (var i = 0; i < userIDs.Length; i++)
             {
                 var user = this.Users[userIDs[i]];
                 users[i] = user;
             }
             this.Users.InvokeNotifyMessageEvent(authentication, users, message);
         }
     }, nameof(IUserServiceCallback.OnMessageReceived));
 }
示例#11
0
 protected override void OnTableCleared(DataTableClearEventArgs e)
 {
     base.OnTableCleared(e);
     if (this.IsLoading == false)
     {
         this.contentsInfo = this.SignatureDate;
     }
 }
示例#12
0
 protected override void OnRowDeleted(DataRowChangeEventArgs e)
 {
     base.OnRowDeleted(e);
     if (this.IsLoading == false)
     {
         this.contentsInfo = this.SignatureDate;
     }
 }
示例#13
0
 void IDomainServiceCallback.OnDomainCreated(SignatureDate signatureDate, DomainInfo domainInfo, DomainState domainState)
 {
     this.InvokeAsync(() =>
     {
         var authentication = this.userContext.Authenticate(signatureDate);
         var domain         = this.Domains.AddDomain(authentication, domainInfo);
         domain.InvokeDomainStateChanged(authentication, domainState);
     }, nameof(IDomainServiceCallback.OnDomainCreated));
 }
示例#14
0
 void IDomainServiceCallback.OnUserChanged(SignatureDate signatureDate, Guid domainID, DomainUserInfo domainUserInfo, DomainUserState domainUserState)
 {
     this.InvokeAsync(() =>
     {
         var domain         = this.Domains[domainID];
         var authentication = this.userContext.Authenticate(signatureDate);
         domain.InvokeUserChanged(authentication, domainUserInfo, domainUserState);
     }, nameof(IDomainServiceCallback.OnUserChanged));
 }
示例#15
0
 void IDomainServiceCallback.OnPropertyChanged(SignatureDate signatureDate, Guid domainID, string propertyName, object value)
 {
     this.InvokeAsync(() =>
     {
         var domain         = this.Domains[domainID];
         var authentication = this.userContext.Authenticate(signatureDate);
         domain.InvokePropertyChanged(authentication, propertyName, value);
     }, nameof(IDomainServiceCallback.OnPropertyChanged));
 }
示例#16
0
 void IDomainServiceCallback.OnDomainDeleted(SignatureDate signatureDate, Guid domainID, bool isCanceled)
 {
     this.InvokeAsync(() =>
     {
         var domain         = this.Domains[domainID];
         var authentication = this.userContext.Authenticate(signatureDate);
         domain.Dispose(authentication, isCanceled);
     }, nameof(IDomainServiceCallback.OnDomainDeleted));
 }
示例#17
0
 void IDomainServiceCallback.OnRowRemoved(SignatureDate signatureDate, Guid domainID, DomainRowInfo[] rows)
 {
     this.InvokeAsync(() =>
     {
         var domain         = this.Domains[domainID];
         var authentication = this.userContext.Authenticate(signatureDate);
         domain.InvokeRowRemoved(authentication, rows);
     }, nameof(IDomainServiceCallback.OnRowRemoved));
 }
示例#18
0
 public ItemEventArgs(Authentication authentication, T item, object metaData)
     : base(item)
 {
     if (authentication.SignatureDate.ID == string.Empty)
     {
         throw new CremaException();
     }
     this.signatureDate = authentication.SignatureDate;
     this.metaData      = metaData;
 }
示例#19
0
 public ItemsEventArgs(Authentication authentication, IEnumerable <T> items, object metaData)
 {
     if (authentication.SignatureDate.ID == string.Empty)
     {
         throw new CremaException();
     }
     this.signatureDate = authentication.SignatureDate;
     this.items         = items.ToArray();
     this.metaData      = metaData;
 }
示例#20
0
 void IDomainServiceCallback.OnServiceClosed(SignatureDate signatureDate, CloseInfo closeInfo)
 {
     this.service.Abort();
     this.service = null;
     this.timer?.Dispose();
     this.timer = null;
     this.serviceDispatcher.Dispose();
     this.serviceDispatcher = null;
     this.InvokeAsync(() =>
     {
         this.cremaHost.RemoveService(this);
     }, nameof(IDomainServiceCallback.OnServiceClosed));
 }
示例#21
0
 void IDomainServiceCallback.OnDomainStateChanged(SignatureDate signatureDate, Guid domainID, DomainState domainState)
 {
     this.InvokeAsync(() =>
     {
         var domain = this.Domains[domainID];
         if (domain == null)
         {
             return;
         }
         var authentication = this.userContext.Authenticate(signatureDate);
         domain.InvokeDomainStateChanged(authentication, domainState);
     }, nameof(IDomainServiceCallback.OnDomainStateChanged));
 }
示例#22
0
 void IUserServiceCallback.OnUsersStateChanged(SignatureDate signatureDate, string[] userIDs, UserState[] states)
 {
     this.InvokeAsync(() =>
     {
         var authentication = this.Authenticate(signatureDate);
         var users          = new User[userIDs.Length];
         for (var i = 0; i < userIDs.Length; i++)
         {
             var user = this.Users[userIDs[i]];
             user.SetUserState(states[i]);
             users[i] = user;
         }
         this.Users.InvokeUsersStateChangedEvent(authentication, users);
     }, nameof(IUserServiceCallback.OnUsersStateChanged));
 }
示例#23
0
 void IUserServiceCallback.OnUsersKicked(SignatureDate signatureDate, string[] userIDs, string[] comments)
 {
     this.InvokeAsync(() =>
     {
         var authentication = this.Authenticate(signatureDate);
         var users          = new User[userIDs.Length];
         for (var i = 0; i < userIDs.Length; i++)
         {
             var user      = this.Users[userIDs[i]];
             user.IsOnline = false;
             users[i]      = user;
         }
         this.Users.InvokeUsersKickedEvent(authentication, users, comments);
     }, nameof(IUserServiceCallback.OnUsersKicked));
 }
示例#24
0
        internal void Add(SignatureDate signatureDate, string memberID, AccessType accessType)
        {
            if (this.Contains(memberID) == true)
            {
                throw new ArgumentException();
            }

            var members = this.Members.ToList();

            members.Add(new AccessMemberInfo()
            {
                SignatureDate = new SignatureDate(memberID, signatureDate.DateTime), AccessType = accessType
            });
            this.Members = members.ToArray();
        }
示例#25
0
 void IUserServiceCallback.OnUsersLoggedOut(SignatureDate signatureDate, string[] userIDs)
 {
     this.InvokeAsync(() =>
     {
         var authentication = this.Authenticate(signatureDate);
         var users          = new User[userIDs.Length];
         for (var i = 0; i < userIDs.Length; i++)
         {
             var user      = this.Users[userIDs[i]];
             user.IsOnline = false;
             users[i]      = user;
         }
         this.Users.InvokeUsersLoggedOutEvent(authentication, users, CloseInfo.Empty);
     }, nameof(IUserServiceCallback.OnUsersLoggedOut));
 }
示例#26
0
 void IDataBaseCollectionServiceCallback.OnDataBasesAuthenticationLeft(SignatureDate signatureDate, string[] dataBaseNames, AuthenticationInfo authenticationInfo)
 {
     this.InvokeAsync(() =>
     {
         var authentication = this.userContext.Authenticate(signatureDate);
         var dataBases      = new DataBase[dataBaseNames.Length];
         for (var i = 0; i < dataBaseNames.Length; i++)
         {
             var dataBaseName = dataBaseNames[i];
             var dataBase     = this[dataBaseName];
             dataBase.SetAuthenticationLeft(authentication);
             dataBases[i] = dataBase;
         }
         this.InvokeItemsAuthenticationLeftEvent(authentication, dataBases);
     }, nameof(IDataBaseCollectionServiceCallback.OnDataBasesAuthenticationLeft));
 }
示例#27
0
        internal void Remove(SignatureDate _, string memberID)
        {
            if (this.Contains(memberID) == false)
            {
                throw new ArgumentException();
            }

            var member = this.Members.First(item => item.ID == memberID);

            if (member.AccessType == AccessType.Owner)
            {
                throw new ArgumentException();
            }

            this.Members = this.Members.Where(item => item.ID != memberID).ToArray();
        }
示例#28
0
        public static bool TryGetAttributeAsSignatureDate(this XmlReader reader, string user, string dateTime, out SignatureDate value)
        {
            var id = reader.GetAttribute(user);

            if (reader.TryGetAttributeAsDateTime(dateTime, XmlDateTimeSerializationMode.Utc, out var dateTimeValue) == true || id != null)
            {
                value = new SignatureDate()
                {
                    ID       = id ?? string.Empty,
                    DateTime = dateTimeValue,
                };
                return(true);
            }
            value = SignatureDate.Empty;
            return(false);
        }
示例#29
0
 void IUserServiceCallback.OnUsersChanged(SignatureDate signatureDate, UserInfo[] userInfos)
 {
     this.InvokeAsync(() =>
     {
         var authentication = this.Authenticate(signatureDate);
         var users          = new User[userInfos.Length];
         for (var i = 0; i < userInfos.Length; i++)
         {
             var userInfo = userInfos[i];
             var user     = this.Users[userInfo.ID];
             user.SetUserInfo(userInfo);
             users[i] = user;
         }
         this.Users.InvokeUsersChangedEvent(authentication, users);
     }, nameof(IUserServiceCallback.OnUsersChanged));
 }
示例#30
0
 void IDataBaseCollectionServiceCallback.OnDataBasesInfoChanged(SignatureDate signatureDate, DataBaseInfo[] dataBaseInfos)
 {
     this.InvokeAsync(() =>
     {
         var authentication = this.userContext.Authenticate(signatureDate);
         var dataBases      = new DataBase[dataBaseInfos.Length];
         for (var i = 0; i < dataBaseInfos.Length; i++)
         {
             var dataBaseInfo = dataBaseInfos[i];
             var dataBase     = this[dataBaseInfo.Name];
             dataBase.SetDataBaseInfo(dataBaseInfo);
             dataBases[i] = dataBase;
         }
         this.InvokeItemsInfoChangedEvent(authentication, dataBases);
     }, nameof(IDataBaseCollectionServiceCallback.OnDataBasesInfoChanged));
 }