예제 #1
0
        private void LoadMetadata()
        {
            lock (metadataLoadLock)
            {
                try
                {
                    options.SPOptions.Logger?.WriteInformation("Loading metadata for federation from " + metadataLocation);
                    var metadata = MetadataLoader.LoadFederation(
                        metadataLocation,
                        SigningKeys,
                        options.SPOptions.ValidateCertificates,
                        options.SPOptions.MinIncomingSigningAlgorithm);

                    var identityProvidersMetadata = metadata.ChildEntities.Cast <ExtendedEntityDescriptor>()
                                                    .Where(ed => ed.RoleDescriptors.OfType <IdentityProviderSingleSignOnDescriptor>().Any());

                    var identityProviders = new List <IdentityProvider>();

                    foreach (var idpMetadata in identityProvidersMetadata)
                    {
                        var idp = new IdentityProvider(idpMetadata.EntityId, options.SPOptions)
                        {
                            AllowUnsolicitedAuthnResponse = allowUnsolicitedAuthnResponse
                        };

                        idp.ReadMetadata(idpMetadata);
                        identityProviders.Add(idp);
                    }

                    RegisterIdentityProviders(identityProviders);

                    MetadataValidUntil = metadata.CalculateMetadataValidUntil();

                    LastMetadataLoadException = null;
                }
                catch (Exception ex)
                {
                    options.SPOptions.Logger?.WriteError("Metadata loading failed from " + metadataLocation, ex);
                    var now = DateTime.UtcNow;

                    if (MetadataValidUntil < now)
                    {
                        // If download failed, ignore the error and trigger a scheduled reload.
                        RemoveAllRegisteredIdentityProviders();
                        MetadataValidUntil = DateTime.MinValue;
                    }
                    else
                    {
                        ScheduleMetadataReload();
                    }

                    LastMetadataLoadException = ex;
                }
            }
        }
예제 #2
0
        private void DoLoadMetadata()
        {
            lock (metadataLoadLock)
            {
                try
                {
                    var metadata = MetadataLoader.LoadIdp(MetadataUrl);

                    ReadMetadata(metadata);
                }
                catch (WebException)
                {
                    MetadataValidUntil = DateTime.MinValue;
                    throw;
                }
            }
        }
        private void DoLoadMetadata()
        {
            lock (metadataLoadLock)
            {
                try
                {
                    var metadata = MetadataLoader.LoadIdp(
                        MetadataLocation,
                        spOptions.Compatibility.UnpackEntitiesDescriptorInIdentityProviderMetadata);

                    ReadMetadata(metadata);
                }
                catch (WebException)
                {
                    MetadataValidUntil = DateTime.MinValue;
                    throw;
                }
            }
        }
        private void DoLoadMetadata()
        {
            if (LoadMetadata)
            {
                lock (metadataLoadLock)
                {
                    try
                    {
                        spOptions.Logger?.WriteInformation("Loading metadata for idp " + EntityId.Id);
                        var metadata = MetadataLoader.LoadIdp(
                            MetadataLocation,
                            spOptions.Compatibility.UnpackEntitiesDescriptorInIdentityProviderMetadata);

                        ReadMetadata(metadata);
                    }
                    catch (WebException ex)
                    {
                        spOptions.Logger?.WriteError("Failed to load metadata for idp " + EntityId.Id, ex);
                        MetadataValidUntil = DateTime.MinValue;
                        throw;
                    }
                }
            }
        }
예제 #5
0
 public Federation(Uri metadataUrl, bool allowUnsolicitedAuthnResponse)
     : this(MetadataLoader.LoadFederation(metadataUrl), allowUnsolicitedAuthnResponse)
 {
 }