コード例 #1
0
ファイル: Main.cs プロジェクト: WildGenie/Howling-Software-V3
        public Main()
        {
            AutoEvNr.Check4Update(Globals.version);
            bool isLegit = checker.CheckFiles();

            if (!isLegit)
            {
                Error.CstmError.Show("You don't have permission to access the tool due wrong/modified files!");
                Application.Exit();
            }

            if (Globals.helper == true)
            {
                tabControl1.SelectedTab = tabPage5;
                tabControl2.Visible     = false;
                label1.Text             = "Howling Software | Update";
            }

            bool authed = auth.Authenticate(Globals.secret_key);

            if (authed != true)
            {
                Error.CstmError.Show("Please contact the Administration");
                Environment.Exit(0);
            }
            InitializeComponent();
        }
コード例 #2
0
    private IEnumerator AuthenticateWithServer(string username, string password)
    {
        canAuthenticate = false;
        try
        {
            Log("Authenticating with server...");

            //Auth.Authenticate("player" + UnityEngine.Random.Range(1, 9999).ToString("0000"), "wowowow");

            Auth.Authenticate(username, password);

            while (Auth.Authenticating)
            {
                yield return(new WaitForSeconds(0.1f));
            }

            if (Auth.Authenticated)
            {
                LogDebug("Authenticated");
                yield break;
            }

            LogError("Authentication failed.");
        }
        finally
        {
            canAuthenticate = true;
        }
    }
コード例 #3
0
        public void LoginAdminWithWrongCredentials()
        {
            Auth.Logout();
            User user = Auth.Authenticate(AuthAdminName, AuthAdminPass + "wrong");

            Assert.IsNull(user);
        }
コード例 #4
0
        protected override Task <AuthenticationTicket> AuthenticateCoreAsync()
        {
            var apiKey = Request.Headers[TheOptions.ApiKeyHeaderName];

            if (!String.IsNullOrEmpty(apiKey))
            {
                // Get the user
                var authUser = Auth.Authenticate(CredentialBuilder.CreateV1ApiKey(apiKey));
                if (authUser != null)
                {
                    // Set the current user
                    Context.Set(Constants.CurrentUserOwinEnvironmentKey, authUser);

                    return(Task.FromResult(
                               new AuthenticationTicket(
                                   AuthenticationService.CreateIdentity(
                                       authUser.User,
                                       AuthenticationTypes.ApiKey,
                                       new Claim(NuGetClaims.ApiKey, apiKey)),
                                   new AuthenticationProperties())));
                }
                else
                {
                    Logger.WriteWarning("No match for API Key!");
                }
            }
            else
            {
                Logger.WriteVerbose("No API Key Header found in request.");
            }
            return(Task.FromResult <AuthenticationTicket>(null));
        }
コード例 #5
0
        private void TxtUsernameKeyDown(object sender, KeyEventArgs e)
        {
            // if this is a debugging session login automattically
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // this has to be removed after development
                if (e.Control && e.Alt)
                {
                    if (txtUsername.Text == "")
                    {
                        txtUsername.Text = "su";
                    }
                    UserInformation userInfo = null;

                    if (BLL.Settings.UseNewUserManagement)
                    {
                        userInfo = Auth.Authenticate(txtUsername.Text);
                        if (userInfo == null)
                        {
                            //errorLogger.SaveError(0, 1, 1, 2, "Login Attempt", "Warehouse", new InvalidCredentialException("Invalid credentials, Username = " + username));
                            //return false;
                        }
                        Thread.CurrentPrincipal = SecurityPrincipal.CreateSecurityPrincipal(userInfo);
                    }

                    User usr = new User();
                    usr.Where.UserName.Value = txtUsername.Text;
                    usr.Query.Load();
                    LogUserIn(usr);
                }
            }
        }
コード例 #6
0
        public async Task <IActionResult> Login(string email, string password)
        {
            IAuthUser user = null;

            //TODO check if null

            try
            {
                user = await Auth.Authenticate(email, password);
            }
            catch (UnauthorizedAccessException ex)
            {
                return(Json(new
                {
                    success = false,
                    error = ex.Message
                }));
            }

            Response.CreateAuthCookie(user.ID, "DBID");

            return(Json(new
            {
                success = true,
                redirect = "/"
            }));
        }
