Пример #1
0
        public override void Initialize([NotNull] HttpWebClientProtocol service, [NotNull] SpContextBase context)
        {
            Assert.ArgumentNotNull(service, "service");
            Assert.ArgumentNotNull(context, "context");

            if (string.IsNullOrEmpty(((NetworkCredential)context.Credentials).UserName))
            {
                string message = "Claims-based authentication requires username";
                if (context.Credentials == CredentialCache.DefaultNetworkCredentials)
                {
                    message = "Default credentials isn't applicable for claims-based authentication";
                }

                throw new Exception(message);
            }

            var credential = (NetworkCredential)context.Credentials;
            var cookies    = this.cache.GetUnexpired(context.Url, credential);

            if (cookies == null)
            {
                cookies = this.claimsBasedWorkflow.GetAuthenticationCookies(context.Url, credential);
                this.cache.Add(context.Url, credential, cookies, DateTime.Now.Add(this.CookiesExpirationInterval));
            }

            service.CookieContainer = cookies;
        }
Пример #2
0
 public void UpdateProxy(HttpWebClientProtocol proxy)
 {
     proxy.Timeout           = this.Timeout;
     proxy.AllowAutoRedirect = this.AllowAutoRedirect;
     proxy.PreAuthenticate   = this.PreAuthenticate;
     if (this.UseCookieContainer)
     {
         if (proxy.CookieContainer == null)
         {
             proxy.CookieContainer = new CookieContainer();
         }
     }
     else
     {
         proxy.CookieContainer = null;
     }
     proxy.Url         = this.Server.Url;
     proxy.Credentials = this.ReadCredentials(proxy.Credentials, new Uri(this.Server.Url), this.Server.UseDefaultCredentials, this.Server.UserNameForBasicAuth, this.Server.PasswordForBasicAuth);
     if (((this.HttpProxy != null) && (this.HttpProxy.Url != null)) && (this.HttpProxy.Url.Length > 0))
     {
         Uri uri = new Uri(this.HttpProxy.Url);
         if (proxy.Proxy == null)
         {
             proxy.Proxy = new WebProxy();
         }
         WebProxy proxy2 = proxy.Proxy as WebProxy;
         proxy2.Address     = uri;
         proxy2.Credentials = this.ReadCredentials(proxy2.Credentials, uri, this.Server.UseDefaultCredentials, this.Server.UserNameForBasicAuth, this.Server.PasswordForBasicAuth);
     }
     if (this.additionalProperties != null)
     {
         this.additionalProperties.UpdateProxy(proxy);
     }
 }
Пример #3
0
        /// <summary>
        /// Sets the url of the target Web service.
        /// </summary>
        /// <param name="service">
        ///   The service.
        /// </param>
        /// <param name="server">
        ///   The server.
        /// </param>
        /// <param name="name">
        ///   The name.
        /// </param>
        /// <param name="context"> The context of the SharePoint server.</param>
        private static void SetUpService(HttpWebClientProtocol service, Uri server, string name, SpContextBase context)
        {
            service.Url = StringUtil.RemovePostfix('/', server.ToString()) + name;
            var init = ConnectionConfigurationsFactory.CreateInstance(context);

            init.Initialize(service, context);
        }
Пример #4
0
        private void FillInvokeTab()
        {
            Assembly proxyAssembly = wsdl.ProxyAssembly;

            if (proxyAssembly != null)
            {
                treeMethods.Nodes.Clear();
                foreach (System.Type type in proxyAssembly.GetTypes())
                {
                    if (TreeNodeProperty.IsWebService(type))
                    {
                        TreeNode node = treeMethods.Nodes.Add(type.Name, type.Name);
                        HttpWebClientProtocol proxy    = (HttpWebClientProtocol)Activator.CreateInstance(type);
                        ProxyProperty         property = new ProxyProperty(proxy);
                        property.RecreateSubtree(null);
                        node.Tag          = property.TreeNode;
                        proxy.Credentials = CredentialCache.DefaultCredentials;
                        SoapHttpClientProtocol protocol2 = proxy as SoapHttpClientProtocol;
                        if (protocol2 != null)
                        {
                            protocol2.CookieContainer   = new CookieContainer();
                            protocol2.AllowAutoRedirect = true;
                        }
                        foreach (MethodInfo info in type.GetMethods())
                        {
                            if (TreeNodeProperty.IsWebMethod(info))
                            {
                                node.Nodes.Add(info.Name, info.Name).Tag = info;
                            }
                        }
                    }
                }
                this.treeMethods.ExpandAll();
            }
        }
