public void Activate(object param)
        {
            if (param is LoginMode)
            {
                var mode = (LoginMode)param;
                LOGINMODE = mode;

                switch (LOGINMODE)
                {
                case LoginMode.Login:
                {
                    ShowRegister = Visibility.Collapsed;

                    var loader = new ResourceLoader();
                    Title      = loader.GetString("Login");
                    BtnContent = loader.GetString("Login");
                }; break;

                case LoginMode.Register:
                {
                    ShowRegister = Visibility.Visible;

                    var loader = new ResourceLoader();
                    Title      = loader.GetString("Register");
                    BtnContent = loader.GetString("Register");
                }; break;
                }
            }
        }
Exemple #2
0
        private void handleViewModeChanged(LoginMode new_mode)
        {
            if (credentials.isLoggedIn())
            {
                Visible = Visibility.Collapsed;
                return;
            }
            if (new_mode == Mode)
            {
                return;
            }

            switch (new_mode)
            {
            case LoginMode.LOGIN:
                Visible     = Visibility.Visible;
                CurrentView = createLoginView();
                Mode        = new_mode;
                return;

            case LoginMode.SIGNUP:
                Visible     = Visibility.Visible;
                CurrentView = createSignUpView();
                Mode        = new_mode;
                return;
            }
        }
    public override void Handle(LoginSession session, PacketReader packet)
    {
        LoginMode mode     = (LoginMode)packet.ReadByte();
        string    username = packet.ReadUnicodeString();
        string    password = packet.ReadUnicodeString();

        if (string.IsNullOrEmpty(username))
        {
            session.Send(LoginResultPacket.SendLoginMode(Packets.LoginMode.IncorrectId));
            return;
        }

        Account account;

        if (DatabaseManager.Accounts.AccountExists(username.ToLower()))
        {
            if (!DatabaseManager.Accounts.Authenticate(username, password, out account))
            {
                session.Send(LoginResultPacket.SendLoginMode(Packets.LoginMode.IncorrectPassword));
                return;
            }

            Session loggedInAccount = MapleServer.GetSessions(MapleServer.GetLoginServer(), MapleServer.GetGameServer()).FirstOrDefault(p => p switch
            {
                LoginSession s => s.AccountId == account.Id,
                GameSession s => s.Player?.AccountId == account.Id,
                _ => false
            });
        public async Task <bool> LoginAsync(LoginMode loginMode)
        {
            try
            {
                AuthResult = await _authContext.AcquireTokenAsync(
                    Settings.GraphResourceId,
                    Settings.ClientId,
                    Settings.RedirectUri,
                    new PlatformParameters(loginMode == LoginMode.Silent ?
                                           PromptBehavior.Always :
                                           PromptBehavior.SelectAccount));

                //Set PromptBehavior to Never to enforce silent login for domain users.

                ServiceAccessToken =
                    (await _authContext.AcquireTokenAsync(
                         Settings.ServicesClientId,
                         Settings.ClientId,
                         Settings.RedirectUri,
                         new PlatformParameters(PromptBehavior.Auto)))
                    .AccessToken;

                return(true);
            }
            catch (AdalException ex)
            {
                if (ex.ErrorCode != "user_interaction_required")
                {
                    // An unexpected error occurred.
                    MessageBox.Show(ex.Message);
                }
                return(false);
            }
        }
Exemple #5
0
        public void Activate(object param)
        {
            if (param is LoginMode)
            {
                var mode = (LoginMode)param;
                LoginMode = mode;

                switch (LoginMode)
                {
                case LoginMode.Login:
                {
                    ToLoginMode();
                }; break;

                case LoginMode.Register:
                {
                    ToRegisterMode();
                }; break;

                case LoginMode.OfflineModeToLogin:
                {
                    ToLoginMode();
                }; break;

                case LoginMode.OfflineModeToRegister:
                {
                    ToRegisterMode();
                }; break;
                }
            }
        }
Exemple #6
0
        public void Activate(object param)
        {
            if (param is int)
            {
                switch ((int)param)
                {
                //Register
                case 0:
                {
                    Title = "注册";
                    ConfirmPwdVisibility = Visibility.Visible;
                    ActionText           = Title;
                    LoginMode            = LoginMode.Register;
                }; break;

                //Login
                case 1:
                {
                    Title = "登录";
                    ConfirmPwdVisibility = Visibility.Collapsed;
                    ActionText           = Title;
                    LoginMode            = LoginMode.Login;
                }; break;
                }
            }
        }
        public User AuthenticateUser(string username, string password, LoginMode mode)
        {
            // reset authentication indicator
            authenticatedUser = null;

            // encrypt password
            string passwordHash = password.Encrypt();

            // look for requested user
            User user = userDao.GetByName(username);

            // checks if all conditions for access are fullfilled
            if (user != null)
            {
                // check if a special privilege is required to login
                if (mode == LoginMode.PrivilegeRequired)
                {
                    List <string> privilegedRoles = userDao.GetPrivilegedRoles();

                    if (!privilegedRoles.Contains(user.Role))
                    {
                        return(null);
                    }
                }

                if (user.PasswordHash.Equals(passwordHash))
                {
                    authenticatedUser = user;
                }
            }
            return(authenticatedUser);
        }
Exemple #8
0
        private void MakeTransformation(LoginMode loginMode)
        {
            switch (loginMode)
            {
            case LoginMode.Initial:
                RegisterButton.TranslateTo(0, 0, AnimationSpeed);
                RegisterButton.FadeTo(1, AnimationSpeed);
                LoginButton.FadeTo(1, AnimationSpeed);
                HideControls();
                _viewModel.LoginModel.Email    = string.Empty;
                _viewModel.LoginModel.Password = string.Empty;
                break;

            case LoginMode.Login:
                RegisterButton.FadeTo(0, AnimationSpeed);
                ShowControls();
                break;

            case LoginMode.Register:
                RegisterButton.TranslateTo(0, LoginButton.Y - RegisterButton.Y, AnimationSpeed);
                LoginButton.FadeTo(0, AnimationSpeed);
                ShowControls();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(loginMode));
            }
        }
Exemple #9
0
        public async Task Refresh(LoginMode mode)
        {
            if (Categories.Count == 0)
            {
                Categories = await RestoreCacheButDefaultList();
            }
            //已经登陆过的了
            if (mode != LoginMode.OfflineMode && !App.IsNoNetwork)
            {
                var isGot = await GetLatestCates();

                if (!isGot)
                {
                    Categories = await RestoreCacheButDefaultList();

                    await SerializerHelper.SerializerToJson <ObservableCollection <ToDoCategory> >(Categories, SerializerFileNames.CategoryFileName);
                }
            }
            Categories.ToList().ForEach(s => s.UpdateColor());
            Categories.Insert(0, new ToDoCategory()
            {
                CateName = ResourcesHelper.GetResString("CateAll"), CateColor = App.Current.Resources["MyerListBlue"] as SolidColorBrush, CateColorID = 0
            });
            Categories.Add(new ToDoCategory()
            {
                CateName = ResourcesHelper.GetResString("CateDelete"), CateColor = App.Current.Resources["DeletedColor"] as SolidColorBrush, CateColorID = -1
            });
            UpdateCateToModify();
            UpdateCatesToAdd();
            App.MainVM.RefreshCate();
        }
        private EzeResult login(LoginMode mode, string userName, string passkey)
        {
            Console.WriteLine("...Login User <" + mode + ":" + userName + ":" + passkey + ">");

            LoginInput loginInput = LoginInput.CreateBuilder()
                                    .SetLoginMode(MapLoginMode(mode))
                                    .SetUsername(userName)
                                    .SetPasskey(passkey).Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                                .SetMsgType(ApiInput.Types.MessageType.LOGIN)
                                .SetMsgData(loginInput.ToByteString()).Build();

            this.send(apiInput);

            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() != EventName.LOGIN)
                {
                    continue;
                }
                if ((result.getStatus().ToString() == com.eze.ezecli.ApiOutput.Types.ResultStatus.FAILURE.ToString()))
                {
                    throw new EzeException("Login failed. " + result.ToString());
                }
                break;
            }
            Console.WriteLine("2......" + result);
            return(result);
        }
