Exemplo n.º 1
0
        public void showAndSetupDialog(UserRequestType urt, int port, string title, string messageBoxTitle)
        {
            Random    rand     = new Random();
            int       randPort = rand.Next(2502, 3001);
            AddDialog dialog   = new AddDialog(title);

            dialog.ShowDialog();
            if (dialog.result != null)
            {
                switch (urt)
                {
                case UserRequestType.CREATE_SERVER:
                    groupServer = new Server(this, randPort);
                    groupServer.Window_Loaded();

                    //mGroupCLient = new Client(randPort);
                    //mGroupCLient.OnLoginPressed();

                    initUserView("Group: " + dialog.result, CustomButton.ButtonType.CREATED_GROUP, null, groupServer);
                    chatTitle.Text = dialog.result;
                    string code = encodeIpAndPort(randPort, dialog.result, true);
                    groupServer.groupCode = code;
                    chatCode.Text         = code;
                    break;

                case UserRequestType.JOIN_SERVER:
                    string[] decode = decodeIpAndPort(dialog.result);
                    if (decode != null)
                    {
                        chatTitle.Text = decode[0];
                        groupClient    = new Client(Convert.ToInt32(decode[2]), username, this);
                        groupClient.ConnectToGroupServer();
                        initUserView("Group: " + decode[0], CustomButton.ButtonType.JOINED_GROUP, groupClient, null);
                    }

                    //testServer = new Server(this, 2005);
                    //testServer.Window_Loaded();

                    break;

                case UserRequestType.ADDUSER:
                    string[] usrDecode = decodeIpAndPort(dialog.result);
                    if (usrDecode != null)
                    {
                        mClient = new Client(Convert.ToInt32(usrDecode[2]), username, this);
                        mClient.OnLoginPressed();
                        initUserView("User: "******"Error");
            }
        }
Exemplo n.º 2
0
        public virtual async Task <string> CreateUserRequestAsync(string username, UserRequestType requestType)
        {
            var password    = Guid.NewGuid().ToString();
            var credentials = JObject.FromObject(new {
                username,
                password
            });

            using (var algorithm = TripleDES.Create()) {
                var request = new UserRequest {
                    Key         = algorithm.Key,
                    IV          = algorithm.IV,
                    Username    = username,
                    Password    = CryptoUtilities.CreateHash(password),
                    RequestType = requestType
                };

                await _repository.InsertAsync(request);

                var ciphertext = CryptoUtilities.Encrypt(credentials.ToString(), algorithm.Key, algorithm.IV);

                return(HttpUtility.UrlEncode(request.Id + ":" + ciphertext));
            }
        }
 public UserRequest(string userId, UserRequestType userRequestType)
 {
     UserId          = userId;
     UserRequestType = userRequestType;
 }
Exemplo n.º 4
0
 public Request(UserRequestType type = UserRequestType.STUB, string mainData = "", string additionalInfo = "")
 {
     Type           = type;
     MainData       = mainData;
     AdditionalInfo = additionalInfo;
 }
Exemplo n.º 5
0
 public UserRequest(UserRequestType UserRequestType, string PhoneNumber, string Body)
 {
     this.UserRequestType = UserRequestType;
     this.PhoneNumber     = PhoneNumber;
     this.Body            = Body;
 }
Exemplo n.º 6
0
 public UserRequest(IUser user, UserRequestType userRequestType, Dictionary <string, List <string> > parameters)
 {
     User        = user;
     RequestType = userRequestType;
     Parameters  = parameters;
 }
        public void ConvertRawDataIntoUserRequestType(string message, UserRequestType expected)
        {
            var userRequest = telegramHandler.ParseUserMessageText(telegramUser, message);

            Assert.AreEqual(expected, userRequest.RequestType);
        }