Пример #5
0
        private void InvokeWebMethod()
        {
            MethodProperty currentMethodProperty = GetCurrentMethodProperty();

            if (currentMethodProperty != null)
            {
                HttpWebClientProtocol proxy      = currentMethodProperty.GetProxyProperty().GetProxy();
                RequestProperties     properties = new RequestProperties(proxy);
                try
                {
                    MethodInfo  method        = currentMethodProperty.GetMethod();
                    System.Type declaringType = method.DeclaringType;
                    WSSWebRequest.RequestTrace = properties;
                    object[] parameters = currentMethodProperty.ReadChildren() as object[];
                    object   result     = method.Invoke(proxy, BindingFlags.Public, null, parameters, null);
                    treeOutput.Nodes.Clear();
                    MethodProperty property2 = new MethodProperty(currentMethodProperty.GetProxyProperty(), method, result, parameters);
                    property2.RecreateSubtree(null);
                    treeOutput.Nodes.Add(property2.TreeNode);
                    treeOutput.ExpandAll();
                }
                finally
                {
                    WSSWebRequest.RequestTrace = null;
                    propRequest.SelectedObject = properties;
                    richRequest.Text           = properties.requestPayLoad;
                    richResponse.Text          = properties.responsePayLoad;
                }
            }
        }
 internal DiscoveryClientProtocol(HttpWebClientProtocol protocol) : base(protocol)
 {
     this.references            = new DiscoveryClientReferenceCollection();
     this.documents             = new DiscoveryClientDocumentCollection();
     this.inlinedSchemas        = new Hashtable();
     this.additionalInformation = new ArrayList();
     this.errors = new DiscoveryExceptionDictionary();
 }
Пример #7
0
 /// <summary>
 /// Initialize the web service proxy stub.
 /// </summary>
 /// <param name="request">The client proxy to initialize</param>
 /// <param name="domainID">The identifier for the domain.</param>
 public void InitializeWebClient(HttpWebClientProtocol request, string domainID)
 {
     request.UserAgent       = userAgent;
     request.Credentials     = credentials;
     request.CookieContainer = cookieHash[domainID] as CookieContainer;
     request.Proxy           = ProxyState.GetProxyState(new Uri(request.Url));
     request.PreAuthenticate = true;
 }
        public override void Initialize([NotNull] HttpWebClientProtocol service, [NotNull] SpContextBase context)
        {
            Assert.ArgumentNotNull(service, "service");
            Assert.ArgumentNotNull(context, "context");

            service.Credentials     = context.Credentials;
            service.PreAuthenticate = true;
        }
Пример #9
0
        private void AddHeaders()
        {
            TreeNode node1 = base.TreeNode.Nodes.Add("Headers");

            FieldInfo[]           infoArray1 = GetSoapHeaders(method, isIn);
            HttpWebClientProtocol protocol1  = proxyProperty.GetProxy();

            foreach (FieldInfo info1 in infoArray1)
            {
                object obj1 = (protocol1 != null) ? info1.GetValue(protocol1) : null;
                CreateTreeNodeProperty(base.GetIncludedTypes(info1.FieldType), info1.Name, obj1).RecreateSubtree(node1);
            }
            node1.ExpandAll();
        }
Пример #10
0
        private void AddHeaders()
        {
            TreeNode parentNode = base.TreeNode.Nodes.Add("Headers");

            FieldInfo[]           soapHeaders = GetSoapHeaders(this.method, this.isIn);
            HttpWebClientProtocol proxy       = this.proxyProperty.GetProxy();

            foreach (FieldInfo info in soapHeaders)
            {
                object val = (proxy != null) ? info.GetValue(proxy) : null;
                TreeNodeProperty.CreateTreeNodeProperty(base.GetIncludedTypes(info.FieldType), info.Name, val).RecreateSubtree(parentNode);
            }
            parentNode.ExpandAll();
        }
