Beispiel #1
0
        public AddSpaceTypeViewModel(INavigationService navigationService, ISessionStore sessionStore, IApiCognito apiCognito, IPageDialogService dialogService) :
            base(navigationService, sessionStore, apiCognito, dialogService)
        {
            this.Title = "Ajouter un type d'espace";

            this.CmdAddSpaceType = new Command(AddSpaceType);
        }
Beispiel #2
0
 public TelegramClient(ISessionStore store, string sessionUserId, int apiId, string apiHash)
 {
     _apiId     = apiId;
     _apiHash   = apiHash;
     _session   = Session.TryLoadOrCreateNew(store, sessionUserId);
     _transport = new TcpTransport(_session.ServerAddress, _session.Port);
 }
Beispiel #3
0
        public void FindCompatibleSessionWithTwoThreads()
        {
            ISessionStore   store   = container.Resolve <ISessionStore>();
            ISessionFactory factory = container.Resolve <ISessionFactory>();

            ISession session = factory.OpenSession();

            SessionDelegate sessDelegate = new SessionDelegate(true, session, store);

            store.Store(Constants.DefaultAlias, sessDelegate);

            ISession session2 = store.FindCompatibleSession(Constants.DefaultAlias);

            Assert.IsNotNull(session2);
            Assert.AreSame(sessDelegate, session2);

            Thread newThread = new Thread(FindCompatibleSessionOnOtherThread);

            newThread.Start();

            arEvent.WaitOne();

            sessDelegate.Dispose();

            Assert.IsTrue(store.IsCurrentActivityEmptyFor(Constants.DefaultAlias));
        }
Beispiel #4
0
 public AddCriterionViewModel(INavigationService navigationService, ISessionStore sessionStore, IApiCognito apiCognito, IPageDialogService dialogService) :
     base(navigationService, sessionStore, apiCognito, dialogService)
 {
     this.Title           = "Ajouter un critère";
     this.CmdAddCriterion = new MvvmHelpers.Commands.Command(ValidCriterion);
     this.Tools           = new List <Tool>()
     {
         new Tool()
         {
             Id    = 1,
             Label = "Cafetière"
         },
         new Tool()
         {
             Id    = 2,
             Label = "Chaise"
         },
         new Tool()
         {
             Id    = 3,
             Label = "Vidéo projecteur"
         },
         new Tool()
         {
             Id    = 4,
             Label = "Tableau"
         }
     };
 }
Beispiel #5
0
 public DragonContext(
     ISessionStore sessionStore,
     IUserStore userStore)
 {
     m_sessionStore = sessionStore;
     m_userStore    = userStore;
 }
Beispiel #6
0
        public MultitenantSessionMiddleware(
            RequestDelegate next,
            ILoggerFactory loggerFactory,
            IDataProtectionProvider dataProtectionProvider,
            ISessionStore sessionStore,
            IOptions <SessionOptions> options)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            if (dataProtectionProvider == null)
            {
                throw new ArgumentNullException(nameof(dataProtectionProvider));
            }

            if (sessionStore == null)
            {
                throw new ArgumentNullException(nameof(sessionStore));
            }

            _next                   = next;
            _loggerFactory          = loggerFactory;
            _dataProtectionProvider = dataProtectionProvider;
            _sessionStore           = sessionStore;
        }
Beispiel #7
0
        /// <summary>
        /// Creates a new <see cref="SessionMiddleware"/>.
        /// </summary>
        /// <param name="next">The <see cref="RequestDelegate"/> representing the next middleware in the pipeline.</param>
        /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> representing the factory that used to create logger instances.</param>
        /// <param name="sessionStore">The <see cref="ISessionStore"/> representing the session store.</param>
        /// <param name="options">The session configuration options.</param>
        public SessionMiddleware(
            RequestDelegate next,
            ILoggerFactory loggerFactory,
            ISessionStore sessionStore,
            IOptions <SessionOptions> options)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            if (sessionStore == null)
            {
                throw new ArgumentNullException(nameof(sessionStore));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _next         = next;
            _logger       = loggerFactory.CreateLogger <SessionMiddleware>();
            _options      = options.Value;
            _sessionStore = sessionStore;
            _sessionStore.Connect();
        }
        public Task <QueryTrain.Result> QueryTrainAsync(ISessionStore session, QueryTrain.Request request)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var trains = session.Retrieve <Internal.TrainOptions>("train_options");
            var train  = trains.Options.First(x => x.OptionRef == request.OptionRef);

            return(Task.FromResult(new QueryTrain.Result
            {
                Train = new QueryTrain.Result.TrainOption
                {
                    OptionRef = train.OptionRef,
                    DisplayNumber = train.DisplayNumber,
                    Brand = train.Brand,
                    BEntire = train.BEntire,
                    IsFirm = train.IsFirm,
                    HasElectronicRegistration = train.HasElectronicRegistration,
                    HasDynamicPricing = train.HasDynamicPricing,
                    Depart = train.Depart,
                    Arrive = train.Arrive,
                    TripDuration = train.TripDuration,
                    RouteStart = train.RouteStart,
                    RouteEndStation = train.RouteEndStation
                }
            }));
        }
