public DefaultTokenService(IUserService users, CoreSettings settings, IClaimsProvider claimsProvider, ITokenHandleStore tokenHandles)
 {
     _users = users;
     _settings = settings;
     _claimsProvider = claimsProvider;
     _tokenHandles = tokenHandles;
 }
 public LoginResult(SignInMessage message, HttpRequestMessage request, CoreSettings settings, InternalConfiguration internalConfig)
 {
     _message = message;
     _settings = settings;
     _request = request;
     _internalConfig = internalConfig;
 }
 public AuthenticationController(IUserService userService, CoreSettings settings, IExternalClaimsFilter externalClaimsFilter, AuthenticationOptions authenticationOptions, InternalConfiguration internalConfiguration)
 {
     _userService = userService;
     _settings = settings;
     _externalClaimsFilter = externalClaimsFilter;
     _authenticationOptions = authenticationOptions;
     _internalConfiguration = internalConfiguration;
 }
示例#4
0
 public SettingsController(
     CommonMethods commonMethods,
     CoreSettings coreSettings,
     IOptionsMonitor <ILog> option)
 {
     CommonMethods = commonMethods;
     CoreSettings  = coreSettings;
     Log           = option.Get("ASC.ApiSystem");
 }
 public TokenRequestValidator(CoreSettings settings, IAuthorizationCodeStore authorizationCodes, IUserService users, IScopeService scopes, IAssertionGrantValidator assertionValidator, ICustomRequestValidator customRequestValidator)
 {
     _settings = settings;
     _authorizationCodes = authorizationCodes;
     _users = users;
     _scopes = scopes;
     _assertionValidator = assertionValidator;
     _customRequestValidator = customRequestValidator;
 }
 public TokenRequestValidator(CoreSettings settings, IAuthorizationCodeStore authorizationCodes, IUserService users, IScopeService scopes, IAssertionGrantValidator assertionValidator, ICustomRequestValidator customRequestValidator)
 {
     _settings           = settings;
     _authorizationCodes = authorizationCodes;
     _users                  = users;
     _scopes                 = scopes;
     _assertionValidator     = assertionValidator;
     _customRequestValidator = customRequestValidator;
 }
示例#7
0
 public FilesLinkUtility(CommonLinkUtility commonLinkUtility, CoreBaseSettings coreBaseSettings, CoreSettings coreSettings, IConfiguration configuration, InstanceCrypto instanceCrypto)
 {
     CommonLinkUtility = commonLinkUtility;
     CoreBaseSettings  = coreBaseSettings;
     CoreSettings      = coreSettings;
     Configuration     = configuration;
     InstanceCrypto    = instanceCrypto;
     FilesUploaderURL  = Configuration["files.uploader.url"] ?? "~";
 }
示例#8
0
 public Tenant SaveTenant(CoreSettings coreSettings, Tenant tenant)
 {
     tenant = Service.SaveTenant(coreSettings, tenant);
     CacheNotifyItem.Publish(new TenantCacheItem()
     {
         TenantId = tenant.TenantId
     }, CacheNotifyAction.InsertOrUpdate);
     return(tenant);
 }
示例#9
0
 public AuthenticationController(ILogger logger, IUserService userService, CoreSettings settings, IExternalClaimsFilter externalClaimsFilter, AuthenticationOptions authenticationOptions, InternalConfiguration internalConfiguration)
 {
     this.logger                = logger;
     this.userService           = userService;
     this.settings              = settings;
     this.externalClaimsFilter  = externalClaimsFilter;
     this.authenticationOptions = authenticationOptions;
     this.internalConfiguration = internalConfiguration;
 }
