在肥皂消息中包含kerberos票据absoleto SoapContext.Security

时间:2014-06-06 11:25:51

标签: soap kerberos wse

我在对服务的请求中包含一个Kerberos票证标题,但正如我正在做的那样,但是说是SoapContext.Security absoleto。

任何人都可以帮我解决这个问题吗?

我的代码是:

 private void button1_Click(object sender, EventArgs e)
    {
        try
        {
            //default option selected is Kerberos.
            string option = "Kerberos";

            if (radioButton1.Checked)
                option = "UserName";
            if (radioButton2.Checked)
                option = "Kerberos";

            //declare any Security Token
            SecurityToken token = null;
            switch (option)
            {
                case "UserName":
                    {
                        try
                        {
                            //create a username Token.
                            UsernameToken unToken = new UsernameToken(textBox1.Text, textBox2.Text, PasswordOption.SendPlainText);
                            //assign the any SecurityToken an Username Token.
                            token = unToken;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                            return;
                        }
                        break;
                    }
                case "Kerberos":
                    {
                        try
                        {
                            Console.WriteLine(System.Net.Dns.GetHostName());
                            //create a kerberos Token.
                            KerberosToken kToken = new KerberosToken(System.Net.Dns.GetHostName());

                            //assign the any SecurityToken an Username Token.
                            token = kToken;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                            return;
                        }
                        break;
                    }
                default:
                    {
                        break;
                    }
            }

            if (token == null)
                throw new ApplicationException("Unable to obtain security token.");

            // Create an instance of the web service proxy that has been generated.
            SecureServiceProxy.WebService1 proxy = new ClientTest.SecureServiceProxy.WebService1();
            proxy.SetPolicy("KerberosClient");

            //set the time to live to any value.
            proxy.RequestSoapContext.Security.Timestamp.TtlInSeconds = 60;


            // Add the SecurityToken to the SOAP Request Context.
            proxy.RequestSoapContext.Security.Tokens.Add(token);

            // Sign the SOAP message with a signatureobject.
            proxy.RequestSoapContext.Security.Elements.Add(new MessageSignature(token));



            // Create and Send the request
            long a = long.Parse(textLong1.Text);
            long b = long.Parse(textLong2.Text);
            //call the web service.
            long result = proxy.perform(a, b);
            //Display the result.
            MessageBox.Show(a + " + " + b + " = " + result.ToString());
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            MessageBox.Show(ex.Message);
            return;
        }
    }

我的警告显示它已经过时了以下几行代码:

proxy.RequestSoapContext.Security.Timestamp.TtlInSeconds = 60;


            // Add the SecurityToken to the SOAP Request Context.
            proxy.RequestSoapContext.Security.Tokens.Add(token);

            // Sign the SOAP message with a signatureobject.
            proxy.RequestSoapContext.Security.Elements.Add(new MessageSignature(token));

但不知道如何解决

0 个答案:

没有答案