コード例 #1
0
        public async Task Start()
        {
            this._client.ReceiveBufferSize = 65536;
            this._client.SendBufferSize    = 65536;
            this._listener.AddConnection(this);
            try
            {
                this._stream = new NegotiateStream(this._client.GetStream());
                ExtendedProtectionPolicy policy = new ExtendedProtectionPolicy(PolicyEnforcement.Never);
                NetworkCredential        nc     = new NetworkCredential();
                await this._stream.AuthenticateAsServerAsync(nc, ProtectionLevel.EncryptAndSign, TokenImpersonationLevel.Identification);

                await this.Read();
            }
            catch (AuthenticationException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (ObjectDisposedException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                this.Dispose();
            }
        }
コード例 #2
0
 public virtual Task AuthenticateAsServerAsync(
     NetworkCredential credential, ExtendedProtectionPolicy policy,
     ProtectionLevel requiredProtectionLevel,
     TokenImpersonationLevel requiredImpersonationLevel)
 {
     throw new NotImplementedException();
 }
コード例 #3
0
ファイル: _NegoState.cs プロジェクト: dox0/DotNet471RS3
        //
        //
        //
        internal void ValidateCreateContext(string package,
                                            NetworkCredential credential,
                                            string servicePrincipalName,
                                            ExtendedProtectionPolicy policy,
                                            ProtectionLevel protectionLevel,
                                            TokenImpersonationLevel impersonationLevel)
        {
            if (policy != null)
            {
                if (!AuthenticationManager.OSSupportsExtendedProtection)
                {
                    if (policy.PolicyEnforcement == PolicyEnforcement.Always)
                    {
                        throw new PlatformNotSupportedException(SR.GetString(SR.security_ExtendedProtection_NoOSSupport));
                    }
                }
                else
                {
                    // One of these must be set if EP is turned on
                    if (policy.CustomChannelBinding == null && policy.CustomServiceNames == null)
                    {
                        throw new ArgumentException(SR.GetString(SR.net_auth_must_specify_extended_protection_scheme), "policy");
                    }
                }

                _ExtendedProtectionPolicy = policy;
            }
            else
            {
                _ExtendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never);
            }

            ValidateCreateContext(package, true, credential, servicePrincipalName, _ExtendedProtectionPolicy.CustomChannelBinding, protectionLevel, impersonationLevel);
        }
コード例 #4
0
        internal SecurityProtocolFactory(SecurityProtocolFactory factory) : this()
        {
            if (factory == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(factory));
            }

            this.actAsInitiator         = factory.actAsInitiator;
            this.addTimestamp           = factory.addTimestamp;
            this.detectReplays          = factory.detectReplays;
            this.incomingAlgorithmSuite = factory.incomingAlgorithmSuite;
            this.maxCachedNonces        = factory.maxCachedNonces;
            this.maxClockSkew           = factory.maxClockSkew;
            this.outgoingAlgorithmSuite = factory.outgoingAlgorithmSuite;
            this.replayWindow           = factory.replayWindow;
            this.channelSupportingTokenAuthenticatorSpecification = new Collection <SupportingTokenAuthenticatorSpecification>(new List <SupportingTokenAuthenticatorSpecification>(factory.channelSupportingTokenAuthenticatorSpecification));
            this.scopedSupportingTokenAuthenticatorSpecification  = new Dictionary <string, ICollection <SupportingTokenAuthenticatorSpecification> >(factory.scopedSupportingTokenAuthenticatorSpecification);
            this.standardsManager          = factory.standardsManager;
            this.timestampValidityDuration = factory.timestampValidityDuration;
            // this.auditLogLocation = factory.auditLogLocation;
            this.suppressAuditFailure = factory.suppressAuditFailure;
            // this.serviceAuthorizationAuditLevel = factory.serviceAuthorizationAuditLevel;
            // this.messageAuthenticationAuditLevel = factory.messageAuthenticationAuditLevel;
            if (factory.securityBindingElement != null)
            {
                this.securityBindingElement = (SecurityBindingElement)factory.securityBindingElement.Clone();
            }
            this.securityTokenManager     = factory.securityTokenManager;
            this.privacyNoticeUri         = factory.privacyNoticeUri;
            this.privacyNoticeVersion     = factory.privacyNoticeVersion;
            this.endpointFilterTable      = factory.endpointFilterTable;
            this.extendedProtectionPolicy = factory.extendedProtectionPolicy;
            this.nonceCache = factory.nonceCache;
        }
        private ExtendedProtectionPolicy SelectExtendedProtectionPolicy(HttpListenerRequest request)
        {
            ExtendedProtectionPolicy extendedProtectionPolicy = null;
            ExtendedProtectionPolicy policy2;

            try
            {
                HttpChannelListener listener;
                if (base.TryLookupUri(request.Url, request.HttpMethod, base.HostNameComparisonMode, out listener))
                {
                    extendedProtectionPolicy = listener.ExtendedProtectionPolicy;
                }
                else
                {
                    extendedProtectionPolicy = ChannelBindingUtility.DisabledPolicy;
                }
                policy2 = extendedProtectionPolicy;
            }
            catch (Exception exception)
            {
                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Error);
                throw;
            }
            return(policy2);
        }