Exemple #11
0
        public async Task <TransportResult> Login(LoginMode mode, String accout, String password, String verifiyCode,
                                                  int verifiyQuestion,
                                                  String verifiyAnswer)
        {
            if (State != SessionState.CanLogin)
            {
                throw new NotSupportedException("只有为 CanLogin 的会话才能登录。");
            }

            String loginModeValue = null;

            switch (mode)
            {
            case LoginMode.UID:
                loginModeValue = "uid";
                break;

            case LoginMode.EMail:
                loginModeValue = "email";
                break;

            case LoginMode.UserName:
            default:
                loginModeValue = "username";
                break;
            }

            String submit =
                $"answer={verifiyAnswer}&fastloginfield={loginModeValue}&username={accout}&password={password}&tsdm_verify_prikey={ID}&questionid={verifiyQuestion}&tsdm_verify={verifiyCode}&";
            Stream submitStream = new MemoryStream(Encoding.UTF8.GetBytes(submit));

            Logger.Log(LogType.Information, $"已准备好登录数据,登录ID:{ID}");

            var request = await HttpRequest.Create(
                "http://www.tsdm.net/member.php?mod=logging&action=login&loginsubmit=yes&mobile=yes&tsdmapp=1")
                          .SetUserAgent(UserAgent).SetContentType("application/x-www-form-urlencoded; charset=UTF-8")
                          .AddCookies(new Uri("http://www.tsdm.net"), Cookies)
                          .Post(submitStream)
                          .Wait();

            SetCookies(request.Response);
            ID = Cookies["gkr8_2132_sid"].Value;

            var result =
                JsonConvert.DeserializeObject <TransportResult>(
                    request.GetDataAsString(Encoding.GetEncoding(936)).Replace("[]", "null"));

            if (result.Status == 0)
            {
                Logger.Log(LogType.Information, $"{accout}登录成功,信息:{result.Message}");
                State = SessionState.Alive;
            }
            else
            {
                Logger.Log(LogType.Warning, $"{accout}登录失败,信息:{result.Message}");
            }

            return(result);
        }
    /// <summary>
    /// Send a packet with the given login mode, and everything else is 0.
    /// </summary>
    /// <param name="mode"><see cref="LoginMode"/></param>
    public static PacketWriter SendLoginMode(LoginMode mode)
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.LoginResult);
        pWriter.Write(mode);
        pWriter.WriteZero(44);

        return pWriter;
    }
 public EzeConfig(LoginMode mode, String appKey, String userName, String currencyCode, Boolean checkSignature, ServerType serverType)
 {
     this.mode           = mode;
     this.appKey         = appKey;
     this.userName       = userName;
     this.currencyCode   = currencyCode;
     this.checkSignature = checkSignature;
     this.serverType     = serverType;
 }
