Beispiel #1
0
 // Methods
 internal void ApplyConfiguration(FederatedMessageSecurityOverHttp s)
 {
     s.AlgorithmSuite = AlgorithmSuite;
     foreach (ClaimTypeElement cte in ClaimTypeRequirements)
     {
         s.ClaimTypeRequirements.Add(cte.Create());
     }
     s.EstablishSecurityContext = EstablishSecurityContext;
     s.IssuedKeyType            = IssuedKeyType;
     s.IssuedTokenType          = IssuedTokenType;
     if (Issuer.Address != null)
     {
         s.IssuerAddress = new EndpointAddress(Issuer.Address, Issuer.Identity.Create(), Issuer.Headers.Headers);
     }
     if (!String.IsNullOrEmpty(Issuer.Binding))
     {
         s.IssuerBinding = ConfigUtil.CreateBinding(Issuer.Binding, Issuer.BindingConfiguration);
     }
     if (IssuerMetadata.Address != null)
     {
         s.IssuerMetadataAddress = new EndpointAddress(IssuerMetadata.Address, IssuerMetadata.Identity.Create(), IssuerMetadata.Headers.Headers);
     }
     s.NegotiateServiceCredential = NegotiateServiceCredential;
     foreach (XmlElementElement xee in TokenRequestParameters)
     {
         s.TokenRequestParameters.Add(xee.XmlElement);
     }
 }
        public static Binding GetBindingByProtocolMapping(Uri address)
        {
            ProtocolMappingElement el = ConfigUtil.ProtocolMappingSection.ProtocolMappingCollection [address.Scheme];

            if (el == null)
            {
                return(null);
            }
            return(ConfigUtil.CreateBinding(el.Binding, el.BindingConfiguration));
        }
        protected internal override object CreateBehavior()
        {
            ServiceMetadataBehavior b = new ServiceMetadataBehavior();

            b.HttpGetEnabled  = HttpGetEnabled;
            b.HttpsGetEnabled = HttpsGetEnabled;
            b.HttpGetUrl      = HttpGetUrl;
            b.HttpsGetUrl     = HttpsGetUrl;
            if (!String.IsNullOrEmpty(HttpGetBinding))
            {
                b.HttpGetBinding = ConfigUtil.CreateBinding(HttpGetBinding, HttpGetBindingConfiguration);
            }
            if (!String.IsNullOrEmpty(HttpsGetBinding))
            {
                b.HttpsGetBinding = ConfigUtil.CreateBinding(HttpsGetBinding, HttpsGetBindingConfiguration);
            }
            return(b);
        }
        protected internal override object CreateBehavior()
        {
            var ret = new ServiceDebugBehavior()
            {
                HttpHelpPageEnabled            = HttpHelpPageEnabled,
                HttpsHelpPageEnabled           = HttpsHelpPageEnabled,
                HttpHelpPageUrl                = HttpHelpPageUrl,
                HttpsHelpPageUrl               = HttpsHelpPageUrl,
                IncludeExceptionDetailInFaults = IncludeExceptionDetailInFaults,
            };

            if (!String.IsNullOrEmpty(HttpHelpPageBinding))
            {
                ret.HttpHelpPageBinding = ConfigUtil.CreateBinding(HttpHelpPageBinding, HttpHelpPageBindingConfiguration);
            }
            if (!String.IsNullOrEmpty(HttpsHelpPageBinding))
            {
                ret.HttpsHelpPageBinding = ConfigUtil.CreateBinding(HttpsHelpPageBinding, HttpsHelpPageBindingConfiguration);
            }
            return(ret);
        }
Beispiel #5
0
        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;
        }