コード例 #6
0
        ExtendedProtectionPolicy SelectExtendedProtectionPolicy(HttpListenerRequest request)
        {
            ExtendedProtectionPolicy result = null;

            try
            {
                HttpChannelListener channelListener;
                if (base.TryLookupUri(request.Url, request.HttpMethod,
                                      this.HostNameComparisonMode, request.IsWebSocketRequest, out channelListener))
                {
                    result = channelListener.ExtendedProtectionPolicy;
                }
                else
                {
                    //if the listener isn't found, then the auth scheme will be anonymous
                    //(see SelectAuthenticationScheme function) and will fall through to the
                    //404 Not Found code path, so it doesn't really matter what we return from here...
                    result = ChannelBindingUtility.DisabledPolicy;
                }

                return(result);
            }
            catch (Exception e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Error);
                throw;
            }
        }
コード例 #7
0
        internal void ValidateCreateContext(
            string package,
            NetworkCredential credential,
            string servicePrincipalName,
            ExtendedProtectionPolicy policy,
            ProtectionLevel protectionLevel,
            TokenImpersonationLevel impersonationLevel)
        {
            if (policy != null)
            {
                // One of these must be set if EP is turned on
                if (policy.CustomChannelBinding == null && policy.CustomServiceNames == null)
                {
                    throw new ArgumentException(SR.net_auth_must_specify_extended_protection_scheme, nameof(policy));
                }

                _extendedProtectionPolicy = policy;
            }
            else
            {
                _extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never);
            }

            ValidateCreateContext(package, true, credential, servicePrincipalName, _extendedProtectionPolicy.CustomChannelBinding, protectionLevel, impersonationLevel);
        }
コード例 #8
0
 public HttpTransportSecurity()
 {
     _clientCredentialType = DefaultClientCredentialType;
     _proxyCredentialType  = DefaultProxyCredentialType;
     Realm = DefaultRealm;
     _extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy;
 }
