2

我正在尝试获取用户令牌并构建 URL,以便用户每次单击文件时都无需登录。下面是我的代码。我的问题是我需要传递下面显示的整个令牌值吗?我得到的代币价值是

symmetric:algorithm:QUVT:keyid:NTZkYTNkNmI=:data:7P9aJHzkfGTOlwtotuWGaMqfU9COECscA9yxMdK64ZLa298A3tsGlHKHDFp0cH+gn/SiMrwKfbWNZybPXaltgo5e4H4Ak8KUiCRKWfS68qhmjfw69qPv9ib96vL3TzNORYFpp/hrwvp8aX4CQIZlBA==

问题是,一旦我复制 URL 并将其粘贴到浏览器中,它就会将我带到登录页面。虽然我没有收到任何错误,但它应该将用户直接带到图像查看器,而是将我带到登录页面,如果我登录它会正确打开文件。

我究竟做错了什么?

string text = "";
            string userName = "userName";
            string pwd = "*****";
            fileNetID = "{5FCE7E04-3D74-4A93-AA53-26C12A2FD4FC}";
            Uri uri = null;
            string workplaceURL = "http://filenet:9081/WorkPlaceXT";
            uri = new Uri(workplaceURL + "/setCredentials?op=getUserToken&userId=" + this.encodeLabel(userName) + "&password=" + this.encodeLabel(pwd) + "&verify=true");
            System.Net.WebRequest webRequest = System.Net.WebRequest.Create(uri);
            System.Net.WebResponse webResponse = webRequest.GetResponse();
            StreamReader streamReader = new StreamReader(webResponse.GetResponseStream());
            String token = streamReader.ReadToEnd();
            string contentURL = string.Empty;
            contentURL = workplaceURL + "/getContent?objectType=document&impersonate=true&objectStoreName=OBJECTSTORE&id=" + HttpUtility.UrlEncode(fileNetID);
            contentURL += "&ut=" + HttpUtility.UrlEncode(encodeLabel(token));
            return contentURL;
4

1 回答 1

0

这是我的函数,你可以看到最后几行我如何在最后展开令牌:

public static string getCEUserToken(string baseURL, string uid, string pwd)
{
    string UserToken = "";
    System.Net.WebRequest request = System.Net.WebRequest.Create(baseURL +      "/setCredentials?op=getUserToken&userId=" + uid + "&password=" + pwd +
    "&verify=true");
    request.Method = "POST";
    System.Net.WebResponse response = request.GetResponse();
    Stream stream = response.GetResponseStream();
    byte[] token = new byte[response.ContentLength];
    stream.Read(token, 0, (int)response.ContentLength);
    response.Close();

    foreach (byte chr in token)
        UserToken += System.Convert.ToChar(chr);

    return System.Web.HttpUtility.UrlEncode(UserToken);
}
于 2014-02-17T18:08:20.470 回答