Пример #11
0
        private void ReadHeaders()
        {
            TreeNode node               = base.TreeNode.Nodes[0];
            Type     declaringType      = method.DeclaringType;
            HttpWebClientProtocol proxy = proxyProperty.GetProxy();

            foreach (TreeNode node2 in node.Nodes)
            {
                var tag = node2.Tag as ClassProperty;
                if (tag != null)
                {
                    declaringType.GetField(tag.Name).SetValue(proxy, tag.ReadChildren());
                }
            }
        }
Пример #12
0
        private void ReadHeaders()
        {
            TreeNode node1 = base.TreeNode.Nodes[0];
            Type     type1 = method.DeclaringType;
            HttpWebClientProtocol protocol1 = proxyProperty.GetProxy();

            foreach (TreeNode node2 in node1.Nodes)
            {
                ClassProperty property1 = node2.Tag as ClassProperty;
                if (property1 != null)
                {
                    type1.GetField(property1.Name).SetValue(protocol1, property1.ReadChildren());
                }
            }
        }
Пример #13
0
 private void InitAdditionalProperties(HttpWebClientProtocol proxy)
 {
     if (proxyTypeHandlers == null)
     {
         proxyTypeHandlers = new Hashtable();
         CustomHandler[] handlerArray1 = Configuration.MasterConfig.ProxyProperties;
         if ((handlerArray1 != null) && (handlerArray1.Length > 0))
         {
             foreach (CustomHandler handler1 in handlerArray1)
             {
                 string text1 = handler1.TypeName;
                 string text2 = handler1.Handler;
                 if (((text1 != null) && (text1.Length != 0)) && ((text2 != null) && (text2.Length != 0)))
                 {
                     Type type1 = Type.GetType(text1);
                     if (type1 == null)
                     {
                         MainForm.ShowMessage(this, MessageType.Warning,
                                              string.Format(typeNotFoundMessage, text1));
                     }
                     else
                     {
                         Type type2 = Type.GetType(text2);
                         if (type2 == null)
                         {
                             MainForm.ShowMessage(this, MessageType.Warning,
                                                  string.Format(typeNotFoundMessage, text2));
                         }
                         else
                         {
                             proxyTypeHandlers.Add(type1, type2);
                         }
                     }
                 }
             }
         }
     }
     for (Type type3 = proxy.GetType(); type3 != typeof(object); type3 = type3.BaseType)
     {
         Type type4 = proxyTypeHandlers[type3] as Type;
         if (type4 != null)
         {
             AdditionalProperties = (IAdditionalProperties)Activator.CreateInstance(type4, new object[] { proxy });
             return;
         }
     }
 }
 private void InitAdditionalProperties(HttpWebClientProtocol proxy)
 {
     if (proxyTypeHandlers == null)
     {
         proxyTypeHandlers = new Hashtable();
         CustomHandler[] proxyProperties = Configuration.MasterConfig.ProxyProperties;
         if ((proxyProperties != null) && (proxyProperties.Length > 0))
         {
             foreach (CustomHandler handler in proxyProperties)
             {
                 string typeName = handler.TypeName;
                 string str2     = handler.Handler;
                 if (((typeName != null) && (typeName.Length != 0)) && ((str2 != null) && (str2.Length != 0)))
                 {
                     Type key = Type.GetType(typeName);
                     if (key == null)
                     {
                         MainForm.ShowMessage(this, MessageType.Warning,
                                              string.Format(typeNotFoundMessage, typeName));
                     }
                     else
                     {
                         Type type = Type.GetType(str2);
                         if (type == null)
                         {
                             MainForm.ShowMessage(this, MessageType.Warning,
                                                  string.Format(typeNotFoundMessage, str2));
                         }
                         else
                         {
                             proxyTypeHandlers.Add(key, type);
                         }
                     }
                 }
             }
         }
     }
     for (Type type3 = proxy.GetType(); type3 != typeof(object); type3 = type3.BaseType)
     {
         var type4 = proxyTypeHandlers[type3] as Type;
         if (type4 != null)
         {
             AdditionalProperties = (IAdditionalProperties)Activator.CreateInstance(type4, new object[] { proxy });
             break;
         }
     }
 }
