Beispiel #1
0
        protected override RoleDescriptorType GetDescriptor(IMetadataConfiguration configuration)
        {
            var idpConfiguration = configuration as IIdpSSOMetadataConfiguration;

            if (idpConfiguration == null)
            {
                throw new InvalidCastException(string.Format("Expected type: {0} but was: {1}", typeof(IdpSSOMetadataConfiguration).Name, configuration.GetType().Name));
            }

            var descriptor = new IdpSsoDescriptor
            {
                ID = configuration.DescriptorId,
                WantAuthnRequestsSigned    = idpConfiguration.WantAuthnRequestsSigned,
                ProtocolSupportEnumeration = idpConfiguration.SupportedProtocols.ToArray()[0]
            };


            foreach (var sso in idpConfiguration.SingleSignOnServices)
            {
                var singleSignOnService = new SingleSignOnService()
                {
                    Location = sso.Location,

                    Binding = sso.Binding
                };

                descriptor.SingleSignOnServices.Add(singleSignOnService);
            }

            return(descriptor);
        }
        public void IdentityProvider_ConstructedFromEntityDescriptor_DoesntScheduleMedataRefresh()
        {
            MetadataRefreshScheduler.minInterval = new TimeSpan(0, 0, 0, 0, 1);

            var ed = new EntityDescriptor
            {
                ValidUntil = DateTime.UtcNow.AddYears(-1),
                EntityId   = new EntityId("http://localhost:13428/idpMetadata")
            };

            var idpSsoDescriptor = new IdpSsoDescriptor();

            idpSsoDescriptor.ProtocolsSupported.Add(new Uri("urn:oasis:names:tc:SAML:2.0:protocol"));
            ed.RoleDescriptors.Add(idpSsoDescriptor);

            var pe = new SingleSignOnService()
            {
                Binding  = Saml2Binding.HttpRedirectUri,
                Location = new Uri("http://idp.example.com/sso")
            };

            idpSsoDescriptor.SingleSignOnServices.Add(pe);

            idpSsoDescriptor.Keys.Add(SignedXmlHelper.TestKeyDescriptor);

            var subject = new IdentityProvider(ed.EntityId, StubFactory.CreateSPOptions());

            subject.ReadMetadata(ed);

            // Ugly, but have to wait and see that nothing happened. Have tried
            // some different timeouts but need 100 to ensure fail before bug
            // is fixed :-(
            Thread.Sleep(100);

            // Would be changed if metadata was reloaded.
            subject.SingleSignOnServiceUrl.Should().Be(pe.Location);
        }