/// <summary> /// Ctor. /// </summary> public LoginControlViewModel(IDialogService dialogService, ITokenService tokenService, ISynchronizationService synchronizationService, IUserCredentials userCredentials, ILogger logger) { System.Threading.ThreadPool.QueueUserWorkItem((x) => { try { DevicesList = NFCWMQService.GetConnectedDevices(); } catch (Exception) { } }); _dialogService = dialogService; _tokenService = tokenService; _synchronizationService = synchronizationService; _userCredentials = userCredentials; _logger = logger; Title = "NFCRing - Fence"; AddCommand = new RelayCommand(Add, () => AllowAdd); RemoveCommand = new RelayCommand <RingItemViewModel>(Remove); SelectImageCommand = new RelayCommand <string>(SelectImage); SaveNameCommand = new RelayCommand <object>(SaveName, x => !string.IsNullOrEmpty(Items.FirstOrDefault(y => Equals(x, y.Token))?.Name)); CancelEditNameCommand = new RelayCallbackCommand <object>(CancelEditName); RefreshConnectedDevicesCommand = new RelayCallbackCommand <object>(RefreshConnectedDevices); AboutCommand = new RelayCommand(AboutCommandMethod); PropertyChanged += OnPropertyChanged; }
public Task <IUserCredentials> GetUserCredentials(IUserCredentials credentials) { IUserCredentials cred = null; string username = credentials?.Username; string password = credentials?.Password; if (string.IsNullOrEmpty(username)) { Console.Write("Enter Username: "******"Username: "******"Enter Password: "); password = HelperUtils.ReadLineMasked(); } if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { cred = new UserCredencials { Username = username, Password = password }; } return(Task.FromResult(cred)); }
public static IUser CreateMockUser(int id, IUserCredentials credentials) { // ignore id as it's not defined in IUser - just here for consistency Mock<IUser> mock = new Mock<IUser>(); mock.Setup(u => u.Credentials).Returns(credentials); return mock.Object; }
public IUserProfileServiceResult CreateUserProfile(IUserCredentials credentials, ILogger logger) { StringBuilder profileDir = new StringBuilder(MAX_PATH); uint size = (uint)profileDir.Capacity; bool profileExists = false; uint error = CreateProfile(credentials.Sid, credentials.Username, profileDir, size); // 0x800700b7 - Profile already exists. if (error != 0 && error != 0x800700b7) { logger?.LogError(Resources.Error_UserProfileCreateFailed, credentials.Domain, credentials.Username, error); } else if (error == 0x800700b7) { profileExists = true; logger?.LogInformation(Resources.Info_UserProfileAlreadyExists, credentials.Domain, credentials.Username); } else { logger?.LogInformation(Resources.Info_UserProfileCreated, credentials.Domain, credentials.Username); } return(new RUserProfileServiceResponse(error, profileExists, profileDir.ToString())); }
public LoginStepViewModel(IDialogService dialogService, IUserCredentials userCredentials) { _dialogService = dialogService; _userCredentials = userCredentials; UserName = _userCredentials.GetName(); }
public TwitchChat(IUserCredentials credentials) { Credentials = credentials; UserName = Credentials.UserName.ToLowerInvariant(); notify = new NotifyObjectHelper(this); Channels = new ChatChannelCollection(this); }
public IUserCredentials LogOn(string identity) { Current = Factory.GetNewUserCredential(new NetworkCredential() { UserName = identity }); return(Current); }
/// <summary> /// Initializes a new instance of <see cref="TmiClient"/> /// </summary> /// <param name="credentials">the credentials to use for login</param> /// <seealso cref="IUserCredentials"/> /// <see cref="UserCredentials"/> public TmiClient(IUserCredentials credentials) { if (credentials == null) { throw new ArgumentNullException(nameof(credentials)); } Credentials = credentials; userName = Credentials.UserName.ToLowerInvariant(); }
public void SaveUserCredentials(IUserCredentials userCredentials) { if (userCredentials == null) { throw new ArgumentNullException(nameof(userCredentials)); } _credentialsRepository.Save(userCredentials); }
public SecurityToken LogOn(IUserCredentials myUserCredentials) { if (myUserCredentials is RemoteUserPasswordCredentials) { _SecurityToken = _GraphDSService.LogOn(((RemoteUserPasswordCredentials)myUserCredentials).ServiceObject); return(_SecurityToken); } return(null); }
/// <inheritdoc /> public async Task <IUserCredentials> ChangeRecoveryQuestionAsync(IUserCredentials userCredentials, string userId, CancellationToken cancellationToken = default(CancellationToken)) => await PostAsync <UserCredentials>(new HttpRequest { Uri = "/api/v1/users/{userId}/credentials/change_recovery_question", Payload = userCredentials, PathParameters = new Dictionary <string, object>() { ["userId"] = userId, }, }, cancellationToken).ConfigureAwait(false);
//TODO: find a better solution than returning null. Don't return null! public object AuthUser(string Email, string Password) { IUserCredentials Credentials = Database.GetUserCredentials(Email); if (Credentials is null || !Hasher.CheckPassword(Credentials.Password, Password)) { return(null); } return(Credentials.UserUid); }
public IUserProfileServiceResult CreateUserProfile(IUserCredentials credentials, ILogger logger) { // Future: Switching Broker service to network service will eliminate the need for login here // The same holds true for profile deletion. The login token can be obtained via cross process // handle duplication IntPtr token = IntPtr.Zero; IntPtr password = IntPtr.Zero; RUserProfileServiceResponse result = new RUserProfileServiceResponse(13, false, string.Empty); uint error = 0; try { password = Marshal.SecureStringToGlobalAllocUnicode(credentials.Password); if (LogonUser(credentials.Username, credentials.Domain, password, (int)LogonType.LOGON32_LOGON_NETWORK, (int)LogonProvider.LOGON32_PROVIDER_DEFAULT, out token)) { WindowsIdentity winIdentity = new WindowsIdentity(token); StringBuilder profileDir = new StringBuilder(MAX_PATH); uint size = (uint)profileDir.Capacity; bool profileExists = false; error = CreateProfile(winIdentity.User.Value, credentials.Username, profileDir, size); // 0x800700b7 - Profile already exists. if (error != 0 && error != 0x800700b7) { logger?.LogError(Resources.Error_UserProfileCreateFailed, credentials.Domain, credentials.Username, error); result = RUserProfileServiceResponse.Blank; } else if (error == 0x800700b7) { profileExists = true; logger?.LogInformation(Resources.Info_UserProfileAlreadyExists, credentials.Domain, credentials.Username); } else { logger?.LogInformation(Resources.Info_UserProfileCreated, credentials.Domain, credentials.Username); } profileDir = new StringBuilder(MAX_PATH * 2); size = (uint)profileDir.Capacity; if (GetUserProfileDirectory(token, profileDir, ref size)) { logger?.LogInformation(Resources.Info_UserProfileDirectoryFound, credentials.Domain, credentials.Username, profileDir.ToString()); result = new RUserProfileServiceResponse(0, profileExists, profileDir.ToString()); } else { logger?.LogError(Resources.Error_UserProfileDirectoryWasNotFound, credentials.Domain, credentials.Username, Marshal.GetLastWin32Error()); result = new RUserProfileServiceResponse((uint)Marshal.GetLastWin32Error(), profileExists, profileDir.ToString()); } } else { logger?.LogError(Resources.Error_UserLogonFailed, credentials.Domain, credentials.Username, Marshal.GetLastWin32Error()); result = new RUserProfileServiceResponse((uint)Marshal.GetLastWin32Error(), false, null); } } finally { if (token != IntPtr.Zero) { CloseHandle(token); } if(password != IntPtr.Zero) { Marshal.ZeroFreeGlobalAllocUnicode(password); } } return result; }
public async Task <long> Save(string streamId, IEnumerable <object> events, long expectedVersion, Metadata metadata, IUserCredentials userCredentials = null) { var userCreds = userCredentials == null ? null : new global::EventStore.ClientAPI.SystemData.UserCredentials(userCredentials.Username, userCredentials.Password); var eventDatas = events.Select(x => ToDb(x, metadata)).ToArray(); var result = await _connection.AppendToStreamAsync(streamId, expectedVersion, eventDatas, userCreds); return(result.NextExpectedVersion); }
public static bool GetUserCredentials(IUserCredentials dialog, out string user, out string pass) { if (dialog.ShowDialog() != DialogResult.OK) { user = null; pass = null; return(false); } user = dialog.User; pass = dialog.Pass; return(true); }
public static bool GetUserCredentials(IUserCredentials dialog, out string user, out string pass) { if (dialog.ShowDialog() != DialogResult.OK) { user = null; pass = null; return false; } user = dialog.User; pass = dialog.Pass; return true; }
public async Task <IAuthenticationResult> Login(string apiKey, IUserCredentials userCredentials) { var request = MessageAssembler.ToMessage <IUserCredentials, UserCredentials>(userCredentials); var response = await WithAnonymousClient() .ForApplication(apiKey) .OnVersion(2) .Post(request) .To("session") .ForHttpResponseMessageReader(); return(await BuildAuthenticationResult(response)); }
public T LoadUserByCredentials <T>(IUserCredentials credentials) where T : IEntity, IUser { AssertNotIsNullOrWhiteSpace(credentials.Username, new UsernameMissingException()); AssertNotIsNullOrWhiteSpace(credentials.Password, new PasswordMissingException()); Guid?id = userDataManager.FindUserByCredentials(credentials); AssertHasValue(id, new InvalidCredentialsException(credentials)); return(LoadEntity <T>(id.Value, TYPE_USER)); }
public IUser Validate(IUserCredentials credentials) { IUser user = m_repository.Get(credentials.Email); if (null == user || !m_encryptor.IsMatch(credentials.Password, user.Credentials.Password)) { throw new AuthenticationException(); } Debug.Assert(null != user); return user; }
/// <summary> /// Initializes a new instance of the /// <see cref="BrowserStackLoginHelper"/> class. /// </summary> public BrowserStackLoginHelper(IAsyncActionsFactory asyncActionsFactory, IInfoService infoService, IServiceInvoker serviceInvoker, IUserCredentials userCredentials, IApolloServicesLocations apolloServicesLocations, ICookieContainerSpecificWebRequestCreator cookieContainerSpecificWebRequestCreator) { mAsyncActionsFactory = asyncActionsFactory; mCookieContainerSpecificWebRequestCreator = cookieContainerSpecificWebRequestCreator; mServiceInvoker = serviceInvoker; mUserCredentials = userCredentials; mApolloServicesLocations = apolloServicesLocations; mInfoService = infoService; }
public IUserProfileServiceResult DeleteUserProfile(IUserCredentials credMock, ILogger logger) { if (!TestingValidParse) { // If parse succeeded but did not generate an object, // for example, JSON parse of white spaces. credMock.Should().BeNull(); return UserProfileResultMock.Create(false, false); } ValidateUsername(credMock?.Username); ValidateDomain(credMock?.Domain); ValidatePassword(credMock?.Password.ToUnsecureString()); return UserProfileResultMock.Create(TestingValidAccount, TestingExistingAccount); }
public IUserProfileServiceResult DeleteUserProfile(IUserCredentials credMock, ILogger logger) { if (!TestingValidParse) { // If parse succeeded but did not generate an object, // for example, JSON parse of white spaces. credMock.Should().BeNull(); return(UserProfileResultMock.Create(false, false)); } ValidateUsername(credMock?.Username); ValidateDomain(credMock?.Domain); ValidateSid(credMock?.Sid); return(UserProfileResultMock.Create(TestingValidAccount, TestingExistingAccount)); }
public async Task <IUserConfiguration> ResolveUserConfiguration(IUserCredentials credentials, IConfiguration configuration) { var result = new UserConfiguration { Username = credentials?.Username, Password = credentials?.Password }; if (string.IsNullOrEmpty(result.Username)) { result.Username = configuration?.LastLogin; } if (!string.IsNullOrEmpty(result.Username) && string.IsNullOrEmpty(result.Password)) { result.Password = configuration?.Users? .Where(x => string.Compare(x.Username, result.Username, true) == 0) .Select(x => x.Password) .FirstOrDefault(); } while (string.IsNullOrEmpty(result.Username) || string.IsNullOrEmpty(result.Password)) { if (Ui == null) { throw new KeeperRequiresUI(); } var creds = await Ui.GetUserCredentials(result); if (creds == null) { return(null); } result.Username = creds.Username; result.Password = creds.Password; } if (!string.IsNullOrEmpty(result.Username) && string.IsNullOrEmpty(result.TwoFactorToken)) { result.TwoFactorToken = configuration?.Users? .Where(x => string.Compare(x.Username, result.Username, true) == 0) .Select(x => x.TwoFactorToken) .FirstOrDefault(); } return(result); }
public IUserProfileServiceResult DeleteUserProfile(IUserCredentials credentials, ILogger logger) { logger?.LogInformation(Resources.Info_DeletingUserProfile, credentials.Domain, credentials.Username); IntPtr token = IntPtr.Zero; IntPtr password = IntPtr.Zero; int error = 0; string sid=string.Empty; StringBuilder profileDir = new StringBuilder(MAX_PATH * 2); uint size = (uint)profileDir.Capacity; bool profileExists = false; try { password = Marshal.SecureStringToGlobalAllocUnicode(credentials.Password); if (LogonUser(credentials.Username, credentials.Domain, password, (int)LogonType.LOGON32_LOGON_NETWORK, (int)LogonProvider.LOGON32_PROVIDER_DEFAULT, out token)) { WindowsIdentity winIdentity = new WindowsIdentity(token); if (GetUserProfileDirectory(token, profileDir, ref size) && !string.IsNullOrWhiteSpace(profileDir.ToString())) { sid = winIdentity.User.Value; profileExists = true; } else { error = Marshal.GetLastWin32Error(); logger?.LogError(Resources.Error_UserProfileDirectoryWasNotFound, credentials.Domain, credentials.Username, error); } } } finally { if (token != IntPtr.Zero) { CloseHandle(token); } if (password != IntPtr.Zero) { Marshal.ZeroFreeGlobalAllocUnicode(password); } } string profile = "<deleted>"; if (!string.IsNullOrWhiteSpace(sid)) { if (DeleteProfile(sid, null, null)) { logger?.LogInformation(Resources.Info_DeletedUserProfile, credentials.Domain, credentials.Username); } else { error = Marshal.GetLastWin32Error(); logger?.LogError(Resources.Error_DeleteUserProfileFailed, credentials.Domain, credentials.Username, error); profile = profileDir.ToString(); } } return new RUserProfileServiceResponse((uint)error, profileExists, profile); }
public async Task <ISubscription> SubscribeToAll(Func <ISubscription, IEventData, Task> onEventAppeared, Action <ISubscription, string, Exception> onSubscriptionDropped = null, IUserCredentials userCredentials = null) { var subscriptionId = Guid.NewGuid().ToString(); var creds = userCredentials != null ? new global::EventStore.ClientAPI.SystemData.UserCredentials(userCredentials.Username, userCredentials.Password) : null; var esSubscription = await _connection.SubscribeToAllAsync(true, async (_, ev) => await HandleEvent(onEventAppeared, _subscriptions[subscriptionId], ev), (_, reason, ex) => onSubscriptionDropped(_subscriptions[subscriptionId], reason.ToString(), ex), creds); var subscription = _subscriptions[subscriptionId] = new Subscription(esSubscription); return(subscription); }
public CookieContainer Login(IUserCredentials userCredentials) { var cookieContainer = new CookieContainer(); var data_str = $"email={userCredentials.Email}&pword={userCredentials.Password}&authenticate=signin"; var data_bytes = Encoding.ASCII.GetBytes(data_str); var request = HttpWebRequest.CreateHttp("https://www.saltybet.com/authenticate?signin=1"); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data_bytes.Length; request.AllowAutoRedirect = true; request.CookieContainer = cookieContainer; using (Stream stream = request.GetRequestStream()) { stream.Write(data_bytes, 0, data_bytes.Length); stream.Close(); } WebResponse response; try { response = request.GetResponse(); } catch (WebException e) { if (e.Status == WebExceptionStatus.ProtocolError) { //Expected (HTTP 302 Temporarily moved). } else { Console.WriteLine("Error occurred while logging in..."); return(null); } } OnLoggedIn(new EventArgs()); return(cookieContainer); }
/// <summary> /// Ctor. /// </summary> public LoginControlViewModel(IDialogService dialogService, ITokenService tokenService, ISynchronizationService synchronizationService, IUserCredentials userCredentials, ILogger logger) { _dialogService = dialogService; _tokenService = tokenService; _synchronizationService = synchronizationService; _userCredentials = userCredentials; _logger = logger; Title = "NFCRing - Fence"; AddCommand = new RelayCommand(Add, () => AllowAdd); RemoveCommand = new RelayCommand <RingItemViewModel>(Remove); SelectImageCommand = new RelayCommand <string>(SelectImage); SaveNameCommand = new RelayCommand <object>(SaveName, x => !string.IsNullOrEmpty(Items.FirstOrDefault(y => Equals(x, y.Token))?.Name)); CancelEditNameCommand = new RelayCallbackCommand <object>(CancelEditName); PropertyChanged += OnPropertyChanged; }
public ActionResult LogOn(SignInViewModel model) { if (ModelState.IsValid) { if (Service.IsValidUser(model.UserName)) { IUserCredentials user = Service.LogOn(model.UserName); CookieService.EnsureCookie(Request, Response, model.UserName, model.RememberMe); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } return(RedirectToAction("SignIn", model)); }
/// <summary> /// Initializes a new instance of the <see cref="NsiAuthModule"/> class. /// Create a new instance of the <see cref="NsiAuthModule"/> class /// </summary> public NsiAuthModule() { _log.Debug("Starting SRI Authentication and dataflow authorization module."); AuthUtils.ValidateConfig(ConfigManager.Instance.Config, this.GetType()); this._userCred = UserCredentialsFactory.Instance.CreateUserCredentials(); this._authentication = AuthenticationProviderFactory.Instance.CreateAuthenticationProvider(); this._realm = ConfigManager.Instance.Config.Realm; string anonUser = ConfigManager.Instance.Config.AnonymousUser; if (!string.IsNullOrEmpty(anonUser)) { this._anonUser = UserFactory.Instance.CreateUser(this._realm); if (this._anonUser != null) { this._anonUser.UserName = anonUser; } } }
public IUserProfileServiceResult DeleteUserProfile(IUserCredentials credentials, ILogger logger) { logger?.LogInformation(Resources.Info_DeletingUserProfile, credentials.Domain, credentials.Username); int error = 0; RUserProfileServiceResponse result; if (DeleteProfile(credentials.Sid, null, null)) { logger?.LogInformation(Resources.Info_DeletedUserProfile, credentials.Domain, credentials.Username); result = new RUserProfileServiceResponse((uint)error, true, "<deleted>"); } else { error = Marshal.GetLastWin32Error(); logger?.LogError(Resources.Error_DeleteUserProfileFailed, credentials.Domain, credentials.Username, error); result = new RUserProfileServiceResponse((uint)error, false, ""); } return(result); }
public ActionResult Login(IUserCredentials credentials, string returnUrl) { // problem with the binding of credentials if (!ModelState.IsValid) { return RedirectTo("Login", returnUrl); } try { IUser user = m_membership.Validate(credentials); m_authentication.Login(user.Forename, false); } catch (ValidationException ex) { ex.ToModelErrors(ModelState, ""); return RedirectTo("Login", returnUrl); } return Redirect(UrlHelpers.SanitiseUrl(returnUrl)); }
public async Task <IEnumerable <IEventData> > Read(string streamId, long start = 0, IUserCredentials userCredentials = null) { return(await _eventStore.Read(streamId, start, userCredentials)); }
public IUserProfileServiceResult DeleteUserProfile(IUserCredentials credentails, ILogger logger) { // The fuzz test generated a valid parse-able JSON for the test we fail the login return UserProfileResultMock.Create(false, false); }
public SecurityToken LogOn(IUserCredentials toBeAuthenticatedCredentials) { return new SecurityToken(); }
/// <inheritdoc /> public async Task <IForgotPasswordResponse> ForgotPasswordSetNewPasswordAsync(IUserCredentials user, string userId, bool?sendEmail = true, CancellationToken cancellationToken = default(CancellationToken)) => await PostAsync <ForgotPasswordResponse>(new HttpRequest { Uri = "/api/v1/users/{userId}/credentials/forgot_password", Verb = HttpVerb.Post, Payload = user, PathParameters = new Dictionary <string, object>() { ["userId"] = userId, }, QueryParameters = new Dictionary <string, object>() { ["sendEmail"] = sendEmail, }, }, cancellationToken).ConfigureAwait(false);
public async Task <IEnumerable <IEventData> > Read(string streamId, long start = 0, IUserCredentials userCredentials = null) { var userCreds = userCredentials == null ? null : new global::EventStore.ClientAPI.SystemData.UserCredentials(userCredentials.Username, userCredentials.Password); var result = await _connection.ReadStreamEventsForwardAsync(streamId, start, _batchSize, true, userCreds); return(result.Events.Select(FromDb)); }
public bool Logoff() { Current = Factory.GetNewUserCredential(new NetworkCredential()); return(true); }
public IdentityService(IItemFactory factory, IUserCredentials identity) { Factory = factory ?? ServiceFactory.Get <IItemFactory>(); Current = identity ?? Factory.GetNewUserCredential(new NetworkCredential()); }
public async Task <ReadBatchResult> ReadBatch(string streamId, long start, int count, IUserCredentials userCredentials = null) { var userCreds = userCredentials == null ? null : new global::EventStore.ClientAPI.SystemData.UserCredentials(userCredentials.Username, userCredentials.Password); var result = await _connection.ReadStreamEventsForwardAsync(streamId, start, count, true, userCreds); var events = result.Events.Select(FromDb).ToArray(); return(new ReadBatchResult(result.Stream, result.FromEventNumber, result.NextEventNumber, result.IsEndOfStream, events)); }
public AccountDigestAuthenticationProvider(IUserCredentials users) { _users = users; }
IUser IUserRepository.CreateUser(string forename, string surname, IUserCredentials credentials) { IUser user = new User { Forename = forename ?? "", Surname = surname ?? "" }; user.Credentials = credentials; return user; }
public static IUser CreateMockUser(IUserCredentials credentials) { return CreateMockUser(0, credentials); }