public void UpdateAccountTest()
        {
            try
            {
                AccountsRequester accountRequester = new AccountsRequester("AC66c1bebe590a6389f60efa0ee9ce74d44bc29747", "e1b6406c8db5369912234f006ce1cbaa267561da");

                Type      type      = typeof(APIRequester);
                FieldInfo fieldInfo = type.GetField("persyUrl", BindingFlags.NonPublic | BindingFlags.Instance);
                if (fieldInfo != null)
                {
                    fieldInfo.SetValue(accountRequester, "http://CreateAccountTest:3000");
                }

                WebRequest.RegisterPrefix("http://CreateAccountTest:3000", new TestWebRequestCreate());

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{\"uri\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747\", \"revision\" : 3, \"dateCreated\" : \"Mon, 30 Jan 2017 16:30:49 GMT\", \"dateUpdated\" : \"Mon, 30 Jan 2017 17:31:47 GMT\", \"accountId\" : \"AC66c1bebe590a6389f60efa0ee9ce74d44bc29747\", \"authToken\" : \"e1b6406c8db5369912234f006ce1cbaa267561da\", \"alias\" : \"new test account 1\", \"label\" : \"test account 1 label\", \"type\" : \"trial\", \"status\" : \"active\", \"subresourceUris\" : {\"applications\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Applications\", \"calls\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Calls\", \"availablePhoneNumbers\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/AvailablePhoneNumbers\", \"conferences\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Conferences\", \"incomingPhoneNumbers\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/IncomingPhoneNumbers\", \"logs\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Logs\", \"callingNumbers\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/CallingNumbers\", \"recordings\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Recordings\", \"queues\" : \"/Accounts/AC66c1bebe590a6389f60efa0ee9ce74d44bc29747/Queues\"}}");
                AccountOptions options = new AccountOptions();
                options.setAlias("new test account 1");
                options.setLabel("test account 1 label");
                Account account = accountRequester.update("AC66c1bebe590a6389f60efa0ee9ce74d44bc29747");

                Assert.IsNotNull(account);
                Assert.AreEqual(account.getAlias, "new test account 1");
                Assert.AreEqual(account.getLabel, "test account 1 label");
            }
            catch (PersyException pe)
            {
                Assert.Fail(pe.Message);
            }
        }
        public static string ReadValue(this AccountOption ao)
        {
            AccountOptions acc   = AccountOptions.Default;
            object         value = ao.GetValue();
            string         s     = "Undefined";

            if (value.Exists())
            {
                if (value.IsList())
                {
                    IEnumerable <object> v = (value as IEnumerable <object>).Cast <object>();
                    if (v.Funct())
                    {
                        s = string.Join(", ", v);
                    }
                    else
                    {
                        s = "Empty";
                    }
                }
                else
                {
                    s = value.ToString();
                }
            }
            return(s);
        }
Exemplo n.º 3
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });

            services.AddNodeServices(options =>
            {
                if (CurrentEnvironment.IsDevelopment())
                {
                    options.LaunchWithDebugging = true;
                    options.DebuggingPort       = 9229;
                    options.ProjectPath         = "../Frontend/ClientApp";
                }
                else
                {
                    options.ProjectPath = "ClientApp/";
                }
            });

            services.AddSpaPrerenderer();
            services.AddSingleton(GetPrerenderContent());
            services
            .AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.NullValueHandling     = NullValueHandling.Ignore;
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });


            var accountOptions = new AccountOptions(
                Configuration[Defaults.ORGANIZATION_ID],
                Configuration[Defaults.TECHNICAL_ACCOUNT_ID],
                Configuration[Defaults.CLIENT_ID],
                Configuration[Defaults.CLIENT_SECRET]);


            var securityKey = GetSecurityKey(Configuration[Defaults.CERTIFICATE_PATH]);
            var reactorApi  = new ReactorApi(accountOptions, securityKey);


            services
            .AddSingleton(reactorApi)
            .AddSingleton <ReactorService>();


            services.AddCors(options =>
            {
                options.AddPolicy(Defaults.ALL_CORS_POLICY,
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });
        }
Exemplo n.º 4
0
        public AccountService(
            IAccountStore store,
            AccountOptions options,
            ILogger <AccountService> logger,
            IIssuerService issuerService,
            IProfileService profileService,
            IMapper mapper,
            IHttpContextAccessor httpContextAccessor = null
            )
        {
            _options        = options;
            _logger         = logger;
            _certStore      = issuerService;
            _profileService = profileService ?? new DefaultProfileService(store, _options);
            _rand           = new Random();
            _store          = store;
            Mapper          = mapper;

            var http = httpContextAccessor?.HttpContext;

            string url = http is HttpContext
                ? $"{http.Request.Scheme}://{http.Request.Host.Value}{http.Request.PathBase}"
                : "";

            _serviceUrl = options.Profile.ImageServerUrl ?? url + options.Profile.ImagePath;
        }
