public async void SendRequestedCredentials(List <CredentialType> types) { List <Credential> requestedCredentials = new List <Credential>(); foreach (CredentialType credentialType in types) { Credential cred = await CredentialRepository.GetCredentialByType(credentialType); if (cred != null) { requestedCredentials.Add(cred); System.Diagnostics.Debug.WriteLine(cred.CredentialType); } } if (requestedCredentials != null && requestedCredentials.Count > 0) { await DataService.SendRequestedCredentials(requestedCredentials); await DisplayAlert("Success!", "Your Credentials have been shared!", "OK"); } else { await DisplayAlert("Failure", "You do not hold one or more of the requested Credentials. Visit your Credential Authority to add more Credentials to your Mobile Account.", "OK"); } }
public List <Forest> FindByDn(string dn) { CredentialRepository credential = new CredentialRepository(_mySQLContext); credential.DN = dn; return(FindAll(credential)); }
public bool Delete(string dn, string samName) { GroupRepository ldapGroup = new GroupRepository(_mySQLContext); CredentialRepository credential = new CredentialRepository(_mySQLContext); Group result = new Group(); credential.DN = dn; result = ldapGroup.FindBySamName(credential, samName); try { if (result != null) { return(ldapGroup.Delete(credential, result)); } else { return(false); } } catch (Exception e) { Console.WriteLine("\r\nUnexpected exception occurred:\r\n\t" + e.GetType() + ":" + e.Message); return(false); } }
public void InitializeVariables() { _credentialRepository = new CredentialRepository(); _credential = _credentialRepository .GetDefaultMarketplaceCredential("BigCommerce", "TEST"); }
public async Task Initialize() { ApplicationDbFactory = new ApplicationDbFactory("InMemoryDatabase"); await ApplicationDbFactory.Create().Database.EnsureDeletedAsync(); await ApplicationDbFactory.Create().Database.EnsureCreatedAsync(); ApplicationDbFactory.Create().ResetValueGenerators(); ApplicationUserRepository = new UserRepository(ApplicationDbFactory.Create(), ApplicationUserValidator); FollowerRepository = new FollowerRepository(ApplicationDbFactory.Create(), FollowerValidator); CredentialRepository = new CredentialRepository(ApplicationDbFactory.Create(), CredentialValidator); CredentialTypeRepository = new CredentialTypeRepository(ApplicationDbFactory.Create(), CredentialTypeValidator); RoleRepository = new RoleRepository(ApplicationDbFactory.Create(), RoleValidator); UserRoleRepository = new UserRoleRepository(ApplicationDbFactory.Create(), UserRoleValidator); RolePermissionRepository = new RolePermissionRepository(ApplicationDbFactory.Create(), RolePermissionValidator); PermissionRepository = new PermissionRepository(ApplicationDbFactory.Create(), PermissionValidator); HttpContextAccessor = new HttpContextAccessor(); // NOTE: Don't actually use it, when using Startup it will inject the HttpContext. (here it will always be null) UserManager = new UserManager(ApplicationUserRepository, CredentialTypeRepository, CredentialRepository, RoleRepository, UserRoleRepository, RolePermissionRepository, PermissionRepository, HttpContextAccessor, Hasher, SaltGenerator); UserService = new UserService(UserManager, ApplicationUserRepository, FollowerRepository); // A Credential type is required for a user to be able to login or register. await CredentialTypeRepository.CreateAsync(new CredentialType { Code = "Email", Name = "Email", Position = 1 }); }
public CredentialManagerTests() { //arrange var options = new DbContextOptionsBuilder <StorageContext>() .UseInMemoryDatabase(databaseName: "CredentialManager") .Options; var context = new StorageContext(options); validCredential = new Credential { Id = new Guid("10ea9a48-7365-4b86-8897-e1d5969137e6"), StartDate = new DateTime(2000, 12, 31, 12, 00, 0), EndDate = new DateTime(3000, 12, 31, 12, 00, 0), }; invalidCredential = new Credential { Id = new Guid("10ea9a48-7365-4b86-8897-e1d5969137e6"), StartDate = new DateTime(2000, 12, 31, 12, 00, 0), EndDate = new DateTime(2010, 12, 31, 12, 00, 0), }; var logger = Mock.Of <ILogger <Credential> >(); var httpContextAccessor = new Mock <IHttpContextAccessor>(); httpContextAccessor.Setup(req => req.HttpContext.User.Identity.Name).Returns(It.IsAny <string>()); var repo = new CredentialRepository(context, logger, httpContextAccessor.Object); manager = new CredentialManager(repo); }
public async Task InitializeAsync() { ApplicationDbFactory = new ApplicationDbFactory("InMemoryDatabase"); await ApplicationDbFactory.Create().Database.EnsureDeletedAsync(); await ApplicationDbFactory.Create().Database.EnsureCreatedAsync(); ApplicationDbFactory.Create().ResetValueGenerators(); ApplicationUserRepository = new UserRepository(ApplicationDbFactory.Create(), ApplicationUserValidator); FollowerRepository = new FollowerRepository(ApplicationDbFactory.Create(), FollowerValidator); CredentialRepository = new CredentialRepository(ApplicationDbFactory.Create(), CredentialValidator); CredentialTypeRepository = new CredentialTypeRepository(ApplicationDbFactory.Create(), CredentialTypeValidator); RoleRepository = new RoleRepository(ApplicationDbFactory.Create(), RoleValidator); UserRoleRepository = new UserRoleRepository(ApplicationDbFactory.Create(), UserRoleValidator); RolePermissionRepository = new RolePermissionRepository(ApplicationDbFactory.Create(), RolePermissionValidator); PermissionRepository = new PermissionRepository(ApplicationDbFactory.Create(), PermissionValidator); HttpContextAccessor = new HttpContextAccessor(); // NOTE: Don't actually use it, when using Startup it will inject the HttpContext. (here it will always be null) UserManager = new UserManager(ApplicationUserRepository, CredentialTypeRepository, CredentialRepository, RoleRepository, UserRoleRepository, RolePermissionRepository, PermissionRepository, HttpContextAccessor, Hasher, SaltGenerator); UserService = new UserService(UserManager, ApplicationUserRepository, FollowerRepository); FollowerService = new FollowerService(FollowerRepository, ApplicationUserRepository); // A Credential type is required for a user to be able to login or register. await CredentialTypeRepository.CreateAsync(new CredentialType { Code = "Email", Name = "Email", Position = 1 }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); }
public OrdersManager(CompositionContainer container) { container.ComposeParts(this); _marketplaceMode = ConfigurationManager.AppSettings["MarketplaceMode"]; _credentialRepository = new CredentialRepository(); _logger = new LoggerRepository(); _emailService = new EmailNotificationService(); }
public List <Forest> FindAll() { ConfigurationRepository config = new ConfigurationRepository(_mySQLContext); CredentialRepository credential = new CredentialRepository(_mySQLContext); credential.DN = config.GetConfiguration("DefaultDN"); return(FindAll(credential)); }
public List <GroupVO> GetGroups(string userDn) { UserRepository ldapUser = new UserRepository(_mySQLContext); CredentialRepository credential = new CredentialRepository(_mySQLContext); credential.DN = userDn; return(_converter.ParseList(ldapUser.GetGroups(credential, userDn))); }
public EmployeesController(IDataRepository <Employee> employeeRepository, IDataRepository <Credential> credentialRepository, IDataRepository <EmployeeProjectAssignment> employeeProjectAssignmentRepository, IDataRepository <LabourGrade> labourGradeRepository) { this._employeeRepository = (EmployeeRepository)employeeRepository; this._credentialRepository = (CredentialRepository)credentialRepository; this._employeeProjectAssignmentRepository = employeeProjectAssignmentRepository; this._labourGradeRepository = labourGradeRepository; }
public BigCommerceMarketplaceOrdersProviderTests() { AutoMapperConfig.RegisterAutoMappers(); _credentialService = new CredentialService(); _credential = _credentialService.GetCredential("BigCommerce", MarketplaceMode.TEST.ToString()); _credentialRepository = new CredentialRepository(); _credentialRepo = _credentialRepository.GetDefaultCredential("BigCommerce", MarketplaceMode.TEST.ToString()); }
public async void displayCredentialList() { userCredentials = await CredentialRepository.GetAllCredentialsAsync(); if (userCredentials != null && userCredentials.Count > 0) { credentialList.ItemsSource = userCredentials; } }
private async void InitializeDatabases() { await UserRepository.InitializeTableAsync(); await MobileAccountRepository.InitializeTableAsync(); await CredentialRepository.InitializeTableAsync(); await EventRepository.InitializeTableAsync(); }
public App() { InitializeComponent(); UserRepo = new UserRepository(dbPath); CredentialRepo = new CredentialRepository(dbPath); EventRepo = new EventRepository(dbPath); MobileAccountRepo = new MobileAccountRepository(dbPath); MainPage = new NavigationPage(new MainPage()); }
public void TryGetCredentials_StorageLocationDoesNotExists_ReturnsFalse() { // Given var location = Path.GetTempPath() + Guid.NewGuid() + ".dat"; var sut = new CredentialRepository(location); // When var actual = sut.TryGetCredential("http://portal.azure.com", out _); // Then actual.Should().BeFalse(); }
public void Remove_NoCredentialsStoredForUrl_NothingHappen() { // Given using var temp = new TempFile(); var sut = new CredentialRepository(temp.Location); // When var removeAction = sut.Invoking(s => s.Remove("http://portal.azure.com")); // Then removeAction.Should().NotThrow(); }
public void Store_CredentialNull_ThrowsException() { // Given using var temp = new TempFile(); var sut = new CredentialRepository(temp.Location); // When var storeAction = sut.Invoking(s => s.Store("http://portal.azure.com", null)); // Then storeAction.Should().Throw <ArgumentNullException>(); }
public void TryGetCredentials_StorageExistsButEmpty_ReturnsFalse() { // Given using var temp = new TempFile(); var sut = new CredentialRepository(temp.Location); // When var actual = sut.TryGetCredential("http://portal.azure.com", out _); // Then actual.Should().BeFalse(); }
private readonly ProjectRepository _projectRepository; //likewise public TimesheetsController(IDataRepository <Timesheet> timesheetRepository, IDataRepository <Employee> employeeRepository, IDataRepository <TimesheetRow> timesheetRowRepository, IDataRepository <Credential> credentialRepository, IDataRepository <LabourGrade> labourGradeRepository, IDataRepository <WorkPackage> workPackageRepository, IDataRepository <Project> projectRepository) { this._timesheetRepository = (TimesheetRepository)timesheetRepository; this._employeeRepository = employeeRepository; this._timesheetRowRepository = (TimesheetRowRepository)timesheetRowRepository; this._credentialRepository = (CredentialRepository)credentialRepository; this._labourGradeRepository = (LabourGradeRepository)labourGradeRepository; this._workPackageRepository = (WorkPackageRepository)workPackageRepository; this._projectRepository = (ProjectRepository)projectRepository; }
public async Task Initialize() { ApplicationDbFactory = new ApplicationDbFactory("InMemoryDatabase"); await ApplicationDbFactory.Create().Database.EnsureDeletedAsync(); await ApplicationDbFactory.Create().Database.EnsureCreatedAsync(); ApplicationDbFactory.Create().ResetValueGenerators(); MemeRepository = new MemeRepository(ApplicationDbFactory.Create(), MemeValidator); ApplicationUserRepository = new UserRepository(ApplicationDbFactory.Create(), ApplicationUserValidator); FollowerRepository = new FollowerRepository(ApplicationDbFactory.Create(), FollowerValidator); CredentialRepository = new CredentialRepository(ApplicationDbFactory.Create(), CredentialValidator); CredentialTypeRepository = new CredentialTypeRepository(ApplicationDbFactory.Create(), CredentialTypeValidator); RoleRepository = new RoleRepository(ApplicationDbFactory.Create(), RoleValidator); UserRoleRepository = new UserRoleRepository(ApplicationDbFactory.Create(), UserRoleValidator); RolePermissionRepository = new RolePermissionRepository(ApplicationDbFactory.Create(), RolePermissionValidator); PermissionRepository = new PermissionRepository(ApplicationDbFactory.Create(), PermissionValidator); CommentRepository = new CommentRepository(ApplicationDbFactory.Create(), CommentValidator); HttpContextAccessor = new HttpContextAccessor(); // NOTE: Don't actually use it, when using Startup it will inject the HttpContext. (here it will always be null) UserManager = new UserManager(ApplicationUserRepository, CredentialTypeRepository, CredentialRepository, RoleRepository, UserRoleRepository, RolePermissionRepository, PermissionRepository, HttpContextAccessor, Hasher, SaltGenerator); UserService = new UserService(UserManager, ApplicationUserRepository, FollowerRepository); CommentService = new CommentService(CommentRepository, MemeRepository); // A Credential type is required for a user to be able to login or register. await CredentialTypeRepository.CreateAsync(new CredentialType { Code = "Email", Name = "Email", Position = 1 }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); Meme meme = new Meme { Id = "a0Q558q", ImageUrl = "https://images-cdn.9gag.com/photo/a0Q558q_700b.jpg", VideoUrl = "http://img-9gag-fun.9cache.com/photo/a0Q558q_460sv.mp4", PageUrl = "http://9gag.com/gag/a0Q558q", Title = "Old but Gold" }; await MemeRepository.CreateAsync(meme); }
public void Store_HappyPath_StorageFileCreated() { // Given using var temp = new TempFile(false); var sut = new CredentialRepository(temp.Location); // When var credential = new OAuthTokenCredential("[DisplayId]", "[AccessToken]", DateTime.UtcNow, "[RefreshToken]"); sut.Store("http://portal.azure.com", credential); // Then File.Exists(temp.Location).Should().BeTrue(); }
public bool ResetPass(string dn, string samName, string pass) { if (Exist(dn, samName)) { UserRepository ldapUser = new UserRepository(_mySQLContext); CredentialRepository credential = new CredentialRepository(_mySQLContext); credential.DN = dn; return(ldapUser.ResetPassBySamName(credential, samName, pass)); } else { return(false); } }
private void ReplaceCredentialInternal(User user, Credential credential) { // Find the credentials we're replacing, if any var creds = user.Credentials .Where(cred => cred.Type == credential.Type) .ToList(); foreach (var cred in creds) { user.Credentials.Remove(cred); CredentialRepository.DeleteOnCommit(cred); } user.Credentials.Add(credential); }
public void CanGetCredentialUsingICredentialListConstuctor() { var foo = new SimpleCredential(); var bar = new SimpleCredential("bar"); var credentialRepository = new CredentialRepository(new List <ICredential> { foo, bar }); credentialRepository.TryGet(null, out var fooCredential); credentialRepository.TryGet("bar", out var barCredential); fooCredential.Should().BeSameAs(foo); barCredential.Should().BeSameAs(bar); }
public void CanCreateSymmetricCryptoByCredentialRepositoryWithEncoding() { var credentialMock = new Mock <ICredential>(); credentialMock.Setup(cm => cm.Algorithm).Returns(SymmetricAlgorithm.Aes); credentialMock.Setup(cm => cm.IVSize).Returns(16); credentialMock.Setup(cm => cm.GetKey()).Returns(GetSequentialByteArray(16)); var credentialRepo = new CredentialRepository(new List <ICredential> { credentialMock.Object }); var crypto = new SymmetricCrypto(credentialRepo, Encoding.ASCII); crypto.Should().NotBe(null); }
public void TryGetCredential_DataPreviouslyStored_ReturnsTrue() { using var temp = new TempFile(); var url = "http://portal.azure.com"; // Given var storingSut = new CredentialRepository(temp.Location); storingSut.Store(url, new OAuthTokenCredential("[DisplayId]", "[AccessToken]", DateTime.UtcNow, "[RefreshToken]")); var readingSut = new CredentialRepository(temp.Location); // When var actual = readingSut.TryGetCredential(url, out _); // Then actual.Should().BeTrue(); }
public void Remove_ExistingItem_ItemRemoved() { var url = "http://portal.azure.com"; using var temp = new TempFile(); // Given var sut = new CredentialRepository(temp.Location); sut.Store(url, new OAuthTokenCredential("[DisplayId]", "[AccessToken]", DateTime.UtcNow, "[RefreshToken]")); // When sut.Remove(url); // Then sut.TryGetCredential(url, out _).Should().BeFalse(); }
public void TryGetCredential_DataPreviouslyStored_ReturnsExpectedCredentials() { using var temp = new TempFile(); var expected = new OAuthTokenCredential("[DisplayId]", "[AccessToken]", DateTime.UtcNow, "[RefreshToken]"); var url = "http://portal.azure.com"; // Given var sut = new CredentialRepository(temp.Location); sut.Store(url, expected); // When sut.TryGetCredential(url, out var actual); // Then actual.Should().BeEquivalentTo(expected); }
public HttpResponseMessage <ServiceResponseWithResultData <Guid?> > Login(UserLogin userLogin) { if (userLogin == null || string.IsNullOrEmpty(userLogin.EmailAddress) || string.IsNullOrEmpty(userLogin.Password)) { return(CompleteResponseWithData(new ServiceResponseWithResultData <Guid?> { State = ServiceResponseStateType.FailedValidation })); } // Define Query ISingleResultQuery <CredentialQueryStrategy, CredentialEntity> query = QueryFactory.CreateNewSingleResultQuery <CredentialQueryStrategy, CredentialEntity>(); string hash = AuthenticationHashHelper.GenerateCredentialHash(userLogin.EmailAddress, userLogin.Password); query.QueryStrategy.WithHash(hash); // Retrieve Data query = CredentialRepository.Retrieve(query, false); CredentialEntity queryResults = query.Result; var responseData = new ServiceResponseWithResultData <Guid?> { State = queryResults == null ? ServiceResponseStateType.FailedAuthentication : ServiceResponseStateType.Succeeded, ResultData = queryResults == null ? (Guid?)null : queryResults.UserRsn }; // Complete the response HttpResponseMessage <ServiceResponseWithResultData <Guid?> > response = CompleteResponseWithData(responseData); // If authentication has succeeded then return now. if (responseData.State != ServiceResponseStateType.Succeeded || responseData.ResultData == null) { return(response); } // Copy encrypted auth token to X-Token for SignalR string authenticationTokenName = DependencyResolver.Current.Resolve <IConfigurationManager>().GetSetting("Cqrs.Web.AuthenticationTokenName") ?? "X-Token"; var cookie = new CookieHeaderValue(authenticationTokenName, responseData.ResultData.Value.ToString("N")) { Expires = DateTimeOffset.Now.AddDays(1), }; response.Headers.AddCookies(new[] { cookie }); return(response); }