Beispiel #9
0
        SessionStoreSync(Some <IVarGetter <Session> > session, Some <ISessionStore> store)
        {
            _session = session.Value;
            _store   = store.Value;

            _task = SaveLoop();
        }
        public AddParticipantViewModel(INavigationService navigationService, ISessionStore sessionStore, IApiCognito apiCognito, IPageDialogService dialogService) :
            base(navigationService, sessionStore, apiCognito, dialogService)
        {
            this.Title           = "Ajouter un participant";
            this.ListViewVisible = false;

            this.CmdAddParticipant = new Command(ValidParticipant);

            this._tempListUser = new List <User>
            {
                new User {
                    Id = 1, Email = "*****@*****.**"
                },
                new User {
                    Id = 2, Email = "*****@*****.**"
                },
                new User {
                    Id = 3, Email = "*****@*****.**"
                },
                new User {
                    Id = 4, Email = "*****@*****.**"
                },
                new User {
                    Id = 5, Email = "*****@*****.**"
                },
                new User {
                    Id = 6, Email = "*****@*****.**"
                },
                new User {
                    Id = 7, Email = "*****@*****.**"
                }
            };
        }
 public UserAgentServiceContextEnabledCheck(
     ISessionStore sessionStore,
     IUserAgentServiceContextEnabledCheckConfiguration configuration)
 {
     SessionStore  = sessionStore;
     Configuration = configuration;
 }