Exemplo n.º 5
0
 public DefaultProfileService(
     IAccountStore store,
     AccountOptions options
     )
 {
     _store   = store;
     _options = options;
 }
Exemplo n.º 6
0
 static int ListAccounts(AccountOptions options)
 {
     Console.WriteLine($"{"Name".PadRight(15)}{"Profit".PadRight(10)}\t{"Balance".PadRight(10)}\t{"Type".PadRight(14)}Account ID");
     foreach (Account account in accountModels.Accounts)
     {
         Console.WriteLine($"{account.AccountName.PadRight(15)} {account.Balance.ProfitLoss.ToString().PadRight(10)} \t{ Math.Round(account.Balance.BalanceBalance).ToString().PadRight(10)}\t{account.AccountType.PadRight(14)}{account.AccountId}");
     }
     return(0);
 }
Exemplo n.º 7
0
 public CookieService(
     IHttpContextAccessor context,
     IDataProtectionProvider dp,
     AccountOptions accountOptions
     )
 {
     _context = context;
     _dp      = dp.CreateProtector(AppConstants.DataProtectionPurpose);
     _expires = accountOptions.Password.ResetTokenExpirationMinutes;
 }
Exemplo n.º 8
0
        public static Interpreter GetInterpreter(AccountOption ao)
        {
            AccountOptions opts = AccountOptions.Default;

            if (opts.TryGetOptionProperty(ao, out PropertyInfo p))
            {
                return(Interpret(p));
            }
            throw new Exception("Invalid account option property.");
        }
Exemplo n.º 9
0
        public static Interpreter Interpret(PropertyInfo p)
        {
            AccountOptions opts = AccountOptions.Default;

            p.TryGetIcon(out Emoji icon);
            p.TryGetName(out string name);
            p.TryGetDefinition(out string definition);
            p.TryGetAccountOption(out AccountOption option);
            return(new Interpreter(p.PropertyType, name ?? p.Name, definition, value: p.GetValue(opts).Read(), icon: icon, id: (ulong)option));
        }
        public static object GetValue(this AccountOption ao)
        {
            AccountOptions acc = AccountOptions.Default;

            if (acc.TryGetValue(ao, out object obj))
            {
                return(obj);
            }
            throw new Exception("Invalid account option property.");
        }
        public static Type GetValueType(this AccountOption ao)
        {
            AccountOptions acc = AccountOptions.Default;

            if (acc.TryGetType(ao, out Type type))
            {
                return(type);
            }
            throw new Exception("Invalid account option property.");
        }
 /// <summary>
 /// Configure User Identity - ASP.NET Identity
 /// </summary>
 /// <typeparam name="THttpUser">Implementation of ISystemUser</typeparam>
 /// <returns></returns>
 public static ISsoConfigurationBuilder ConfigureUserIdentity <THttpUser>(this IServiceCollection builder)
     where THttpUser : class, ISystemUser
 {
     builder
     .BaseSsoConfiguration <THttpUser>()
     .AddIdentity <UserIdentity, IdentityRole>(AccountOptions.NistAccountOptions())
     .AddEntityFrameworkStores <ApplicationSsoContext>()
     .AddDefaultTokenProviders();
     return(new SsoBuilder(builder));
 }
Exemplo n.º 13
0
 public HomeController(
     HomeService clientService,
     BrandingOptions branding,
     AccountOptions authorizationOptions,
     ILogger <HomeController> logger
     ) : base(branding, logger)
 {
     _viewSvc = clientService;
     Options  = authorizationOptions;
 }
Exemplo n.º 14
0
 static void RunAccountOptions(AccountOptions options)
 {
     if (options.CreateAccount)
     {
         Console.WriteLine("Create Account : ");
     }
     if (options.DeleteAccount)
     {
         Console.WriteLine("Delete Account : ");
     }
 }
Exemplo n.º 15
0
 public AccountService(
     IOptions <AccountOptions> accountOptionsAccessor,
     IIdentityServerInteractionService interaction,
     IHttpContextAccessor httpContextAccessor,
     IAuthenticationSchemeProvider schemeProvider,
     IClientStore clientStore)
 {
     _accountOptions      = accountOptionsAccessor.Value;
     _interaction         = interaction;
     _httpContextAccessor = httpContextAccessor;
     _schemeProvider      = schemeProvider;
     _clientStore         = clientStore;
 }
        public static async Task ReadAsync(this ISocketMessageChannel Channel, Interpreter itr, OldAccount a)
        {
            AccountOptions opts = AccountOptions.Default;

            if (opts.OutputFormat == OutputFormat.Markdown)
            {
                await Channel.SendMessageAsync(itr.Markdown());
            }
            else
            {
                await Channel.SendEmbedAsync(itr.Build(a));
            }
        }