コード例 #9
0
 protected HttpTransportBindingElement(HttpTransportBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
     AllowCookies                = elementToBeCloned.AllowCookies;
     AuthenticationScheme        = elementToBeCloned.AuthenticationScheme;
     BypassProxyOnLocal          = elementToBeCloned.BypassProxyOnLocal;
     _decompressionEnabled       = elementToBeCloned._decompressionEnabled;
     _hostNameComparisonMode     = elementToBeCloned._hostNameComparisonMode;
     _inheritBaseAddressSettings = elementToBeCloned.InheritBaseAddressSettings;
     KeepAliveEnabled            = elementToBeCloned.KeepAliveEnabled;
     _maxBufferSize              = elementToBeCloned._maxBufferSize;
     _maxBufferSizeInitialized   = elementToBeCloned._maxBufferSizeInitialized;
     _maxPendingAccepts          = elementToBeCloned._maxPendingAccepts;
     _method      = elementToBeCloned._method;
     Proxy        = elementToBeCloned.Proxy;
     ProxyAddress = elementToBeCloned.ProxyAddress;
     _proxyAuthenticationScheme = elementToBeCloned._proxyAuthenticationScheme;
     _realm = elementToBeCloned._realm;
     _requestInitializationTimeout = elementToBeCloned._requestInitializationTimeout;
     _transferMode = elementToBeCloned._transferMode;
     UnsafeConnectionNtlmAuthentication = elementToBeCloned.UnsafeConnectionNtlmAuthentication;
     _useDefaultWebProxy       = elementToBeCloned._useDefaultWebProxy;
     _webSocketSettings        = elementToBeCloned._webSocketSettings.Clone();
     _extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy;
     MessageHandlerFactory     = elementToBeCloned.MessageHandlerFactory;
 }
コード例 #10
0
ファイル: NegotiateStream.cs プロジェクト: must/dotnet-corefx
 public virtual Task AuthenticateAsServerAsync(
     NetworkCredential credential, ExtendedProtectionPolicy policy,
     ProtectionLevel requiredProtectionLevel,
     TokenImpersonationLevel requiredImpersonationLevel)
 {
     return(Task.Factory.FromAsync((callback, state) => BeginAuthenticateAsServer(credential, policy, requiredProtectionLevel, requiredImpersonationLevel, callback, state), EndAuthenticateAsClient, null));
 }
コード例 #11
0
 /// <summary>
 /// Called by servers to authenticate the client, and optionally the server, in a client-server connection. The authentication process uses the specified server credentials, authentication options, and extended protection policy.
 /// </summary>
 /// <param name="credential">The NetworkCredential that is used to establish the identity of the client.</param>
 /// <param name="policy">The ExtendedProtectionPolicy that is used for extended protection.</param>
 /// <param name="requiredProtectionLevel">One of the ProtectionLevel values, indicating the security services for the stream.</param>
 /// <param name="requiredImpersonationLevel">One of the TokenImpersonationLevel values, indicating how the server can use the client's credentials to access resources.</param>
 public VaserKerberosServer(NetworkCredential credential, ExtendedProtectionPolicy policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel)
 {
     _credential = credential;
     _requiredProtectionLevel    = requiredProtectionLevel;
     _requiredImpersonationLevel = requiredImpersonationLevel;
     _policy = policy;
 }
コード例 #12
0
 public TcpTransportSecurity()
 {
     _clientCredentialType     = DefaultClientCredentialType;
     _protectionLevel          = DefaultProtectionLevel;
     _extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy;
     _sslProtocols             = TransportDefaults.SslProtocols;
 }
コード例 #13
0
        //does not validate the ExtendedProtectionPolicy.CustomServiceNames collections on the policies
        public static bool AreEqual(ExtendedProtectionPolicy policy1, ExtendedProtectionPolicy policy2)
        {
            Debug.Assert(policy1 != null, "policy1 param cannot be null");
            Debug.Assert(policy2 != null, "policy2 param cannot be null");

            if (policy1.PolicyEnforcement == PolicyEnforcement.Never && policy2.PolicyEnforcement == PolicyEnforcement.Never)
            {
                return(true);
            }

            if (policy1.PolicyEnforcement != policy2.PolicyEnforcement)
            {
                return(false);
            }

            if (policy1.ProtectionScenario != policy2.ProtectionScenario)
            {
                return(false);
            }

            if (policy1.CustomChannelBinding != policy2.CustomChannelBinding)
            {
                return(false);
            }

            return(true);
        }