Пример #15
0
        protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }
            if ((this.SessionId != "") && (this.SessionId != null))
            {
                this.PopulateSessionCookie();
            }
            object proxyInstance           = Activator.CreateInstance(this.ProxyClass);
            HttpWebClientProtocol protocol = proxyInstance as HttpWebClientProtocol;

            protocol.CookieContainer = this.SessionCookieContainer;
            base.RaiseGenericEvent <InvokeWebServiceEventArgs>(InvokingEvent, this, new InvokeWebServiceEventArgs(proxyInstance));
            MethodInfo method = this.ProxyClass.GetMethod(this.MethodName, BindingFlags.Public | BindingFlags.Instance);

            object[] parameters = InvokeHelper.GetParameters(method, this.ParameterBindings);
            WorkflowParameterBinding binding = null;

            if (this.ParameterBindings.Contains("(ReturnValue)"))
            {
                binding = this.ParameterBindings["(ReturnValue)"];
            }
            object obj3 = null;

            try
            {
                obj3 = this.ProxyClass.InvokeMember(this.MethodName, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, proxyInstance, parameters, CultureInfo.InvariantCulture);
            }
            catch (TargetInvocationException exception)
            {
                if (exception.InnerException != null)
                {
                    throw exception.InnerException;
                }
                throw;
            }
            if (binding != null)
            {
                binding.Value = obj3;
            }
            InvokeHelper.SaveOutRefParameters(parameters, method, this.ParameterBindings);
            base.RaiseGenericEvent <InvokeWebServiceEventArgs>(InvokedEvent, this, new InvokeWebServiceEventArgs(proxyInstance));
            return(ActivityExecutionStatus.Closed);
        }
Пример #16
0
        private static void SetupProxyServer(HttpWebClientProtocol ws, string proxyUrl, string user, string password, string domain)
        {
            if (!String.IsNullOrEmpty(proxyUrl))
            {
                WebProxy wp  = new WebProxy();
                Uri      uri = new Uri(proxyUrl);
                wp.Address = uri;

                if (!String.IsNullOrEmpty(user) || !String.IsNullOrEmpty(password) || !String.IsNullOrEmpty(domain))
                {
                    NetworkCredential credentials = new NetworkCredential(user, password, domain);
                    wp.Credentials = credentials;
                }

                ws.Proxy = wp;
            }
        }
Пример #17
0
 public RequestProperties(HttpWebClientProtocol proxy)
 {
     if (proxy != null)
     {
         this.Method             = HttpMethod.POST;
         this.preAuthenticate    = proxy.PreAuthenticate;
         this.timeout            = proxy.Timeout;
         this.useCookieContainer = proxy.CookieContainer != null;
         SoapHttpClientProtocol protocol = proxy as SoapHttpClientProtocol;
         if (protocol != null)
         {
             this.allowAutoRedirect         = protocol.AllowAutoRedirect;
             this.allowWriteStreamBuffering = protocol.AllowAutoRedirect;
             WebProxy proxy2 = protocol.Proxy as WebProxy;
             this.HttpProxy = ((proxy2 != null) && (proxy2.Address != null)) ? proxy2.Address.ToString() : null;
         }
     }
 }
Пример #18
0
 public RequestProperties(HttpWebClientProtocol proxy)
 {
     allowAutoRedirect         = true;
     allowWriteStreamBuffering = true;
     timeout = 0x2710;
     if (proxy != null)
     {
         Method             = HttpMethod.POST;
         preAuthenticate    = proxy.PreAuthenticate;
         timeout            = proxy.Timeout;
         useCookieContainer = proxy.CookieContainer != null;
         SoapHttpClientProtocol protocol1 = proxy as SoapHttpClientProtocol;
         if (protocol1 != null)
         {
             allowAutoRedirect         = protocol1.AllowAutoRedirect;
             allowWriteStreamBuffering = protocol1.AllowAutoRedirect;
             WebProxy proxy1 = protocol1.Proxy as WebProxy;
             HttpProxy = ((proxy1 != null) && (proxy1.Address != null)) ? proxy1.Address.ToString() : null;
         }
     }
 }
