Example #1
0
 public void SendUserRSAKeyUpdated(string loginName)
 {
     if (string.IsNullOrEmpty(loginName))
     {
         return;
     }
     _mq.BasicPublish(
         routingKey: MqKeyword.UserRSAKeyUpdatedRoutingKey,
         basicProperties: CreateBasicProperties(),
         body: UserMqBodyUtil.GetLoginNameMqSendBody(loginName));
 }
Example #2
0
 public void SendUpdateUserRSAKey(string loginName, RSAKey key)
 {
     if (string.IsNullOrEmpty(loginName) || key == null)
     {
         return;
     }
     _mq.BasicPublish(
         routingKey: MqKeyword.UpdateUserRSAKeyRoutingKey,
         basicProperties: CreateBasicProperties(loginName),
         body: UserMqBodyUtil.GetUpdateUserRSAKeyMqSendBody(key));
 }
Example #3
0
 protected override Dictionary <string, Action <BasicDeliverEventArgs> > DoGetPaths()
 {
     return(new Dictionary <string, Action <BasicDeliverEventArgs> > {
         [MqKeyword.UpdateUserRSAKeyRoutingKey] = ea => {
             string loginName = ea.BasicProperties.ReadHeaderString(MqKeyword.LoginNameHeaderName);
             string appId = ea.BasicProperties.AppId;
             var key = UserMqBodyUtil.GetUpdateUserRSAKeyMqReceiveBody(ea.Body);
             VirtualRoot.Execute(new UpdateUserRSAKeyMqCommand(appId, loginName, ea.GetTimestamp(), key));
         }
     });
 }
Example #4
0
 public void SendUserPasswordChanged(string loginName)
 {
     if (string.IsNullOrEmpty(loginName))
     {
         return;
     }
     _mqChannel.BasicPublish(
         exchange: MqKeyword.NTMinerExchange,
         routingKey: MqKeyword.UserPasswordChangedRoutingKey,
         basicProperties: CreateBasicProperties(),
         body: UserMqBodyUtil.GetLoginNameMqSendBody(loginName));
 }
Example #5
0
 public void SendUpdateUserRSAKey(string loginName, RSAKey key)
 {
     if (string.IsNullOrEmpty(loginName) || key == null)
     {
         return;
     }
     _serverConnection.MqChannel.BasicPublish(
         exchange: MqKeyword.NTMinerExchange,
         routingKey: MqKeyword.UpdateUserRSAKeyRoutingKey,
         basicProperties: CreateBasicProperties(loginName),
         body: UserMqBodyUtil.GetUpdateUserRSAKeyMqSendBody(key));
 }
Example #6
0
        protected sealed override Dictionary <string, Action <BasicDeliverEventArgs> > GetPaths()
        {
            var paths = new Dictionary <string, Action <BasicDeliverEventArgs> > {
                [MqKeyword.UserAddedRoutingKey] = ea => {
                    string loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                    string appId     = ea.BasicProperties.AppId;
                    VirtualRoot.RaiseEvent(new UserAddedMqEvent(appId, loginName, ea.GetTimestamp()));
                },
                [MqKeyword.UserUpdatedRoutingKey] = ea => {
                    string loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                    string appId     = ea.BasicProperties.AppId;
                    VirtualRoot.RaiseEvent(new UserUpdatedMqEvent(appId, loginName, ea.GetTimestamp()));
                },
                [MqKeyword.UserRemovedRoutingKey] = ea => {
                    string loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                    string appId     = ea.BasicProperties.AppId;
                    VirtualRoot.RaiseEvent(new UserRemovedMqEvent(appId, loginName, ea.GetTimestamp()));
                },
                [MqKeyword.UserEnabledRoutingKey] = ea => {
                    string loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                    string appId     = ea.BasicProperties.AppId;
                    VirtualRoot.RaiseEvent(new UserEnabledMqEvent(appId, loginName, ea.GetTimestamp()));
                },
                [MqKeyword.UserDisabledRoutingKey] = ea => {
                    string loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                    string appId     = ea.BasicProperties.AppId;
                    VirtualRoot.RaiseEvent(new UserDisabledMqEvent(appId, loginName, ea.GetTimestamp()));
                },
                [MqKeyword.UserPasswordChangedRoutingKey] = ea => {
                    string loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                    string appId     = ea.BasicProperties.AppId;
                    VirtualRoot.RaiseEvent(new UserPasswordChangedMqEvent(appId, loginName, ea.GetTimestamp()));
                },
                // 该事件通常不会发生,因为用户注册的时候已经生成了RSA公私钥对了,RSA非空时不会更新
                [MqKeyword.UserRSAKeyUpdatedRoutingKey] = ea => {
                    string loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                    string appId     = ea.BasicProperties.AppId;
                    VirtualRoot.RaiseEvent(new UserRSAKeyUpdatedMqEvent(appId, loginName, ea.GetTimestamp()));
                }
            };
            var dic = DoGetPaths();

            if (dic != null)
            {
                foreach (var kv in dic)
                {
                    paths[kv.Key] = kv.Value;
                }
            }
            return(paths);
        }
