protected internal void ApplyConfiguration(ClientCredentials cb) { cb.SupportInteractive = SupportInteractive; // how is "Type" used? // ClientCertificate if (!String.IsNullOrEmpty(ClientCertificate.FindValue)) { cb.ClientCertificate.SetCertificate(ClientCertificate.StoreLocation, ClientCertificate.StoreName, ClientCertificate.X509FindType, ClientCertificate.FindValue); } // HttpDigest if (HttpDigest.ImpersonationLevel != TokenImpersonationLevel.None) { throw new NotImplementedException(); } // IssuedToken var bi = cb.IssuedToken; var ci = IssuedToken; bi.CacheIssuedTokens = ci.CacheIssuedTokens; bi.DefaultKeyEntropyMode = ci.DefaultKeyEntropyMode; bi.IssuedTokenRenewalThresholdPercentage = ci.IssuedTokenRenewalThresholdPercentage; foreach (IssuedTokenClientBehaviorsElement ccb in ci.IssuerChannelBehaviors) { bi.IssuerChannelBehaviors.Add(new Uri(ccb.IssuerAddress, UriKind.RelativeOrAbsolute), ConfigUtil.CreateEndpointBehaviors(ccb.BehaviorConfiguration)); } bi.LocalIssuerAddress = ci.LocalIssuer.CreateInstance(); bi.LocalIssuerBinding = ConfigUtil.CreateBinding(ci.LocalIssuer.Binding, ci.LocalIssuer.BindingConfiguration); bi.MaxIssuedTokenCachingTime = ci.MaxIssuedTokenCachingTime; // Peer if (!String.IsNullOrEmpty(Peer.Certificate.FindValue)) { cb.Peer.SetCertificate(Peer.Certificate.StoreLocation, Peer.Certificate.StoreName, Peer.Certificate.X509FindType, Peer.Certificate.FindValue); } // cb.Peer.MeshPassword = /* cannot fill it here */ cb.Peer.MessageSenderAuthentication.CustomCertificateValidator = (X509CertificateValidator)CreateInstance(Peer.MessageSenderAuthentication.CustomCertificateValidatorType); cb.Peer.MessageSenderAuthentication.CertificateValidationMode = Peer.MessageSenderAuthentication.CertificateValidationMode; cb.Peer.MessageSenderAuthentication.RevocationMode = Peer.MessageSenderAuthentication.RevocationMode; cb.Peer.MessageSenderAuthentication.TrustedStoreLocation = Peer.MessageSenderAuthentication.TrustedStoreLocation; cb.Peer.PeerAuthentication.CustomCertificateValidator = (X509CertificateValidator)CreateInstance(Peer.PeerAuthentication.CustomCertificateValidatorType); cb.Peer.PeerAuthentication.CertificateValidationMode = Peer.PeerAuthentication.CertificateValidationMode; cb.Peer.PeerAuthentication.RevocationMode = Peer.PeerAuthentication.RevocationMode; cb.Peer.PeerAuthentication.TrustedStoreLocation = Peer.PeerAuthentication.TrustedStoreLocation; // ServiceCertificate var bsc = cb.ServiceCertificate; var csc = ServiceCertificate; var bsca = bsc.Authentication; var csca = csc.Authentication; bsc.DefaultCertificate = csc.DefaultCertificate.CreateInstance(); bsca.CertificateValidationMode = csca.CertificateValidationMode; if (csca.CustomCertificateValidatorType != null) { bsca.CustomCertificateValidator = (X509CertificateValidator)CreateInstance(csca.CustomCertificateValidatorType); } bsca.RevocationMode = csca.RevocationMode; bsca.TrustedStoreLocation = csca.TrustedStoreLocation; foreach (X509ScopedServiceCertificateElement sce in ServiceCertificate.ScopedCertificates) { bsc.ScopedCertificates.Add(sce.TargetUri, sce.CreateInstance()); } // cb.UserNamePassword : not configurable ... // Windows cb.Windows.AllowedImpersonationLevel = Windows.AllowedImpersonationLevel; cb.Windows.AllowNtlm = Windows.AllowNtlm; }
// it was extraneous... internal EndpointIdentity Create() { return(ConfigUtil.CreateInstance(this)); }
protected internal override object CreateBehavior() { var b = new ServiceAuthorizationBehavior(); if (!String.IsNullOrEmpty(ServiceAuthorizationManagerType)) { b.ServiceAuthorizationManager = (ServiceAuthorizationManager)Activator.CreateInstance(ConfigUtil.GetTypeFromConfigString(ServiceAuthorizationManagerType, NamedConfigCategory.None)); } foreach (var apte in AuthorizationPolicies) { throw new NotImplementedException(); } if (!String.IsNullOrEmpty(RoleProviderName)) { throw new NotImplementedException(); } b.ImpersonateCallerForAllOperations = ImpersonateCallerForAllOperations; b.PrincipalPermissionMode = PrincipalPermissionMode; return(b); }
X509Certificate2 GetCertificate(StoreLocation storeLocation, StoreName storeName, X509FindType findType, object findValue) { return(ConfigUtil.CreateCertificateFrom(storeLocation, storeName, findType, findValue)); }