Exemplo n.º 17
0
 public ProfileController(
     ILogger <ProfileController> logger,
     IAccountService accountService,
     IDistributedCache cache,
     AccountOptions options,
     IAppMailClient mailer
     ) : base(logger)
 {
     _svc     = accountService;
     _cache   = cache;
     _options = options;
     _mailer  = mailer;
 }
Exemplo n.º 18
0
        public static async Task SetOptionAsync(OrikivoCommandContext Context, AccountOption option, object obj)
        {
            AccountOptions opts = AccountOptions.Default;

            opts.TryGetValue(option, out object value);
            if (opts.TrySetValue(option, obj))
            {
                string msg = $"{option} - {(value.Exists() ? value.Read() : "Undefined")}";
                opts.TryGetValue(option, out value);
                msg += $" => {(value.Exists() ? value.Read() : "Undefined")}";
                await Context.Channel.SendMessageAsync(msg);
            }
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(
                                                             Configuration.GetConnectionString("DefaultConnection")));

            services.AddDefaultIdentity <IdentityUser>(AccountOptions.NistAccountOptions())
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();
            services.UpgradePasswordSecurity().UseArgon2 <IdentityUser>();

            services.AddControllersWithViews();
            services.AddRazorPages();
        }
Exemplo n.º 20
0
 public AccountController(
     IOptions <AccountOptions> accountOptionsAccessor,
     ILoginService <ApplicationUser> loginService,
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IHttpContextAccessor httpContextAccessor,
     IAuthenticationSchemeProvider schemeProvider,
     IEventService events)
 {
     _accountOptions = accountOptionsAccessor.Value;
     _loginService   = loginService;
     _interaction    = interaction;
     _events         = events;
     _account        = new AccountService(accountOptionsAccessor, interaction, httpContextAccessor, schemeProvider, clientStore);
 }
 public AccountController(
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IAuthenticationSchemeProvider schemeProvider,
     IEventService events,
     TestUserStore users,
     IOptions <AccountOptions> accountOptions)
 {
     _users          = users;
     _interaction    = interaction;
     _clientStore    = clientStore;
     _schemeProvider = schemeProvider;
     _events         = events;
     _accountOptions = accountOptions.Value;
 }
Exemplo n.º 22
0
        public DiscordController(AccountOptions options, ILoggerFactory loggerFactory)
        {
            _options = options;

            _webhookClients = new Dictionary <string, DiscordWebhookClient>();

            _discordLogger = loggerFactory.CreateLogger($"account.{Name}");

            _socketClient                  = new DiscordSocketClient();
            _socketClient.Log             += Log;
            _socketClient.MessageReceived += MessageReceived;
            _socketClient.MessageUpdated  += MessageUpdated;
            _socketClient.MessageDeleted  += MessageDeleted;
            _socketClient.LoginAsync(TokenType.Bot, _options.Token).Wait();
            _socketClient.StartAsync().Wait();
        }
Exemplo n.º 23
0
        public TestContext(
            AccountDbContext ctx,
            ILoggerFactory loggerFactory,
            IMapper mapper
            )
        {
            _ctx           = ctx;
            _loggerFactory = loggerFactory;
            Mapper         = mapper;

            _options = new AccountOptions();
            _options.Password.History              = 3;
            _options.Password.ComplexityText       = "At least 8 characters containing uppercase and lowercase letters, numbers, and symbols";
            _options.Password.ComplexityExpression = @"(?=^.{8,}$)(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[`~!@#$%^&*\(\)\-_=+\[\]\{\}\\|;:'"",<\.>/?\ ]).*$";
            _options.Registration.AllowedDomains   = @"^.+@.*jam\.net|test\.com$";
            _options.Registration.AllowedDomains   = @"jam.net test.com";
            // _options.Registration.RequireNameFromCertificate = true;
            _options.Authentication.LockThreshold = 5;
        }
Exemplo n.º 24
0
 public AccountViewService(
     IIdentityServerInteractionService interaction,
     IHttpContextAccessor httpContextAccessor,
     IAuthenticationSchemeProvider schemeProvider,
     IClientStore clientStore,
     AccountOptions options,
     AuthorizationOptions authOptions,
     IHostEnvironment env,
     CookieService cookies
     )
 {
     _interaction         = interaction;
     _httpContextAccessor = httpContextAccessor;
     _schemeProvider      = schemeProvider;
     _clientStore         = clientStore;
     _options             = options;
     _authOptions         = authOptions;
     _env     = env;
     _cookies = cookies;
 }