コード例 #14
0
        internal SecurityProtocolFactory(SecurityProtocolFactory factory)
            : this()
        {
            if (factory == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("factory");
            }

            _actAsInitiator         = factory._actAsInitiator;
            _addTimestamp           = factory._addTimestamp;
            _detectReplays          = factory._detectReplays;
            _incomingAlgorithmSuite = factory._incomingAlgorithmSuite;
            _maxCachedNonces        = factory._maxCachedNonces;
            _maxClockSkew           = factory._maxClockSkew;
            _outgoingAlgorithmSuite = factory._outgoingAlgorithmSuite;
            _replayWindow           = factory._replayWindow;
            _channelSupportingTokenAuthenticatorSpecification = new Collection <SupportingTokenAuthenticatorSpecification>(new List <SupportingTokenAuthenticatorSpecification>(factory._channelSupportingTokenAuthenticatorSpecification));
            _scopedSupportingTokenAuthenticatorSpecification  = new Dictionary <string, ICollection <SupportingTokenAuthenticatorSpecification> >(factory._scopedSupportingTokenAuthenticatorSpecification);
            _standardsManager                = factory._standardsManager;
            _timestampValidityDuration       = factory._timestampValidityDuration;
            _auditLogLocation                = factory._auditLogLocation;
            _suppressAuditFailure            = factory._suppressAuditFailure;
            _serviceAuthorizationAuditLevel  = factory._serviceAuthorizationAuditLevel;
            _messageAuthenticationAuditLevel = factory._messageAuthenticationAuditLevel;
            if (factory._securityBindingElement != null)
            {
                _securityBindingElement = (SecurityBindingElement)factory._securityBindingElement.Clone();
            }
            _securityTokenManager     = factory._securityTokenManager;
            _privacyNoticeUri         = factory._privacyNoticeUri;
            _privacyNoticeVersion     = factory._privacyNoticeVersion;
            _extendedProtectionPolicy = factory._extendedProtectionPolicy;
            _nonceCache = factory._nonceCache;
        }
コード例 #15
0
        public void Constructor_PolicyEnforcement_MembersAreSet()
        {
            var extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never);

            Assert.Equal(PolicyEnforcement.Never, extendedProtectionPolicy.PolicyEnforcement);
            Assert.Equal(ProtectionScenario.TransportSelected, extendedProtectionPolicy.ProtectionScenario);
        }
コード例 #16
0
 protected HttpTransportBindingElement(HttpTransportBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
     this.allowCookies               = elementToBeCloned.allowCookies;
     this.authenticationScheme       = elementToBeCloned.authenticationScheme;
     this.bypassProxyOnLocal         = elementToBeCloned.bypassProxyOnLocal;
     this.decompressionEnabled       = elementToBeCloned.decompressionEnabled;
     this.hostNameComparisonMode     = elementToBeCloned.hostNameComparisonMode;
     this.inheritBaseAddressSettings = elementToBeCloned.InheritBaseAddressSettings;
     this.keepAliveEnabled           = elementToBeCloned.keepAliveEnabled;
     this.maxBufferSize              = elementToBeCloned.maxBufferSize;
     this.maxBufferSizeInitialized   = elementToBeCloned.maxBufferSizeInitialized;
     this.maxPendingAccepts          = elementToBeCloned.maxPendingAccepts;
     this.method       = elementToBeCloned.method;
     this.proxyAddress = elementToBeCloned.proxyAddress;
     this.proxyAuthenticationScheme = elementToBeCloned.proxyAuthenticationScheme;
     this.realm = elementToBeCloned.realm;
     this.requestInitializationTimeout = elementToBeCloned.requestInitializationTimeout;
     this.transferMode = elementToBeCloned.transferMode;
     this.unsafeConnectionNtlmAuthentication = elementToBeCloned.unsafeConnectionNtlmAuthentication;
     this.useDefaultWebProxy       = elementToBeCloned.useDefaultWebProxy;
     this.webSocketSettings        = elementToBeCloned.webSocketSettings.Clone();
     this.webProxy                 = elementToBeCloned.webProxy;
     this.extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy;
     if (elementToBeCloned.anonymousUriPrefixMatcher != null)
     {
         this.anonymousUriPrefixMatcher = new HttpAnonymousUriPrefixMatcher(elementToBeCloned.anonymousUriPrefixMatcher);
     }
     this.MessageHandlerFactory = elementToBeCloned.MessageHandlerFactory;
 }