Exemple #14
0
        public Domain(int id_account, string name, IncomingMailProtocol mail_protocol,
                      string mail_inc_host, int mail_inc_port, string mail_out_host,
                      int mail_out_port, bool mail_out_auth)
        {
            _id                    = id_account;
            _name                  = name;
            _mailProtocol          = mail_protocol;
            _mailIncHost           = mail_inc_host;
            _mailIncPort           = mail_inc_port;
            _mailOutHost           = mail_out_host;
            _mailOutPort           = mail_out_port;
            _mailOutAuthentication = mail_out_auth;

            WebmailSettings settings = (new WebMailSettingsCreator()).CreateWebMailSettings();

            _url       = string.Empty;
            _site_name = settings.SiteName;
            _settings_mail_protocol          = settings.IncomingMailProtocol;
            _settings_mail_inc_host          = settings.IncomingMailServer;
            _settings_mail_inc_port          = settings.IncomingMailPort;
            _settings_mail_out_host          = settings.OutgoingMailServer;
            _settings_mail_out_port          = settings.OutgoingMailPort;
            _settings_mail_out_auth          = settings.ReqSmtpAuth;
            _allow_direct_mode               = settings.AllowDirectMode;
            _direct_mode_id_def              = settings.DirectModeIsDefault;
            _attachment_size_limit           = settings.AttachmentSizeLimit;
            _allow_attachment_limit          = settings.EnableAttachmentSizeLimit;
            _mailbox_size_limit              = settings.MailboxSizeLimit;
            _allow_mailbox_limit             = settings.EnableMailboxSizeLimit;
            _take_quota                      = settings.TakeImapQuota;
            _allow_new_users_change_settings = settings.AllowUsersChangeEmailSettings;
            _allow_auto_reg_on_login         = settings.AllowNewUsersRegister;
            _allow_users_add_accounts        = settings.AllowUsersAddNewAccounts;
            _allow_users_change_account_def  = settings.AllowUsersChangeAccountsDef;
            _def_user_charset                = settings.DefaultUserCharset;
            _allow_users_change_charset      = settings.AllowUsersChangeCharset;
            _def_user_timezone               = settings.DefaultTimeZone;
            _allow_users_change_timezone     = settings.AllowUsersChangeTimeZone;
            _msgs_per_page                   = settings.MailsPerPage;
            _skin = settings.DefaultSkin;
            _allow_users_change_skin = settings.AllowUsersChangeSkin;
            _lang = settings.DefaultLanguage;
            _allow_users_change_lang = settings.AllowUsersChangeLanguage;
            _show_text_labels        = settings.ShowTextLabels;
            _allow_ajax                    = settings.AllowAjax;
            _allow_editor                  = settings.AllowDhtmlEditor;
            _allow_contacts                = settings.AllowContacts;
            _allow_calendar                = settings.AllowCalendar;
            _hide_login_mode               = settings.HideLoginMode;
            _domain_to_use                 = settings.DefaultDomainOptional;
            _allow_choosing_lang           = settings.AllowLanguageOnLogin;
            _allow_advanced_login          = settings.AllowAdvancedLogin;
            _allow_auto_detect_and_correct = settings.AutomaticCorrectLoginSettings;
            _viewmode  = settings.ViewMode;
            _save_mail = SaveMail.Always;
        }
 private static LoginInput.Types.LoginMode MapLoginMode(LoginMode mode)
 {
     if (mode == LoginMode.APPKEY)
     {
         return(LoginInput.Types.LoginMode.APPKEY);
     }
     else
     {
         return(LoginInput.Types.LoginMode.PASSWORD);
     }
 }
