예제 #1
0
        /// <summary>
        /// Using client(consumer) id and key, start a 'readonly' Application-auth'd session
        /// </summary>
        /// <remarks>ref: https://dev.twitter.com/docs/api/1.1/post/oauth2/invalidate_token </remarks>
        public static async Task <bool> StopApplicationOnlyAuth(this IApplicationSession appsession)
        {
            if (string.IsNullOrEmpty(appsession.clientID))
            {
                throw new ArgumentException("Twitter Consumer Key is required for Application only Auth");
            }
            if (string.IsNullOrEmpty(appsession.clientSecret))
            {
                throw new ArgumentException("Twitter Consumer Secret is required for Application only Auth");
            }

            // ref: https://dev.twitter.com/docs/auth/application-only-auth
            // and ref: http://tools.ietf.org/html/rfc6749#section-4.4
            // and ref: https://dev.twitter.com/docs/api/1.1/post/oauth2/invalidate_token

            var oAuth2TokenUrlPostRequestRfc6749 = new SortedDictionary <string, string>
            {
                { "access_token", appsession.bearerToken }
            };

            var result = await appsession.PostAsync(TwitterApi.OAuth2TokenRevokeUrl(), oAuth2TokenUrlPostRequestRfc6749, forInitialAuth : true);

            if (!result.IsSuccessStatusCode)
            {
                return(false);
            }
            var content = await result.Content.ReadAsStringAsync();

            var jresponse = JObject.Parse(content);

            appsession.bearerToken = (string)jresponse["access_token"];
            appsession.IsActive    = false;
            return(true);
        }
예제 #2
0
        /// <summary>
        /// 登录信息
        /// </summary>
        public void Sign(string tokenStr)
        {
            WpfHelper.SignIn(tokenStr);
            session  = EngineHelper.Resolve <IApplicationSession>();
            culture  = session.Accessor.Culture.Name;
            clientIp = session.Accessor.ClientIp;
            appCode  = session.Accessor.AppCode;
            token    = tokenStr;

            Console.WriteLine($"Service Sign status:{session.IsAuthenticated}, account: {session.User.Account}");
        }
예제 #3
0
        public FieldProblem_Owen()
        {
            #region Mock Objects
            m_objMockRepository = new MockRepository();
            m_objIApplication   = (IApplicationSession)m_objMockRepository.StrictMock(typeof(IApplicationSession));
            m_objIMetricBroker  = (IMetricBroker)m_objMockRepository.StrictMock(typeof(IMetricBroker));
            #endregion

            #region DataSets

            m_objDSRatioMetric = new DataSet();

            using (m_objMockRepository.Ordered())
            {
                Rhino.Mocks.Expect.Call(m_objIApplication.IMetricBroker).Return(m_objIMetricBroker);
                Rhino.Mocks.Expect.Call(m_objIMetricBroker.FetchMetric("Risk")).Return(m_objDSRatioMetric);
            }
            m_objMockRepository.ReplayAll();

            #endregion

            m_objIMetric = Metric.GetByName(m_objIApplication, "Risk");
            m_objMockRepository.VerifyAll();
        }
예제 #4
0
 Metric(IApplicationSession pv_objIApplicationSession, DataSet pv_objDataSet)
 {
     m_objIApplicationSession = pv_objIApplicationSession;
 }
예제 #5
0
        public void TFsetup()
        {
            #region Mock Objects
            m_objMockRepository = new MockRepository();
            m_objIApplication = (IApplicationSession)m_objMockRepository.StrictMock(typeof(IApplicationSession));
            m_objIMetricBroker = (IMetricBroker)m_objMockRepository.StrictMock(typeof(IMetricBroker));
            #endregion

            #region DataSets

            m_objDSRatioMetric = new DataSet();

            using (m_objMockRepository.Ordered())
            {
                Rhino.Mocks.Expect.Call(m_objIApplication.IMetricBroker).Return(m_objIMetricBroker);
                Rhino.Mocks.Expect.Call(m_objIMetricBroker.FetchMetric("Risk")).Return(m_objDSRatioMetric);
            }
            m_objMockRepository.ReplayAll();

            #endregion

            m_objIMetric = Metric.GetByName(m_objIApplication, "Risk");
            m_objMockRepository.VerifyAll();
        }