示例#10
0
        public async Task <IActionResult> Update([FromRoute] Guid?domainId, [FromRoute] string code, [FromBody] Dictionary <string, string> lookupData)
        {
            IActionResult result = null;

            try
            {
                if (result == null && (!domainId.HasValue || Guid.Empty.Equals(domainId.Value)))
                {
                    result = BadRequest("Missing domain id parameter value");
                }
                if (result == null && string.IsNullOrEmpty(code))
                {
                    result = BadRequest("Missing lookup code parameter value");
                }
                if (result == null)
                {
                    using ILifetimeScope scope = _container.BeginLifetimeScope();
                    SettingsFactory settingsFactory = scope.Resolve <SettingsFactory>();
                    CoreSettings    settings        = settingsFactory.CreateCore(_settings.Value);
                    ILookupFactory  factory         = scope.Resolve <ILookupFactory>();
                    ILookup         innerLookup     = null;
                    Func <CoreSettings, ILookupSaver, ILookup, Task> save = (sttngs, svr, lkup) => svr.Update(sttngs, lkup);
                    if (!(await VerifyDomainAccount(domainId.Value, settingsFactory, _settings.Value, scope.Resolve <IDomainService>())))
                    {
                        result = StatusCode(StatusCodes.Status401Unauthorized);
                    }
                    if (result == null)
                    {
                        innerLookup = await factory.GetByCode(settings, domainId.Value, code);
                    }
                    if (result == null && innerLookup == null)
                    {
                        innerLookup = factory.Create(domainId.Value, code);
                        save        = (sttngs, svr, lkup) => svr.Create(sttngs, lkup);
                    }
                    if (result == null && innerLookup != null)
                    {
                        innerLookup.Data = lookupData;
                        await save(settings, scope.Resolve <ILookupSaver>(), innerLookup);

                        IMapper mapper = MapperConfigurationFactory.CreateMapper();
                        result = Ok(
                            mapper.Map <Lookup>(innerLookup)
                            );
                    }
                }
            }
            catch (Exception ex)
            {
                using (ILifetimeScope scope = _container.BeginLifetimeScope())
                {
                    await LogException(ex, scope.Resolve <IExceptionService>(), scope.Resolve <SettingsFactory>(), _settings.Value);
                }
                result = StatusCode(StatusCodes.Status500InternalServerError);
            }
            return(result);
        }
示例#11
0
 public CoreWrapper(ICore core, CoreSettings coreSettings)
 {
     Sip             = coreSettings.Sip ?? core.Sip;
     CallManager     = coreSettings.CallManager ?? core.CallManager;
     PluginManager   = coreSettings.PluginManager ?? core.PluginManager;
     SettingsManager = coreSettings.SettingsManager ?? core.SettingsManager;
     ContactsManager = coreSettings.ContactsManager ?? core.ContactsManager;
     Audio           = coreSettings.Audio ?? core.Audio;
 }
示例#12
0
        public void SetupDatabase()
        {
            var database = CoreSettings.Get("Database", "VPServices.db");

            Connection             = new SQLiteConnection(database, true);
            Connection.BusyTimeout = TimeSpan.MaxValue;

            Log.Info("Database", "Set up {0} as database", database);
        }
 public AuthenticationController(ILogger logger, IUserService userService, CoreSettings settings, IExternalClaimsFilter externalClaimsFilter, AuthenticationOptions authenticationOptions, InternalConfiguration internalConfiguration)
 {
     this.logger = logger;
     this.userService = userService;
     this.settings = settings;
     this.externalClaimsFilter = externalClaimsFilter;
     this.authenticationOptions = authenticationOptions;
     this.internalConfiguration = internalConfiguration;
 }
示例#14
0
        public CompatibilityAPICoreHTTPHandler(CoreSettings settings, ILogger logger)
        {
            APIBehaviourVersion = 0;
            DefaultAction       = null;
            IsQueryByPost       = false;

            _settings = settings;
            _logger   = logger;
        }
示例#15
0
        public CompatibilityAPIMiddleware(RequestDelegate next, IConfiguration config, ILogger <CompatibilityAPIMiddleware> logger)
        {
            _settings = new CoreSettings();
            config.GetSection("CoreSettings").Bind(_settings);

            _next = next;

            _logger = logger;
        }
示例#16
0
 public DataStoreConsumer(
     TenantManager tenantManager,
     CoreBaseSettings coreBaseSettings,
     CoreSettings coreSettings,
     IConfiguration configuration,
     ICacheNotify <ConsumerCacheItem> cache)
     : base(tenantManager, coreBaseSettings, coreSettings, configuration, cache)
 {
 }
示例#17
0
 public BaseCommonLinkUtility(
     CoreBaseSettings coreBaseSettings,
     CoreSettings coreSettings,
     TenantManager tenantManager,
     IOptionsMonitor <ILog> options,
     CommonLinkUtilitySettings settings)
     : this(null, coreBaseSettings, coreSettings, tenantManager, options, settings)
 {
 }
示例#18
0
            public void WithRemoteAccessTokenThrowsArgumentException()
            {
                var settings      = new CoreSettings();
                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterRemoteAccessToken(new Guid());

                Assert.Throws <ArgumentException>(() => accessControl.UpgradeLocalAccess(token, "password123"));
            }
