public FederationPartyConfiguration BuildContext(string federationPartyId)
        {
            if (this._cacheProvider.Contains(federationPartyId))
            {
                return(this._cacheProvider.Get <FederationPartyConfiguration>(federationPartyId));
            }

            var federationPartyContext = this._dbContext.Set <FederationPartySettings>()
                                         .FirstOrDefault(x => x.FederationPartyId == federationPartyId);

            if (federationPartyContext == null)
            {
                throw new InvalidOperationException(String.Format("No federation patty settings found for id: {0}", federationPartyId));
            }

            var context = new FederationPartyConfiguration(federationPartyId, federationPartyContext.MetadataPath)
            {
                OutboundBinding = new Uri(federationPartyContext.OutboundBinding ?? Bindings.Http_Redirect),
                InboundBinding  = new Uri(federationPartyContext.InboundBinding ?? Bindings.Http_Post),
            };
            var federationPartyAuthnRequestConfiguration = this.BuildFederationPartyAuthnRequestConfiguration(federationPartyContext.AutnRequestSettings, federationPartyContext.MetadataSettings.SPDescriptorSettings.EntityId);

            context.FederationPartyAuthnRequestConfiguration = federationPartyAuthnRequestConfiguration;

            context.RefreshInterval          = MetadataHelper.TimeSpanFromDatapartEntry(federationPartyContext.RefreshInterval);
            context.AutomaticRefreshInterval = MetadataHelper.TimeSpanFromDatapartEntry(federationPartyContext.AutoRefreshInterval);
            this.BuildMetadataContext(context, federationPartyContext.MetadataSettings);
            object policy = new MemoryCacheItemPolicy();

            ((ICacheItemPolicy)policy).SlidingExpiration = TimeSpan.FromDays(1);
            this._cacheProvider.Put(federationPartyId, context, (ICacheItemPolicy)policy);
            return(context);
        }
        public ICacheItemPolicy RegisterDependency(bool registerMonitor)
        {
            var policy = new MemoryCacheItemPolicy();

            if (registerMonitor)
            {
                var monitor = GetChangeMonitor();

                policy.ChangeMonitors.Add(monitor);
            }

            return(policy);
        }
Beispiel #3
0
        public RelyingPartyContext BuildRelyingPartyContext(string relyingPartyId)
        {
            if (this._cacheProvider.Contains(relyingPartyId))
            {
                return(this._cacheProvider.Get <RelyingPartyContext>(relyingPartyId));
            }

            var relyingPartyContext = this._dbContext.Set <RelyingPartySettings>()
                                      .FirstOrDefault(x => x.RelyingPartyId == relyingPartyId);

            var context = new RelyingPartyContext(relyingPartyId, relyingPartyContext.MetadataPath);

            context.RefreshInterval          = TimeSpan.FromSeconds(relyingPartyContext.RefreshInterval);
            context.AutomaticRefreshInterval = TimeSpan.FromDays(relyingPartyContext.AutoRefreshInterval);
            object policy = new MemoryCacheItemPolicy();

            ((ICacheItemPolicy)policy).SlidingExpiration = TimeSpan.FromDays(1);
            this._cacheProvider.Put(relyingPartyId, context, (ICacheItemPolicy)policy);
            return(context);
        }
Beispiel #4
0
        public FederationPartyConfiguration BuildContext(string federationPartyId)
        {
            if (this._cacheProvider.Contains(federationPartyId))
            {
                return(this._cacheProvider.Get <FederationPartyConfiguration>(federationPartyId));
            }

            var federationPartyContext = this._dbContext.Set <FederationPartySettings>()
                                         .FirstOrDefault(x => x.FederationPartyId == federationPartyId);

            var context = new FederationPartyConfiguration(federationPartyId, federationPartyContext.MetadataPath);
            var federationPartyAuthnRequestConfiguration = this.BuildFederationPartyAuthnRequestConfiguration(federationPartyContext.AutnRequestSettings);

            context.FederationPartyAuthnRequestConfiguration = federationPartyAuthnRequestConfiguration;

            context.RefreshInterval          = TimeSpan.FromSeconds(federationPartyContext.RefreshInterval);
            context.AutomaticRefreshInterval = TimeSpan.FromDays(federationPartyContext.AutoRefreshInterval);
            this.BuildMetadataContext(context, federationPartyContext.MetadataSettings);
            object policy = new MemoryCacheItemPolicy();

            ((ICacheItemPolicy)policy).SlidingExpiration = TimeSpan.FromDays(1);
            this._cacheProvider.Put(federationPartyId, context, (ICacheItemPolicy)policy);
            return(context);
        }
Beispiel #5
0
        /// <summary>
        /// Inserts value with specified key or updates if it already exists
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        public void Put(string key, object value)
        {
            var policy = new MemoryCacheItemPolicy();

            this.Put(key, value, policy);
        }