예제 #1
0
        /// <summary>
        ///     创建Token
        /// </summary>
        /// <param name="creds"></param>
        /// <returns></returns>
        public override Token Create(Credentials creds)
        {
            if (creds == null)
            {
                throw new ArgumentException("身份认证信息不能为空");
            }
            ContextInfo contextInfo = creds.GetContextInfo();
            string      tokenStr    = TokenHelper.BuildSecureTokenStr(this.TokenSize);
            Token       token       = TokenHelper.CreateToken(tokenStr, contextInfo);

            if (token != null)
            {
                _tokenStorage.Add(token.TokenStr, token);
            }
            return(token);
        }
예제 #2
0
 /// <summary>
 ///     创建Token串
 /// </summary>
 /// <param name="enterpriseID"></param>
 /// <param name="tokenSize"></param>
 /// <returns></returns>
 private static string BuildTokenStr(string enterpriseID, int tokenSize)
 {
     return(string.Format("{0}{1}{2}", enterpriseID, TokenStrSplitSymbol,
                          TokenHelper.BuildSecureTokenStr(tokenSize)));
 }