示例#19
0
        public async Task <IActionResult> Create([FromBody] ClientCredentialRequest client)
        {
            IActionResult result = null;

            try
            {
                if (result == null && client == null)
                {
                    result = BadRequest("Missing client data");
                }
                if (result == null && string.IsNullOrEmpty(client.Name))
                {
                    result = BadRequest("Missing client name value");
                }
                if (result == null && (!client.AccountId.HasValue || client.AccountId.Value.Equals(Guid.Empty)))
                {
                    result = BadRequest("Missing account id value");
                }
                if (result == null && !UserCanAccessAccount(client.AccountId.Value))
                {
                    result = StatusCode(StatusCodes.Status401Unauthorized);
                }
                if (result == null && string.IsNullOrEmpty(client.Secret))
                {
                    result = BadRequest("Missing secret value");
                }
                if (result == null && client.Secret.Trim().Length < 16)
                {
                    result = BadRequest("Client secret must be at least 16 characters in lenth");
                }
                if (result == null)
                {
                    using ILifetimeScope scope = _container.BeginLifetimeScope();
                    IClientFactory clientFactory = scope.Resolve <IClientFactory>();
                    IClient        innerClient   = await clientFactory.Create(client.AccountId.Value, client.Secret);

                    IMapper mapper = MapperConfigurationFactory.CreateMapper();
                    mapper.Map <Client, IClient>(client, innerClient);
                    SettingsFactory settingsFactory = scope.Resolve <SettingsFactory>();
                    CoreSettings    settings        = settingsFactory.CreateAccount(_settings.Value);
                    IClientSaver    saver           = scope.Resolve <IClientSaver>();
                    await saver.Create(settings, innerClient);

                    result = Ok(mapper.Map <Client>(innerClient));
                }
            }
            catch (Exception ex)
            {
                using (ILifetimeScope scope = _container.BeginLifetimeScope())
                {
                    await LogException(ex, scope.Resolve <IExceptionService>(), scope.Resolve <SettingsFactory>(), _settings.Value);
                }
                result = StatusCode(StatusCodes.Status500InternalServerError);
            }
            return(result);
        }
        public WsFederationController(CoreSettings settings, IUserService users, ILogger logger, SignInValidator validator, SignInResponseGenerator signInResponseGenerator, MetadataResponseGenerator metadataResponseGenerator, ICookieService cookies)
        {
            _settings = settings;
            _logger   = logger;

            _validator = validator;
            _signInResponseGenerator   = signInResponseGenerator;
            _metadataResponseGenerator = metadataResponseGenerator;
            _cookies = cookies;
        }
 public WsFederationController(CoreSettings settings, IUserService users, SignInValidator validator, SignInResponseGenerator signInResponseGenerator, MetadataResponseGenerator metadataResponseGenerator, ITrackingCookieService cookies, InternalConfiguration internalConfig, WsFederationPluginOptions wsFedOptions)
 {
     _settings                  = settings;
     _internalConfig            = internalConfig;
     _wsfedOptions              = wsFedOptions;
     _validator                 = validator;
     _signInResponseGenerator   = signInResponseGenerator;
     _metadataResponseGenerator = metadataResponseGenerator;
     _cookies = cookies;
 }
示例#22
0
 // Called when the scene is loaded.
 void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     if (LoadSceneTransitionData.PlacePlayer)
     {
         CoreSettings coreSettingsAsset = CoreSettings.LoadCoreSettings();
         coreSettings.CurrentPlatform.GetPlayerTransform().position = LoadSceneTransitionData.PlacePosition;
         LoadSceneTransitionData.PlacePlayer = false;         // Reset the player status.
         SceneManager.sceneLoaded           -= OnSceneLoaded; //Unregister this evenet.
     }
 }
 public WsFederationController(CoreSettings settings, IUserService users, SignInValidator validator, SignInResponseGenerator signInResponseGenerator, MetadataResponseGenerator metadataResponseGenerator, ITrackingCookieService cookies, InternalConfiguration internalConfig, WsFederationPluginOptions wsFedOptions)
 {
     _settings = settings;
     _internalConfig = internalConfig;
     _wsfedOptions = wsFedOptions;
     _validator = validator;
     _signInResponseGenerator = signInResponseGenerator;
     _metadataResponseGenerator = metadataResponseGenerator;
     _cookies = cookies;
 }
示例#24
0
        /// <summary>
        /// Private constructor for implementation Singleton pattern
        /// </summary>
        private BundleTransformerContext()
        {
            var          configContext = new ConfigurationContext();
            CoreSettings coreConfig    = configContext.GetCoreSettings();

            Configuration = configContext;
            FileSystem    = new FileSystemContext();
            Styles        = new StyleContext(coreConfig.Styles);
            Scripts       = new ScriptContext(coreConfig.Scripts);
        }
示例#25
0
 public OneDriveLoginProvider(
     TenantManager tenantManager,
     CoreBaseSettings coreBaseSettings,
     CoreSettings coreSettings,
     IConfiguration configuration,
     ICacheNotify <ConsumerCacheItem> cache,
     string name, int order, Dictionary <string, string> props, Dictionary <string, string> additional = null)
     : base(tenantManager, coreBaseSettings, coreSettings, configuration, cache, name, order, props, additional)
 {
 }
