public HandleSignOnCommand(IProcessQueries queries, IProcessCommands commands, IWriteEntities entities, IAuthenticate authenticator) { _queries = queries; _commands = commands; _entities = entities; _authenticator = authenticator; }
public AuthenticationRepository() { if (_repos == null) { _repos = new RcAuthenticationService(); } }
private async Task <object> AuthenticateUser(IClientContext context, IUserAccount user, string sessionSalt, IAuthenticate authenticateRequest) { object response; if (user.IsLocked) { response = _authenticationMessageFactory.CreateAuthenticationResult(AuthenticateReplyState.Locked, null); } else { var serverHash = _passwordHasher.HashPassword(user.HashedPassword, sessionSalt); if (_passwordHasher.Compare(serverHash, authenticateRequest.AuthenticationToken)) { context.ChannelData["Principal"] = await PrincipalFactory.CreatePrincipalAsync(user); var proof = _passwordHasher.HashPassword(user.HashedPassword, authenticateRequest.ClientSalt); response = _authenticationMessageFactory.CreateAuthenticationResult(AuthenticateReplyState.Success, proof); } else { response = _authenticationMessageFactory.CreateAuthenticationResult(AuthenticateReplyState.IncorrectLogin, null); } } return(response); }
public SurveyController(ISurveyRoot _surveyRoot, ISurveyQuestions _surveyQuestionRoot, IMemoryCache _memoryCache, IAuthenticate authContext) : base(_memoryCache, authContext) { surveyRoot = _surveyRoot; surveyQuestionRoot = _surveyQuestionRoot; authenticationContext = authContext; memoryCache = _memoryCache; }
public AuthenticationController(IMapper mapper, IAuthenticate IAuthenticate, IConfiguration IConfiguration) { _response = new Response(); _mapper = mapper; _IAuthenticate = IAuthenticate; _IConfiguration = IConfiguration; }
public void AuthenticationShouldSucceed() { const string testBaseUri = "https://127.0.0.1"; const string expectedRequestUrl = testBaseUri + "/v15/access_tokens"; const string testClientId = "1a2b3c4d5e6f7g8h9i0j"; const string testMerchantUsername = "******"; const string testMerchantPassword = "******"; string expectedRequestbody = string.Format("{{\"access_token\": {{" + "\"api_key\": \"{0}\"" + ",\"username\": \"{1}\"" + ",\"password\": \"{2}\"" + "}}}}", testClientId, testMerchantUsername, testMerchantPassword); // This response format does not matter for this test. RestResponse expectedResponse = new RestResponse { StatusCode = HttpStatusCode.OK, }; IAuthenticate auth = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModule <IAuthenticate, AccessTokenRequest>( expectedResponse, expectedRequestbody, expectedAccessToken: null, expectedRequestUrl: expectedRequestUrl, environmentToUse: new LevelUpEnvironment(testBaseUri)); var token = auth.Authenticate(testClientId, testMerchantUsername, testMerchantPassword); }
public AuthController( IAuthenticate login, IRegister register ) { _login = login; _register = register; }
public FacilityReservationController(IFacilityReservationService facilityReservationService, IPublicArea publicArea, IGuestService guestService, IAuthenticate authenticator) { _facilityReservationService = facilityReservationService; _publicArea = publicArea; _guestService = guestService; _authenticator = authenticator; }
public SwaggerAuthentication(RequestDelegate next, IHostingEnvironment environment, IAuthenticate authenticate, IOptions <AppSettingModel> options) { _next = next; _environment = environment; _authenticate = authenticate; _options = options; }
/// <summary> /// Creates a new instance of <see cref="BearerAuthenticationHandler"/> /// </summary> /// <param name="options">Configuration options</param> /// <param name="logger">Logger</param> /// <param name="encoder">Url encoder</param> /// <param name="clock">System clock</param> /// <param name="authService">Authentication service</param> public BearerAuthenticationHandler( IOptionsMonitor <BearerAuthenticationOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, IAuthenticate authService) : base(options, logger, encoder, clock) { _authService = authService; }
public bool CloseDoor(int user_id, int door_id) { authentication = new Authenticate(); if (authentication.IsAuthenticated(user_id, door_id)) { return(simulation.GetBuilding(0).CloseDoor(user_id, door_id)); } return(false); }
static UserAccessTokenHolder() { IAuthenticate auth = GetSandboxedLevelUpModule <IAuthenticate>(); var token = auth.Authenticate(LevelUpTestConfiguration.Current.ClientId, LevelUpTestConfiguration.Current.ConsumerUsername, LevelUpTestConfiguration.Current.ConsumerPassword); SandboxedLevelUpUserAccessToken = token.Token; }
/// <summary> /// Reads an ICU data header, checks the data format, and returns the data version. /// </summary> /// <remarks> /// Assumes that the <see cref="ByteBuffer"/> position is 0 on input. /// <para/> /// The buffer byte order is set according to the data. /// The buffer position is advanced past the header (including UDataInfo and comment). /// <para/> /// See C++ ucmndata.h and unicode/udata.h. /// </remarks> /// <returns>dataVersion</returns> /// <exception cref="IOException">If this is not a valid ICU data item of the expected dataFormat.</exception> public static int ReadHeader(ByteBuffer bytes, int dataFormat, IAuthenticate authenticate) { Debug.Assert(bytes != null && bytes.Position == 0); byte magic1 = bytes.Get(2); byte magic2 = bytes.Get(3); if (magic1 != MAGIC1 || magic2 != MAGIC2) { throw new IOException(MAGIC_NUMBER_AUTHENTICATION_FAILED_); } byte isBigEndian = bytes.Get(8); byte charsetFamily = bytes.Get(9); byte sizeofUChar = bytes.Get(10); if (isBigEndian < 0 || 1 < isBigEndian || charsetFamily != CHAR_SET_ || sizeofUChar != CHAR_SIZE_) { throw new IOException(HEADER_AUTHENTICATION_FAILED_); } bytes.Order = isBigEndian != 0 ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; int headerSize = bytes.GetChar(0); int sizeofUDataInfo = bytes.GetChar(4); if (sizeofUDataInfo < 20 || headerSize < (sizeofUDataInfo + 4)) { throw new IOException("Internal Error: Header size error"); } // TODO: Change Authenticate to take int major, int minor, int milli, int micro // to avoid array allocation. byte[] formatVersion = new byte[] { bytes.Get(16), bytes.Get(17), bytes.Get(18), bytes.Get(19) }; if (bytes.Get(12) != (byte)(dataFormat >> 24) || bytes.Get(13) != (byte)(dataFormat >> 16) || bytes.Get(14) != (byte)(dataFormat >> 8) || bytes.Get(15) != (byte)dataFormat || (authenticate != null && !authenticate.IsDataVersionAcceptable(formatVersion))) { // "; data format %02x%02x%02x%02x, format version %d.%d.%d.%d" throw new IOException(HEADER_AUTHENTICATION_FAILED_ + string.Format("; data format {0:x2}{1:x2}{2:x2}{3:x2}, format version {4}.{5}.{6}.{7}", bytes.Get(12), bytes.Get(13), bytes.Get(14), bytes.Get(15), formatVersion[0] & 0xff, formatVersion[1] & 0xff, formatVersion[2] & 0xff, formatVersion[3] & 0xff)); } bytes.Position = headerSize; return // dataVersion ((bytes.Get(20) << 24) | ((bytes.Get(21) & 0xff) << 16) | ((bytes.Get(22) & 0xff) << 8) | (bytes.Get(23) & 0xff)); }
public LoginPageViewModel(IAuthenticate authenticate, INavigationService navigationService, IPageDialogService pageDialogService, ISecuredStorageWrapper securedStorageWrapper, IDeviceService deviceService) : base(navigationService, pageDialogService, deviceService) { _authenticate = authenticate; _securedStorageWrapper = securedStorageWrapper; }
public AuthController(IConfiguration configuration, IAuthenticate authenticate, ILogger logger) { //_logger = UnityHelper.Container.Resolve<ILogger>(); _logger = logger; _configuration = configuration; var appSettingsSection = _configuration.GetSection("AppSettings"); appSettings = appSettingsSection.Get <AppSettings>(); _authenticate = authenticate; }
public void SetUp() { _httpClientWrapper = Substitute.For <IHttpClientWrapper>(); _authenticate = Substitute.For <IAuthenticate>(); _configuration = Substitute.For <IConfiguration>(); _configuration.GetValue <string>("ApiMediaType").Returns("test-media-string"); _sut = new ApiClient(_httpClientWrapper, _authenticate, _configuration); }
public UserController( IAuthenticate authenticate, ILoggerManager log, IToken <IUser> token, IEncryption aESSecurity) { this._authenticate = authenticate; this._aES = aESSecurity; this._log = log; this._token = token; }
public AccountController(IAppSetting setting, IAuthenticate authenticate, IEncryption encryption, ILoggerManager logger, IToken <IUser> token) { this._authenticate = authenticate; this._encryption = encryption; this._logger = logger; this._token = token; }
public LoginService( IOptions <AuthHeaderClientConfig> clientConfig, IOptions <AuthenticationConfig> authConfig, IAuthenticatedHttpClientWithHeader client, IAuthenticate authenticator, HttpLoggerService logger) { _clientConfig = clientConfig; _authConfig = authConfig; _client = client; _client.Authenticator = authenticator; _logger = logger; }
public void AuthenticationShouldFailForErrorCode404NotFound() { const string testClientId = "1212whatsinthestew34noonesreallysure"; const string testMerchantUsername = "******"; const string testMerchantPassword = "******"; RestResponse expected = new RestResponse { StatusCode = HttpStatusCode.NotFound }; IAuthenticate auth = ClientModuleUnitTestingUtilities.GetMockedLevelUpModule <IAuthenticate>(expected); // Should throw exception for non-200 [OK] response auth.Authenticate(testClientId, testMerchantUsername, testMerchantPassword); }
public void GivenALogInRequest() { _authenticationObject = new Authenticate(); _loginWindowThread = new Thread(new ThreadStart(() => { _authenticationResult = _authenticationObject.AuthenticateUser(); })); _loginWindowThread.SetApartmentState(ApartmentState.STA); _loginWindowThread.Start(); _loginWindowObject = GetDialogWindowObjectFromHandle(); }
public async Task <MobileServiceUser> LoginAsync() { IAuthenticate auth = DependencyService.Get <IAuthenticate>(); MobileServiceUser user = await auth.Authenticate(_client, MobileServiceAuthenticationProvider.Facebook); if (user == null) { Device.BeginInvokeOnMainThread(async() => { await Application.Current.MainPage.DisplayAlert("Ops!", "Problema no Login", "Ok"); }); } return(user); }
public StoreManager(INotificationStore notificationStore, ICategoryStore categoryStore, IFavoriteStore favoriteStore, ISessionStore sessionStore, ISpeakerStore speakerStore, IEventStore eventStore, ISponsorStore sponsorStore, IFeedbackStore feedbackStore, IAuthenticate authenticator, IWorkshopStore workshopStore, IApplicationDataStore applicationDataStore) { _notificationStore = notificationStore; _categoryStore = categoryStore; _favoriteStore = favoriteStore; _sessionStore = sessionStore; _speakerStore = speakerStore; _eventStore = eventStore; _sponsorStore = sponsorStore; _feedbackStore = feedbackStore; _authenticator = authenticator; _workshopStore = workshopStore; _applicationDataStore = applicationDataStore; Task.Run(async() => { await InitializeAsync().ConfigureAwait(false); }).Wait(); }
public customerController( IAuthenticate authenticate, IGarageRepository garageRepository, IServiceRepository serviceRepository, ICustomerRepository customerRepository, ILogtimeRepository logtimeRepository) { this.authenticate = authenticate; this.customerRepository = customerRepository; this.serviceRepository = serviceRepository; this.garageRepository = garageRepository; this.logtimeRepository = logtimeRepository; ah = new authenticateHandler(this.authenticate, this.logtimeRepository); sh = new serviceHandler(this.serviceRepository, this.garageRepository); ch = new CustomerHandler(this.customerRepository); }
public systemAdminController( IAuthenticate authenticate, IServiceRepository serviceRepository, ISysAdminRepository sysAdminRepository, IGarageRepository garageRepository, ILogtimeRepository logtimeRepository) { this.authenticate = authenticate; this.sysAdminRepository = sysAdminRepository; this.serviceRepository = serviceRepository; this.garageRepository = garageRepository; this.logtimeRepository = logtimeRepository; ah = new authenticateHandler(this.authenticate, this.logtimeRepository); sh = new serviceHandler(this.serviceRepository, this.garageRepository); sah = new systemAdminHandler(this.sysAdminRepository); }
/// <summary> /// Performs the Authenticate(...) call to retrieve the access token that will be required for most of the /// subsequent requests you make to the LevelUp platform. /// </summary> private static string Authenticate(string merchantUserName, string merchantPassword, string apiKey) { try { IAuthenticate authenticator = LevelUpClientFactory.Create <IAuthenticate>(LuIdentifier, LuEnvironment); AccessToken tokenObj = authenticator.Authenticate(apiKey, merchantUserName, merchantPassword); return(tokenObj.Token); } catch (LevelUpApiException ex) { Console.WriteLine(string.Format("There was an error authenticating your user. Are the credentials " + "correct? {0}{0}Exception Details: {1}", Environment.NewLine, ex.Message)); return(null); } }
/// <summary> /// Cria um novo usuário no sistema. /// </summary> /// <param name="username">Nome do usuário.</param> /// <param name="password">Senha de acesso.</param> /// <param name="email">Email associado com o usuário.</param> /// <param name="passwordQuestion">Pergunta para a senha.</param> /// <param name="passwordAnswer">Resposta da pergunta para a recuperação da senha.</param> /// <param name="isApproved">Identifica se o usuário é aprovado.</param> /// <param name="identityProvider">Nome do provedor de identidade do usuário.</param> /// <param name="userKey">Chave que identifica o usuário.</param> /// <param name="ignoreCaptcha">Indica se o usuário irá ignorar o controle por captcha</param> /// <param name="status">Situação do usuário.</param> /// <param name="fullname">Nome do usuário</param> /// <param name="parameters">Parametros adicionais para a criação do usuário</param> /// <returns></returns> public virtual Security.IUser CreateUser(string username, string password, string fullname, string email, string passwordQuestion, string passwordAnswer, bool isApproved, string identityProvider, string userKey, bool ignoreCaptcha, out UserCreateStatus status, params SecurityParameter[] parameters) { IIdentityProviderManager providerFlow = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IIdentityProviderManager>(); var result = GetUser(username, false) as Security.Authentication.IAutheticableUser; if ((result != null) && (!String.IsNullOrEmpty(result.UserKey))) { status = UserCreateStatus.DuplicateUserName; result = null; } else { result.UserName = username; result.Email = email; result.FullName = fullname; result.IdentityProvider = identityProvider; result.LastPasswordChangedDate = ServerData.GetDateTime(); result.PasswordAnswer = passwordAnswer; result.PasswordQuestion = passwordQuestion; result.UserName = username; result.IdentityProviderId = providerFlow.GetProviderByName(identityProvider).IdentityProviderId; if (InsertUser(result)) { status = UserCreateStatus.Success; result = GetUser(username, false) as Security.Authentication.IAutheticableUser; IAuthenticate provider = Activator.CreateInstance((providerFlow.GetProviderByName(identityProvider).Type)) as IAuthenticate; if (provider.CanCreateUser) { if (provider.CreateNewUser(result, password, parameters).Success) { status = UserCreateStatus.Success; } else { status = UserCreateStatus.DuplicateProviderUserKey; } } } else { status = UserCreateStatus.ProviderError; } } return(result); }
public AuthenticateResultDTO Authenticate(Credentials credentials) { AuthenticateResultDTO result = new AuthenticateResultDTO(); IAuthenticate authenticate = BusinessFactory.GetAuthentication(); if (authenticate.IsValid(credentials)) { result.IsAuthenticated = true; result.UserId = BusinessFactory.GetUserProcess().GetUser(credentials).UserId; result.Token = authenticate.BuildToken(credentials); } else { result.IsAuthenticated = false; result.ErrorMessage = "Invalid username or password."; } return(result); }
public mechanicController( IApplicationRepository applicationRepository, IAuthenticate authenticate, IServiceRepository serviceRepository, IMechanicRepository mechanicRepository, IGarageRepository garageRepository, ILogtimeRepository logtimeRepository) { this.authenticate = authenticate; this.mechanicRepository = mechanicRepository; this.serviceRepository = serviceRepository; this.applicationRepository = applicationRepository; this.garageRepository = garageRepository; this.logtimeRepository = logtimeRepository; ah = new authenticateHandler(this.authenticate, this.logtimeRepository); sh = new serviceHandler(this.serviceRepository, this.garageRepository); mh = new MechanicHandler(this.mechanicRepository, this.garageRepository, this.applicationRepository); }
public ActionResult Index(AuthenticationModel userDetails) { if (ModelState.IsValid) { IAuthenticate authenticationService = AuthenticationFactory.getAuthService(); bool authenticated = authenticationService.Authenticate(userDetails.Username, userDetails.Password); if (authenticated) { FormsAuthentication.SetAuthCookie(userDetails.Username, false); // Forward User to Application Home Page return(RedirectToAction("Index", "Home")); } } // Forward user to Not Authenticated Alert page return(View("NotAuthenticated")); }
public garageController( IApplicationRepository applicationRepository, IAuthenticate authenticate, IServiceRepository serviceRepository, IGarageRepository garageRepository, ILogtimeRepository logtimeRepository, ILocationRepository locationRepository) { this.locationRepository = locationRepository; this.authenticate = authenticate; this.serviceRepository = serviceRepository; this.garageRepository = garageRepository; this.applicationRepository = applicationRepository; this.logtimeRepository = logtimeRepository; ah = new authenticateHandler(this.authenticate, this.logtimeRepository); sh = new serviceHandler(this.serviceRepository, this.garageRepository); gh = new GarageHandler(this.applicationRepository, this.garageRepository, this.locationRepository); }
private async Task<object> AuthenticateUser(IClientContext context, IUserAccount user, string sessionSalt, IAuthenticate authenticateRequest) { object response; if (user.IsLocked) response = _authenticationMessageFactory.CreateAuthenticationResult(AuthenticateReplyState.Locked, null); else { var serverHash = _passwordHasher.HashPassword(user.HashedPassword, sessionSalt); if (_passwordHasher.Compare(serverHash, authenticateRequest.AuthenticationToken)) { context.ChannelData["Principal"] = await PrincipalFactory.CreatePrincipalAsync(user); var proof = _passwordHasher.HashPassword(user.HashedPassword, authenticateRequest.ClientSalt); response = _authenticationMessageFactory.CreateAuthenticationResult(AuthenticateReplyState.Success, proof); } else response = _authenticationMessageFactory.CreateAuthenticationResult(AuthenticateReplyState.IncorrectLogin, null); } return response; }
public App() { AuthenticationProvider = new AuthenticationProvider(); MainPage = new NavigationPage(new LoginPage()); }
public static void Init (IAuthenticate authenticator) { Authenticator = authenticator; }
/// <summary> /// Constructor to establish this class' dependencies. Since the /// class is not "complete" (can't operate) without an authentication /// provider, we require an object up front. /// </summary> /// <param name="authProvider"></param> public MyClassWithDependencyInjection(IAuthenticate authProvider) { if (authProvider == null) throw new ArgumentNullException("authProvider"); _authenticationProvider = authProvider; }
public AuthorizationFilter(IAuthenticate authenticator) { Check.NotNull(authenticator, "authenticator"); this.authenticator = authenticator; Check.InjectedMembers(this); }
public App() { Authenticator = DependencyService.Get<IAuthenticate>(); MainPage = new NavigationPage(new LoginPage()); }
public AccountController() { _authenticator = new DatabaseAuthentication(); _userRepository = new NHUserRepository(); }