Beispiel #1
0
        public SquidexClientManager(Uri serviceUrl, string applicationName, IAuthenticator authenticator, IHttpConfigurator httpConfigurator = null)
        {
            Guard.NotNull(serviceUrl, nameof(serviceUrl));
            Guard.NotNull(authenticator, nameof(authenticator));
            Guard.NotNullOrEmpty(applicationName, nameof(applicationName));

            this.authenticator    = authenticator;
            this.httpConfigurator = httpConfigurator;
            this.applicationName  = applicationName;
            this.serviceUrl       = serviceUrl;
            this.httpConfigurator = httpConfigurator ?? NoopHttpConfigurator.Instance;
        }
Beispiel #2
0
 public SquidexClientManager(Uri serviceUrl, string applicationName, IAuthenticator authenticator, IHttpConfigurator httpConfigurator = null)
     : this(new SquidexOptions {
     Url = serviceUrl.ToString(), Authenticator = authenticator, AppName = applicationName, Configurator = httpConfigurator
 })
 {
 }
Beispiel #3
0
 public SquidexClientManager(string serviceUrl, string applicationName, string clientId, string clientSecret, IHttpConfigurator httpConfigurator = null)
     : this(new SquidexOptions {
     Url = serviceUrl, ClientId = clientId, ClientSecret = clientSecret, AppName = applicationName, Configurator = httpConfigurator
 })
 {
 }
Beispiel #4
0
        internal void CheckAndFreeze()
        {
            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                throw new ArgumentException("URL must be a valid absolute URL.");
            }

            url = url.TrimEnd('/', ' ');

            if (string.IsNullOrWhiteSpace(appName))
            {
                throw new ArgumentException("App name is not defined.");
            }

            if (!string.IsNullOrWhiteSpace(assetCDN))
            {
                if (!Uri.IsWellFormedUriString(assetCDN, UriKind.Absolute))
                {
                    throw new ArgumentException("Asset CDN URL must be absolute if specified.");
                }

                contentCDN = contentCDN.TrimEnd('/', ' ');
            }

            if (!string.IsNullOrWhiteSpace(contentCDN))
            {
                if (!Uri.IsWellFormedUriString(contentCDN, UriKind.Absolute))
                {
                    throw new ArgumentException("Content CDN URL must be absolute if specified.");
                }

                assetCDN = assetCDN.TrimEnd('/', ' ');
            }

            if (authenticator == null)
            {
                if (string.IsNullOrWhiteSpace(clientId))
                {
                    throw new ArgumentException("Client id is not defined.");
                }

                if (string.IsNullOrWhiteSpace(clientSecret))
                {
                    throw new ArgumentException("Client secret is not defined.");
                }

                var cache = new MemoryCache(Options.Create(new MemoryCacheOptions()));

                authenticator = new CachingAuthenticator($"TOKEN_{Url}", cache, new Authenticator(Url, clientId, clientSecret));
            }

            if (configurator == null)
            {
                configurator = NoopHttpConfigurator.Instance;
            }

            if (clientFactory == null)
            {
                clientFactory = NoopHttpConfigurator.Instance;
            }

            if (httpClientTimeout == TimeSpan.Zero)
            {
                httpClientTimeout = TimeSpan.FromSeconds(100);
            }

            isFrozen = true;
        }
Beispiel #5
0
 public SquidexClientManager(string serviceUrl, string applicationName, IAuthenticator authenticator, IHttpConfigurator httpConfigurator = null)
     : this(new Uri(serviceUrl, UriKind.Absolute), applicationName, authenticator, httpConfigurator)
 {
 }
Beispiel #6
0
 public SquidexClientManager(string serviceUrl, string applicationName, string clientId, string clientSecret, IHttpConfigurator httpConfigurator = null)
     : this(new Uri(serviceUrl, UriKind.Absolute), applicationName,
            new CachingAuthenticator($"TOKEN_{serviceUrl}", new MemoryCache(Options.Create(new MemoryCacheOptions())),
                                     new Authenticator(serviceUrl, clientId, clientSecret)),
            httpConfigurator)
 {
 }