using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Windows.Forms;

using BusinessCommon;

using BusinessWindows.LoginReference;

namespace BusinessWindows
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            LoginInformation information = new LoginService().GetTicket(txtUserId.Text, txtPassword.Text, Environment.MachineName);
            if (information.Name != null)
            {
                AuthenticationTicket ticket = new AuthenticationTicket(information.Name, information.IssueDate, information.Expiration, information.Roles, information.UserData);
                MyIdentity identity = new MyIdentity(ticket);
                Thread.CurrentPrincipal = new MyPrincipal(identity);
                MessageBox.Show("認証されました");
            }
            else
            {
                MessageBox.Show("認証に失敗しました");
            }
        }
    }
}