关于单点登录的一些说明。原创
金蝶云社区-请输入昵称___
请输入昵称___
11人赞赏了该文章 918次浏览 未经作者许可,禁止转载编辑于2021年08月02日 14:50:35
  1. 首先用管理员进入:系统管理-系统管理-第三方系统登录授权。

  2. 获取应用ID,系统自动生成密钥。关于集成用户,非必填项,也不是第三方登录的默认用户名。具体有啥作用,也没弄明白,希望有知道的人能分享下。

  3. 根据官方提供的文档 https://vip.kingdee.com/article/9788 生成第三方链接。

  4. 官方的文档引用了

    Kingdee.BOS.Util中的SHA1Util.GetSignature(签名算法)、JSON.KDObjectConverter.SerializeObject(序列化)、ToBase6(扩展)三个方法

       Kingdee.BOS.BusinessEntity.LoginSimplePassportLoginArg(实体类参数),如果不想引用这两个插件,可以反编译提取出来,结果如下。 

    签名:

  public string GetSignature(string[] arr)
        {
            System.Array.Sort<string>(arr, System.StringComparer.Ordinal);
            string s = string.Join("", arr);
            System.Security.Cryptography.SHA1 sHA = System.Security.Cryptography.SHA1.Create();
            byte[] array = sHA.ComputeHash(System.Text.Encoding.UTF8.GetBytes(s));
            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
            byte[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                byte b = array2[i];
                stringBuilder.AppendFormat("{0:x2}", b);
            }
            return stringBuilder.ToString();
        }

序列化:根据自己使用的DLL如litJson、Newtonsoft进行序列化,也可以自行实现。

 DateTime Jan1st1970 = new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc);
            long timestamp = (long)(System.DateTime.UtcNow - Jan1st1970).TotalMilliseconds/1000;


ToBase6扩展:

 public  string ToBase64( byte[] binBuffer)
        {
            int num = (int)System.Math.Ceiling((double)binBuffer.Length / 3.0) * 4;
            char[] array = new char[num];
            System.Convert.ToBase64CharArray(binBuffer, 0, binBuffer.Length, array, 0);
            return  new string(array);
        }

实体类LoginSimplePassportLoginArg

  public class SimplePassportLoginArg
        {
            
            /// <summary>
            /// 数据中心
            /// </summary>
            public string dbid { get; set; }
         
            /// <summary>
            /// 用户名称
            /// </summary>
            public string username { get; set; }
            /// <summary>
            /// 应用程序ID
            /// </summary>
            public string appid { get; set; }
            /// <summary>
            /// 签名数据
            /// </summary>
            public string signeddata { get; set; }
            /// <summary>
            /// 时间戳
            /// </summary>
            public string timestamp { get; set; }
            /// <summary>
            /// 语言ID,中文2052(默认),英文1033,繁体3076;
            /// </summary>
            public string lcid { get; set; }
            /// <summary>
            ///  XT=云之家集成(同时要求entryrole=XT);SimPas=简单通行证集成;
            /// </summary>
            public string origintype { get; set; }
            /// <summary>
            /// 入口角色
            /// </summary>
            public string entryrole { get; set; }
            /// <summary>
            /// 登录后默认打开功能的表单id;
            /// </summary>
            public string formid { get; set; }
            /// <summary>
            ///  登录后默认打开功能的格式,目前有单据bill和列表list两种方式,没有列表的功能统一为bill;
            /// </summary>
            public string formtype { get; set; }
            /// <summary>
            ///   ormid对应表单的主键;formtype为list时忽略,formtype为bill时起作用,如果为空表示新增状态;
            /// </summary>
            public string pkid { get; set; }
            /// <summary>
            /// 作为用户自定义参数传入,使用于二开,具体内容和格式由二开人员确定,最终在指定表单的插件中通过
            /// </summary>
            public string otherargs { get; set; }
            /// <summary>
            /// 登录打开单据模式,默认页签打开,single主控台显示表单
            /// </summary>
            public string openmode { get; set; }
        }

5.当 formtype为bill状态时,openmode设置为single,打开的窗口为不带母版页的单据窗口,其他条件下都是带有母版页。




赞 11