示例#26
0
文件: Helpers.cs 项目: yongjan/Espera
 public static Library CreateLibrary(CoreSettings settings  = null, ILibraryReader reader            = null, ILibraryWriter writer = null,
                                     IFileSystem fileSystem = null, ILocalSongFinder localSongFinder = null)
 {
     return(new LibraryBuilder().WithReader(reader)
            .WithWriter(writer)
            .WithSettings(settings)
            .WithFileSystem(fileSystem)
            .WithSongFinder(localSongFinder)
            .Build());
 }
示例#27
0
            public void ThrowsArgumentExceptionIfGuidIsGarbage()
            {
                var settings = new CoreSettings {
                    LockRemoteControl = false
                };

                var accessControl = new AccessControl(settings);

                Assert.Throws <ArgumentException>(() => accessControl.ObserveAccessPermission(new Guid()));
            }
示例#28
0
            public void ThrowsInvalidOperationExceptionIfLocalPasswordIsNotSet()
            {
                var settings = new CoreSettings();

                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                Assert.Throws <InvalidOperationException>(() => accessControl.DowngradeLocalAccess(token));
            }
示例#29
0
        public async Task <IActionResult> Update([FromRoute] Guid?id, [FromBody] Domain domain)
        {
            IActionResult result = null;

            try
            {
                if (result == null && (!id.HasValue || id.Value.Equals(Guid.Empty)))
                {
                    result = BadRequest("Missing domain id value");
                }
                if (result == null && domain == null)
                {
                    result = BadRequest("Missing domain data");
                }
                if (result == null && string.IsNullOrEmpty(domain.Name))
                {
                    result = BadRequest("Missing domain name value");
                }
                if (result == null)
                {
                    using ILifetimeScope scope = _container.BeginLifetimeScope();
                    SettingsFactory settingsFactory = scope.Resolve <SettingsFactory>();
                    CoreSettings    settings        = settingsFactory.CreateAccount(_settings.Value);
                    IDomainFactory  domainFactory   = scope.Resolve <IDomainFactory>();
                    IDomain         innerDomain     = await domainFactory.Get(settings, id.Value);

                    if (result == null && innerDomain == null)
                    {
                        result = NotFound();
                    }
                    if (result == null && !UserCanAccessAccount(innerDomain.AccountId))
                    {
                        result = StatusCode(StatusCodes.Status401Unauthorized);
                    }
                    if (result == null)
                    {
                        IMapper mapper = MapperConfigurationFactory.CreateMapper();
                        mapper.Map <Domain, IDomain>(domain, innerDomain);
                        IDomainSaver saver = scope.Resolve <IDomainSaver>();
                        await saver.Update(settings, innerDomain);

                        result = Ok(mapper.Map <Domain>(innerDomain));
                    }
                }
            }
            catch (Exception ex)
            {
                using (ILifetimeScope scope = _container.BeginLifetimeScope())
                {
                    await LogException(ex, scope.Resolve <IExceptionService>(), scope.Resolve <SettingsFactory>(), _settings.Value);
                }
                result = StatusCode(StatusCodes.Status500InternalServerError);
            }
            return(result);
        }
        public AuthorizeRequestValidator(CoreSettings core, IScopeService scopes, IClientService clients, IUserService users, ICustomRequestValidator customValidator)
        {
            _core = core;
            _scopes = scopes;
            _clients = clients;
            _users = users;
            _customValidator = customValidator;

            _validatedRequest = new ValidatedAuthorizeRequest();
            _validatedRequest.CoreSettings = _core;
        }
示例#31
0
            public void WithBogusAccessTokenThrowsArgumentException()
            {
                var settings = new CoreSettings
                {
                    RemoteControlPassword = "******"
                };

                var accessControl = new AccessControl(settings);

                Assert.Throws <ArgumentException>(() => accessControl.UpgradeRemoteAccess(new Guid(), "password123"));
            }
        public WsFederationController(CoreSettings settings, IUserService users, ILogger logger, SignInValidator validator, SignInResponseGenerator signInResponseGenerator, MetadataResponseGenerator metadataResponseGenerator, ICookieService cookies, InternalConfiguration internalConfig)
        {
            _settings = settings;
            _logger = logger;
            _internalConfig = internalConfig;

            _validator = validator;
            _signInResponseGenerator = signInResponseGenerator;
            _metadataResponseGenerator = metadataResponseGenerator;
            _cookies = cookies;
        }