コード例 #17
0
        public void HttpTransportSecurity_DisableTransportAuthentication()
        {
            ExtendedProtectionPolicy policy   = new ExtendedProtectionPolicy(PolicyEnforcement.Never);
            HttpTransportSecurity    security = new HttpTransportSecurity()
            {
                ClientCredentialType = HttpClientCredentialType.Basic,
                ProxyCredentialType  = HttpProxyCredentialType.Basic,
                Realm = "MyRealm",
                ExtendedProtectionPolicy = policy
            };
            HttpTransportBindingElement binding = new HttpTransportBindingElement();

            // first configure it
            security.ConfigureTransportAuthentication(binding);

            Assert.AreEqual(AuthenticationSchemes.Basic, binding.AuthenticationScheme, "AuthenticationScheme failed to init");
            Assert.AreEqual(AuthenticationSchemes.Basic, binding.ProxyAuthenticationScheme, "ProxyAuthenticationScheme failed to init");
            Assert.AreEqual("MyRealm", binding.Realm, "Realm failed to init");
            Assert.AreEqual(policy, binding.ExtendedProtectionPolicy, "ExtendedProtectionPolicy failed to init");

            // then disable it
            security.DisableTransportAuthentication(binding);

            Assert.AreEqual(AuthenticationSchemes.Anonymous, binding.AuthenticationScheme, "AuthenticationScheme failed to init");
            Assert.AreEqual(AuthenticationSchemes.Anonymous, binding.ProxyAuthenticationScheme, "ProxyAuthenticationScheme failed to init");
            Assert.AreEqual(string.Empty, binding.Realm, "Realm failed to init");
            Assert.AreEqual(policy, binding.ExtendedProtectionPolicy, "ExtendedProtectionPolicy failed to init");
        }
        internal KerberosReceiverSecurityToken(
            byte[] request,
            string id,
            bool doAuthenticate,
            string valueTypeUri,
            ChannelBinding channelBinding,
            ExtendedProtectionPolicy extendedProtectionPolicy)
        {
            if (request == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("request"));
            }
            if (id == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("id"));
            }

            this.id                       = id;
            this.request                  = request;
            this.valueTypeUri             = valueTypeUri;
            this.channelBinding           = channelBinding;
            this.extendedProtectionPolicy = extendedProtectionPolicy;

            if (doAuthenticate)
            {
                Initialize(null, channelBinding, extendedProtectionPolicy);
            }
        }
コード例 #19
0
            internal override void WriteTo(XmlWriter xml)
            {
                if (xml == null)
                {
                    return;
                }
                if (this.policyHelper != null)
                {
                    xml.WriteElementString("PolicyEnforcement", this.policyHelper.PolicyEnforcement.ToString());
                    xml.WriteElementString("ProtectionScenario", this.policyHelper.ProtectionScenario.ToString());

                    xml.WriteStartElement("ServiceNameCollection");

                    if (this.policyHelper.ServiceNameCollection != null && this.policyHelper.ServiceNameCollection.Count > 0)
                    {
                        foreach (string serviceName in this.policyHelper.ServiceNameCollection)
                        {
                            xml.WriteElementString("ServiceName", serviceName);
                        }
                    }

                    xml.WriteFullEndElement();

                    if (this.isServer)
                    {
                        this.channelBindingUsed = this.policyHelper.ShouldAddChannelBindingToASC();
                    }
                    else
                    {
                        this.channelBindingUsed = this.policyHelper.ChannelBinding != null;
                    }

                    xml.WriteElementString("ChannelBindingUsed", this.channelBindingUsed.ToString());

                    if (this.channelBinding != null && this.policyHelper.PolicyEnforcement != PolicyEnforcement.Never && this.channelBindingUsed == true)
                    {
                        ExtendedProtectionPolicy extendedProtection = new ExtendedProtectionPolicy(policyHelper.PolicyEnforcement, channelBinding);
                        xml.WriteElementString("ChannelBindingData", GetBase64EncodedChannelBindingData(extendedProtection));
                    }
                }
                else
                {
                    // This is the case for KerberosRequestorSecurityToken where policyHelper is null.
                    if (this.channelBinding != null)
                    {
                        xml.WriteElementString("ChannelBindingUsed", "true");

                        // We do not know the PolicyEnforcement value here on the client side and we can not pass Never
                        //as ExtendedProtectionPolicy constructor would throw on PolicyEnforcement.Never
                        ExtendedProtectionPolicy extendedProtection = new ExtendedProtectionPolicy(PolicyEnforcement.WhenSupported, channelBinding);
                        xml.WriteElementString("ChannelBindingData", GetBase64EncodedChannelBindingData(extendedProtection));
                    }
                    else
                    {
                        xml.WriteElementString("ChannelBindingUsed", "false");
                        xml.WriteElementString("ChannelBindingData", null);
                    }
                }
            }