Exemplo n.º 25
0
        public static List <Interpreter> InterpretAll()
        {
            AccountOptions     opts = AccountOptions.Default;
            List <Interpreter> itrs = new List <Interpreter>();

            foreach (PropertyInfo p in opts.ValidProperties)
            {
                object value = p.GetValue(opts);
                if (!value.Exists())
                {
                    if (opts.EmptyFormat == NullObjectHandling.Ignore)
                    {
                        continue;
                    }
                }

                itrs.Add(Interpret(p));
            }

            return(itrs);
        }
Exemplo n.º 26
0
        /// <summary>
        /// 获取账套选项集合
        /// </summary>
        /// <returns></returns>
        public ActionResult <IEnumerable <OptionsItemView> > GetAccountOptionItems(Guid accountid)
        {
            var re  = AccountOptions.GetOptions();
            var opt = accountrps.Queryable(q => q.ID == accountid).FirstOrDefault();
            IEnumerable <OptionItemSet> optsets;

            if (!string.IsNullOrEmpty(opt.AccountOptions))
            {
                optsets = Newtonsoft.Json.JsonConvert.DeserializeObject <IEnumerable <OptionItemSet> >(opt.AccountOptions);
                foreach (var item in re)
                {
                    switch (item.OptionType)
                    {
                    case PublicEnum.AccountOptionItemType.Bool:
                    case PublicEnum.AccountOptionItemType.Date:
                    case PublicEnum.AccountOptionItemType.Int:
                    case PublicEnum.AccountOptionItemType.Number:
                    case PublicEnum.AccountOptionItemType.String:
                        item.ItemValue = optsets.FirstOrDefault(q => q.OptionKey == item.OptionKey).ItemValue;
                        break;

                    case PublicEnum.AccountOptionItemType.Enum:
                        item.ItemValue = optsets.FirstOrDefault(q => q.OptionKey == item.OptionKey).ItemValue;
                        break;

                    case PublicEnum.AccountOptionItemType.List:
                        item.ListValue = optsets.FirstOrDefault(q => q.OptionKey == item.OptionKey).ListValue;
                        break;

                    case PublicEnum.AccountOptionItemType.MultiValue:
                        item.MultiValue = optsets.FirstOrDefault(q => q.OptionKey == item.OptionKey).MultiValue;
                        break;

                    default:
                        break;
                    }
                }
            }
            return(new ActionResult <IEnumerable <OptionsItemView> >(re));
        }
Exemplo n.º 27
0
 public AccountController(
     ILogger <AccountController> logger,
     AccountViewService viewSvc,
     CookieService cookieService,
     IAccountService accountSvc,
     ClientService clientSvc,
     IAppMailClient mailer,
     BrandingOptions branding,
     AccountOptions options,
     IDistributedCache memcache,
     IIdentityServerInteractionService idInteraction
     ) : base(branding, logger)
 {
     _viewSvc     = viewSvc;
     _cookies     = cookieService;
     _accountSvc  = accountSvc;
     _clientSvc   = clientSvc;
     _options     = options;
     _cache       = memcache;
     _interaction = idInteraction;
     _mailer      = mailer;
 }
Exemplo n.º 28
0
 public AccountServiceTests()
 {
     _accountOptions = GetRequiredService <IOptionsSnapshot <AccountOptions> >().Value;
     _accountService = GetRequiredService <AccountService>();
 }
Exemplo n.º 29
0
 public AccountService(IKeyStore keyStore, IOptionsSnapshot <AccountOptions> options)
 {
     _keyStore       = keyStore;
     _accountOptions = options.Value;
 }
Exemplo n.º 30
0
        public AccountResult CreateAccount(string emailAddres, string password, string fullname, AccountOptions options)
        {
            var url     = $"{this._baseUrl}/account/createaccount/";
            var request = new AccountRequest
            {
                ApiKey       = this._apiKey,
                EmailAddress = emailAddres,
                Password     = password,
                Fullname     = fullname,
            };

            if (options != null)
            {
                if (!string.IsNullOrEmpty(options.AgencyId))
                {
                    request.AgencyId = options.AgencyId;
                }

                if (options.AgencyAccount.HasValue)
                {
                    request.AgencyAccount = options.AgencyAccount.Value;
                }

                if (options.Type.HasValue)
                {
                    request.Type = options.Type.Value;
                }
            }

            var xmlRequest   = this._parser.Serialize(request);
            var httpResponse = this._httpClient.Request(url, xmlRequest);

            if (httpResponse.Status != HttpStatus.Successful)
            {
                return(new AccountResult
                {
                    Status = Status.Error,
                    Message = "Http error"
                });
            }

            var result = this._parser.Deserialize <AccountResult>(httpResponse.Result);

            return(result);
        }