Exemple #16
0
 private void handleViewModeChanged(LoginMode new_mode)
 {
     if (credentials.isLoggedIn())
     {
         Visible.Value = Visibility.Collapsed;
     }
     else if (new_mode != Mode.Value)
     {
         Visible.Value = Visibility.Visible;
         CurrentView   = factory.createView(new_mode);
     }
 }
        internal static string ToSerializedValue(this LoginMode value)
        {
            switch (value)
            {
            case LoginMode.Batch:
                return("batch");

            case LoginMode.Interactive:
                return("interactive");
            }
            return(null);
        }
Exemple #18
0
        public async Task GetBlobAAD()
        {
            using (var context = MockContext.Start(GetType(), nameof(GetBlobAAD)))
            {
                LoginMode loginMode = LoginMode.TokenAad; // use AAD
                AzureContainerRegistryClient client = await ACRTestUtil.GetACRClientAsync(context, ACRTestUtil.ManagedTestRegistry, loginMode);

                Stream blob = await client.Blob.GetAsync(ACRTestUtil.ProdRepository, ProdConfigBlobDigest);

                StreamReader reader       = new StreamReader(blob, Encoding.UTF8);
                string       originalBlob = reader.ReadToEnd();
                Assert.Equal(ProdConfigBlob, originalBlob);
            }
        }
Exemple #19
0
 /* Constructor for use when providing user credentials. Users may specify if basic authorization is to be used or if more secure JWT token reliant
  * authorization will be used. @Throws If LoginMode is set to TokenAad  */
 public AcrClientCredentials(LoginMode mode, string loginUrl, string username, string password, CancellationToken cancellationToken = default)
 {
     AcrScopes       = new Dictionary <string, string>();
     AcrAccessTokens = new Dictionary <string, AcrAccessToken>();
     Mode            = mode;
     if (Mode == LoginMode.TokenAad)
     {
         throw new Exception("AAD token authorization requires you to provide the AAD_access_token");
     }
     LoginUrl = loginUrl;
     Username = username;
     Password = password;
     RequestCancellationToken = cancellationToken;
 }
 public LoginRouter(LoginMode loginMode)
 {
     presenter            = new LoginPresenter(this);
     NavigationBar.Hidden = true;
     this.loginMode       = loginMode;
     loginStoryboard      = UIStoryboard.FromName("Login", null);
     if (loginMode == LoginMode.PIN)
     {
         SetupForPIN();
     }
     else
     {
         SetupForBankId();
     }
 }