コード例 #20
0
 public void ExtendedProtectionPolicy_SetCustomChannelBinding_ThrowsObjectDisposedException()
 {
     using (var listener = new HttpListener())
     {
         var protectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Always, new CustomChannelBinding());
         AssertExtensions.Throws <ArgumentException>("value", "CustomChannelBinding", () => listener.ExtendedProtectionPolicy = protectionPolicy);
     }
 }
コード例 #21
0
 public virtual void AuthenticateAsServer(NetworkCredential credential, ExtendedProtectionPolicy policy, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel)
 {
     if (!ComNetOS.IsWin2K)
     {
         throw new PlatformNotSupportedException(SR.GetString("Win2000Required"));
     }
     this._NegoState.ValidateCreateContext(this._Package, credential, string.Empty, policy, requiredProtectionLevel, requiredImpersonationLevel);
     this._NegoState.ProcessAuthentication(null);
 }
コード例 #22
0
 public TcpTransportBindingElement()
     : base()
 {
     this.listenBacklog            = TcpTransportDefaults.GetListenBacklog();
     this.portSharingEnabled       = TcpTransportDefaults.PortSharingEnabled;
     this.teredoEnabled            = TcpTransportDefaults.TeredoEnabled;
     this.connectionPoolSettings   = new TcpConnectionPoolSettings();
     this.extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy;
 }
コード例 #23
0
        public void ExtendedProtectionPolicy_NoCustomServiceNamesAndNoCustomChannelBinding_ToString()
        {
            var    extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Always);
            string expectedResult           = $"ProtectionScenario={extendedProtectionPolicy.ProtectionScenario}; PolicyEnforcement={PolicyEnforcement.Always}; CustomChannelBinding=<null>; ServiceNames=<null>";

            string result = extendedProtectionPolicy.ToString();

            Assert.Equal(expectedResult, result);
        }
コード例 #24
0
 internal void ValidateCreateContext(string package,
                                     NetworkCredential credential,
                                     string servicePrincipalName,
                                     ExtendedProtectionPolicy policy,
                                     ProtectionLevel protectionLevel,
                                     TokenImpersonationLevel impersonationLevel)
 {
     throw new PlatformNotSupportedException();
 }
コード例 #25
0
            internal string GetBase64EncodedChannelBindingData(ExtendedProtectionPolicy extendedProtectionPolicy)
            {
                MemoryStream    ms        = new MemoryStream();
                BinaryFormatter formatter = new BinaryFormatter();

                formatter.Serialize(ms, extendedProtectionPolicy);
                byte[] channelBindingData = ms.GetBuffer();
                return(Convert.ToBase64String(channelBindingData, Base64FormattingOptions.None));
            }
