コード例 #1
0
        public static EntitiesDescriptor GetEntitiesDescriptor()
        {
            var descriptor = new EntitiesDescriptor();
            var entityDesc = EntityDescriptorProviderMock.GetEntityDescriptor();

            descriptor.ChildEntities.Add(entityDesc);
            return(descriptor);
        }
コード例 #2
0
        public static EntityDescriptor GetSpEntityDescriptor(string entityId)
        {
            var descriptor = new EntityDescriptor(new EntityId(entityId));
            var cert       = EntityDescriptorProviderMock.GetMockCertificate();
            var idpRole    = new ServiceProviderSingleSignOnDescriptor();

            idpRole.AssertionConsumerServices.Add(0, new IndexedProtocolEndpoint(0, new Uri(ProtocolBindings.HttpRedirect), new Uri("http://localhost:60879")));
            descriptor.RoleDescriptors.Add(idpRole);
            return(descriptor);
        }
コード例 #3
0
        public static EntityDescriptor GetEntityDescriptor()
        {
            var descriptor = new EntityDescriptor();
            var cert       = EntityDescriptorProviderMock.GetMockCertificate();
            var idpRole    = new IdentityProviderSingleSignOnDescriptor();

            idpRole.SingleSignOnServices.Add(new ProtocolEndpoint(new Uri(ProtocolBindings.HttpRedirect), new Uri("http://localhost:60879")));
            descriptor.RoleDescriptors.Add(idpRole);
            return(descriptor);
        }
コード例 #4
0
        public static EntityDescriptor GetIdpEntityDescriptor(string entityId)
        {
            var descriptor = new EntityDescriptor(new EntityId(entityId));
            var cert       = EntityDescriptorProviderMock.GetMockCertificate();
            var idpRole    = new IdentityProviderSingleSignOnDescriptor();

            idpRole.ProtocolsSupported.Add(new Uri("urn:oasis:names:tc:SAML:2.0:protocol"));
            idpRole.SingleSignOnServices.Add(new ProtocolEndpoint(new Uri(ProtocolBindings.HttpRedirect), new Uri("http://localhost:60879")));
            descriptor.RoleDescriptors.Add(idpRole);
            return(descriptor);
        }
コード例 #5
0
        public static EntitiesDescriptor GetEntitiesDescriptor(int idpEntities, int spEntities)
        {
            var descriptor = new EntitiesDescriptor();

            for (var i = 0; i < idpEntities; i++)
            {
                var entityDesc = EntityDescriptorProviderMock.GetIdpEntityDescriptor(String.Format("IdpEntityId_{0}", i));
                descriptor.ChildEntities.Add(entityDesc);
            }

            for (var i = 0; i < spEntities; i++)
            {
                var entityDesc = EntityDescriptorProviderMock.GetSpEntityDescriptor(String.Format("SPEntityId_{0}", i));
                descriptor.ChildEntities.Add(entityDesc);
            }
            return(descriptor);
        }
コード例 #6
0
        public override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var entity     = EntityDescriptorProviderMock.GetIdpEntityDescriptor("IdpEntity");
            var serialiser = new MetadataSerializer();
            var sb         = new StringBuilder();

            using (var writer = XmlWriter.Create(sb))
            {
                serialiser.WriteMetadata(writer, entity);
                writer.Flush();
                HttpClientMock.Metadata = sb.ToString();
                var content = new StreamContent(new MemoryStream(Encoding.UTF8.GetBytes(HttpClientMock.Metadata)));
                var message = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = content
                };
                return(message);
            }
        }