示例#33
0
            public void ThrowsWrongPasswordExceptionOnWrongPassword()
            {
                var settings      = new CoreSettings();
                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                accessControl.SetLocalPassword(token, "password123");

                Assert.Throws <WrongPasswordException>(() => accessControl.UpgradeLocalAccess(token, "lolol"));
            }
示例#34
0
            public void ThrowsArgumentExceptionOnBogusAccessToken()
            {
                var settings      = new CoreSettings();
                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                accessControl.SetLocalPassword(token, "password123");

                Assert.Throws <ArgumentException>(() => accessControl.UpgradeLocalAccess(new Guid(), "password123"));
            }
示例#35
0
            public void ThrowsInvalidOperationExceptionIfGuestSystemIsDisabled()
            {
                var settings = new CoreSettings {
                    EnableGuestSystem = false
                };

                var  accessControl = new AccessControl(settings);
                Guid token         = accessControl.RegisterRemoteAccessToken(new Guid());

                Assert.Throws <InvalidOperationException>(() => accessControl.RegisterVote(token, SetupVotedEntry()));
            }
示例#36
0
 public DataStoreConsumer(
     TenantManager tenantManager,
     CoreBaseSettings coreBaseSettings,
     CoreSettings coreSettings,
     IConfiguration configuration,
     ICacheNotify <ConsumerCacheItem> cache,
     string name, int order, Dictionary <string, string> props, Dictionary <string, string> additional)
     : base(tenantManager, coreBaseSettings, coreSettings, configuration, cache, name, order, props, additional)
 {
     Init(additional);
 }
示例#37
0
 public VKLoginProvider(TenantManager tenantManager,
                        CoreBaseSettings coreBaseSettings,
                        CoreSettings coreSettings,
                        IConfiguration configuration,
                        ICacheNotify <ConsumerCacheItem> cache,
                        Signature signature,
                        InstanceCrypto instanceCrypto,
                        string name, int order, Dictionary <string, string> props, Dictionary <string, string> additional = null)
     : base(tenantManager, coreBaseSettings, coreSettings, configuration, cache, signature, instanceCrypto, name, order, props, additional)
 {
 }
示例#38
0
 public ClickatellUSAProvider(
     TenantManager tenantManager,
     CoreBaseSettings coreBaseSettings,
     CoreSettings coreSettings,
     IConfiguration configuration,
     ICacheNotify <ConsumerCacheItem> cache,
     IOptionsMonitor <ILog> options,
     string name, int order, Dictionary <string, string> additional = null)
     : base(tenantManager, coreBaseSettings, coreSettings, configuration, cache, options, name, order, null, additional)
 {
 }
 public AuthorizeEndpointController(
     AuthorizeRequestValidator validator, 
     AuthorizeResponseGenerator responseGenerator, 
     AuthorizeInteractionResponseGenerator interactionGenerator, 
     CoreSettings settings,
     InternalConfiguration internalConfiguration)
 {
     _settings = settings;
     _internalConfiguration = internalConfiguration;
 
     _responseGenerator = responseGenerator;
     _interactionGenerator = interactionGenerator;
     _validator = validator;
 }
            public void PlayNowCommandCanExecuteSmokeTest()
            {
                var settings = new CoreSettings();

                using (Library library = Helpers.CreateLibrary(settings))
                {
                    Guid accessToken = library.LocalAccessControl.RegisterLocalAccessToken();

                    var vm = new LocalViewModel(library, new ViewSettings(), settings, accessToken);

                    var canExecuteColl = vm.PlayNowCommand.CanExecuteObservable.CreateCollection();

                    library.LocalAccessControl.SetLocalPassword(accessToken, "Password");
                    library.LocalAccessControl.DowngradeLocalAccess(accessToken);

                    Assert.Equal(new[] { true, false }, canExecuteColl);
                }
            }
