Exemplo n.º 1
0
        private static SPSSODescriptorConfiguration BuildSPSSODescriptorConfiguration(SPDescriptorSettings sPDescriptor, OrganisationConfiguration organisation)
        {
            var sPSSODescriptorConfiguration = new SPSSODescriptorConfiguration
            {
                WantAssertionsSigned         = sPDescriptor.WantAssertionsSigned,
                ValidUntil                   = sPDescriptor.ValidUntil,
                Organisation                 = organisation,
                AuthenticationRequestsSigned = sPDescriptor.RequestSigned,
                CacheDuration                = MetadataHelper.TimeSpanFromDatapartEntry(sPDescriptor.CacheDuration),
                RoleDescriptorType           = typeof(ServiceProviderSingleSignOnDescriptor),
                ErrorUrl = new Uri(sPDescriptor.ErrorUrl)
            };

            sPDescriptor.NameIdFormats.Aggregate(sPSSODescriptorConfiguration, (c, next) =>
            {
                c.NameIdentifierFormats.Add(new Uri(next.Uri));
                return(c);
            });

            //logout services
            sPDescriptor.LogoutServices.Aggregate(sPSSODescriptorConfiguration.SingleLogoutServices, (t, next) =>
            {
                t.Add(new EndPointConfiguration
                {
                    Binding  = new Uri(next.Binding.Uri),
                    Location = new Uri(next.Url)
                });
                return(t);
            });
            //supported protocols
            sPDescriptor.Protocols.Aggregate(sPSSODescriptorConfiguration.ProtocolSupported, (t, next) =>
            {
                t.Add(new Uri(next.Uri));
                return(t);
            });

            //key descriptors

            sPDescriptor.Certificates.Aggregate(sPSSODescriptorConfiguration.KeyDescriptors, (t, next) =>
            {
                var keyDescriptorConfiguration = MetadataHelper.BuildKeyDescriptorConfiguration(next);
                t.Add(keyDescriptorConfiguration);
                return(t);
            });

            //assertion service
            sPDescriptor.AssertionServices.Aggregate(sPSSODescriptorConfiguration.AssertionConsumerServices, (t, next) =>
            {
                var indexedEndPointConfiguration = new IndexedEndPointConfiguration
                {
                    Index     = next.Index,
                    IsDefault = next.IsDefault,
                    Binding   = new Uri(next.Binding.Uri),
                    Location  = new Uri(next.Url)
                };
                t.Add(indexedEndPointConfiguration);
                return(t);
            });

            return(sPSSODescriptorConfiguration);
        }