コード例 #26
0
 protected TcpTransportBindingElement(TcpTransportBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
     this.listenBacklog            = elementToBeCloned.listenBacklog;
     this.isListenBacklogSet       = elementToBeCloned.isListenBacklogSet;
     this.portSharingEnabled       = elementToBeCloned.portSharingEnabled;
     this.teredoEnabled            = elementToBeCloned.teredoEnabled;
     this.connectionPoolSettings   = elementToBeCloned.connectionPoolSettings.Clone();
     this.extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy;
 }
コード例 #27
0
        public void ExtendedProtectionPolicy_Properties()
        {
            var customChannelBindingParam = new MockCustomChannelBinding();

            var extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Always, customChannelBindingParam);

            Assert.Null(extendedProtectionPolicy.CustomServiceNames);
            Assert.Equal(PolicyEnforcement.Always, extendedProtectionPolicy.PolicyEnforcement);
            Assert.Equal(ProtectionScenario.TransportSelected, extendedProtectionPolicy.ProtectionScenario);
            Assert.Equal(customChannelBindingParam, extendedProtectionPolicy.CustomChannelBinding);
        }
コード例 #28
0
        public void Constructor_CollectionParam()
        {
            var paramValue = new List <string> {
                "Test1", "Test2"
            };
            var expectedServiceNameCollection = new ServiceNameCollection(paramValue);
            var extendedProtectionPolicy      = new ExtendedProtectionPolicy(PolicyEnforcement.Always, ProtectionScenario.TransportSelected, paramValue);

            Assert.Equal(2, extendedProtectionPolicy.CustomServiceNames.Count);
            Assert.Equal(expectedServiceNameCollection, extendedProtectionPolicy.CustomServiceNames);
        }
コード例 #29
0
    public static void ExtendedProtectionPolicy_Propagates_To_TransportBindingElement()
    {
        var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
        var epp     = new ExtendedProtectionPolicy(PolicyEnforcement.Always);

        binding.Security.Transport.ExtendedProtectionPolicy = epp;
        var be   = binding.CreateBindingElements();
        var htbe = be.Find <HttpTransportBindingElement>();

        Assert.Equal(epp, htbe.ExtendedProtectionPolicy);
    }
コード例 #30
0
 public HttpListener()
 {
     prefixes                 = new HttpListenerPrefixCollection(this);
     registry                 = new Hashtable();
     connections              = Hashtable.Synchronized(new Hashtable());
     ctx_queue                = new ArrayList();
     wait_queue               = new ArrayList();
     auth_schemes             = AuthenticationSchemes.Anonymous;
     defaultServiceNames      = new ServiceNameStore();
     extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never);
 }
コード例 #31
0
    	public void ConvertTo_PositiveTests()
    	{
    		ExtendedProtectionPolicy policy = new ExtendedProtectionPolicy(PolicyEnforcement.Never);
    		
    		InstanceDescriptor instanceDescriptor = converter.ConvertTo(null, CultureInfo.InvariantCulture, policy, typeof(InstanceDescriptor)) as InstanceDescriptor;
    		ExtendedProtectionPolicy instanceResult = instanceDescriptor.Invoke() as ExtendedProtectionPolicy;
    		Assert.NotNull(instanceDescriptor);
    		Assert.NotNull(instanceResult);
    		Assert.Equal(PolicyEnforcement.Never, instanceResult.PolicyEnforcement);
    		Assert.Equal(policy.ProtectionScenario, instanceResult.ProtectionScenario);
    		Assert.Null(instanceResult.CustomServiceNames);

    		Assert.Equal(string.Empty, 
    			converter.ConvertTo(null, CultureInfo.InvariantCulture, null, typeof(string)) as string);
    		Assert.Equal(policy.ToString(), 
    			converter.ConvertTo(null, CultureInfo.InvariantCulture, policy, typeof(string)) as string);
    	}
コード例 #32
0
    	public void ConvertTo_NegativeTests(Type destinationType)
    	{
    		ExtendedProtectionPolicy policy = new ExtendedProtectionPolicy(PolicyEnforcement.Never);

    		Assert.Throws<NotSupportedException>(() => converter.ConvertTo(null, CultureInfo.InvariantCulture, policy, destinationType));
    	}