Пример #19
0
        /// <summary>
        /// Connects the specified webClient to its web service.
        /// </summary>
        /// <param name="webClient">HttpWebClientProtocol object.</param>
        /// <param name="webServiceUri">Uri that references the local web service.</param>
        /// <param name="simiasDataPath">Path to the directory where the Simias data is stored.</param>
        static public void Start(HttpWebClientProtocol webClient, Uri webServiceUri, string simiasDataPath)
        {
            bool ignoreCase = (MyEnvironment.Platform == MyPlatformID.Windows) ? true : false;
            int  pingCount  = 0;

            // Start the web service so the password file will be created.
            while ((localPassword == null) || (String.Compare(dataPath, simiasDataPath, ignoreCase) != 0))
            {
                if (Ping(webServiceUri))
                {
                    pingCount = 0;
                    GetLocalPassword(simiasDataPath);
                    if (localPassword == null)
                    {
                        Thread.Sleep(500);
                    }
                }
                else
                {
                    if (++pingCount >= 5)
                    {
                        throw new ApplicationException("The local web service is not responding.");
                    }

                    Thread.Sleep(500);
                }
            }

            string localDomain = localPassword.Substring(0, GuidLength);

            webClient.Credentials     = new NetworkCredential(Environment.UserName, localPassword, localDomain);
            webClient.PreAuthenticate = true;

            // BUGBUG!! - Force mono to authenticate everytime until cookies work on a loopback
            // connection.
//#if WINDOWS
            webClient.CookieContainer = cookies;
//#endif
        }
Пример #20
0
        public ProxyProperties(HttpWebClientProtocol proxy)
        {
            this.Timeout           = proxy.Timeout;
            this.AllowAutoRedirect = proxy.AllowAutoRedirect;
            this.PreAuthenticate   = proxy.PreAuthenticate;
            if (proxy.CookieContainer == null)
            {
                this.UseCookieContainer = true;
            }
            this.Server     = new ServerProperties();
            this.Server.Url = proxy.Url;
            this.SetCredentialValues(proxy.Credentials, new Uri(this.Server.Url), out this.Server.UseDefaultCredentials, out this.Server.UserNameForBasicAuth, out this.Server.PasswordForBasicAuth);
            WebProxy proxy2 = proxy.Proxy as WebProxy;

            if (proxy2 != null)
            {
                this.HttpProxy     = new ServerProperties();
                this.HttpProxy.Url = proxy2.Address.ToString();
                this.SetCredentialValues(proxy2.Credentials, new Uri(this.HttpProxy.Url), out this.HttpProxy.UseDefaultCredentials, out this.HttpProxy.UserNameForBasicAuth, out this.HttpProxy.PasswordForBasicAuth);
            }
            this.InitAdditionalProperties(proxy);
        }
Пример #21
0
 public void UpdateProxy(HttpWebClientProtocol proxy)
 {
     proxy.Timeout           = Timeout;
     proxy.AllowAutoRedirect = AllowAutoRedirect;
     proxy.PreAuthenticate   = PreAuthenticate;
     if (UseCookieContainer)
     {
         if (proxy.CookieContainer == null)
         {
             proxy.CookieContainer = new CookieContainer();
         }
     }
     else
     {
         proxy.CookieContainer = null;
     }
     proxy.Url         = Server.Url;
     proxy.Credentials =
         ReadCredentials(proxy.Credentials, new Uri(Server.Url), Server.UseDefaultCredentials,
                         Server.UserNameForBasicAuth, Server.PasswordForBasicAuth);
     if (((HttpProxy != null) && (HttpProxy.Url != null)) && (HttpProxy.Url.Length > 0))
     {
         Uri uri1 = new Uri(HttpProxy.Url);
         if (proxy.Proxy == null)
         {
             proxy.Proxy = new WebProxy();
         }
         WebProxy proxy1 = proxy.Proxy as WebProxy;
         proxy1.Address     = uri1;
         proxy1.Credentials =
             ReadCredentials(proxy1.Credentials, uri1, Server.UseDefaultCredentials, Server.UserNameForBasicAuth,
                             Server.PasswordForBasicAuth);
     }
     if (additionalProperties != null)
     {
         additionalProperties.UpdateProxy(proxy);
     }
 }
 public abstract void Initialize(HttpWebClientProtocol service, SpContextBase context);
