【问题标题】:RTC Authorization Always FailingRTC 授权总是失败
【发布时间】:2020-07-21 13:11:12
【问题描述】:

(使用 C#) 我正在尝试进行身份验证,但它总是返回失败。我知道我的用户名和密码是正确的。如果这很重要,我们可能会使用 OSLC 1.0。我不确定,但我在 services.xml 文件中看到过几次。 website 我正在使用 3.0.也许有区别?知道我做错了什么吗?

            Debug.Log("Authentication Required");
            // tried with just j_security_check as well (without "authenticated") as he seems to do both on the site
            HttpWebRequest _formPost = (HttpWebRequest)WebRequest.Create(localhost + "authenticated/j_security_check");
            _formPost.Method = "POST";
            _formPost.Timeout = 30000;
            _formPost.CookieContainer = request.CookieContainer;
            _formPost.Accept = "text/xml";
            _formPost.ContentType = "application/x-www-form-urlencoded";

            Byte[] _outBuffer = Encoding.UTF8.GetBytes("j_username=coolcat&j_password=bestPassEvar"); //store in byte buffer
            _formPost.ContentLength = _outBuffer.Length;
            Stream _str = _formPost.GetRequestStream();
            _str.Write(_outBuffer, 0, _outBuffer.Length); //update form
            _str.Close();

            //FormBasedAuth Step2:submit the login form and get the response from the server
            HttpWebResponse _formResponse = (HttpWebResponse)_formPost.GetResponse();

            string _rtcAuthHeader = _formResponse.Headers["X-com-ibm-team-repository-web-auth-msg"];
            //check if authentication has failed
            if ((_rtcAuthHeader != null) && _rtcAuthHeader.Equals("authfailed"))
            {
                Debug.Log("Authentication Failed");
                return;
            }

【问题讨论】:

    标签: c# httpwebrequest rational-team-concert ibm-jazz oslc


    【解决方案1】:

    呃。我就是这样一个假人。用户名/密码是正确的,但我在使用之前对其进行了两次编码! (在上面的代码中没有看到,因为我出于明显的安全原因对其进行了硬编码)。

    【讨论】:

      【解决方案2】:

      您可以在此 github 存储库https://github.com/OSLC/lyo-samples 下找到一些使用 OSLC 与基于 Jazz 的产品进行通信的示例代码。

      我发现这个示例代码专门处理表单身份验证。 https://github.com/OSLC/lyo-samples/blob/master/oslc4j-client-samples/src/main/java/org/eclipse/lyo/oslc4j/client/samples/ERMSample.java

      同一文件夹中的许多程序尝试连接到不同的 Jazz 解决方案。

      【讨论】:

      • 对不起,我应该更清楚我正在使用 C#。我已经更新了问题以表示这一点。 Java 代码并不是特别有用,因为它的做事方式似乎完全不同。
      猜你喜欢
      • 1970-01-01
      • 2021-05-11
      • 2021-05-06
      • 2020-04-03
      • 2021-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多