/// <summary>
 /// Initializes a new instance of the <see cref="ConfigController"/> class
 /// </summary>
 /// <param name="log">Log</param>
 /// <param name="appsManager">apps manager</param>
 /// <param name="serviceVersionInfo">info about version of service</param>
 /// <param name="buildVersionInfo">build version info</param>
 public ConfigController(ILog log, IAppsManager appsManager, IServiceVersionInfo serviceVersionInfo, IBuildVersionInfo buildVersionInfo)
 {
     this.log                = log;
     this.appsManager        = appsManager;
     this.serviceVersionInfo = serviceVersionInfo;
     this.buildVersionInfo   = buildVersionInfo;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="OAuthManager"/> class.
        /// </summary>
        /// <param name="log">Log</param>
        /// <param name="appsManager">apps manager</param>
        /// <param name="usersManager">users manager</param>
        /// <param name="identityProvider">OAuth identity provider</param>
        public OAuthManager(ILog log, IAppsManager appsManager, IUsersManager usersManager, IdentityProviders identityProvider)
            : base(log, appsManager, usersManager)
        {
            this.oauthIdentityProvider = identityProvider;
            switch (this.oauthIdentityProvider)
            {
            case IdentityProviders.Microsoft:
                this.serverIdentityProvider = IdentityProviderType.Microsoft;
                break;

            case IdentityProviders.Facebook:
                this.serverIdentityProvider = IdentityProviderType.Facebook;
                break;

            case IdentityProviders.Google:
                this.serverIdentityProvider = IdentityProviderType.Google;
                break;

            case IdentityProviders.Twitter:
                this.serverIdentityProvider = IdentityProviderType.Twitter;
                break;

            default:
                throw new InvalidOperationException("Code should never reach here.");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MyLinkedAccountsController"/> class
 /// </summary>
 /// <param name="log">Log</param>
 /// <param name="identitiesManager">Identities manager</param>
 /// <param name="usersManager">Users manager</param>
 /// <param name="appsManager">Apps manager</param>
 /// <param name="viewsManager">Views manager</param>
 /// <param name="sessionTokenManager">Session token manager</param>
 public MyLinkedAccountsController(ILog log, IIdentitiesManager identitiesManager, IUsersManager usersManager, IAppsManager appsManager, IViewsManager viewsManager, ISessionTokenManager sessionTokenManager)
 {
     this.log = log;
     this.identitiesManager   = identitiesManager;
     this.usersManager        = usersManager;
     this.appsManager         = appsManager;
     this.viewsManager        = viewsManager;
     this.sessionTokenManager = sessionTokenManager;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthenticationFilter"/> class.
 /// </summary>
 /// <param name="log">Log</param>
 /// <param name="appsManager">Apps manager</param>
 /// <param name="usersManager">Users manager</param>
 /// <param name="authManager">auth manager</param>
 public AuthenticationFilter(
     ILog log,
     IAppsManager appsManager,
     IUsersManager usersManager,
     ICompositeAuthManager authManager)
 {
     this.log          = log ?? throw new ArgumentNullException("AuthenticationFilter constructor: log is null");
     this.appsManager  = appsManager ?? throw new ArgumentNullException("AuthenticationFilter constructor: appsManager is null");
     this.usersManager = usersManager ?? throw new ArgumentNullException("AuthenticationFilter constructor: usersManager is null");
     this.authManager  = authManager ?? throw new ArgumentNullException("AuthenticationFilter constructor: authManager is null");
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SessionsController"/> class
 /// </summary>
 /// <param name="log">Log</param>
 /// <param name="identitiesManager">Identities manager</param>
 /// <param name="tokensManager">Token manager</param>
 /// <param name="usersManager">Users manager</param>
 /// <param name="appsManager">Apps manager</param>
 /// <param name="applicationMetrics">Application metrics logger</param>
 public SessionsController(
     ILog log,
     IIdentitiesManager identitiesManager,
     ISessionTokenManager tokensManager,
     IUsersManager usersManager,
     IAppsManager appsManager,
     IApplicationMetrics applicationMetrics)
 {
     this.log = log;
     this.identitiesManager  = identitiesManager;
     this.tokenManager       = tokensManager;
     this.usersManager       = usersManager;
     this.appsManager        = appsManager;
     this.applicationMetrics = applicationMetrics;
 }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TopicsController"/> class
 /// </summary>
 /// <param name="log">Log</param>
 /// <param name="usersManager">Users manager</param>
 /// <param name="topicsManager">Topics manager</param>
 /// <param name="appsManager">Apps manager</param>
 /// <param name="popularTopicsManager">Popular topics manager</param>
 /// <param name="viewsManager">Views manager</param>
 /// <param name="topicNamesManager">Topic names manager</param>
 /// <param name="handleGenerator">Handle generator</param>
 public TopicsController(
     ILog log,
     IUsersManager usersManager,
     ITopicsManager topicsManager,
     IAppsManager appsManager,
     IPopularTopicsManager popularTopicsManager,
     IViewsManager viewsManager,
     ITopicNamesManager topicNamesManager,
     IHandleGenerator handleGenerator)
     : base(log, viewsManager)
 {
     this.log                  = log;
     this.usersManager         = usersManager;
     this.topicsManager        = topicsManager;
     this.appsManager          = appsManager;
     this.popularTopicsManager = popularTopicsManager;
     this.viewsManager         = viewsManager;
     this.topicNamesManager    = topicNamesManager;
     this.handleGenerator      = handleGenerator;
 }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UsersController"/> class
        /// </summary>
        /// <param name="log">Log</param>
        /// <param name="identitiesManager">Identities manager</param>
        /// <param name="tokenManager">Token manager</param>
        /// <param name="usersManager">Users manager</param>
        /// <param name="popularUsersManager">Popular users manager</param>
        /// <param name="appsManager">Apps manager</param>
        /// <param name="viewsManager">Views manager</param>
        /// <param name="handleGenerator">Handle generator</param>
        /// <param name="applicationMetrics">Application metrics logger</param>
        public UsersController(
            ILog log,
            IIdentitiesManager identitiesManager,
            ISessionTokenManager tokenManager,
            IUsersManager usersManager,
            IPopularUsersManager popularUsersManager,
            IAppsManager appsManager,
            IViewsManager viewsManager,
            IHandleGenerator handleGenerator,
            IApplicationMetrics applicationMetrics)
        {
            this.log = log;
            if (identitiesManager == null || tokenManager == null || popularUsersManager == null || appsManager == null || viewsManager == null || handleGenerator == null)
            {
                this.log.LogException(
                    string.Format(
                        "Calling UserController constructure with null parameters. identitiesManager is {0}, tokenManager is {1}," +
                        "usersManager is {2}, popularUsersManager is {3}, appsManager is {4}, viewsManager is {5}, handleGenerator is {6}",
                        identitiesManager == null ? "null" : "not null",
                        tokenManager == null ? "null" : "not null",
                        usersManager == null ? "null" : "not null",
                        popularUsersManager == null ? "null" : "not null",
                        appsManager == null ? "null" : "not null",
                        viewsManager == null ? "null" : "not null",
                        handleGenerator == null ? "null" : "not null"));
            }

            this.identitiesManager   = identitiesManager;
            this.tokenManager        = tokenManager;
            this.usersManager        = usersManager;
            this.popularUsersManager = popularUsersManager;
            this.appsManager         = appsManager;
            this.viewsManager        = viewsManager;
            this.handleGenerator     = handleGenerator;
            this.applicationMetrics  = applicationMetrics;
        }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SocialPlusAuthManager"/> class.
 /// </summary>
 /// <param name="log">Log</param>
 /// <param name="appsManager">apps manager</param>
 /// <param name="usersManager">users manager</param>
 /// <param name="sessionTokenManager">session token manager</param>
 public SocialPlusAuthManager(ILog log, IAppsManager appsManager, IUsersManager usersManager, ISessionTokenManager sessionTokenManager)
     : base(log, appsManager, usersManager)
 {
     this.sessionTokenManager = sessionTokenManager ?? throw new ArgumentNullException("SocialPlusAuthManager constructor: sessionTokenManager is null");
 }
示例#9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommonAuthManager"/> class.
 /// </summary>
 /// <param name="log">Log</param>
 /// <param name="appsManager">apps manager</param>
 /// <param name="usersManager">users manager</param>
 public CommonAuthManager(ILog log, IAppsManager appsManager, IUsersManager usersManager)
 {
     this.Log          = log ?? throw new ArgumentNullException("CommonAuthManager constructor: log is null");
     this.appsManager  = appsManager ?? throw new ArgumentNullException("CommonAuthManager constructor: appsManager is null");
     this.usersManager = usersManager ?? throw new ArgumentNullException("CommonAuthManager constructor: usersManager is null");
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RequestTokensController"/> class
 /// </summary>
 /// <param name="log">Log</param>
 /// <param name="identitiesManager">Identities manager</param>
 /// <param name="appsManager">Apps manager</param>
 public RequestTokensController(ILog log, IIdentitiesManager identitiesManager, IAppsManager appsManager)
 {
     this.log = log;
     this.identitiesManager = identitiesManager;
     this.appsManager       = appsManager;
 }
示例#11
0
        /// <summary>
        /// Initialization routine
        /// </summary>
        private void Initialize()
        {
            // load the environment configuration file from UtilsInternal
            var sr                    = new FileSettingsReader(ConfigurationManager.AppSettings["ConfigRelativePath"] + Path.DirectorySeparatorChar + environmentName + ".config");
            var certThumbprint        = sr.ReadValue(SocialPlusCertThumbprint);
            var clientID              = sr.ReadValue(EmbeddedSocialClientIdSetting);
            var storeLocation         = StoreLocation.CurrentUser;
            var vaultUrl              = sr.ReadValue(SocialPlusVaultUrlSetting);
            ICertificateHelper cert   = new CertificateHelper(certThumbprint, clientID, storeLocation);
            IKeyVaultClient    client = new AzureKeyVaultClient(cert);

            var log      = new Log(LogDestination.Console, Log.DefaultCategoryName);
            var kv       = new KV(log, clientID, vaultUrl, certThumbprint, storeLocation, client);
            var kvReader = new KVSettingsReader(sr, kv);
            IConnectionStringProvider connectionStringProvider = new ConnectionStringProvider(kvReader);
            int queueBatchIntervalMs = int.Parse(sr.ReadValue(ServiceBusBatchIntervalMsSetting));

            // Lots of things need to be created to create an appsManager.
            ICTStoreManager tableStoreManager = new CTStoreManager(connectionStringProvider);
            bool            tableInit         = false;
            Exception       exception         = null;

            try
            {
                // use Task.Run to ensure that the async Initialize routine runs on a threadpool thread
                Task <bool> task = Task <bool> .Run(() => tableStoreManager.Initialize());

                // task.Result blocks until the result is ready
                tableInit = task.Result;
            }
            catch (Exception e)
            {
                exception = e;
            }

            if (tableInit == false)
            {
                string errorMessage = "CTstore version number does not match the expected version number." + Environment.NewLine +
                                      "If your tables are empty, then you probably forgot to provision storage." + Environment.NewLine +
                                      "If not, then you need to convert the data format and update the storage version number.";
                Console.WriteLine(errorMessage);
                if (exception != null)
                {
                    Console.WriteLine("Exception message:" + exception.Message);
                }

                Environment.Exit(0);
            }

            ICBStoreManager blobStoreManager = new CBStoreManager(connectionStringProvider);
            AppsStore       appsStore        = new AppsStore(tableStoreManager);
            UsersStore      usersStore       = new UsersStore(tableStoreManager);
            ViewsManager    viewsManager     = new ViewsManager(
                log,
                appsStore,
                usersStore,
                new UserRelationshipsStore(tableStoreManager),
                new TopicsStore(tableStoreManager),
                new TopicRelationshipsStore(tableStoreManager),
                new CommentsStore(tableStoreManager),
                new RepliesStore(tableStoreManager),
                new LikesStore(tableStoreManager),
                new PinsStore(tableStoreManager),
                new BlobsStore(blobStoreManager));
            PushNotificationsManager pushManager = new PushNotificationsManager(log, new PushRegistrationsStore(tableStoreManager), appsStore, viewsManager, connectionStringProvider);

            this.appsManager = new AppsManager(appsStore, pushManager);
            SearchManager       searchManager       = new SearchManager(log, connectionStringProvider);
            PopularUsersManager popularUsersManager = new PopularUsersManager(usersStore);
            QueueManager        queueManager        = new QueueManager(connectionStringProvider, queueBatchIntervalMs);
            SearchQueue         searchQueue         = new SearchQueue(queueManager);

            this.usersManager = new UsersManager(usersStore, pushManager, popularUsersManager, searchQueue);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AADAuthManager"/> class.
 /// </summary>
 /// <param name="log">log</param>
 /// <param name="appsManager">apps manager</param>
 /// <param name="usersManager">users manager</param>
 public AADAuthManager(ILog log, IAppsManager appsManager, IUsersManager usersManager)
     : base(log, appsManager, usersManager)
 {
     this.alert = (string msg, Exception ex) => this.Log.LogError(msg, ex);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnonAuthManager"/> class.
 /// </summary>
 /// <param name="log">log</param>
 /// <param name="appsManager">apps manager</param>
 /// <param name="usersManager">users manager</param>
 public AnonAuthManager(ILog log, IAppsManager appsManager, IUsersManager usersManager)
     : base(log, appsManager, usersManager)
 {
 }