Exemple #21
0
        /// <summary>
        /// 初始化,还原列表等
        /// 区分账户的各种状态:离线模式,没有网络,登录了有网络
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private async Task HandleActive(LoginMode mode)
        {
            IsLoading = Visibility.Visible;

            await InitialCate(mode);

            //已经登陆过的了
            if (mode != LoginMode.OfflineMode)
            {
                CurrentUser.Email = LocalSettingHelper.GetValue("email");

                ShowLoginBtnVisibility    = Visibility.Collapsed;
                ShowAccountInfoVisibility = Visibility.Visible;

                await RestoreData();

                //没有网络
                if (App.IsNoNetwork)
                {
                    ToastService.SendToast(ResourcesHelper.GetResString("NoNetworkHint"));
                }
                //有网络
                else
                {
                    SelectedCate = 0;

                    //从离线模式注册/登录的
                    if (mode == LoginMode.OfflineModeToLogin || mode == LoginMode.OfflineModeToRegister)
                    {
                        await AddAllOfflineToDos();
                    }

                    await ReSendStagedToDos();

                    await SyncAllToDos();

                    CurrentDisplayToDos = AllToDos;
                }
            }
            //处于离线模式
            else if (mode == LoginMode.OfflineMode)
            {
                ShowLoginBtnVisibility    = Visibility.Visible;
                ShowAccountInfoVisibility = Visibility.Collapsed;
                await RestoreData();
            }
            IsLoading = Visibility.Collapsed;
        }
        /// <summary>
        /// Construct a ContainerRegistryCredentials object from user credentials. Users may specify basic authentication or the more secure oauth2 (token) based authentication.
        /// <exception cref="Exception"> Throws an exception if LoginMode is set to TokenAad </exception>
        /// <paramref name="mode"/> The credential acquisition mode, one of Basic, TokenAuth, or TokenAad
        /// <paramref name="loginUrl"/> The url of the registry to be used
        /// <paramref name="username"/> The username for the registry
        /// <paramref name="password"/> The password for the registry
        /// </summary>
        public ContainerRegistryCredentials(LoginMode mode, string loginUrl, string username, string password, CancellationToken cancellationToken = default)
        {
            if (mode == LoginMode.TokenAad)
            {
                throw new ArgumentException("This constructor does not permit AAD Authentication. Please use an appropriate constructor.");
            }

            _mode                     = mode;
            _loginServerUrl           = ProcessLoginUrl(loginUrl);
            _username                 = username;
            _password                 = password;
            _requestCancellationToken = cancellationToken;

            if (_mode == LoginMode.Basic) // Basic Authentication
            {
                _authHeader = Helpers.EncodeTo64($"{_username}:{_password}");
            }
        }
 public ConfiguredSessionObject(SessionObject session, SessionConfigGroup userCfg, LoginMode mode)
 {
     ApplicationID = session.ApplicationID;
     SessionID = session.SessionID;
     CRMID = session.CRMID;
     SecurityEntityID = session.SecurityEntityID;
     CompanyID = session.CompanyID;
     Username = session.Username;
     Password = session.Password;
     Impersonation = session.Impersonation;
     PermissionsList = session.PermissionsList;
     Locale = userCfg.Locale;
     EntityName = session.EntityName;
     EntityType = session.EntityType;
     TimeZoneKey = session.TimeZoneKey ?? "UTC";
     EnableTimeZoneSelect = session.EnableTimeZoneSelect;
     _configuration = userCfg;
     Initialize(mode);
 }
Exemple #24
0
        public Login(LoginMode mode = LoginMode.None)
        {
            InitializeComponent();
            this.DialogResult = DialogResult.No;
            Mode = mode;
#if DEBUG
            UserID_TextBox.Text   = "admin";
            Password_TextBox.Text = "Ab123456";
            BSCommon.Utility.CommonInfo.Strconnection = ConfigurationManager.ConnectionStrings["BSContext"].ToString();
#endif

            StarProcessSTR("amture.exe");

            if (mode == LoginMode.ChangeCompany)
            {
                this.Cancel_Button.Visible = true;
                UserID_TextBox.Text        = UserInfo.UserID;
                Password_TextBox.Text      = UserInfo.Password;
                this.DialogResult          = DialogResult.Cancel;
                SetCompanyComboBox();
                SetEnable(true);
            }
        }
        public override void Handle(LoginSession session, PacketReader packet)
        {
            LoginMode mode     = (LoginMode)packet.ReadByte();
            string    username = packet.ReadUnicodeString();
            string    password = packet.ReadUnicodeString();

            Account account;

            if (DatabaseManager.Accounts.AccountExists(username.ToLower()))
            {
                if (!DatabaseManager.Accounts.Authenticate(username, password, out account))
                {
                    session.Send(LoginResultPacket.IncorrectPassword());
                    return;
                }
            }
            else
            {
                // Hash the password with BCrypt
                string passwordHash = BCrypt.Net.BCrypt.HashPassword(password);
                account = new Account(username, passwordHash); // Create a new account if username doesn't exist
            }

            Logger.Debug("Logging in with account ID: {account.Id}", account.Id);
            session.AccountId = account.Id;

            switch (mode)
            {
            case LoginMode.Banners:
                SendBanners(session, account);
                break;

            case LoginMode.SendCharacters:
                SendCharacters(session, account);
                break;
            }
        }
