コード例 #1
0
ファイル: IdentityProvider.cs プロジェクト: pdiddyb/Saml2
        private void ReadMetadataIdpDescriptor(EntityDescriptor metadata)
        {
            var idpDescriptor = metadata.RoleDescriptors
                                .OfType <IdpSsoDescriptor>().Single();

            WantAuthnRequestsSigned = idpDescriptor.WantAuthnRequestsSigned ?? false;

            var ssoService = GetPreferredEndpoint(idpDescriptor.SingleSignOnServices);

            if (ssoService != null)
            {
                binding = Saml2Binding.UriToSaml2BindingType(ssoService.Binding);
                singleSignOnServiceUrl = ssoService.Location;
            }

            var sloService = GetPreferredEndpoint(idpDescriptor.SingleLogoutServices);

            if (sloService != null)
            {
                SingleLogoutServiceUrl         = sloService.Location;
                SingleLogoutServiceBinding     = Saml2Binding.UriToSaml2BindingType(sloService.Binding);
                singleLogoutServiceResponseUrl = sloService.ResponseLocation;
            }

            foreach (var kv in idpDescriptor.ArtifactResolutionServices)
            {
                var ars = kv.Value;
                artifactResolutionServiceUrls[ars.Index] = ars.Location;
            }

            var arsKeys = idpDescriptor.ArtifactResolutionServices.ToLookup(x => x.Value.Index);

            foreach (var ars in artifactResolutionServiceUrls.Keys
                     .Where(k => !arsKeys.Contains(k)))
            {
                artifactResolutionServiceUrls.Remove(ars);
            }

            var keys = idpDescriptor.Keys.Where(k => k.Use == KeyType.Unspecified || k.Use == KeyType.Signing);

            signingKeys.SetLoadedItems(keys.Select(k => k.KeyInfo
                                                   .MakeSecurityKeyIdentifier().First(c => c.CanCreateKey)).ToList());
        }
コード例 #2
0
        public void Saml2Binding_UriToSaml2BindingType_Nullcheck()
        {
            Action a = () => Saml2Binding.UriToSaml2BindingType(null);

            a.Should().Throw <ArgumentNullException>().And.ParamName.Should().Be("uri");
        }
コード例 #3
0
        public void Saml2Binding_UriToSaml2BindingType_Unknown()
        {
            Action a = () => Saml2Binding.UriToSaml2BindingType(new Uri("urn:SomeUnknownUri"));

            a.Should().Throw <ArgumentException>().And.Message.Should().Be("Unknown Saml2 Binding Uri \"urn:SomeUnknownUri\".");
        }
コード例 #4
0
 public void Saml2Binding_UriToSaml2BindingType_Post()
 {
     Saml2Binding.UriToSaml2BindingType(Saml2Binding.HttpPostUri)
     .Should().Be(Saml2BindingType.HttpPost);
 }
コード例 #5
0
 public void Saml2Binding_UriToSaml2BindingType_Redirect()
 {
     Saml2Binding.UriToSaml2BindingType(Saml2Binding.HttpRedirectUri)
     .Should().Be(Saml2BindingType.HttpRedirect);
 }