internal static void BuildContacts(ICollection <System.IdentityModel.Metadata.ContactPerson> contacts, OrganisationConfiguration organisationConfiguration)
        {
            if (contacts == null)
            {
                throw new ArgumentNullException("contacts");
            }
            if (organisationConfiguration == null || organisationConfiguration.OrganisationContacts == null || organisationConfiguration.OrganisationContacts.PersonContact == null)
            {
                return;
            }

            organisationConfiguration.OrganisationContacts.PersonContact.Aggregate(contacts, (c, next) =>
            {
                System.IdentityModel.Metadata.ContactType contactType;
                if (!Enum.TryParse <System.IdentityModel.Metadata.ContactType>(next.ContactType.ToString(), out contactType))
                {
                    throw new InvalidCastException(String.Format("No corespondenting value for Contact type: {0}.", next.ContactType));
                }
                var cp = new System.IdentityModel.Metadata.ContactPerson(contactType)
                {
                    Surname   = next.SurName,
                    GivenName = next.ForeName,
                };
                next.Emails.Aggregate(cp.EmailAddresses, (p, nextEmail) => { p.Add(nextEmail); return(p); });
                next.PhoneNumbers.Aggregate(cp.TelephoneNumbers, (p, nextNumber) => { p.Add(nextNumber); return(p); });
                c.Add(cp);
                return(c);
            });
        }
コード例 #2
0
ファイル: StubFactory.cs プロジェクト: Raschmann/authservices
        private static void AddContacts(SPOptions options)
        {
            var supportContact = new ContactPerson(ContactType.Support)
            {
                Company = "Kentor",
                GivenName = "Anders",
                Surname = "Abel",
            };

            supportContact.TelephoneNumbers.Add("+46 8 587 650 00");
            supportContact.TelephoneNumbers.Add("+46 708 96 50 63");
            supportContact.EmailAddresses.Add("*****@*****.**");
            supportContact.EmailAddresses.Add("*****@*****.**");

            options.Contacts.Add(supportContact);
            options.Contacts.Add(new ContactPerson(ContactType.Technical)); // Deliberately void of info.
        }
コード例 #3
0
        public void KentorAuthServicesSection_Contacts_LoadedFromConfig()
        {
            var subject = KentorAuthServicesSection.Current.Contacts;

            var expected = StubFactory.CreateSPOptions().Contacts;

            // The config file only supports one phone number and one e-mail for each
            // contact, so let's remove the other ones that are added by the stub factory.
            expected.First().TelephoneNumbers.Remove(expected.First().TelephoneNumbers.First());
            expected.First().EmailAddresses.Remove(expected.First().EmailAddresses.First());

            var secondTech = new ContactPerson(ContactType.Technical);
            secondTech.EmailAddresses.Add("*****@*****.**");
            expected.Add(secondTech);

            subject.ShouldBeEquivalentTo(expected);
        }
コード例 #4
0
        private static SPOptions CreateSPOptions()
        {
            var swedish = CultureInfo.GetCultureInfo("sv-se");

            var organization = new Organization();
            organization.Names.Add(new LocalizedName("Kentor", swedish));
            organization.DisplayNames.Add(new LocalizedName("Kentor IT AB", swedish));
            organization.Urls.Add(new LocalizedUri(new Uri("http://www.kentor.se"), swedish));

            var spOptions = new SPOptions
            {
                EntityId = new EntityId("http://*****:*****@example.com");
            spOptions.Contacts.Add(techContact);

            var supportContact = new ContactPerson
            {
                Type = ContactType.Support
            };
            supportContact.EmailAddresses.Add("*****@*****.**");
            spOptions.Contacts.Add(supportContact);

            var attributeConsumingService = new AttributeConsumingService("AuthServices")
            {
                IsDefault = true,
            };

            attributeConsumingService.RequestedAttributes.Add(
                new RequestedAttribute("urn:someName")
                {
                    FriendlyName = "Some Name",
                    IsRequired = true,
                    NameFormat = RequestedAttribute.AttributeNameFormatUri
                });

            attributeConsumingService.RequestedAttributes.Add(
                new RequestedAttribute("Minimal"));

            spOptions.AttributeConsumingServices.Add(attributeConsumingService);

            spOptions.SystemIdentityModelIdentityConfiguration.AudienceRestriction.AudienceMode
                = AudienceUriMode.Never;

            return spOptions;
        }