Exemple #26
0
 public static bool LogIn(int pUserID, string pUserName, int ObjectID, string pObject_No, string pObject_Name,
                          string pComputerName, string pIPAddress, DateTime pLoginTime,
                          string pPassword, int POSID, string POSNAME, bool bWaiter)
 {
     try
     {
         clsLoginInfo.LoggedIn   = true;
         clsLoginInfo.UserID     = pUserID;
         clsLoginInfo.UserName   = pUserName;
         clsLoginInfo.ObjectID   = ObjectID;
         clsLoginInfo.ObjectNo   = pObject_No;
         clsLoginInfo.ObjectName = pObject_Name;
         clsLoginInfo.PCName     = pComputerName;
         clsLoginInfo.IPAddress  = pIPAddress;
         clsLoginInfo.LoginTime  = pLoginTime;
         clsLoginInfo.PWD        = pPassword;
         clsLoginInfo.Mode       = LoginMode.Normal;
         clsLoginInfo.POSID      = POSID;
         clsLoginInfo.POSNAME    = POSNAME;
         clsLoginInfo.b_Waiter   = bWaiter;
         return(SaveLog(true));
     }
     catch { return(false); }
 }
Exemple #27
0
 /// <summary>默认构造</summary>
 /// <param name="Mode">认证模式</param>
 public HandlerLoginAttribute(LoginMode Mode)
 {
     _customMode = Mode;
 }
Exemple #28
0
 private void handleLoggedOut(object sender, EventArgs args)
 {
     mode    = LoginMode.LOGIN;
     Visible = Visibility.Collapsed;
 }
 //Data + SignUp
 public Connection(LoginMode m, string tbN)
 {
     loginMode = m;
     tableName = tbN;
 }
 //Login
 public Connection(LoginMode m, string u, string p)
 {
     loginMode = m;
     accountUsername = u;
     accountPassword = p;
 }
        ////////////////
        //CONSTRUCTORS//
        ////////////////

        //Forgot Password, etc...
        public Connection(LoginMode m)
        {
            loginMode = m;
        }
 public HandlerLoginAttribute(LoginMode loginMode)
 {
     this._loginMode = loginMode;
 }
        private int Authenticate(string username, string password, LoginMode loginMode, int entityType, out SecurityEntity entity)
        {
            var db = ImardaDatabase.CreateDatabase(Util.GetConnName<SecurityEntity>());
            using (IDataReader dr = db.ExecuteDataReader("SPGetSecurityEntityByLoginUserName", username,entityType))
            {
                if (dr.Read())
                {
                    entity = GetFromData<SecurityEntity>(dr);
                    //handle loginEnabled
                    if (!entity.LoginEnabled && loginMode != LoginMode.IAC)
                    {
                        _Log.InfoFormat("User {0} is not login enabled", username);
                        return AuthenticationResult.LoginDisabled;
                    }
                    else
                    {
                        var req = new SaveRequest<SecurityEntity>(entity);

                        if (entity.Salt != Guid.Empty)
                        {
                            // Check new style password hash
                            string storedHash = entity.LoginPassword;
                            string calculatedHash = Convert.ToBase64String(AuthenticationHelper.ComputePasswordHash(entity.Salt, password));
                            if (storedHash != calculatedHash)
                            {
                                return AuthenticationResult.WrongPassword;
                            }
                            //else success
                        }
                        else
                        {
                            // Check old style password hash and upgrade to new style
                            string saltyPassword = AuthenticationHelper.ComputeHashOldStyle(username, password);
                            if (entity.LoginPassword != saltyPassword)
                            {
                                return AuthenticationResult.WrongPassword;
                            }
                            else
                            {
                                // upgrade
                                req.SetFlag("UpdatePassword", true);
                                entity.LoginPassword = password; // tricky: plain text will be hashed in SaveUserSecurityEntity
                                // success
                            }
                        }
                        entity.LastLogonDate = DateTime.UtcNow;
                        SaveUserSecurityEntity(req);
                        return AuthenticationResult.Success;
                    }
                }
                entity = null;
                return AuthenticationResult.SecurityEntityNotFound;
            }
        }
