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