コード例 #7
0
        public bool createOrder(string email, string password, Order newOrder, List <OrderLine> cartLines)
        {
            Task <bool> taskOperation = Task <bool> .Run(() =>
            {
                try
                {
                    Auth.Authenticate(email, password, this.DB);
                }
                catch (UnAuthorizedExc e)
                {
                    return(false);
                }
                try
                {
                    OrderLine[] orderLines = new OrderLine[cartLines.Count];
                    Product cartPoduct     = new Product();
                    OrderLine line         = new OrderLine();
                    for (int i = 0; i < cartLines.Count; i++)
                    {
                        orderLines[i] = cartLines[i];
                    }

                    return(DB.createOrder(newOrder, orderLines));
                }
                catch (FaultException <DBFault> df)
                {
                    throw new FaultException <ManagerFault>(new ManagerFault(df.ToString()));
                }
            });

            return(taskOperation.Result);
        }
コード例 #8
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string username = textBox2.Text;
            string password = textBox3.Text;
            string email    = textBox4.Text;
            string token    = textBox5.Text;
            bool   authed   = auth.Authenticate(Globals.secret_key);

            bool register = auth.Register(username, password, email, token);

            if (authed != true)
            {
                MessageBox.Show("Please contact the Administration", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (register == true && authed == true)
            {
                Error.CstmError.Show("User " + username + " successfully registered!");
                string[] row          = { textBox2.Text, textBox3.Text, textBox5.Text };
                var      listViewItem = new ListViewItem(row);
                listView1.Items.Add(listViewItem);
                label6.Text = Convert.ToString(listView1.Items.Count);
            }
            else
            {
                Error.CstmError.Show("Error please check your Informations");
            }
        }
コード例 #9
0
        private async Task PerformLoginAction()
        {
            if (ValidateControls())
            {
                var clientCreds = new ClientCreds()
                {
                    Clientname = tbClientName.Text,
                    Password   = tbPassword.Text
                };

                AuthResponse authResponse = await authHandler.Authenticate(clientCreds);

                if (authResponse == null)
                {
                    MessageBox.Show("Auth failed, response is null");
                }
                else
                {
                    if (authResponse.Error)
                    {
                        MessageBox.Show("Auth error, message: " + authResponse.Message);
                    }
                    else
                    {
                        Core.Auth = authResponse;
                        TicketScannerForm mainForm = new TicketScannerForm();
                        mainForm.Show();
                    }
                }
            }
        }
コード例 #10
0
ファイル: Login.cs プロジェクト: younasiqw/loader-2
        public Login()
        {
            #region AuthedStuff
            bool isLegit = checker.CheckFiles();
            if (!isLegit)
            {
                MessageBox.Show("You don't have permission to access the tool due wrong/modified files!", "eternity.us");
                Application.Exit();
            }
            bool authed = auth.Authenticate(Stuff.key);
            if (authed != true)
            {
                MessageBox.Show("Please contact the Administration", "eternity.us");
                Environment.Exit(0);
            }
            if (File.Exists(names.path))
            {
                File.Delete(names.path);
            }
            if (File.Exists(names.path2))
            {
                File.Delete(names.path2);
            }

            string           str = Environment.GetFolderPath(Environment.SpecialFolder.System).Substring(0, 1);
            ManagementObject managementObject = new ManagementObject("win32_logicaldisk.deviceid=\"" + str + ":\"");
            managementObject.Get();
            string text = managementObject["VolumeSerialNumber"].ToString();
            user_hwid = Crypt(text);
            #endregion

            InitializeComponent();
            this.Opacity = 0;
            this.TopMost = true;
            timer1.Start();
            LabelInvite.Visible    = false;
            TextInvite.Visible     = false;
            ButtonRegister.Visible = false;

            TextUser.Text     = eternity.us.Properties.Settings.Default.username;
            TextPassword.Text = eternity.us.Properties.Settings.Default.password;
            checkBox1.Checked = eternity.us.Properties.Settings.Default.check;

            timer3.Start();
        }
コード例 #11
0
        public bool Login(string email, string password)
        {
            Task <bool> taskOperation = Task <bool> .Run(() =>
            {
                return(Auth.Authenticate(email, password, this.DB));
            });

            return(taskOperation.Result);
        }
コード例 #12
0
        public void LoginAdminWithCorrectCredentials()
        {
            User user = Auth.Authenticate(AuthAdminName, AuthAdminPass);

            Assert.IsNotNull(user);
            Assert.AreEqual(user, Auth.CurrentUser);
            Auth.Logout();
            Assert.IsNull(Auth.CurrentUser);
        }
コード例 #13
0
        public loader()
        {
            InitializeComponent();
            bool authed = auth.Authenticate("YOUR SECRET CODE");

            if (authed != true)
            {
                Error.CstmError.Show("Please contact the Administration");
                Environment.Exit(0);
            }
        }
コード例 #14
0
ファイル: Main.cs プロジェクト: younasiqw/Howling-Software-V3
        public Main()
        {
            AutoEvNr.Check4Update(Globals.version);
            bool isLegit = checker.CheckFiles();

            if (!isLegit)
            {
                Error.CstmError.Show("You don't have permission to access the tool due wrong/modified files!");
                Application.Exit();
            }

            bool authed = auth.Authenticate(Globals.secret_key);

            if (authed != true)
            {
                Error.CstmError.Show("Please contact the Administration");
                Environment.Exit(0);
            }
            InitializeComponent();
        }
コード例 #15
0
 private T OnError <T>(Exception e)
 {
     if (e is HttpException)
     {
         var httpException = e as HttpException;
         if (httpException.ErrorCode == 401)
         {
             Auth.Authenticate(Config, Api);
         }
     }
     throw e;
 }
コード例 #16
0
        protected override async Task <AuthenticationTicket> AuthenticateCoreAsync()
        {
            var apiKey = Request.Headers[TheOptions.ApiKeyHeaderName];

            if (!string.IsNullOrEmpty(apiKey))
            {
                // Get the user
                var authUser = await Auth.Authenticate(apiKey);

                if (authUser != null)
                {
                    var credential = authUser.CredentialUsed;
                    var user       = authUser.User;

                    // Ensure that the user matches the owner scope
                    if (!user.MatchesOwnerScope(credential))
                    {
                        WriteStatus(ServicesStrings.ApiKeyNotAuthorized, 403);
                    }

                    // Set the current user
                    Context.Set(ServicesConstants.CurrentUserOwinEnvironmentKey, authUser);

                    // Fetch scopes and store them in a claim
                    var scopes = JsonConvert.SerializeObject(
                        credential.Scopes, Formatting.None);

                    // Create authentication ticket
                    return(new AuthenticationTicket(
                               AuthenticationService.CreateIdentity(
                                   user,
                                   AuthenticationTypes.ApiKey,
                                   // In cases where the apikey in the DB differs from the user provided
                                   // value (like apikey.v4) this will hold the hashed value
                                   new Claim(NuGetClaims.ApiKey, credential.Value),
                                   new Claim(NuGetClaims.Scope, scopes),
                                   new Claim(NuGetClaims.CredentialKey, credential.Key.ToString())),
                               new AuthenticationProperties()));
                }
                else
                {
                    // No user was matched
                    Logger.WriteWarning("No match for API Key!");
                }
            }
            else
            {
                Logger.WriteVerbose("No API Key Header found in request.");
            }

            return(null);
        }
コード例 #17
0
ファイル: UserController.cs プロジェクト: rnj612/demo
        public async Task <UserModel> Register(UserModel userx)
        {
            UserModel user = await DBOper.User.Register(userx.mobile, userx.nick_name, userx.login_pwd);

            if (user != null && user.id > int.MinValue)
            {
                var token = Auth.Authenticate(user.id.ToString());
                user.access_token = token;
                user.login_pwd    = string.Empty;
                return(user);
            }
            return(null);
        }
コード例 #18
0
        public static bool Login(string username, string password)
        {
            var userInfo = Auth.Authenticate(username, password);

            if (userInfo == null)
            {
                errorLogger.SaveError(0, 1, 1, 2, "Login Attempt", "Warehouse", new InvalidCredentialException("Invalid credentials, Username = "******"Login Window", "Successful Login");
            return(true);
        }
コード例 #19
0
 private void btLogin_Click_1(object sender, EventArgs e)
 {
     if (Auth.Authenticate(tbLogin.Text, tbPassword.Text) != null)
     {
         this.Hide();
         btLogin.Show();
         MessageBox.Show("Hi you have successfully login " + Auth.CurrentUser.FullName, "alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         MessageBox.Show("Please enter a valid username and password", "alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #20
0
ファイル: UserController.cs プロジェクト: rnj612/demo
        public async Task <UserModel> Login(string mobile, string login_pwd)
        {
            UserModel user = await DBOper.User.GetOne(0, mobile, string.Empty);

            if (user != null)
            {
                if (user.login_pwd.Equals(Md5.GetMd5(login_pwd)))
                {
                    var token = Auth.Authenticate(user.id.ToString());
                    user.access_token = token;
                    user.login_pwd    = string.Empty;
                    return(user);
                }
            }
            return(null);
        }
コード例 #21
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (Auth.Authenticate(email.Text, password.Password))
            {
                MessageBox.Show("Bienvenido: " + Auth.user.Email, "Bienvenido");

                this.Hide();

                var mainWin = Application.Current.Windows.Cast <Window>().FirstOrDefault(window => window is MainWindow) as MainWindow;
                mainWin.currentUser.Text = Auth.user.Name + " " + "(" + Auth.user.Email + ")";
                Application.Current.MainWindow.Show();
            }
            else
            {
                MessageBox.Show("Ingrese Datos Correctos", "Error");
            }
        }
コード例 #22
0
        protected override async Task <AuthenticationTicket> AuthenticateCoreAsync()
        {
            var apiKey = Request.Headers[TheOptions.ApiKeyHeaderName];

            if (!string.IsNullOrEmpty(apiKey))
            {
                // Get the user
                var authUser = await Auth.Authenticate(apiKey);

                if (authUser != null)
                {
                    // Set the current user
                    Context.Set(Constants.CurrentUserOwinEnvironmentKey, authUser);

                    // Fetch scopes and store them in a claim
                    var scopes = JsonConvert.SerializeObject(
                        authUser.CredentialUsed.Scopes, Formatting.None);

                    // Create authentication ticket
                    return(new AuthenticationTicket(
                               AuthenticationService.CreateIdentity(
                                   authUser.User,
                                   AuthenticationTypes.ApiKey,
                                   new Claim(NuGetClaims.ApiKey, apiKey),
                                   new Claim(NuGetClaims.Scope, scopes),
                                   new Claim(NuGetClaims.CredentialKey, authUser.CredentialUsed.Key.ToString())),
                               new AuthenticationProperties()));
                }
                else
                {
                    // No user was matched
                    Logger.WriteWarning("No match for API Key!");
                }
            }
            else
            {
                Logger.WriteVerbose("No API Key Header found in request.");
            }

            return(null);
        }
コード例 #23
0
        private void Button1_Click(object sender, EventArgs e)
        {
            var authKey = AuthKeyTextBox.Text;
            var group   = GroupTextBox.Text;

            if (string.IsNullOrWhiteSpace(authKey) || string.IsNullOrWhiteSpace(group))
            {
                MessageBox.Show("Please check your entries.", this.Text);
                return;
            }

            Global.loginResponse = _auth.Authenticate(authKey, group);

            if (!Global.loginResponse.IsAuthenticated)
            {
                MessageBox.Show("Failed to login.", this.Text);
                return;
            }

            MessageBox.Show("Successfully logged in!", this.Text);

            // Open form or something
        }
コード例 #24
0
        private static async void CarpeDiem( )
        {
            Console.WriteLine("Creating new Process");
            using (Process p = new Process( )
            {
                StartInfo = new ProcessStartInfo( )
                {
                    FileName = "bztais.exe",
                    RedirectStandardError = true,
                    RedirectStandardOutput = true,
                    RedirectStandardInput = true,
                    UseShellExecute = false
                }
            })
            {
                Console.WriteLine("Starting {0} with {1}, {2}, {3}, and {4}",
                                  p.StartInfo.FileName,
                                  p.StartInfo.RedirectStandardError ? "Errors redirected" : "Errors not redirected",
                                  p.StartInfo.RedirectStandardInput ? "Input redirected" : "Input not redirected",
                                  p.StartInfo.RedirectStandardOutput ? "Output redirected" : "Output not redirected",
                                  p.StartInfo.UseShellExecute ? "Shell Execute On" : "Shell Execute Off"
                                  );
                p.Start( );

                StreamReader output = p.StandardOutput;
                while (!p.HasExited)
                {
                    string msg = "";
                    while (!string.IsNullOrEmpty(msg = await output.ReadLineAsync( )))
                    {
                        Console.WriteLine(msg);
                    }
                }
                Console.WriteLine("Program has Quit");
                Auth.Authenticate( );
            }
        }
コード例 #25
0
ファイル: Form1.cs プロジェクト: iirh/AdminPanel
        private void button1_Click(object sender, EventArgs e)
        {
            string username = textBox2.Text;
            string password = textBox3.Text;
            string email    = textBox4.Text;
            string token    = textBox5.Text;
            bool   register = auth.Register(username, password, email, token);

            bool authed = auth.Authenticate(textBox1.Text);

            if (authed != true)
            {
                MessageBox.Show("Please contact the Administration", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (register == true && authed == true)
            {
                MessageBox.Show("User " + username + " successfully registered!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Error please check your Informations", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #26
0
        public User getUserById(string email, string password, int ID)
        {
            Task <User> taskOperation = Task <User> .Run(() =>
            {
                try
                {
                    Auth.Authenticate(email, password, this.DB);
                }
                catch (UnAuthorizedExc e)
                {
                    return(null);
                }
                try
                {
                    return(DB.getUserById(ID));
                }
                catch (FaultException <DBFault> df)
                {
                    throw new FaultException <ManagerFault>(new ManagerFault(df.ToString()));
                }
            });

            return(taskOperation.Result);
        }
コード例 #27
0
        public List <Order> getOrders(string email, string password)
        {
            Task <List <Order> > taskOperation = Task <List <Order> > .Run(() =>
            {
                try
                {
                    Auth.Authenticate(email, password, this.DB);
                }
                catch (UnAuthorizedExc e)
                {
                    return(null);
                }
                try
                {
                    return(new List <Order>(DB.getOrders()));
                }
                catch (FaultException <DBFault> df)
                {
                    throw new FaultException <ManagerFault>(new ManagerFault(df.ToString()));
                }
            });

            return(taskOperation.Result);
        }
コード例 #28
0
        public bool deleteOrder(string email, string password, int ID)
        {
            Task <bool> taskOperation = Task <bool> .Run(() =>
            {
                try
                {
                    Auth.Authenticate(email, password, this.DB);
                }
                catch (UnAuthorizedExc e)
                {
                    return(false);
                }
                try
                {
                    return(DB.deleteOrder(ID));
                }
                catch (FaultException <DBFault> df)
                {
                    throw new FaultException <ManagerFault>(new ManagerFault(df.ToString()));
                }
            });

            return(taskOperation.Result);
        }
コード例 #29
0
        public bool createCategory(string email, string password, Category categoryToCreate)
        {
            Task <bool> taskOperation = Task <bool> .Run(() =>
            {
                try
                {
                    Auth.Authenticate(email, password, this.DB);
                }
                catch (UnAuthorizedExc e)
                {
                    return(false);
                }
                try
                {
                    return(DB.createCategory(categoryToCreate));
                }
                catch (FaultException <DBFault> df)
                {
                    throw new FaultException <ManagerFault>(new ManagerFault(df.ToString()));
                }
            });

            return(taskOperation.Result);
        }
コード例 #30
0
        public bool updateProduct(string email, string password, Product updatedProduct)
        {
            Task <bool> taskOperation = Task <bool> .Run(() =>
            {
                try
                {
                    Auth.Authenticate(email, password, this.DB);
                }
                catch (UnAuthorizedExc e)
                {
                    return(false);
                }
                try
                {
                    return(DB.updateProduct(updatedProduct));
                }
                catch (FaultException <DBFault> df)
                {
                    throw new FaultException <ManagerFault>(new ManagerFault(df.ToString()));
                }
            });

            return(taskOperation.Result);
        }