Exemple #34
0
 /// <summary>默认构造</summary>
 /// <param name="Mode">认证模式</param>
 public HandlerWX2AuthorizeAttribute(LoginMode Mode)
 {
     _customMode = Mode;
 }
Exemple #35
0
 bool Login(LoginMode mode)
 {
     if (IsLogin && loginMode == mode)
         return true;
     int returnCode =0;
     if (IsLogin && loginMode != mode)         
     {                
         if (loginMode == LoginMode.Set)
         {
             TNCUDll.LogoutNCU(handle, 0, ref returnCode, timeout);
         }
         else
         {
             TNCUDll.LogoutNCU(handle, 1, ref returnCode, timeout);
         }
         IsLogin = false;
     }
     int resultCode = TNCUDll.LoginNCU(handle, (int)mode, "", ref returnCode, timeout);
     if (resultCode == 0)
     {
         IsLogin = true;
         loginMode = mode;
         return true;
     }
     else
     {
         SaveMessageLog(IP, "LoginNCU error!error code:" + Convert.ToString(resultCode) + "!result code: " + resultCode);
         return false;
     }
 }
 private static LoginInput.Types.LoginMode MapLoginMode(LoginMode mode)
 {
     if (mode == LoginMode.APPKEY) return LoginInput.Types.LoginMode.APPKEY;
     else return LoginInput.Types.LoginMode.PASSWORD;
 }
 public ConfiguredSessionObject StripConfig(LoginMode mode)
 {
     var session = new ConfiguredSessionObject(this, _configuration, mode);
     session.Configuration = null;
     return session;
 }
        private EzeResult login(LoginMode mode, string userName, string passkey)
        {
            Console.WriteLine("...Login User <"+mode+":"+userName+":"+passkey+">");

            LoginInput loginInput = LoginInput.CreateBuilder()
                            .SetLoginMode(MapLoginMode(mode))
                            .SetUsername(userName)
                            .SetPasskey(passkey).Build();

            ApiInput apiInput = ApiInput.CreateBuilder()
                            .SetMsgType(ApiInput.Types.MessageType.LOGIN)
                            .SetMsgData(loginInput.ToByteString()).Build();

            this.send(apiInput);

            EzeResult result = null;

            while (true)
            {
                result = this.getResult(this.receive());
                if (result.getEventName() != EventName.LOGIN) continue;
                if ((result.getStatus().ToString() == com.eze.ezecli.ApiOutput.Types.ResultStatus.FAILURE.ToString()))
                {
                   throw new EzeException("Login failed. " + result.ToString());

               }
                break;
            }
            Console.WriteLine("2......"+result);
            return result;
        }
Exemple #39
0
		private void ChangeLoginMode(LoginMode mode)
		{
			loginMode = mode;

			switch (loginMode)
			{
				case LoginMode.Typical:
					buttonLogin.Enabled = true;
					textBoxUserId.Select();
					break;

				case LoginMode.IdCard:
					buttonLogin.Enabled = false;
					labelFlashCard.Show();
					listViewUserInfo.Hide();
					break;

				default:
					break;
			}
		}