示例#41
0
        protected override void Configure()
        {
            this.viewSettings = new ViewSettings();
            Locator.CurrentMutable.RegisterConstant(this.viewSettings, typeof(ViewSettings));

            this.coreSettings = new CoreSettings();

            Locator.CurrentMutable.RegisterLazySingleton(() => new Library(new LibraryFileReader(AppInfo.LibraryFilePath),
                new LibraryFileWriter(AppInfo.LibraryFilePath), this.coreSettings, new FileSystem()), typeof(Library));

            Locator.CurrentMutable.RegisterLazySingleton(() => new WindowManager(), typeof(IWindowManager));

            Locator.CurrentMutable.RegisterLazySingleton(() => new SQLitePersistentBlobCache(Path.Combine(AppInfo.BlobCachePath, "api-requests.cache.db")),
                typeof(IBlobCache), BlobCacheKeys.RequestCacheContract);

            Locator.CurrentMutable.RegisterLazySingleton(() =>
                new ShellViewModel(Locator.Current.GetService<Library>(),
                    this.viewSettings, this.coreSettings,
                    Locator.Current.GetService<IWindowManager>(),
                    Locator.Current.GetService<MobileApiInfo>()),
                typeof(ShellViewModel));

            this.ConfigureLogging();
        }
        IHttpActionResult RedirectToLogin(SignInMessage message, NameValueCollection parameters, CoreSettings settings)
        {
            message = message ?? new SignInMessage();

            var path = Url.Route("authorize", null) + "?" + parameters.ToQueryString();
            var url = new Uri(Request.RequestUri, path);
            message.ReturnUrl = url.AbsoluteUri;
            
            return new LoginResult(message, this.Request, settings, _internalConfiguration);
        }
		/// <summary>
		/// Constructs a instance of script transformer
		/// </summary>
		/// <param name="minifier">Minifier</param>
		/// <param name="translators">List of translators</param>
		/// <param name="postProcessors">List of postprocessors</param>
		/// <param name="ignorePatterns">List of patterns of files and directories that
		/// should be ignored when processing</param>
		/// <param name="coreConfig">Configuration settings of core</param>
		public ScriptTransformer(IMinifier minifier, IList<ITranslator> translators, IList<IPostProcessor> postProcessors,
			string[] ignorePatterns, CoreSettings coreConfig)
			: base(ignorePatterns, coreConfig)
		{
			ScriptSettings scriptConfig = coreConfig.Scripts;
			UsePreMinifiedFiles = scriptConfig.UsePreMinifiedFiles;
			CombineFilesBeforeMinification = scriptConfig.CombineFilesBeforeMinification;

			_jsFilesWithMsStyleExtensions = Utils.ConvertToStringCollection(
				coreConfig.JsFilesWithMicrosoftStyleExtensions.Replace(';', ','),
				',', true, true);

			IAssetContext scriptContext = BundleTransformerContext.Current.Scripts;

			_minifier = minifier ?? scriptContext.GetDefaultMinifierInstance();
			_translators = (translators ?? scriptContext.GetDefaultTranslatorInstances())
				.ToList()
				.AsReadOnly()
				;
			_postProcessors = (postProcessors ?? scriptContext.GetDefaultPostProcessorInstances())
				.ToList()
				.AsReadOnly()
				;
		}
		/// <summary>
		/// Constructs a instance of transformer
		/// </summary>
		/// <param name="ignorePatterns">List of patterns of files and directories that
		/// should be ignored when processing</param>
		/// <param name="coreConfig">Configuration settings of core</param>
		protected TransformerBase(string[] ignorePatterns, CoreSettings coreConfig)
		{
			_ignorePatterns = ignorePatterns;
			EnableTracing = coreConfig.EnableTracing;
		}
        public SettingsViewModel(Library library, ViewSettings viewSettings, CoreSettings coreSettings, IWindowManager windowManager, Guid accessToken, MobileApiInfo mobileApiInfo)
        {
            if (library == null)
                Throw.ArgumentNullException(() => library);

            if (viewSettings == null)
                Throw.ArgumentNullException(() => viewSettings);

            if (coreSettings == null)
                Throw.ArgumentNullException(() => coreSettings);

            if (mobileApiInfo == null)
                throw new ArgumentNullException("mobileApiInfo");

            this.library = library;
            this.viewSettings = viewSettings;
            this.coreSettings = coreSettings;
            this.windowManager = windowManager;
            this.accessToken = accessToken;

            this.canCreateAdmin = this
                .WhenAnyValue(x => x.CreationPassword, x => !string.IsNullOrWhiteSpace(x) && !this.isAdminCreated)
                .ToProperty(this, x => x.CanCreateAdmin);

            this.CreateAdminCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.CanCreateAdmin),
                ImmediateScheduler.Instance); // Immediate execution, because we set the password to an empty string afterwards
            this.CreateAdminCommand.Subscribe(p =>
            {
                this.library.LocalAccessControl.SetLocalPassword(this.accessToken, this.CreationPassword);
                this.isAdminCreated = true;
            });

            this.ChangeToPartyCommand = ReactiveCommand.Create(this.CreateAdminCommand.Select(x => true).StartWith(false));
            this.ChangeToPartyCommand.Subscribe(p =>
            {
                this.library.LocalAccessControl.DowngradeLocalAccess(this.accessToken);
                this.ShowSettings = false;
            });

            this.canLogin = this.WhenAnyValue(x => x.LoginPassword, x => !string.IsNullOrWhiteSpace(x))
                .ToProperty(this, x => x.CanLogin);

            this.LoginCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.CanLogin),
                ImmediateScheduler.Instance); // Immediate execution, because we set the password to an empty string afterwards
            this.LoginCommand.Subscribe(p =>
            {
                try
                {
                    this.library.LocalAccessControl.UpgradeLocalAccess(this.accessToken, this.LoginPassword);
                    this.IsWrongPassword = false;

                    this.ShowLogin = false;
                    this.ShowSettings = true;
                }

                catch (WrongPasswordException)
                {
                    this.IsWrongPassword = true;
                }
            });

            this.OpenLinkCommand = ReactiveCommand.Create();
            this.OpenLinkCommand.Cast<string>().Subscribe(x =>
            {
                try
                {
                    Process.Start(x);
                }

                catch (Win32Exception ex)
                {
                    this.Log().ErrorException(String.Format("Could not open link {0}", x), ex);
                }
            });

            this.ReportBugCommand = ReactiveCommand.Create();
            this.ReportBugCommand.Subscribe(p => this.windowManager.ShowWindow(new BugReportViewModel()));

            this.ChangeAccentColorCommand = ReactiveCommand.Create();
            this.ChangeAccentColorCommand.Subscribe(x => this.viewSettings.AccentColor = (string)x);

            this.ChangeAppThemeCommand = ReactiveCommand.Create();
            this.ChangeAppThemeCommand.Subscribe(x => this.viewSettings.AppTheme = (string)x);

            this.UpdateLibraryCommand = ReactiveCommand.Create(this.library.WhenAnyValue(x => x.IsUpdating, x => !x)
                .ObserveOn(RxApp.MainThreadScheduler)
                .CombineLatest(this.library.WhenAnyValue(x => x.SongSourcePath).Select(x => !String.IsNullOrEmpty(x)), (x1, x2) => x1 && x2));
            this.UpdateLibraryCommand.Subscribe(_ => this.library.UpdateNow());

            this.librarySource = this.library.WhenAnyValue(x => x.SongSourcePath)
                .ToProperty(this, x => x.LibrarySource);

            this.port = this.coreSettings.Port;
            this.ChangePortCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Port, NetworkHelpers.IsPortValid));
            this.ChangePortCommand.Subscribe(_ => this.coreSettings.Port = this.Port);

            this.remoteControlPassword = this.coreSettings.RemoteControlPassword;
            this.ChangeRemoteControlPasswordCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.RemoteControlPassword)
                .Select(x => !String.IsNullOrWhiteSpace(x)));
            this.ChangeRemoteControlPasswordCommand.Subscribe(x =>
                this.library.RemoteAccessControl.SetRemotePassword(this.accessToken, this.RemoteControlPassword));
            this.showRemoteControlPasswordError = this.WhenAnyValue(x => x.RemoteControlPassword, x => x.LockRemoteControl,
                    (password, lockRemoteControl) => String.IsNullOrWhiteSpace(password) && lockRemoteControl)
                .ToProperty(this, x => x.ShowRemoteControlPasswordError);

            this.isRemoteAccessReallyLocked = this.library.RemoteAccessControl.WhenAnyValue(x => x.IsRemoteAccessReallyLocked)
                .ToProperty(this, x => x.IsRemoteAccessReallyLocked);

            this.isPortOccupied = mobileApiInfo.IsPortOccupied.ToProperty(this, x => x.IsPortOccupied);

            this.enableChangelog = this.viewSettings.WhenAnyValue(x => x.EnableChangelog)
                .ToProperty(this, x => x.EnableChangelog);

            this.defaultPlaybackEngine = this.coreSettings.WhenAnyValue(x => x.DefaultPlaybackEngine)
                .ToProperty(this, x => x.DefaultPlaybackEngine);
        }
