Ejemplo n.º 1
0
 public static DataSet.SubscriberRow PublishSubscriber(AuthScheme authScheme)
 {
     DataSet.SubscriberDataTable dt = new DataSet.SubscriberDataTable();
     SubscriberTableAdapter ta = new SubscriberTableAdapter();
     dt.AddSubscriberRow(SiteConstant.Title, Guid.NewGuid().ToString("N"), authScheme.ToString(), Constant.Ago);
     ta.Update(dt);
     return dt[0];
 }
Ejemplo n.º 2
0
 public static DataSet.SubscriberRow ResolveSubscriber(string tokenBody, AuthScheme authScheme)
 {
     if (tokenBody == null)
     {
         return PublishSubscriber(authScheme);
     }
     TokenTableAdapter tta = new TokenTableAdapter();
     DataSet.TokenDataTable tdt = tta.GetDataByBody(tokenBody);
     if (tdt.Count == 0)
     {
         return PublishSubscriber(authScheme);
     }
     DataSet.TokenRow token = tdt[0];
     SubscriberTableAdapter sta = new SubscriberTableAdapter();
     DataSet.SubscriberRow subscriber = sta.GetDataById(token.SubscriberId)[0];
     if (subscriber.AuthScheme != authScheme.ToString())
     {
         throw new DoubtfulAuthBehaviorException("�F�؃g�[�N�������s���ꂽ�Ƃ��Ƃ͈قȂ�F�ؕ����œn����܂����B");
     }
     return subscriber;
 }
Ejemplo n.º 3
0
 public bool IsAuthScheme(AuthScheme authScheme)
 {
     return subscriber.AuthScheme == authScheme.ToString();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 使用认证
 /// </summary>
 /// <param name="scheme">认证类型</param>
 /// <param name="auth">认证数据</param>
 public void Authorize(AuthScheme scheme, string auth = "")
 {
     CheckConnection();
     zookeeper.addAuthInfo(scheme.ToString().ToLower(), Encoding.GetBytes(auth));
 }
        // Asynchronously creates an authenticated client to make all API calls
        private async Task InitializeAsync()
        {
            // a. Uncomment one of the Auth schemes below or create your own
            switch (AuthScheme)
            {
            case None:
                break;

            case Bearer:
                await BearerAuthentication(LoginExtension, TokenKey, TokenSource);

                break;

            case Basic:
                BasicAuthentication();
                break;

            default:
                throw new CustomException(string.Format(Resources.Application_InitializeAsync_UnknownAuthSchemeException, AuthScheme.ToString()));
            }

            // b. Create a reusable HTTP Client to make all the API calls
            //CreateClient();

            // c. Get everything else you want from the API here
        }