Example #7
0
        protected override void DoGo(BasicDeliverEventArgs ea)
        {
            base.DoGo(ea);
            switch (ea.RoutingKey)
            {
            case MqKeyword.UpdateUserRSAKeyRoutingKey: {
                string   loginName = ea.BasicProperties.ReadHeaderString(MqKeyword.LoginNameHeaderName);
                DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime);
                string   appId     = ea.BasicProperties.AppId;
                var      key       = UserMqBodyUtil.GetUpdateUserRSAKeyMqReceiveBody(ea.Body);
                VirtualRoot.Execute(new UpdateUserRSAKeyMqMessage(appId, loginName, timestamp, key));
            }
            break;

            default:
                break;
            }
        }
Example #8
0
        protected override bool DoGo(BasicDeliverEventArgs ea)
        {
            bool baseR = base.DoGo(ea);
            bool r     = true;

            switch (ea.RoutingKey)
            {
            case MqKeyword.UpdateUserRSAKeyRoutingKey: {
                string   loginName = ea.BasicProperties.ReadHeaderString(MqKeyword.LoginNameHeaderName);
                DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime);
                string   appId     = ea.BasicProperties.AppId;
                var      key       = UserMqBodyUtil.GetUpdateUserRSAKeyMqReceiveBody(ea.Body);
                VirtualRoot.Execute(new UpdateUserRSAKeyMqCommand(appId, loginName, timestamp, key));
            }
            break;

            default:
                r = false;
                break;
            }
            return(baseR || r);
        }
Example #9
0
        public override bool Go(BasicDeliverEventArgs ea)
        {
            bool baseR = DoGo(ea);
            bool r     = true;

            switch (ea.RoutingKey)
            {
            case MqKeyword.UserAddedRoutingKey: {
                string   loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime);
                string   appId     = ea.BasicProperties.AppId;
                VirtualRoot.RaiseEvent(new UserAddedMqMessage(appId, loginName, timestamp));
            }
            break;

            case MqKeyword.UserUpdatedRoutingKey: {
                string   loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime);
                string   appId     = ea.BasicProperties.AppId;
                VirtualRoot.RaiseEvent(new UserUpdatedMqMessage(appId, loginName, timestamp));
            }
            break;

            case MqKeyword.UserRemovedRoutingKey: {
                string   loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime);
                string   appId     = ea.BasicProperties.AppId;
                VirtualRoot.RaiseEvent(new UserRemovedMqMessage(appId, loginName, timestamp));
            }
            break;

            case MqKeyword.UserEnabledRoutingKey: {
                string   loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime);
                string   appId     = ea.BasicProperties.AppId;
                VirtualRoot.RaiseEvent(new UserEnabledMqMessage(appId, loginName, timestamp));
            }
            break;

            case MqKeyword.UserDisabledRoutingKey: {
                string   loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime);
                string   appId     = ea.BasicProperties.AppId;
                VirtualRoot.RaiseEvent(new UserDisabledMqMessage(appId, loginName, timestamp));
            }
            break;

            case MqKeyword.UserPasswordChangedRoutingKey: {
                string   loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime);
                string   appId     = ea.BasicProperties.AppId;
                VirtualRoot.RaiseEvent(new UserPasswordChangedMqMessage(appId, loginName, timestamp));
            }
            break;

            case MqKeyword.UserRSAKeyUpdatedRoutingKey: {
                string   loginName = UserMqBodyUtil.GetLoginNameMqReceiveBody(ea.Body);
                DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime);
                string   appId     = ea.BasicProperties.AppId;
                VirtualRoot.RaiseEvent(new UserRSAKeyUpdatedMqMessage(appId, loginName, timestamp));
            }
            break;

            default:
                r = false;
                break;
            }
            return(baseR || r);
        }