示例#46
0
		internal void UT_Init(CoreSettings coreSettings, IParserSettings rdbSchemaSettings, XElement settingsElement)
		{
			Init(coreSettings, rdbSchemaSettings, settingsElement);
		}
		/// <summary>
		/// Constructs a instance of style transformer
		/// </summary>
		/// <param name="minifier">Minifier</param>
		/// <param name="translators">List of translators</param>
		/// <param name="postProcessors">List of postprocessors</param>
		/// <param name="ignorePatterns">List of patterns of files and directories that
		/// should be ignored when processing</param>
		/// <param name="coreConfig">Configuration settings of core</param>
		public StyleTransformer(IMinifier minifier, IList<ITranslator> translators, IList<IPostProcessor> postProcessors,
			string[] ignorePatterns, CoreSettings coreConfig)
			: base(ignorePatterns, coreConfig)
		{
			StyleSettings styleConfig = coreConfig.Styles;
			UsePreMinifiedFiles = styleConfig.UsePreMinifiedFiles;
			CombineFilesBeforeMinification = styleConfig.CombineFilesBeforeMinification;

			IAssetContext styleContext = BundleTransformerContext.Current.Styles;

			_minifier = minifier ?? styleContext.GetDefaultMinifierInstance();
			_translators = (translators ?? styleContext.GetDefaultTranslatorInstances())
				.ToList()
				.AsReadOnly()
				;
			_postProcessors = (postProcessors ?? styleContext.GetDefaultPostProcessorInstances())
				.ToList()
				.AsReadOnly()
				;
		}
        IHttpActionResult RedirectToLogin(CoreSettings settings, SignInValidationResult result)
        {
            var message = new SignInMessage();
            message.ReturnUrl = Request.RequestUri.AbsoluteUri;

            if (result.HomeRealm.IsPresent())
            {
                message.IdP = result.HomeRealm;
            }

            return new LoginResult(message, this.Request, settings, _internalConfig);
        }
        private void MigrateCoreSettings()
        {
            var oldCoreSettings = new CoreSettings(this.oldBlobCache);
            var newCoreSettings = new CoreSettings(this.newBlobCache);

            this.MigrateSettingsStorage(oldCoreSettings, newCoreSettings);
        }
		/// <summary>
		/// Constructs a instance of JS-transformer
		/// </summary>
		/// <param name="minifier">Minifier</param>
		/// <param name="translators">List of translators</param>
		/// <param name="postProcessors">List of postprocessors</param>
		/// <param name="ignorePatterns">List of patterns of files and directories that
		/// should be ignored when processing</param>
		/// <param name="coreConfig">Configuration settings of core</param>
		public JsTransformer(IMinifier minifier, IList<ITranslator> translators, IList<IPostProcessor> postProcessors,
			string[] ignorePatterns, CoreSettings coreConfig)
		{
			_scriptTransformer = new ScriptTransformer(minifier, translators, postProcessors, ignorePatterns, coreConfig);
		}
 public DefaultTokenSigningService(CoreSettings settings)
 {
     _settings = settings;
 }
