protected override ApplicationServiceDescriptor BuildDescriptorInternal(RoleDescriptorConfiguration 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 appDescriptor = new ApplicationServiceDescriptor(); appDescriptor.ServiceDescription = "http://localhost:8080/idp/status"; //appDescriptor.Keys.Add(GetSigningKeyDescriptor()); //appDescriptor.PassiveRequestorEndpoints.Add(new EndpointReference("http://docs.oasis-open.org/wsfed/federation/200706")); //appDescriptor.TokenTypesOffered.Add(new Uri(TokenTypes.OasisWssSaml11TokenProfile11)); //appDescriptor.TokenTypesOffered.Add(new Uri(TokenTypes.OasisWssSaml2TokenProfile11)); //ClaimsRepository.GetSupportedClaimTypes().ToList().ForEach(claimType => appDescriptor.ClaimTypesOffered.Add(new DisplayClaim(claimType))); appDescriptor.ProtocolsSupported.Add(new Uri("http://docs.oasis-open.org/wsfed/federation/200706")); return(appDescriptor); //descriptor.ProtocolsSupported.Add(new Uri("http://docs.oasis-open.org/wsfed/federation/200706")); //foreach (var sso in idpConfiguration.SingleSignOnServices) //{ // var singleSignOnService = new ProtocolEndpoint(new Uri(sso.Binding), new Uri(sso.Location)); // descriptor.SingleSignOnServices.Add(singleSignOnService); //} //return descriptor; }
internal static void BuildContacts(RoleDescriptor roleDescriptor, RoleDescriptorConfiguration roleDescriptorConfiguration) { if (roleDescriptor == null) { throw new ArgumentNullException("roleDescriptor"); } if (roleDescriptorConfiguration == null) { throw new ArgumentNullException("roleDescriptorConfiguration"); } var contacts = roleDescriptorConfiguration.Organisation.OrganisationContacts.PersonContact; contacts.Aggregate(roleDescriptor.Contacts, (c, next) => { ContactType contactType; if (!Enum.TryParse <ContactType>(next.ContactType.ToString(), out contactType)) { throw new InvalidCastException(String.Format("No corespondenting value for Contact type: {0}.", next.ContactType)); } var cp = new 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); }); }
internal static void BuildOrganisation(RoleDescriptor roleDescriptor, RoleDescriptorConfiguration roleDescriptorConfiguration) { if (roleDescriptor == null) { throw new ArgumentNullException("roleDescriptor"); } if (roleDescriptorConfiguration == null) { throw new ArgumentNullException("roleDescriptorConfiguration"); } var organisationConfigration = roleDescriptorConfiguration.Organisation; if (organisationConfigration == null) { return; } roleDescriptor.Organization = new Organization(); organisationConfigration.Names.Aggregate(roleDescriptor.Organization, (o, next) => { o.Names.Add(new LocalizedName(next.Name, next.Language)); o.DisplayNames.Add(new LocalizedName(next.DisplayName, next.Language)); return(o); }); organisationConfigration.Urls.Aggregate(roleDescriptor.Organization, (o, next) => { o.Urls.Add(new LocalizedUri(next.Url, next.Language)); return(o); }); }
protected override void BuildInternal(RoleDescriptor descriptor, RoleDescriptorConfiguration configuration) { if (configuration.KeyDescriptors == null) { throw new ArgumentNullException("keyDescriptors"); } foreach (var key in configuration.KeyDescriptors) { var certConfiguration = new X509StoreCertificateConfiguration(key.CertificateContext); var certificate = certConfiguration.GetX509Certificate2(); var keyDescriptor = new KeyDescriptor(); KeyType keyType; if (!Enum.TryParse <KeyType>(key.Use.ToString(), out keyType)) { throw new InvalidCastException(String.Format("Parsing to type{0} failed. Value having been tried:{1}", typeof(KeyType), key.Use)); } keyDescriptor.Use = keyType; keyDescriptor.KeyInfo = new SecurityKeyIdentifier(new X509RawDataKeyIdentifierClause(certificate)); descriptor.Keys.Add(keyDescriptor); } }
public TRole BuildDescriptor(RoleDescriptorConfiguration configuration) { var descriptor = this.BuildDescriptorInternal(configuration); descriptor = this.BuildAll(descriptor, configuration); return(descriptor); }
public static RoleDescriptor ResolveAndBuild(RoleDescriptorConfiguration configuration) { var descriptor = DescriptorBuildersHelper.ResolveDescriptor(configuration.RoleDescriptorType); var del = DescriptorBuildersHelper.GetDescriptorDelegate(configuration.RoleDescriptorType); return(del(descriptor, configuration)); }
protected override void BuildInternal(RoleDescriptor descriptor, RoleDescriptorConfiguration configuration) { if (configuration.Organisation == null) { throw new ArgumentNullException("organisation"); } SSODescriptorBuilderHelper.BuildOrganisation(descriptor, configuration); }
protected override void BuildInternal(RoleDescriptor descriptor, RoleDescriptorConfiguration configuration) { if (configuration.Organisation == null) { return; } SSODescriptorBuilderHelper.BuildOrganisation(descriptor, configuration); }
private TRole BuildAll(RoleDescriptor descriptor, RoleDescriptorConfiguration configuration) { var builders = MemberBuilderFactory.GetBuilders(); builders.Aggregate(descriptor, (d, next) => { next.Build(descriptor, configuration); return(descriptor); }); return((TRole)descriptor); }
protected override void BuildInternal(RoleDescriptor descriptor, RoleDescriptorConfiguration configuration) { if (configuration.ProtocolSupported == null) { throw new ArgumentNullException("protocolSupported"); } configuration.ProtocolSupported.Aggregate(descriptor.ProtocolsSupported, (t, next) => { t.Add(next); return(t); }); }
protected override void BuildInternal(RoleDescriptor descriptor, RoleDescriptorConfiguration configuration) { if (configuration.Organisation == null) { return; } Organization organisation; if (SSODescriptorBuilderHelper.TryBuildOrganisation(configuration.Organisation, out organisation)) { descriptor.Organization = organisation; } }
public virtual void Build(RoleDescriptor descriptor, RoleDescriptorConfiguration configuration) { if (descriptor == null) { throw new ArgumentNullException("descriptor"); } if (configuration == null) { throw new ArgumentNullException("configuration"); } this.BuildInternal(descriptor, configuration); }
protected override void BuildInternal(RoleDescriptor descriptor, RoleDescriptorConfiguration configuration) { var sSODescriptorConfiguration = configuration as SSODescriptorConfiguration; if (sSODescriptorConfiguration == null) { throw new InvalidOperationException(String.Format("Configuration type expected: {0}.", typeof(SSODescriptorConfiguration).Name)); } if (sSODescriptorConfiguration.ArtifactResolutionServices == null) { throw new ArgumentNullException("crtifactResolutionServices"); } sSODescriptorConfiguration.ArtifactResolutionServices.Aggregate(descriptor, (d, next) => { ((SingleSignOnDescriptor)d).ArtifactResolutionServices.Add(next.Index, new IndexedProtocolEndpoint(next.Index, next.Binding, next.Location)); return(d); }); }
protected override void BuildInternal(RoleDescriptor descriptor, RoleDescriptorConfiguration configuration) { var sSODescriptorConfiguration = configuration as SSODescriptorConfiguration; if (sSODescriptorConfiguration == null) { throw new InvalidOperationException(String.Format("Configuration type expected: {0}.", typeof(SSODescriptorConfiguration).Name)); } if (sSODescriptorConfiguration.NameIdentifierFormats == null) { throw new ArgumentNullException("singleLogoutServices"); } sSODescriptorConfiguration.NameIdentifierFormats.Aggregate(descriptor, (d, next) => { ((SingleSignOnDescriptor)d).NameIdentifierFormats.Add(next); return(d); }); }
protected override IdentityProviderSingleSignOnDescriptor BuildDescriptorInternal(RoleDescriptorConfiguration configuration) { var idpConfiguration = configuration as IdPSSODescriptorConfiguration; if (idpConfiguration == null) { throw new InvalidCastException(string.Format("Expected type: {0} but was: {1}", typeof(IdPSSODescriptorConfiguration).Name, configuration.GetType().Name)); } var descriptor = new IdentityProviderSingleSignOnDescriptor { WantAuthenticationRequestsSigned = true }; idpConfiguration.SignOnServices.Aggregate(descriptor, (d, next) => { d.SingleSignOnServices.Add(new ProtocolEndpoint(next.Binding, next.Location)); return(d); }); return(descriptor); }
protected override ServiceProviderSingleSignOnDescriptor BuildDescriptorInternal(RoleDescriptorConfiguration configuration) { var spConfiguration = configuration as SPSSODescriptorConfiguration; if (spConfiguration == null) { throw new InvalidCastException(string.Format("Expected type: {0} but was: {1}", typeof(SPSSODescriptorConfiguration).Name, configuration.GetType().Name)); } var descriptor = new ServiceProviderSingleSignOnDescriptor { WantAssertionsSigned = spConfiguration.WantAssertionsSigned, AuthenticationRequestsSigned = spConfiguration.AuthenticationRequestsSigned }; foreach (var cs in spConfiguration.AssertionConsumerServices) { var consumerService = new IndexedProtocolEndpoint(cs.Index, cs.Binding, cs.Location) { IsDefault = cs.IsDefault }; descriptor.AssertionConsumerServices.Add(cs.Index, consumerService); } return(descriptor); }
protected abstract void BuildInternal(RoleDescriptor descriptor, RoleDescriptorConfiguration configuration);
protected abstract TRole BuildDescriptorInternal(RoleDescriptorConfiguration configuration);
protected override void BuildInternal(RoleDescriptor descriptor, RoleDescriptorConfiguration configuration) { descriptor.ErrorUrl = configuration.ErrorUrl; descriptor.ValidUntil = configuration.ValidUntil.DateTime; }