Beispiel #12
0
 public RequestHandler(IConfiguration configuration, IHtmlSanitizer htmlSanitizer, ISessionStore sessionStore, ApplicationDbContext context)
 {
     _baseUri       = new(configuration.GetSection(_settingKey).Value);
     _htmlSanitizer = htmlSanitizer;
     _context       = context;
     _sessionStore  = sessionStore;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SessionProvider{TSession}"/> class.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <remarks>
 /// Uses a file store.
 /// </remarks>
 public SessionProvider(Server server)
 {
     _server = server;
     _server.InternalPrepareRequest += OnRequest;
     _store = new SessionFileStore(server.ServerName);
     ResponseWriter.HeadersSent += OnHeaderSent;
 }
Beispiel #14
0
        /// <summary>
        /// Creates a new <see cref="SessionMiddleware"/>.
        /// </summary>
        /// <param name="next">The <see cref="RequestDelegate"/> representing the next middleware in the pipeline.</param>
        /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> representing the factory that used to create logger instances.</param>
        /// <param name="sessionStore">The <see cref="ISessionStore"/> representing the session store.</param>
        /// <param name="options">The session configuration options.</param>
        public SessionMiddleware(
            RequestDelegate next,
            ILoggerFactory loggerFactory,
            ISessionStore sessionStore,
            IOptions<SessionOptions> options)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            if (sessionStore == null)
            {
                throw new ArgumentNullException(nameof(sessionStore));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _next = next;
            _logger = loggerFactory.CreateLogger<SessionMiddleware>();
            _options = options.Value;
            _sessionStore = sessionStore;
            _sessionStore.Connect();
        }
Beispiel #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SessionProvider{TSession}"/> class.
 /// </summary>
 /// <param name="server">Web server that the provider is for..</param>
 /// <param name="store">Store to use.</param>
 public SessionProvider(Server server, ISessionStore store)
 {
     _server = server;
     _store  = store;
     _server.RequestReceived    += OnRequest;
     ResponseWriter.HeadersSent += OnHeaderSent;
 }
Beispiel #16
0
 public DragonContext(
     ISessionStore sessionStore,
     IUserStore userStore)
 {
     m_sessionStore = sessionStore;
     m_userStore = userStore;
 }
Beispiel #17
0
        /// <summary>
        /// Creates a new TelegramClient
        /// </summary>
        /// <param name="apiId">The API ID provided by Telegram. Get one at https://my.telegram.org </param>
        /// <param name="apiHash">The API Hash provided by Telegram. Get one at https://my.telegram.org </param>
        /// <param name="store">An ISessionStore object that will handle the session</param>
        /// <param name="sessionUserId">The name of the session that tracks login info about this TelegramClient connection</param>
        /// <param name="handler">A delegate to invoke when a connection is needed and that will return a TcpClient that will be used to connect</param>
        /// <param name="dcIpVersion">Indicates the preferred IpAddress version to use to connect to a Telegram server</param>
        public TelegramClient(int apiId, string apiHash,
                              DataCenterIPVersion dcIpVersion    = DataCenterIPVersion.Default,
                              ISessionStore store                = null,
                              string sessionUserId               = "session",
                              TcpClientConnectionHandler handler = null
                              )
        {
            if (apiId == default(int))
            {
                throw new MissingApiConfigurationException("API_ID");
            }
            if (string.IsNullOrEmpty(apiHash))
            {
                throw new MissingApiConfigurationException("API_HASH");
            }

            if (store == null)
            {
                store = new FileSessionStore();
            }
            this.store = store;

            this.apiHash     = apiHash;
            this.apiId       = apiId;
            this.handler     = handler;
            this.dcIpVersion = dcIpVersion;

            this.sessionUserId = sessionUserId;
        }
Beispiel #18
0
 public InMemoryCredentialStore(
     ISessionStore sessionStore,
     IList <Credential> credentials)
 {
     this.SessionStore = sessionStore ?? throw new ArgumentNullException(nameof(sessionStore));
     this.Credentials  = new List <Credential>(credentials) ?? throw new ArgumentNullException(nameof(credentials));
 }
Beispiel #19
0
        public SessionsController(
            IIdentityServerInteractionService interaction,
            IClientStore clientStore,
            IAuthenticationSchemeProvider schemeProvider,
            IEventService events,
            TestUserStore users,

            ICredentialStore credentialStore,
            ISessionStore sessionStore,
            ILoginAttemptStore loginAttemptStore,
            IRequestInfoService requestInfoService,
            ILoginAttemptLimitingService loginAttemptLimitingService,
            ICredentialPenaltyStore credentialPenaltyStore)
        {
            // if the TestUserStore is not in DI, then we'll just use the global users collection
            // this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity)
            _users = users;

            _interaction    = interaction;
            _clientStore    = clientStore;
            _schemeProvider = schemeProvider;
            _events         = events;

            this.CredentialStore             = credentialStore;
            this.SessionStore                = sessionStore;
            this.LoginAttemptStore           = loginAttemptStore;
            this.RequestInfoService          = requestInfoService;
            this.LoginAttemptLimitingService = loginAttemptLimitingService;
            this.CredentialPenaltyStore      = credentialPenaltyStore;
        }
        /// <summary>
        /// Creates a new <see cref="SessionMiddleware"/>.
        /// </summary>
        /// <param name="next">The <see cref="RequestDelegate"/> representing the next middleware in the pipeline.</param>
        /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> representing the factory that used to create logger instances.</param>
        /// <param name="dataProtectionProvider">The <see cref="IDataProtectionProvider"/> used to protect and verify the cookie.</param>
        /// <param name="sessionStore">The <see cref="ISessionStore"/> representing the session store.</param>
        /// <param name="options">The session configuration options.</param>
        public SessionMiddleware(
            RequestDelegate next,
            ILoggerFactory loggerFactory,
            IDataProtectionProvider dataProtectionProvider,
            ISessionStore sessionStore,
            IOptions <SessionOptions> options)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            if (dataProtectionProvider == null)
            {
                throw new ArgumentNullException(nameof(dataProtectionProvider));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _next          = next ?? throw new ArgumentNullException(nameof(next));
            _logger        = loggerFactory.CreateLogger <SessionMiddleware>();
            _dataProtector = dataProtectionProvider.CreateProtector(nameof(SessionMiddleware));
            _options       = options.Value;
            _sessionStore  = sessionStore ?? throw new ArgumentNullException(nameof(sessionStore));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SessionProvider{TSession}"/> class.
 /// </summary>
 /// <param name="server">Web server that the provider is for..</param>
 /// <param name="store">Store to use.</param>
 public SessionProvider(Server server, ISessionStore store)
 {
     _server = server;
     _store  = store;
     _server.InternalPrepareRequest += OnRequest;
     ResponseWriter.HeadersSent     += OnHeaderSent;
 }
Beispiel #22
0
        public AddReservationViewModel(INavigationService navigationService, ISessionStore sessionStore, IApiCognito apiCognito, IPageDialogService dialogService) :
            base(navigationService, sessionStore, apiCognito, dialogService)
        {
            this.Title = "Ajouter une réservation";

            this.CmdNavigateToAddParticipant = new Command(NavitageToAddParticipant);
            this.CmdAddReservation           = new Command(AddReservation);

            this.ListSpaces = new List <Space>
            {
                new Space {
                    Id = 1, Capacity = 20, Name = "Salle 304"
                },
                new Space {
                    Id = 2, Capacity = 20, Name = "Salle 305"
                },
                new Space {
                    Id = 3, Capacity = 20, Name = "Salle 306"
                },
                new Space {
                    Id = 4, Capacity = 20, Name = "Salle 307"
                },
                new Space {
                    Id = 5, Capacity = 20, Name = "Salle 308"
                },
                new Space {
                    Id = 6, Capacity = 20, Name = "Salle 309"
                },
                new Space {
                    Id = 7, Capacity = 20, Name = "Salle 400"
                },
            };

            this.ListUsers = new List <User>();
        }
Beispiel #23
0
 public SessionFactory([NotNull] string sessionKey, [NotNull] ISessionStore store, TimeSpan idleTimeout, [NotNull] Func <bool> tryEstablishSession)
 {
     _sessionKey          = sessionKey;
     _store               = store;
     _idleTimeout         = idleTimeout;
     _tryEstablishSession = tryEstablishSession;
 }
Beispiel #24
0
        public async Task<QueryReserveCancel.Result> CancelReserveAsync(ISessionStore session)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            var login = session.Retrieve<Session>("login");
            var reserve = session.Retrieve<Parser.Structs.Layer5705>("reserve");

            if (reserve == null)
            {
                throw new ArgumentNullException(nameof(reserve));
            }

            var requestData = new Parser.Structs.Layer5769.Request
            {
                OrderId = reserve.SaleOrderId
            };

            var response = await _parser.CancelReserveAsync(login, requestData);

            reserve.Canceled = true;
            session.Store("reserve", reserve);

            return new QueryReserveCancel.Result
            {
                OrderId = reserve.SaleOrderId,
                Code = response.Result,
                Status = response.Status
            };
        }
        public TLSharpTelegramApi(int apiId, string apiHash, ILog log)
        {
            this.apiId   = apiId;
            this.apiHash = apiHash;
            this.log     = log;

            sessionStore = new FileSessionStore(new DirectoryInfo("session/"));
        }
 public TelegramClientExtended(int apiId,
                               string apiHash,
                               ISessionStore store  = null,
                               string sessionUserId = "session",
                               string sessionPath   = null,
                               TcpClientConnectionHandler handler = null) : base(apiId, apiHash, store, sessionUserId, sessionPath, handler)
 {
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="DefaultSessionManager"/> class.
		/// </summary>
		/// <param name="sessionStore">The session store.</param>
		/// <param name="kernel">The kernel.</param>
		/// <param name="factoryResolver">The factory resolver.</param>
		public DefaultSessionManager(ISessionStore sessionStore, IKernel kernel, ISessionFactoryResolver factoryResolver)
		{
			this.kernel = kernel;
			this.sessionStore = sessionStore;
			this.factoryResolver = factoryResolver;

			Logger = NullLogger.Instance;
		}
 public SessionFactory([NotNull] string sessionKey, [NotNull] ISessionStore store, TimeSpan idleTimeout, [NotNull] Func<bool> tryEstablishSession, bool isNewSessionKey)
 {
     _sessionKey = sessionKey;
     _store = store;
     _idleTimeout = idleTimeout;
     _tryEstablishSession = tryEstablishSession;
     _isNewSessionKey = isNewSessionKey;
 }
 public SqlMapper(IObjectFactory objectFactory, IBatisNet.Common.Utilities.Objects.Members.AccessorFactory accessorFactory)
 {
     this._objectFactory       = objectFactory;
     this._accessorFactory     = accessorFactory;
     this._dataExchangeFactory = new IBatisNet.DataMapper.DataExchange.DataExchangeFactory(this._typeHandlerFactory, this._objectFactory, accessorFactory);
     this._id           = HashCodeProvider.GetIdentityHashCode(this).ToString();
     this._sessionStore = SessionStoreFactory.GetSessionStore(this._id);
 }
Beispiel #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultSessionManager"/> class.
        /// </summary>
        /// <param name="sessionStore">The session store.</param>
        /// <param name="kernel">The kernel.</param>
        /// <param name="factoryResolver">The factory resolver.</param>
        public DefaultSessionManager(ISessionStore sessionStore, IKernel kernel, ISessionFactoryResolver factoryResolver)
        {
            this.kernel          = kernel;
            this.sessionStore    = sessionStore;
            this.factoryResolver = factoryResolver;

            Logger = NullLogger.Instance;
        }
Beispiel #31
0
 public Handler(ILog log, EndpointSettings settings, ISessionStore sessionStore, IThreadManager threadManager, IContext context, IFileSystem fileSystem)
 {
     this.log = log;
     this.settings = settings;
     this.sessionStore = sessionStore;
     this.threadManager = threadManager;
     this.context = context;
     this.fileSystem = fileSystem;
 }
Beispiel #32
0
        /// <summary>
        /// Construct a SessionCipher for encrypt/decrypt operations on a session.
        /// In order to use SessionCipher, a session must have already been created
        /// and stored using <see cref="SessionBuilder"/>.
        /// </summary>
        /// <param name="sessionStore">The <see cref="ISessionStore"/> that contains a session for this recipient.</param>
        /// <param name="preKeyStore">Pre key store.</param>
        /// <param name="signedPreKeyStore">Signed pre key store.</param>
        /// <param name="identityKeyStore">Identity key store.</param>
        /// <param name="remoteAddress">The remote address that messages will be encrypted to or decrypted from.</param>
        public SessionCipher(ISessionStore sessionStore, IPreKeyStore preKeyStore,
		                     ISignedPreKeyStore signedPreKeyStore, IIdentityKeyStore identityKeyStore,
		                     AxolotlAddress remoteAddress)
        {
            _sessionStore = sessionStore;
            _preKeyStore = preKeyStore;
            _remoteAddress = remoteAddress;
            _sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore, identityKeyStore, remoteAddress);
        }
Beispiel #33
0
 public HomeController(
     IHomeAssembler homeAssembler, 
     IStatisticsAssembler statisticsAssembler,
     ISessionStore sessionStore)
 {
     _homeAssembler = homeAssembler;
     _statisticsAssembler = statisticsAssembler;
     _sessionStore = sessionStore;
 }
Beispiel #34
0
        private async Task <TelegramClient> CreateClient(ISessionStore store)
        {
            int    apiId   = 123864;
            string apiHash = "93cc5e4b602e1d61c162b910e1f32c9a";
            var    client  = new TelegramClient(store, apiId, apiHash, new DeviceInfo("HelloEve Test", "HelloEve Test", "HelloEve Test", "en"));
            await client.Start();

            return(client);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultSessionFactory"/> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="sessionStore">The session store.</param>
        /// <param name="transactionManager">The transaction manager.</param>
        public DefaultSessionFactory(IDataSource dataSource, ISessionStore sessionStore, ITransactionManager transactionManager)
		{
            Contract.Require.That(dataSource, Is.Not.Null).When("retrieving argument dataSource in DefaultSessionFactory constructor.");
            Contract.Require.That(sessionStore, Is.Not.Null).When("retrieving argument sessionStore in DefaultSessionFactory constructor.");
            Contract.Require.That(transactionManager, Is.Not.Null).When("retrieving argument transactionManager in DefaultSessionFactory constructor.");

            this.dataSource = dataSource;
            this.sessionStore = sessionStore;
            this.transactionManager = transactionManager;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataMapperLocalSessionScope"/> class.
        /// </summary>
        /// <param name="sessionStore">The session store.</param>
        /// <param name="sessionFactory">The session factory.</param>
        public DataMapperLocalSessionScope(ISessionStore sessionStore, ISessionFactory sessionFactory)
        {
            isSessionLocal = false;
            session = sessionStore.CurrentSession;

            if (session == null)
            {
                session = sessionFactory.OpenSession();
                isSessionLocal = true;
            }
        }
Beispiel #37
0
        public SessionBuilder(ISessionStore sessionStore,
		                      IPreKeyStore preKeyStore,
		                      ISignedPreKeyStore signedPreKeyStore,
		                      IIdentityKeyStore identityKeyStore,
		                      AxolotlAddress remoteAddress)
        {
            _sessionStore      = sessionStore;
            _preKeyStore       = preKeyStore;
            _signedPreKeyStore = signedPreKeyStore;
            _identityKeyStore  = identityKeyStore;
            _remoteAddress     = remoteAddress;
        }
Beispiel #38
0
 /// <summary>
 /// Creates a new <see cref="SessionMiddleware"/>.
 /// </summary>
 /// <param name="next">The <see cref="RequestDelegate"/> representing the next middleware in the pipeline.</param>
 /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> representing the factory that used to create logger instances.</param>
 /// <param name="sessionStore">The <see cref="ISessionStore"/> representing the session store.</param>
 /// <param name="options">The session configuration options.</param>
 public SessionMiddleware(
     [NotNull] RequestDelegate next,
     [NotNull] ILoggerFactory loggerFactory,
     [NotNull] ISessionStore sessionStore,
     [NotNull] IOptions<SessionOptions> options)
 {
     _next = next;
     _logger = loggerFactory.CreateLogger<SessionMiddleware>();
     _options = options.Options;
     _sessionStore = sessionStore;
     _sessionStore.Connect();
 }
 public RequestContext(IRequest request, IResponse response,
     ISessionStore sessionStore, IAuthenticator authenticator,
     IIoCContainer container, IFeatureSet features,
     Interceptors interceptors = null)
 {
     Request = request;
     Response = response;
     _sessionStore = sessionStore;
     _authenticator = authenticator;
     _container = new ContainerWrapper(container);
     Features = features;
     _interceptors = interceptors ?? new Interceptors();
 }
Beispiel #40
0
        protected virtual void SetUpFixture()
        {
            //DateTime start = DateTime.Now;

            configurationSetting = new ConfigurationSetting();
            configurationSetting.Properties.Add("collection2Namespace", "MyBatis.DataMapper.SqlClient.Test.Domain.LineItemCollection2, MyBatis.DataMapper.SqlClient.Test");
            configurationSetting.Properties.Add("nullableInt", "int?");

            string resource = "sqlmap.config";

            try
            {
                IConfigurationEngine engine = new DefaultConfigurationEngine(configurationSetting);
                engine.RegisterInterpreter(new XmlConfigurationInterpreter(resource));
                engine.RegisterModule(new AliasModule());

                IMapperFactory mapperFactory = engine.BuildMapperFactory();
                sessionFactory = engine.ModelStore.SessionFactory;
                dataMapper = ((IDataMapperAccessor)mapperFactory).DataMapper;
                sessionStore = ((IModelStoreAccessor) dataMapper).ModelStore.SessionStore;
            }
            catch (Exception ex)
            {
                Exception e = ex;
                while (e != null)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                    e = e.InnerException;
                }
                throw;
            }

            if (sessionFactory.DataSource.DbProvider.Id.IndexOf("PostgreSql") >= 0)
            {
                ConvertKey = new KeyConvert(Lower);
            }
            else if (sessionFactory.DataSource.DbProvider.Id.IndexOf("oracle") >= 0)
            {
                ConvertKey = new KeyConvert(Upper);
            }
            else
            {
                ConvertKey = new KeyConvert(Normal);
            }

            //			string loadTime = DateTime.Now.Subtract(start).ToString();
            //			Console.WriteLine("Loading configuration time :"+loadTime);
        }
 public RequestProcessor(
     IEnumerable<IInterceptor> interceptors,
     ISessionStore sessionStore,
     IAuthenticator authenticator,
     FeatureSet features,
     IIoCContainer featureSetContainer,
     ISettings settings,
     IArbitrator negotiator
 )
 {
     _interceptors = new Interceptors(interceptors);
     _sessionStore = sessionStore;
     _authenticator = authenticator;
     _features = features;
     _featureSetContainer = featureSetContainer;
     _settings = settings;
     _negotiator = negotiator;
 }
        public DistributedSessionFactory(BoltServerOptions options, ISessionStore  sessionStore, IServerSessionHandler sessionHandler = null)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (sessionStore == null)
            {
                throw new ArgumentNullException(nameof(sessionStore));
            }

            _options = options;
            _sessionStore = sessionStore;
            _sessionHandler = sessionHandler ?? new ServerSessionHandler(options);
            if (_options.SessionTimeout <= TimeSpan.Zero)
            {
                throw new InvalidOperationException("Session timeout is not set.");
            }
        }
Beispiel #43
0
 public static Session TryLoadOrCreateNew(ISessionStore store, string sessionUserId)
 {
     return store.Load(sessionUserId) ?? new Session(store)
     {
         Id = GenerateRandomUlong(),
         SessionUserId = sessionUserId,
         ServerAddress = defaultConnectionAddress,
         Port = defaultConnectionPort
     };
 }
 public DefaultDigestSessionManager(TimeSpan sessionTimeout, ISessionStore sessionStore)
 {
     this.sessionTimeout = sessionTimeout;
     this.sessionStore = sessionStore;
 }
 public DefaultDigestSessionManager(ISessionStore sessionStore)
     : this(new TimeSpan(0, 20, 0), sessionStore)
 {
 }
Beispiel #46
0
 public UserStoreBase(ISessionStore sessionStore)
 {
     m_sessionStore = sessionStore;
 }
Beispiel #47
0
		public static Session FromBytes(byte[] buffer, ISessionStore store, string sessionUserId)
		{
			using (var stream = new MemoryStream(buffer))
			using (var reader = new BinaryReader(stream))
			{
				var id = reader.ReadUInt64();
				var sequence = reader.ReadInt32();
				var salt = reader.ReadUInt64();
				var lastMessageId = reader.ReadInt64();
				var timeOffset = reader.ReadInt32();

				var isAuthExsist = reader.ReadInt32() == 1;
				int sessionExpires = 0;
				User user = null;
				if (isAuthExsist)
				{
					sessionExpires = reader.ReadInt32();
					user = TL.Parse<User>(reader);
				}

				var authData = Serializers.Bytes.read(reader);

				return new Session(store)
				{
					AuthKey = new AuthKey(authData),
					Id = id,
					Salt = salt,
					Sequence = sequence,
					LastMessageId = lastMessageId,
					TimeOffset = timeOffset,
					SessionExpires = sessionExpires,
					User = user,
					SessionUserId = sessionUserId
				};
			}
		}
Beispiel #48
0
 public SqlUserStore(ISessionStore sessionStore)
     : base(sessionStore)
 {
     Init();
 }
Beispiel #49
0
		private Session(ISessionStore store)
		{
			random = new Random();
			_store = store;
		}
Beispiel #50
0
 /// <summary>
 /// Make the default constructor private to prevent
 /// instances from being created.
 /// </summary>
 private DaoManager(string id)
 {
     Id = id;
     _sessionStore = SessionStoreFactory.GetSessionStore(id);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DigestRequestInterceptor"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="realm">The realm.</param>
 /// <param name="sessionStore">The session store.</param>
 public DigestRequestInterceptor(IServerSecretProvider provider, string realm, ISessionStore sessionStore)
     : this(provider, realm, new DefaultDigestSessionManager(sessionStore))
 {
 }
Beispiel #52
0
		public BlogRepository(ISessionManager sessionManager, ISessionStore sessionStore)
		{
			this.sessionStore = sessionStore;
			this.sessionManager = sessionManager;
		}
Beispiel #53
0
 public HomeController(ISessionStore sessionStore)
 {
     _sessionStore = sessionStore;
 }
 public DefaultSessionManager(ISessionStore sessionStore, ISessionFactory sessionFactory)
 {
     this.sessionStore = sessionStore;
     this._sessionFactory = sessionFactory;
 }
Beispiel #55
-1
        public TelegramClient(int apiId, string apiHash,
                              ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null)
        {
            if (apiId == default(int))
            {
                throw new MissingApiConfigurationException("API_ID");
            }
            if (string.IsNullOrEmpty(apiHash))
            {
                throw new MissingApiConfigurationException("API_HASH");
            }

            if (store == null)
            {
                store = new FileSessionStore();
            }

            TLContext.Init();
            _apiHash = apiHash;
            _apiId   = apiId;
            _handler = handler;

            _session   = Session.TryLoadOrCreateNew(store, sessionUserId);
            _transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler);
        }
        /// <summary>
        /// Creates a new TelegramClient
        /// </summary>
        /// <param name="apiId">The API ID provided by Telegram. Get one at https://my.telegram.org </param>
        /// <param name="apiHash">The API Hash provided by Telegram. Get one at https://my.telegram.org </param>
        /// <param name="store">An ISessionStore object that will handle the session</param>
        /// <param name="sessionUserId">The name of the session that tracks login info about this TelegramClient connection</param>
        /// <param name="handler">A delegate to invoke when a connection is needed and that will return a TcpClient that will be used to connect</param>
        /// <param name="dcIpVersion">Indicates the preferred IpAddress version to use to connect to a Telegram server</param>
        public TelegramClient(int apiId, string apiHash,
                              ISessionStore store             = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null,
                              DataCenterIPVersion dcIpVersion = DataCenterIPVersion.Default)
        {
            if (apiId == default(int))
            {
                throw new MissingApiConfigurationException("API_ID");
            }
            if (string.IsNullOrEmpty(apiHash))
            {
                throw new MissingApiConfigurationException("API_HASH");
            }

            if (store == null)
            {
                store = new FileSessionStore();
            }

            this.apiHash     = apiHash;
            this.apiId       = apiId;
            this.handler     = handler;
            this.dcIpVersion = dcIpVersion;

            session   = Session.TryLoadOrCreateNew(store, sessionUserId);
            transport = new TcpTransport(session.DataCenter.Address, session.DataCenter.Port, this.handler);
        }
Beispiel #57
-1
        public TelegramClient(int apiId, string apiHash, ISessionStore store = null, string sessionUserId = "session", string AppVersion = "1.0", string DeviceModel = "PC", string LangCode = "en", string SystemVersion = "Windows", TcpClientConnectionHandler handler = null)
        {
            try
            {
                if (apiId == default(int))
                {
                    throw new MissingApiConfigurationException("API_ID");
                }
                if (string.IsNullOrEmpty(apiHash))
                {
                    throw new MissingApiConfigurationException("API_HASH");
                }

                if (store == null)
                {
                    store = new FileSessionStore();
                }

                TLContext.Init();
                _apiHash       = apiHash;
                _apiId         = apiId;
                _appVersion    = AppVersion;
                _DeviceModel   = DeviceModel;
                _LangCode      = LangCode;
                _SystemVersion = SystemVersion;
                _handler       = handler;
                _session       = Session.TryLoadOrCreateNew(store, sessionUserId);
                _transport     = new TcpTransport(_session.ServerAddress, _session.Port, _handler);
            }
            catch
            {
                throw new Exception("Not connected to the internet");
            }
        }
Beispiel #58
-1
        public TelegramClient(ISessionStore store, string sessionUserId)
		{
			if (_apiId == 0)
				throw new InvalidOperationException("Your API_ID is invalid. Do a configuration first https://github.com/sochix/TLSharp#quick-configuration");

			if (string.IsNullOrEmpty(_apiHash))
				throw new InvalidOperationException("Your API_ID is invalid. Do a configuration first https://github.com/sochix/TLSharp#quick-configuration");

			_transport = new TcpTransport();
			_session = Session.TryLoadOrCreateNew(store, sessionUserId);
		}
Beispiel #59
-1
		public static Session TryLoadOrCreateNew(ISessionStore store, string sessionUserId)
		{
			Session session;

			try
			{
				session = store.Load(sessionUserId);
			}
			catch
			{
				session = new Session(store) { Id = GenerateRandomUlong(), SessionUserId = sessionUserId };
			}

			return session;
		}
Beispiel #60
-1
		public TelegramClient(ISessionStore store, string sessionUserId)
		{
			_transport = new TcpTransport();
			_session = Session.TryLoadOrCreateNew(store, sessionUserId);
		}