public static ProxyAuthenticator Create(CommonAccessToken commonAccessToken, string messageId)
        {
            ProxyAuthenticator.SecurityTracer.TraceDebug <object, CommonAccessToken>(0L, "{0}: creating ProxyAuthenticator for CommonAccessToken: {1}", TraceContext.Get(), commonAccessToken);
            SoapHttpClientAuthenticator soapHttpClientAuthenticator = SoapHttpClientAuthenticator.Create(commonAccessToken);

            ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId);
            return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.OAuth));
        }
        public static ProxyAuthenticator Create(OAuthCredentials credentials, string messageId, bool isAutodiscoverRequest)
        {
            ProxyAuthenticator.SecurityTracer.TraceDebug <object, OAuthCredentials>(0L, "{0}: creating ProxyAuthenticator for OAuthCredentials: {1}", TraceContext.Get(), credentials);
            SoapHttpClientAuthenticator soapHttpClientAuthenticator = isAutodiscoverRequest ? SoapHttpClientAuthenticator.CreateForSoap(credentials) : SoapHttpClientAuthenticator.Create(credentials);

            ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId);
            return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.OAuth));
        }
        public static ProxyAuthenticator CreateForSoap(string messageId)
        {
            ProxyAuthenticator.SecurityTracer.TraceDebug(0L, "{0}: creating ProxyAuthenticator for network service", new object[]
            {
                TraceContext.Get()
            });
            SoapHttpClientAuthenticator soapHttpClientAuthenticator = SoapHttpClientAuthenticator.CreateNetworkServiceForSoap();

            ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId);
            return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.NetworkCredentials));
        }
        public static ProxyAuthenticator Create(WSSecurityHeader wsSecurityHeader, SharingSecurityHeader sharingSecurityHeader, string messageId)
        {
            ProxyAuthenticator.SecurityTracer.TraceDebug(0L, "{0}: creating ProxyAuthenticator for WS-Security", new object[]
            {
                TraceContext.Get()
            });
            SoapHttpClientAuthenticator soapHttpClientAuthenticator = SoapHttpClientAuthenticator.Create(wsSecurityHeader);

            if (sharingSecurityHeader != null)
            {
                soapHttpClientAuthenticator.AdditionalSoapHeaders.Add(sharingSecurityHeader);
            }
            ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId);
            return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.WSSecurity));
        }
        public static ProxyAuthenticator Create(RequestedToken token, SmtpAddress sharingKey, string messageId)
        {
            ProxyAuthenticator.SecurityTracer.TraceDebug(0L, "{0}: creating ProxyAuthenticator for WS-Security", new object[]
            {
                TraceContext.Get()
            });
            XmlElement xmlElement = null;

            if (sharingKey != SmtpAddress.Empty)
            {
                xmlElement = SharingKeyHandler.Encrypt(sharingKey, token.ProofToken);
            }
            SoapHttpClientAuthenticator soapHttpClientAuthenticator = SoapHttpClientAuthenticator.Create(token);

            if (xmlElement != null)
            {
                soapHttpClientAuthenticator.AdditionalSoapHeaders.Add(new SharingSecurityHeader(xmlElement));
            }
            ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId);
            return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.WSSecurity));
        }
        public static ProxyAuthenticator Create(CredentialCache cache, SerializedSecurityContext serializedContext, string messageId)
        {
            SoapHttpClientAuthenticator soapHttpClientAuthenticator;

            if (cache == null)
            {
                ProxyAuthenticator.SecurityTracer.TraceDebug(0L, "{0}: creating ProxyAuthenticator for network service", new object[]
                {
                    TraceContext.Get()
                });
                soapHttpClientAuthenticator = SoapHttpClientAuthenticator.CreateNetworkService();
            }
            else
            {
                ProxyAuthenticator.SecurityTracer.TraceDebug <object, CredentialCache>(0L, "{0}: creating ProxyAuthenticator for credential cache: {1}", TraceContext.Get(), cache);
                soapHttpClientAuthenticator = SoapHttpClientAuthenticator.Create(cache);
            }
            if (serializedContext != null)
            {
                soapHttpClientAuthenticator.AdditionalSoapHeaders.Add(serializedContext);
            }
            ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId);
            return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.NetworkCredentials));
        }