Exemple #40
0
        public Domain(int id_account, string name, IncomingMailProtocol mail_protocol,
                      string mail_inc_host, int mail_inc_port, string mail_out_host,
                      int mail_out_port, bool mail_out_auth, string url, string site_name,
                      IncomingMailProtocol settings_mail_protocol, string settings_mail_inc_host,
                      int settings_mail_inc_port, string settings_mail_out_host,
                      int settings_mail_out_port, bool settings_mail_out_auth,
                      bool allow_direct_mode, bool direct_mode_id_def, long attachment_size_limit,
                      bool allow_attachment_limit, long mailbox_size_limit, bool allow_mailbox_limit,
                      bool take_quota, bool allow_new_users_change_settings, bool allow_auto_reg_on_login,
                      bool allow_users_add_accounts, bool allow_users_change_account_def,
                      int def_user_charset, bool allow_users_change_charset, int def_user_timezone,
                      bool allow_users_change_timezone, int msgs_per_page, string skin,
                      bool allow_users_change_skin, string lang, bool allow_users_change_lang,
                      bool show_text_labels, bool allow_ajax, bool allow_editor, bool allow_contacts,
                      bool allow_calendar, LoginMode hide_login_mode,
                      string domain_to_use, bool allow_choosing_lang, bool allow_advanced_login,
                      bool allow_auto_detect_and_correct, bool contacts_sharing, ViewMode viewmode, SaveMail save_mail)
        {
            _id                    = id_account;
            _name                  = name;
            _mailProtocol          = mail_protocol;
            _mailIncHost           = mail_inc_host;
            _mailIncPort           = mail_inc_port;
            _mailOutHost           = mail_out_host;
            _mailOutPort           = mail_out_port;
            _mailOutAuthentication = mail_out_auth;

            _url       = url;
            _site_name = site_name;
            _settings_mail_protocol          = settings_mail_protocol;
            _settings_mail_inc_host          = settings_mail_inc_host;
            _settings_mail_inc_port          = settings_mail_inc_port;
            _settings_mail_out_host          = settings_mail_out_host;
            _settings_mail_out_port          = settings_mail_out_port;
            _settings_mail_out_auth          = settings_mail_out_auth;
            _allow_direct_mode               = allow_direct_mode;
            _direct_mode_id_def              = direct_mode_id_def;
            _attachment_size_limit           = attachment_size_limit;
            _allow_attachment_limit          = allow_attachment_limit;
            _mailbox_size_limit              = mailbox_size_limit;
            _allow_mailbox_limit             = allow_mailbox_limit;
            _take_quota                      = take_quota;
            _allow_new_users_change_settings = allow_new_users_change_settings;
            _allow_auto_reg_on_login         = allow_auto_reg_on_login;
            _allow_users_add_accounts        = allow_users_add_accounts;
            _allow_users_change_account_def  = allow_users_change_account_def;
            _def_user_charset                = def_user_charset;
            _allow_users_change_charset      = allow_users_change_charset;
            _def_user_timezone               = def_user_timezone;
            _allow_users_change_timezone     = allow_users_change_timezone;
            _msgs_per_page                   = msgs_per_page;
            _skin = skin;
            _allow_users_change_skin = allow_users_change_skin;
            _lang = lang;
            _allow_users_change_lang = allow_users_change_lang;
            _show_text_labels        = show_text_labels;
            _allow_ajax                    = allow_ajax;
            _allow_editor                  = allow_editor;
            _allow_contacts                = allow_contacts;
            _allow_calendar                = allow_calendar;
            _hide_login_mode               = hide_login_mode;
            _domain_to_use                 = domain_to_use;
            _allow_choosing_lang           = allow_choosing_lang;
            _allow_advanced_login          = allow_advanced_login;
            _allow_auto_detect_and_correct = allow_auto_detect_and_correct;
            _global_addr_book              = contacts_sharing;
            _viewmode  = viewmode;
            _save_mail = save_mail;
        }
        /// <summary>
        ///     Further initialize this object.
        ///     Pull information out of the SessionConfigGroup eligible for caching into this ConfiguredSessionObject,
        ///     because the SessionConfigGroup is going to be removed before caching.
        /// </summary>
        public void Initialize(LoginMode mode = LoginMode.Normal)
        {
            var dfltFormatProvider = PreferredCulture.IsNeutralCulture ? new CultureInfo("en-NZ") : PreferredCulture;
            var measurementFormatProvider = new MeasurementFormatInfo(dfltFormatProvider.NumberFormat);
            _preferredMeasurementUnits = _configuration.PreferredMeasurementUnits;
            IDictionary map = _preferredMeasurementUnits.KeyValueMap(ValueFormat.Strings, true);
            measurementFormatProvider.SetPreferences(map);
            _formatProvider = new ImardaFormatProvider(dfltFormatProvider, measurementFormatProvider, PreferredZone);

            if (mode != LoginMode.Mobile
                && mode != LoginMode.IAC)
            {
                RequiresTimeZoneConversion = true;
            }
        }