/// <summary> /// 初始化验证信息 /// </summary> /// <param name="profile">角色信息</param> /// <param name="accessToken">账号访问标识</param> /// <param name="properties">账号属性表</param> /// <param name="type">角色类型</param> public AuthenticationInfo(AuthenticationProfile profile, Guid accessToken, Dictionary <string, string> properties, string type) { Profile = profile; AccessToken = accessToken; Properties = properties; Type = type; }
/// <summary> /// 设置角色名和uuid /// </summary> /// <param name="name">角色名</param> /// <param name="id">角色的uuid,如果为null将自动生成一个</param> public void SetProfile(string name, Guid?id = null) { if (string.IsNullOrWhiteSpace(name)) { throw new AuthenticationException("Invalid username"); } if (id.HasValue) { profile = new AuthenticationProfile(name, id.Value); } else { MD5 md5 = new MD5CryptoServiceProvider(); profile = new AuthenticationProfile(name, new Guid(md5.ComputeHash(Encoding.GetEncoding("utf-8").GetBytes(name)))); } }