Пример #23
0
 /// <summary>
 /// Initializes the web client
 /// </summary>
 /// <param name="request">Inital request</param>
 internal void InitializeWebClient(HttpWebClientProtocol request)
 {
     connectionState.InitializeWebClient(request, domainID);
 }
Пример #24
0
 /// <summary>
 /// Initializes web client
 /// </summary>
 /// <param name="request">Request for the connection</param>
 /// <param name="servicePath">Path of the service request</param>
 public void InitializeWebClient(HttpWebClientProtocol request, string servicePath)
 {
     request.Url = baseUri + servicePath.TrimStart('/');
     connection.InitializeWebClient(request);
 }
Пример #25
0
 internal DiscoveryClientProtocol(HttpWebClientProtocol protocol) : base(protocol)
 {
 }
Пример #26
0
 public ProxyProperty(HttpWebClientProtocol proxy) : base(new Type[] { typeof(ProxyProperties) }, "Proxy")
 {
     this.proxy      = proxy;
     proxyProperties = new ProxyProperties(proxy);
 }
Пример #27
0
        private void SendWebRequest()
        {
            Encoding          encoding       = new UTF8Encoding(true);
            RequestProperties selectedObject = this.propRequest.SelectedObject as RequestProperties;
            HttpWebRequest    request        = (HttpWebRequest)WebRequest.CreateDefault(new Uri(selectedObject.Url));

            if ((selectedObject.HttpProxy != null) && (selectedObject.HttpProxy.Length != 0))
            {
                request.Proxy = new WebProxy(selectedObject.HttpProxy);
            }
            request.Method                    = selectedObject.Method.ToString();
            request.ContentType               = selectedObject.ContentType;
            request.Headers["SOAPAction"]     = selectedObject.SOAPAction;
            request.SendChunked               = selectedObject.SendChunked;
            request.AllowAutoRedirect         = selectedObject.AllowAutoRedirect;
            request.AllowWriteStreamBuffering = selectedObject.AllowWriteStreamBuffering;
            request.KeepAlive                 = selectedObject.KeepAlive;
            request.Pipelined                 = selectedObject.Pipelined;
            request.PreAuthenticate           = selectedObject.PreAuthenticate;
            request.Timeout                   = selectedObject.Timeout;
            HttpWebClientProtocol proxy = this.GetCurrentMethodProperty().GetProxyProperty().GetProxy();

            if (selectedObject.UseCookieContainer)
            {
                if (proxy.CookieContainer != null)
                {
                    request.CookieContainer = proxy.CookieContainer;
                }
                else
                {
                    request.CookieContainer = new CookieContainer();
                }
            }
            CredentialCache cache = new CredentialCache();
            bool            flag  = false;

            if ((selectedObject.BasicAuthUserName != null) && (selectedObject.BasicAuthUserName.Length != 0))
            {
                cache.Add(new Uri(selectedObject.Url), "Basic", new NetworkCredential(selectedObject.BasicAuthUserName, selectedObject.BasicAuthPassword));
                flag = true;
            }
            if (selectedObject.UseDefaultCredential)
            {
                cache.Add(new Uri(selectedObject.Url), "NTLM", (NetworkCredential)CredentialCache.DefaultCredentials);
                flag = true;
            }
            if (flag)
            {
                request.Credentials = cache;
            }
            if (selectedObject.Method == RequestProperties.HttpMethod.POST)
            {
                request.ContentLength = this.richRequest.Text.Length + encoding.GetPreamble().Length;
                StreamWriter writer = new StreamWriter(request.GetRequestStream(), encoding);
                writer.Write(this.richRequest.Text);
                writer.Close();
            }
            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                this.DumpResponse(response);
                response.Close();
            }
            catch (WebException exception)
            {
                if (exception.Response != null)
                {
                    this.DumpResponse((HttpWebResponse)exception.Response);
                }
                else
                {
                    this.richResponse.Text = exception.ToString();
                }
            }
            catch (Exception exception2)
            {
                this.richResponse.Text = exception2.ToString();
            }
        }