Esempio n. 1
0
 public PrivateAuthSession(PrivateClient client, PrivateSession session, PrivateAuthentication authParameters)
 {
     this.Parameters = authParameters;
     this.Session    = session;
     this.Client     = client;
     this.cookies    = new Lazy <CookieContainer>(NewCookieContainer);
 }
Esempio n. 2
0
        internal PrivateSession(PrivateClient client, PrivateAuthentication auth, IOptions <SessionOptions> options) : base(client, auth, DetermineAuthMethodFactory(client, auth), options)
        {
            Cache = new ProxyMemoryCache <PrivateAuthentication>(client.Cache, auth);

            var settings = client.ServerSettings as PrivateServerSettings.IExtraSettings;

            HttpClientHandlerFactory = (settings == null || settings.HttpClientHandlerFactory == null)
                ? () => new HttpClientHandler()
                : settings.HttpClientHandlerFactory;

            if (options != null && options.Value.LoggerFactory != null)
            {
                SessionLogger = options.Value.LoggerFactory.CreateLogger <PrivateSession>();
            }

            Logger.LogDebug("Initialising session");
        }
Esempio n. 3
0
        public static PrivateClient CreateClient(ServerSettings settings = null)
        {
            // create copy to protect against external changes
            var settingToUse = settings == null ? new PrivateServerSettings() : new PrivateServerSettings
            {
                ServerUrl         = settings.ServerUrl,
                Version           = settings.Version,
                AutoDetectVersion = settings.AutoDetectVersion
            };

            PrivateClient client = new PrivateClient(settingToUse.ReadOnly());

            if (settingToUse.AutoDetectVersion)
            {
                using (var session = client.CreateSession(PrivateAuthentication.NoCredentials))
                {
                    settingToUse.Version = session.Call(MetaDataRequest.DetectCurrentVersion());
                }
            }
            return(client);
        }
Esempio n. 4
0
        public static IPrivateClient CreateClient(IServerSettings settings = null)
        {
            // create copy to protect against external changes
            var settingToUse = settings == null ? new PrivateServerSettings() : new PrivateServerSettings
            {
                ServerUrl                = settings.ServerUrl,
                Version                  = settings.Version,
                AutoDetectVersion        = settings.AutoDetectVersion,
                HttpClientHandlerFactory = settings is PrivateServerSettings.IExtraSettings ? ((PrivateServerSettings.IExtraSettings)settings).HttpClientHandlerFactory : null,
                LoggerFactory            = settings is PrivateServerSettings.IExtraSettings ? ((PrivateServerSettings.IExtraSettings)settings).LoggerFactory : new LoggerFactory(),
            };

            PrivateClient client = new PrivateClient(settingToUse.ReadOnly());

            if (settingToUse.AutoDetectVersion)
            {
                using (var session = client.CreateSession(PrivateAuthentication.NoCredentials))
                {
                    settingToUse.Version = session.Call(MetaDataRequest.DetectCurrentVersion());
                }
            }
            return(client);
        }
Esempio n. 5
0
 public FixedSessionAuthMethod(PrivateClient client, PrivateSession session)
 {
     this.client  = client;
     this.session = session;
 }
Esempio n. 6
0
 internal PrivateSession(PrivateClient client, PrivateAuthentication auth) : base(client, auth, DetermineAuthMethodFactory(client, auth))
 {
     Cache = new ProxyMemoryCache <PrivateAuthentication>(client.Cache, auth);
 }
Esempio n. 7
0
 private static Func <PrivateSession, IAuthenticationMethod <PrivateAuthentication> > DetermineAuthMethodFactory(PrivateClient client, PrivateAuthentication auth)
 {
     if (PrivateAuthentication.NoCredentials.Equals(auth))
     {
         return(NoCredentialAuthMethodFunc);
     }
     return((session) => auth.Session != null
         ? (IAuthenticationMethod <PrivateAuthentication>) new FixedSessionAuthMethod(client, session)
         : (IAuthenticationMethod <PrivateAuthentication>) new LoginAuthMethod(client, session));
 }
Esempio n. 8
0
 public LoginAuthSession(PrivateClient client, PrivateSession session, PrivateAuthentication authParameters) : base(client, session, authParameters)
 {
 }