示例#52
0
		private void Init(CoreSettings settings, IParserSettings rdbSchemaSettings, XElement doc)
		{
			_coreSettings = settings;
			_rdbSchemaSettings = rdbSchemaSettings;

			var outputFolder =
				doc
					.Descendants()
					.Single(e => e.Name == OutputFolderElement)
					.Value;
			_log.Add("OutputFolder={0}.", outputFolder);

			var projectPath =
				doc
					.Descendants()
					.Single(e => e.Name == ProjectPathElement)
					.Value;
			_log.Add("ProjectPath={0}.", projectPath);

			var xmlOutputFilename =
				doc
					.Descendants()
					.Single(e => e.Name == XmlOutputFilenameElement)
					.Value;
			_log.Add("XmlOutputFilename={0}.", xmlOutputFilename);

			_surfaceSettings = new SurfaceSettings(
				outputFolder, 
				projectPath, 
				xmlOutputFilename
			);
		}
示例#53
0
		private void Init(CoreSettings settings, IParserSettings rdbSchemaSettings, XElement doc)
		{
			_coreSettings = settings;
			_rdbSchemaSettings = rdbSchemaSettings;
			_pocoSettings = new PocoSettings(
				bool.Parse(doc.Descendants(MakePartialElement).Single().Value),

				doc.Descendants(NameSpaceElement).Single().Attributes(NameSpaceNameAttribute).Single().Value,
				
				doc.Descendants(NameSpaceElement).Single().Descendants(NameSpaceCommentsElement).Single().Descendants(NameSpaceCommentElement).Select(e=>e.Value).ToList(),

				bool.Parse(doc.Descendants(ConstructorsElement).Single().Descendants(ConstructorsDefaultElement).Single().Value),
				bool.Parse(doc.Descendants(ConstructorsElement).Single().Descendants(ConstructorsAllPropertiesElement).Single().Value),
				bool.Parse(doc.Descendants(ConstructorsElement).Single().Descendants(ConstructorsAllPropertiesSansPrimaryKeyElement).Single().Value),
				bool.Parse(doc.Descendants(ConstructorsElement).Single().Descendants(ConstructorCopy).Single().Value),

				bool.Parse(doc.Descendants(MethodsElement).Single().Descendants(MethodsEqualsElement).Single().Value),
				doc.Descendants(MethodsElement).Single().Descendants(MethodsEqualsElement).Single().Attributes(MethodsEqualsRegexAttribute).Single().Value,

				doc.Descendants(OutputFolderElement).Single().Value,
				doc.Descendants(ProjectPathElement).Single().Value,
				doc.Descendants(XmlOutputFilenameElement).Single().Value
			);
		}