예제 #6
0
 /// <summary>
 /// 获取应用程序上下文
 /// </summary>
 protected virtual IApplicationSession GetApplicationContext()
 {
     return(ApplicationSession ?? (ApplicationSession = Security.ApplicationSession.Current));
 }
예제 #7
0
        public FieldProblem_Owen()
        {
            m_objIApplication = (IApplicationSession)MockRepository.GenerateStrictMock(typeof(IApplicationSession), null, null);
            m_objIMetricBroker = (IMetricBroker)MockRepository.GenerateStrictMock(typeof(IMetricBroker), null, null);

            m_objDSRatioMetric = new DataSet();

            m_objIApplication.Expect(x => x.IMetricBroker).Return(m_objIMetricBroker);
            m_objIMetricBroker.Expect(x => x.FetchMetric("Risk")).Return(m_objDSRatioMetric);

            m_objIMetric = Metric.GetByName(m_objIApplication, "Risk");

            m_objIMetricBroker.AssertWasCalled(x => x.FetchMetric("Risk")).After(m_objIApplication.AssertWasCalled(x => x.IMetricBroker));

            m_objIApplication.VerifyAllExpectations();
            m_objIMetricBroker.VerifyAllExpectations();
        }
예제 #8
0
 public OwnIdentity(bool isAuthenticated, string name, IApplicationSession applicationSession)
 {
     IsAuthenticated    = isAuthenticated;
     Name               = name;
     ApplicationSession = applicationSession;
 }
예제 #9
0
 /// <summary>
 /// 初始化组件
 /// </summary>
 private void Init()
 {
     _applicationSession = GetApplicationContext();
 }
예제 #10
0
 Metric(IApplicationSession pv_objIApplicationSession, DataSet pv_objDataSet)
 {
     m_objIApplicationSession = pv_objIApplicationSession;
 }
예제 #11
0
 public DbBenchmarkWriter(IApplicationSession session, IBenchmark_Insert insertBenchmark)
 {
     this.session = session;
     this.insertBenchmark = insertBenchmark;
 }
예제 #12
0
 /// <summary>
 /// 获取应用程序上下文
 /// </summary>
 protected virtual IApplicationSession GetApplicationContext()
 {
     return _applicationSession ?? (_applicationSession = ApplicationSession.Current);
 }
예제 #13
0
 /// <summary>
 /// 初始化组件
 /// </summary>
 private void Init()
 {
     _applicationSession = GetApplicationContext();
 }
예제 #14
0
 public static IMetric GetByID(IApplicationSession pv_objIApplicationSession, long pv_lMetricID)
 {
     return new Metric(pv_objIApplicationSession, pv_objIApplicationSession.IMetricBroker.FetchMetric(pv_lMetricID));
 }
예제 #15
0
 public static IMetric GetByName(IApplicationSession pv_objIApplicationSession, string pv_strMetricName)
 {
     return(new Metric(pv_objIApplicationSession, pv_objIApplicationSession.IMetricBroker.FetchMetric(pv_strMetricName)));
 }
예제 #16
0
 public static IMetric GetByName(IApplicationSession pv_objIApplicationSession, string pv_strMetricName)
 {
     return new Metric(pv_objIApplicationSession, pv_objIApplicationSession.IMetricBroker.FetchMetric(pv_strMetricName));
 }
예제 #17
0
 public static IMetric GetByID(IApplicationSession pv_objIApplicationSession, long pv_lMetricID)
 {
     return(new Metric(pv_objIApplicationSession, pv_objIApplicationSession.IMetricBroker.FetchMetric(pv_lMetricID)));
 }
예제 #18
0
 /// <summary>
 /// 获取应用程序上下文
 /// </summary>
 protected virtual IApplicationSession GetApplicationContext()
 {
     return(_applicationSession ?? (_applicationSession = ApplicationSession.Current));
 }
예제 #19
0
 public OwnIdentity( bool isAuthenticated, string name,IApplicationSession applicationSession)
 {
     IsAuthenticated = isAuthenticated;
     Name = name;
     ApplicationSession = applicationSession;
 }