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