コード例 #1
0
        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));
        }
コード例 #2
0
 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");
 }
コード例 #3
0
 public AccountService(
     IAccountContext accountContext,
     IPasswordHasher <Account> passwordHasher)
 {
     _accountContext = accountContext;
     _passwordHasher = passwordHasher;
 }
コード例 #4
0
        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));
        }
コード例 #5
0
ファイル: CertesWrapper.cs プロジェクト: cshawky/WinCertes1
        /// <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);
            }
        }
コード例 #6
0
 public DatabaseContext(IAccountContext accountContext, string databaseId, Func <Database> databaseGetter)
 {
     AccountContext  = accountContext;
     DatabaseId      = databaseId;
     _databaseGetter = databaseGetter;
     Containers      = new ContainerService(databaseGetter);
 }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
 public PasswordRecoveryByResetLink(IAccountContext accountContext, IEmailSender eMailSender, ISystemContext systemContext, IConfigurationProvider configProvider)
 {
     this.accountContext = accountContext;
     this.eMailSender    = eMailSender;
     this.systemContext  = systemContext;
     this.configProvider = configProvider;
 }
コード例 #9
0
 public PasswordRecoveryByResetLink(IAccountContext accountContext, IEmailSender eMailSender, ISystemContext systemContext, IConfigurationProvider configProvider)
 {
     this.accountContext = accountContext;
     this.eMailSender = eMailSender;
     this.systemContext = systemContext;
     this.configProvider = configProvider;
 }
コード例 #10
0
 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;
 }
コード例 #11
0
 public TaskBusiness(UnitOfWork unitOfWork,
                     PhaseBusiness phase, AccountBusiness account,
                     IAccountContext accountContext) : base(unitOfWork)
 {
     _phase          = phase;
     _account        = account;
     _accountContext = accountContext;
 }
コード例 #12
0
 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;
 }
コード例 #13
0
 public DBInit(ApplicationDbContext context,
               IAccountContext accountContext,
               ILogger <DBInit> logger)
 {
     _accountContext = accountContext;
     _context        = context;
     _logger         = logger;
 }
コード例 #14
0
 /// <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>());
 }
コード例 #15
0
 public ResetPasswordModel(IAccountContext accountContext,
                           IOptionsMonitor <AppConfig> appConfig,
                           INotificationHandler <DomainNotification> notifications,
                           IMediatorHandler bus) : base(appConfig)
 {
     _accountContext = accountContext;
     _notifications  = (DomainNotificationHandler)notifications;
     _bus            = bus;
 }
コード例 #16
0
        public AccountRepository(ContextTypes type)
        {
            switch (type)
            {
            case ContextTypes.MemoryContext: context = new AccountMemoryContext(); break;

            case ContextTypes.MSSQLContext: context = new AccountContext(); break;
            }
        }
コード例 #17
0
ファイル: PasswordChanger.cs プロジェクト: ZenHiro/MvcAccount
        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);
        }
コード例 #18
0
 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;
 }
コード例 #19
0
 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();
 }
コード例 #20
0
ファイル: RuleBuilderExtensions.cs プロジェクト: adamm931/POC
 public static void ExistingAccountById <TRequest>(
     this IRuleBuilderInitial <TRequest, Guid> builder,
     IAccountContext context)
 {
     builder
     .Cascade(CascadeMode.StopOnFirstFailure)
     .NotEmpty()
     .SetValidator(new ExistingAccountByIdValidator(context));
 }
コード例 #21
0
        /// <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);
        }
コード例 #22
0
ファイル: EmailChanger.cs プロジェクト: ZenHiro/MvcAccount
        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);
        }
コード例 #23
0
 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;
 }
コード例 #24
0
        /// <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;
        }
コード例 #25
0
 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;
 }
コード例 #26
0
ファイル: AccountRepo.cs プロジェクト: YouriSaman/WorkersTool
 public AccountRepo(Context contextType)
 {
     if (contextType == Context.Mssql)
     {
         iContext = new AccountSqlContext();
     }
     else if (contextType == Context.Memory)
     {
         //iContext = MemoryContext;
     }
 }
コード例 #27
0
ファイル: HomeController.cs プロジェクト: skant33/CM
        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();
        }
コード例 #28
0
        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));
        }
コード例 #29
0
        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();
        }
コード例 #30
0
        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));
        }
コード例 #31
0
ファイル: Context.cs プロジェクト: dotnetvn-projects/EzTask
 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;
 }
コード例 #32
0
ファイル: AcmeContext.cs プロジェクト: sjkp/certes
        /// <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));
        }
コード例 #33
0
            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)}");
            }
コード例 #34
0
ファイル: AcmeContext.cs プロジェクト: sjkp/certes
        /// <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));
        }
コード例 #35
0
 public TaskCatRefreshTokenProvider(IAccountContext authRepository)
 {
     this.authRepository = authRepository;
 }
コード例 #36
0
 public AdminRepository(IAccountContext context) : base((DbContext) context) { }
コード例 #37
0
ファイル: UserManager.cs プロジェクト: sgrzeda/aetherweb
 public UserManager(IAccountContext account_context, ICharacterContext character_context)
 {
     _account_context = account_context;
     _character_context = character_context;
     _users = new Dictionary<string, IUser>();
 }
コード例 #38
0
 public AccountRepository(IAccountContext context)
 {
     Context = context;
 }
コード例 #39
0
 public TaskCatAuthorizationServerProvider(IAccountContext authRepository)
 {
     this.authRepository = authRepository;
 }
コード例 #40
0
ファイル: PasswordChanger.cs プロジェクト: ZenHiro/MvcAccount
 public PasswordChanger(AccountConfiguration config, IAccountContext context)
     : this(config, context, null, null)
 {
 }
コード例 #41
0
ファイル: EmailChanger.cs プロジェクト: ZenHiro/MvcAccount
 public EmailChanger(AccountConfiguration config, IAccountContext context)
     : this(config, context, null, null, null)
 {
 }
コード例 #42
0
 public RefreshTokensController(IAccountContext authRepository)
 {
     this.authRepository = authRepository;
 }
コード例 #43
0
ファイル: AccountController.cs プロジェクト: NerdCats/TaskCat
 /// <summary>
 /// Account Controller Constructor
 /// </summary>
 /// <param name="accountContext">
 /// AuthRepository is an Authentication Repository Instance
 /// </param>
 public AccountController(IAccountContext accountContext)
 {
     this.accountContext = accountContext;
 }