static ContextAccountBundle GetNonStagingParameters() { Uri server = WellKnownServers.LetsEncryptV2; AcmeContext ctx; if (File.Exists(ACC_LOC)) { ctx = AccountHelper.GetContextWithAccount(ACC_LOC, server); } else { ctx = new AcmeContext(server); } IAccountContext account = AccountHelper.RetriveAccount(ctx); Account accInfo = AccountHelper.RetriveAccountDetails(account); if (!accInfo.Status.HasValue) { throw new AcmeException("Account has not had its status set yet"); } else if (accInfo.Status.Value == AccountStatus.Revoked || accInfo.Status.Value == AccountStatus.Deactivated) { throw new AcmeException("Account is either revoked or deactivated"); } return(new ContextAccountBundle(ctx, account)); }
public ExistingAccountByIdValidator(IAccountContext context) { // TODO: localize fluent validator exceptions RuleFor(model => model) .MustAsync(async(model, token) => await context.AccountByIdExists(model)) .WithMessage((model, value) => $"Account with id: {value} is not found"); }
public AccountService( IAccountContext accountContext, IPasswordHasher <Account> passwordHasher) { _accountContext = accountContext; _passwordHasher = passwordHasher; }
public AccountNodeViewModel( CosmosAccount account, IAccountContext context, AccountFolderNodeViewModel?parent, AccountCommands accountCommands, DatabaseCommands databaseCommands, IViewModelFactory viewModelFactory, IMessenger messenger, IClientPool clientPool) { Id = account.Id; Context = context; Parent = parent; _viewModelFactory = viewModelFactory; _clientPool = clientPool; _name = account.Name; Commands = new[] { new CommandViewModel("Create database", databaseCommands.CreateCommand, this), CommandViewModel.Separator(), new CommandViewModel("Refresh", RefreshCommand), CommandViewModel.Separator(), new CommandViewModel("Add account", accountCommands.AddCommand, Parent), new CommandViewModel("Edit account", accountCommands.EditCommand, this), new CommandViewModel("Remove account", accountCommands.RemoveCommand, this), }; messenger.Subscribe(this).To <AccountEditedMessage>((vm, message) => vm.OnAccountEdited(message)); messenger.Subscribe(this).To <DatabaseCreatedMessage>((vm, message) => vm.OnDatabaseCreated(message)); messenger.Subscribe(this).To <DatabaseDeletedMessage>((vm, message) => vm.OnDatabaseDeleted(message)); }
/// <summary> /// Register the local computer's account on the ACME service /// </summary> /// <returns>true if registration is successful, false otherwise</returns> public async Task <bool> RegisterNewAccount() { WinCertesOptions _options = Program._winCertesOptions; try { InitCertes(); Certes.Acme.Resource.Directory directory = await _acme.GetDirectory(); InitCertes(); IAccountContext accountCtx = await _acme.NewAccount(_options.AccountEmail, true); _options.Registered = true; logger.Info($"Successfully registered account {_options.AccountEmail} with certificate authority {_options.ServiceUri.ToString()}"); if ((directory.Meta != null) && (directory.Meta.TermsOfService != null)) { logger.Info($"Please check the ACME Service ToS at: {directory.Meta.TermsOfService.ToString()}"); } return(true); } catch (Exception exp) { logger.Error($"Failed to register account {_options.AccountEmail} with certificate authority {_options.ServiceUri.ToString()}: {ProcessCertesException(exp)}"); return(false); } }
public DatabaseContext(IAccountContext accountContext, string databaseId, Func <Database> databaseGetter) { AccountContext = accountContext; DatabaseId = databaseId; _databaseGetter = databaseGetter; Containers = new ContainerService(databaseGetter); }
/// <summary> /// Save the current account key /// </summary> /// <returns> </returns> private bool SaveAccountKey(IAccountContext accountContext = null) { string pem = _acme.AccountKey.ToPem(); _settings.AccountKey = pem; System.IO.File.WriteAllText(_settingsFolder + "\\c-acc.key", pem); if (accountContext != null) { _settings.AccountUri = accountContext.Location.ToString(); // archive account id history System.IO.File.AppendAllText( _settingsFolder + "\\c-acc-archive", _settings.AccountUri + "\r\n" + (_settings.AccountEmail ?? "") + "\r\n" + pem ); } return(true); }
public PasswordRecoveryByResetLink(IAccountContext accountContext, IEmailSender eMailSender, ISystemContext systemContext, IConfigurationProvider configProvider) { this.accountContext = accountContext; this.eMailSender = eMailSender; this.systemContext = systemContext; this.configProvider = configProvider; }
public GevechtRepo(IGevechtContext gContext, IPokemonContext pContext, IHomeContext hContext, IAanvalContext anContext, IAccountContext acContext) { this.gCtx = gContext; this.pCtx = pContext; this.hCtx = hContext; this.anCtx = anContext; this.acCtx = acContext; }
public TaskBusiness(UnitOfWork unitOfWork, PhaseBusiness phase, AccountBusiness account, IAccountContext accountContext) : base(unitOfWork) { _phase = phase; _account = account; _accountContext = accountContext; }
public JoinModel(IPlayerAppService playerAppService, IAccountContext account, INotificationHandler <DomainNotification> notifications, IOptionsMonitor <AppConfig> appConfig, IMediatorHandler bus) : base(appConfig) { _account = account; _playerAppService = playerAppService; _notifications = (DomainNotificationHandler)notifications; _bus = bus; }
public DBInit(ApplicationDbContext context, IAccountContext accountContext, ILogger <DBInit> logger) { _accountContext = accountContext; _context = context; _logger = logger; }
/// <summary> /// All new /// </summary> /// <param name="acmeContext"></param> /// <param name="accountContext"></param> /// <param name="orderContext"></param> /// <param name="workDir"></param> /// <param name="loggerFactory"></param> public FreeCertContext(IAcmeContext acmeContext, IAccountContext accountContext, IOrderContext orderContext, string workDir, ILoggerFactory loggerFactory) { _workDir = workDir; _loggerFactory = loggerFactory; AcmeContext = acmeContext; AccountContext = accountContext; OrderContext = orderContext; _dnsResolver = new DnsResolver(_loggerFactory.CreateLogger <DnsResolver>()); }
public ResetPasswordModel(IAccountContext accountContext, IOptionsMonitor <AppConfig> appConfig, INotificationHandler <DomainNotification> notifications, IMediatorHandler bus) : base(appConfig) { _accountContext = accountContext; _notifications = (DomainNotificationHandler)notifications; _bus = bus; }
public AccountRepository(ContextTypes type) { switch (type) { case ContextTypes.MemoryContext: context = new AccountMemoryContext(); break; case ContextTypes.MSSQLContext: context = new AccountContext(); break; } }
public PasswordChanger(AccountConfiguration config, IAccountContext context, AccountRepository repo, PasswordService passServ) { if (config == null) throw new ArgumentNullException("config"); if (context == null) throw new ArgumentNullException("context"); this.context = context; this.repo = new AccountRepositoryWrapper(config.RequireDependency(repo)); this.passServ = config.RequireDependency(passServ); }
public BaseHub(IAccountContext account, INotificationHandler <DomainNotification> notifications, IMudOnlineProvider mudOnlineProvider, IOptionsMonitor <AppConfig> appConfig, ILogger <MudHub> logger, IMediatorHandler bus) { _account = account; _notifications = (DomainNotificationHandler)notifications; _mudOnlineProvider = mudOnlineProvider; _appConfig = appConfig.CurrentValue; _logger = logger; _bus = bus; }
public Validator(IAccountContext context) { RuleFor(model => model.AccountUsername).ExistingAccountByUsername(context); RuleFor(model => model.City).NotEmpty(); RuleFor(model => model.Email).EmailAddress(); RuleFor(model => model.Phone).NotEmpty(); RuleFor(model => model.Region).NotEmpty(); RuleFor(model => model.ZipCode).NotEmpty(); }
public static void ExistingAccountById <TRequest>( this IRuleBuilderInitial <TRequest, Guid> builder, IAccountContext context) { builder .Cascade(CascadeMode.StopOnFirstFailure) .NotEmpty() .SetValidator(new ExistingAccountByIdValidator(context)); }
/// <summary> /// 创建新的ACME帐户 /// </summary> /// <param name="acmeContext">ACME上下文</param> /// <param name="email">邮件(用于注册ACME帐户)</param> /// <returns></returns> public static async Task <IAccountContext> GetAccountContextByNewAsync(AcmeContext acmeContext, string email) { IAccountContext account = null; if (!string.IsNullOrWhiteSpace(email)) { account = await acmeContext.NewAccount(email, true); } return(account); }
public EmailChanger(AccountConfiguration config, IAccountContext context, AccountRepository repo, PasswordService passwordService, FormsAuthenticationService formsAuthService) { if (config == null) throw new ArgumentNullException("config"); if (context == null) throw new ArgumentNullException("context"); this.config = config; this.context = context; this.repo = new AccountRepositoryWrapper(config.RequireDependency(repo)); this.passServ = config.RequireDependency(passwordService); this.formsAuthService = config.RequireDependency(formsAuthService); }
public SendVerifyEmailModel(IAccountContext accountContext, IOptionsMonitor <AppConfig> appConfig, INotificationHandler <DomainNotification> notifications, IUserAppService userAppService, IMediatorHandler bus) : base(appConfig) { _accountContext = accountContext; _notifications = (DomainNotificationHandler)notifications; _userAppService = userAppService; _bus = bus; }
/// <summary> /// Cause initialization of Certes /// </summary> /// <param name="signerPath"></param> /// <param name="registrationPath"></param> /// <param name="email"></param> public void InitRegistration(string signerPath, string registrationPath, string email) { // Signer path y registrationpath son específicos de la librería vieja, pero usamos el directorio que indican // para guardar la configuración del registro de cuenta de certes. Como el registration depende del entorno, ponemos la AcmeUri en el hash del propio // nombre del fichero. string settingsFilePath = Path.Combine(Path.GetDirectoryName(signerPath), UtilsEncryption.GetMD5(email + "::" + this.AcmeUri), "certes.json"); UtilsSystem.EnsureDirectoryExists(settingsFilePath); // Initialization and renewal/revocation handling // We get the CertesWrapper object, that will do most of the job. // RS256 Let's generate a new key (RSA is good enough IMHO) var serviceUri = new Uri(this.AcmeUri); this.Logger.LogInfo(true, "Using Acme URI: " + serviceUri); CertesSettings settings; this.HttpClient = new HttpClient(); this.AcmeHttpClient = new AcmeHttpClient(serviceUri, this.HttpClient); if (File.Exists(settingsFilePath)) { // Si ya teníamos unos settings, siginifica que la cuenta ya está registrada settings = JsonConvert.DeserializeObject <CertesSettings>(File.ReadAllText(settingsFilePath)); this.AcmeContext = new AcmeContext(serviceUri, KeyFactory.FromDer(settings.Key), this.AcmeHttpClient); } else { // Hay que crear una nueva cuenta con su clave, y registrarla en ACME settings = new CertesSettings() { AccountEmail = email, ServiceUri = serviceUri, Key = KeyFactory.NewKey(KeyAlgorithm.RS256).ToDer() }; // Register the account this.AcmeContext = new AcmeContext(serviceUri, KeyFactory.FromDer(settings.Key), this.AcmeHttpClient); IAccountContext accountCtx = this.AcmeContext.NewAccount(settings.AccountEmail, true).Result; File.WriteAllText(settingsFilePath, JsonConvert.SerializeObject(settings)); Certes.Acme.Resource.Directory directory = this.AcmeContext.GetDirectory().Result; this.Logger.LogInfo(true, $"Successfully registered account {settings.AccountEmail} with certificate authority {serviceUri.AbsoluteUri}"); if ((directory.Meta != null) && (directory.Meta.TermsOfService != null)) { this.Logger.LogInfo(true, $"Please check the ACME Service ToS at: {directory.Meta.TermsOfService}"); } } this.CertesSettings = settings; }
public ProjectBusiness(UnitOfWork unitOfWork, TaskBusiness task, IWebEnvironment hostEnvironment, IMessageCenter mesageCenter, AccountBusiness accountBusiness, IAccountContext accountContext) : base(unitOfWork) { _task = task; _hostEnvironment = hostEnvironment; _mesageCenter = mesageCenter; _accountBusiness = accountBusiness; _accountContext = accountContext; }
public AccountRepo(Context contextType) { if (contextType == Context.Mssql) { iContext = new AccountSqlContext(); } else if (contextType == Context.Memory) { //iContext = MemoryContext; } }
public HomeController(IConfiguration iconfiguration) { string con = iconfiguration.GetSection("ConnectionStrings").GetSection("connectionstring").Value; iappointmentContext = new AppointmentMsSqlContext(con); appointmentrepo = new AppointmentRepo(iappointmentContext); iaccountcontext = new AccountMsSqlContext(con); accountrepo = new AccountRepo(iaccountcontext); accVeri = new AccountVerification(); }
public AccountManager( IAccountContext accountContext, ICryptoProvider cryptoProvider, ISystemContext systemContext, IDependencyResolver dependencyResolver) { this.accountContext = accountContext; this.cryptoProvider = cryptoProvider; this.systemContext = systemContext; this.dependencyResolver = dependencyResolver; //This resolved instance is delayed until here because we want to make sure the user validator also uses the same DB Access instances this.userValidator = dependencyResolver.Resolve <IUserValidator>(DependencyOverride.CreateNew <IUsersRepository>(accountContext.Users)); }
public AccountController(IConfiguration iconfiguration) { string con = iconfiguration.GetSection("ConnectionStrings").GetSection("connectionstring").Value; iaccountcontext = new AccountMsSqlContext(con); accountrepo = new AccountRepo(iaccountcontext); inotificationcontext = new NotificationMsSqlContext(con); notificationrepo = new NotificationRepo(inotificationcontext); accVeri = new AccountVerification(); }
public AccountManager( IAccountContext accountContext, ICryptoProvider cryptoProvider, ISystemContext systemContext, IDependencyResolver dependencyResolver) { this.accountContext = accountContext; this.cryptoProvider = cryptoProvider; this.systemContext = systemContext; this.dependencyResolver = dependencyResolver; //This resolved instance is delayed until here because we want to make sure the user validator also uses the same DB Access instances this.userValidator = dependencyResolver.Resolve<IUserValidator>(DependencyOverride.CreateNew<IUsersRepository>(accountContext.Users)); }
public static void Configure(this IApplicationBuilder applicationBuilder, IHttpContextAccessor httpContextAccessor, IWebEnvironment webHostEnvironment, SessionManager sessionManager, CookiesManager cookiesManager, ILanguageLocalization languageLocalization, IAccountContext accountContext) { _httpContextAccessor = httpContextAccessor; CurrentAccount = accountContext; _cookiesManager = cookiesManager; _sessionManager = sessionManager; _webHostEnvironment = webHostEnvironment; _languageLocalization = languageLocalization; }
/// <summary> /// Creates the account. /// </summary> /// <returns> /// The account created. /// </returns> public async Task <IAccountContext> NewAccount(IList <string> contact, bool termsOfServiceAgreed) { var body = new Account { Contact = contact, TermsOfServiceAgreed = termsOfServiceAgreed }; var resp = await AccountContext.NewAccount(this, body, true); return(accountContext = new AccountContext(this, resp.Location)); }
public Validator(IAccountContext context) { RuleFor(model => model.AccountUsername).ExistingAccountByUsername(context); RuleFor(model => model.FirstName).NotEmpty(); RuleFor(model => model.LastName).NotEmpty(); RuleFor(model => model.MiddleName).NotEmpty(); RuleFor(model => model.BirthDay).NotEmpty().LessThan(model => DateTime.UtcNow); RuleFor(model => model.Gender) .NotEmpty() .Must(model => Domain.Gender.IsValidGender(model)) .WithMessage(model => $"Invalid value: {model.Gender} for gender. The value can be: {string.Join(", ", Domain.Gender.AllNames)}"); }
/// <summary> /// Gets the ACME account context. /// </summary> /// <returns>The ACME account context.</returns> public async Task <IAccountContext> Account() { if (accountContext != null) { return(accountContext); } var resp = await AccountContext.NewAccount(this, new Account.Payload { OnlyReturnExisting = true }, true); return(accountContext = new AccountContext(this, resp.Location)); }
public TaskCatRefreshTokenProvider(IAccountContext authRepository) { this.authRepository = authRepository; }
public AdminRepository(IAccountContext context) : base((DbContext) context) { }
public UserManager(IAccountContext account_context, ICharacterContext character_context) { _account_context = account_context; _character_context = character_context; _users = new Dictionary<string, IUser>(); }
public AccountRepository(IAccountContext context) { Context = context; }
public TaskCatAuthorizationServerProvider(IAccountContext authRepository) { this.authRepository = authRepository; }
public PasswordChanger(AccountConfiguration config, IAccountContext context) : this(config, context, null, null) { }
public EmailChanger(AccountConfiguration config, IAccountContext context) : this(config, context, null, null, null) { }
public RefreshTokensController(IAccountContext authRepository) { this.authRepository = authRepository; }
/// <summary> /// Account Controller Constructor /// </summary> /// <param name="accountContext"> /// AuthRepository is an Authentication Repository Instance /// </param> public AccountController(IAccountContext accountContext) { this.accountContext = accountContext; }