private static bool AppLogOffCallBackUrlExist(List <AppLogOffCallBackUrl> list, string appID, string callbackUrl) { bool result = false; for (int i = 0; i < list.Count; i++) { AppLogOffCallBackUrl au = list[i]; if (string.Compare(au.AppID, appID, true) == 0 && string.Compare(au.LogOffCallBackUrl, callbackUrl, true) == 0) { result = true; break; } } return(result); }
/// <summary> /// 得到每一个应用注销所使用的回调Url /// </summary> /// <returns></returns> public List <AppLogOffCallBackUrl> GetAllRelativeAppsLogOffCallBackUrl() { ExceptionHelper.CheckStringIsNullOrEmpty(this.SessionID, "SessionID"); ExceptionHelper.CheckStringIsNullOrEmpty(this.ApplicationID, "ApplicationID"); ExceptionHelper.CheckStringIsNullOrEmpty(this.CallbackUrl, "CallbackUrl"); List <AppLogOffCallBackUrl> urls = PassportSignInSettings.GetConfig().PersistSignInInfo.GetAllRelativeAppsLogOffCallBackUrl(this.SessionID); if (AppLogOffCallBackUrlExist(urls, this.ApplicationID, this.CallbackUrl) == false) { AppLogOffCallBackUrl au = new AppLogOffCallBackUrl(); au.AppID = this.ApplicationID; au.LogOffCallBackUrl = this.CallbackUrl; urls.Add(au); } return(urls); }
/// <summary> /// 获取注销时所有需要注销的Url回调地址 /// </summary> /// <param name="sessionID">sessionID</param> /// <returns>相关应用的注销回调地址列表</returns> /// <remarks> /// <code source="..\Framework\TestProjects\DeluxeWorks.Library.Passport.Test\DataObjectsTest.cs" region="GetAppLogOffCallBackTest" lang="cs" title="获取相关应用的注销回调地址列表" /> /// </remarks> public List <AppLogOffCallBackUrl> GetAllRelativeAppsLogOffCallBackUrl(string sessionID) { ExceptionHelper.CheckStringIsNullOrEmpty(sessionID, "sessionID"); string sql = string.Format("SELECT APP_ID, APP_LOGOFF_URL FROM PASSPORT_TICKET WHERE SIGNIN_ID = {0}", TSqlBuilder.Instance.CheckQuotationMark(sessionID, true)); DataTable table; using (DbContext context = DbContext.GetContext(DataAdapter.DBConnectionName)) { Database db = DatabaseFactory.Create(DataAdapter.DBConnectionName); table = db.ExecuteDataSet(CommandType.Text, sql).Tables[0]; } Dictionary <string, AppLogOffCallBackUrl> dict = new Dictionary <string, AppLogOffCallBackUrl>(StringComparer.OrdinalIgnoreCase); foreach (DataRow row in table.Rows) { AppLogOffCallBackUrl au = new AppLogOffCallBackUrl(); au.AppID = row["APP_ID"].ToString(); au.LogOffCallBackUrl = row["APP_LOGOFF_URL"].ToString(); dict[au.AppID + "-" + au.LogOffCallBackUrl] = au; } List <AppLogOffCallBackUrl> list = new List <AppLogOffCallBackUrl>(); foreach (KeyValuePair <string, AppLogOffCallBackUrl> kv in dict) { list.Add(kv.Value); } return(list); }
private void LogOffAllAPP(string sessionID, string appID, string callbackUrl) { ExceptionHelper.CheckStringIsNullOrEmpty(sessionID, "sessionID"); ExceptionHelper.CheckStringIsNullOrEmpty(appID, "appID"); ExceptionHelper.CheckStringIsNullOrEmpty(callbackUrl, "callbackUrl"); List<AppLogOffCallBackUrl> urls = PassportSignInSettings.GetConfig().PersistSignInInfo.GetAllRelativeAppsLogOffCallBackUrl(sessionID); if (AppLogOffCallBackUrlExist(urls, appID, callbackUrl) == false) { AppLogOffCallBackUrl au = new AppLogOffCallBackUrl(); au.AppID = appID; au.LogOffCallBackUrl = callbackUrl; urls.Add(au); } this.RenderCallBackUrls(urls); PassportSignInSettings.GetConfig().PersistSignInInfo.DeleteRelativeSignInInfo(sessionID); PassportManager.ClearSignInCookie(); }
private void LogOffAllAPP(string sessionID, string appID, string callbackUrl) { ExceptionHelper.CheckStringIsNullOrEmpty(sessionID, "sessionID"); ExceptionHelper.CheckStringIsNullOrEmpty(appID, "appID"); ExceptionHelper.CheckStringIsNullOrEmpty(callbackUrl, "callbackUrl"); List<AppLogOffCallBackUrl> list = PassportSignInSettings.GetConfig().PersistSignInInfo.GetAllRelativeAppsLogOffCallBackUrl(sessionID); if (AppLogOffCallBackUrlExist(list, appID, callbackUrl) == false) { AppLogOffCallBackUrl au = new AppLogOffCallBackUrl(); au.AppID = appID; au.LogOffCallBackUrl = callbackUrl; list.Add(au); } HtmlTable table = new HtmlTable(); tableContainer.InnerHtml = string.Empty; tableContainer.Controls.Add(table); foreach (AppLogOffCallBackUrl au in list) { HtmlTableRow tRow = new HtmlTableRow(); table.Controls.Add(tRow); HtmlTableCell cell = new HtmlTableCell(); cell.InnerText = " "; tRow.Controls.Add(cell); cell = new HtmlTableCell(); tRow.Controls.Add(cell); HtmlImage img = new HtmlImage(); img.Align = "absmiddle"; img.Src = au.LogOffCallBackUrl; img.Alt = img.Src; cell.Controls.Add(img); cell = new HtmlTableCell(); cell.InnerText = string.Format(Translate("退出应用程序{0}"), au.AppID); tRow.Controls.Add(cell); } PassportSignInSettings.GetConfig().PersistSignInInfo.DeleteRelativeSignInInfo(sessionID); PassportManager.ClearSignInCookie(); }
/// <summary> /// 获取注销时所有需要注销的Url回调地址 /// </summary> /// <param name="sessionID">sessionID</param> /// <returns>相关应用的注销回调地址列表</returns> /// <remarks> /// <code source="..\Framework\TestProjects\DeluxeWorks.Library.Passport.Test\DataObjectsTest.cs" region="GetAppLogOffCallBackTest" lang="cs" title="获取相关应用的注销回调地址列表" /> /// </remarks> public List<AppLogOffCallBackUrl> GetAllRelativeAppsLogOffCallBackUrl(string sessionID) { ExceptionHelper.CheckStringIsNullOrEmpty(sessionID, "sessionID"); string sql = string.Format("SELECT APP_ID, APP_LOGOFF_URL FROM PASSPORT_TICKET WHERE SIGNIN_ID = {0}", TSqlBuilder.Instance.CheckQuotationMark(sessionID, true)); DataTable table; using (DbContext context = DbContext.GetContext(DataAdapter.DBConnectionName)) { Database db = DatabaseFactory.Create(DataAdapter.DBConnectionName); table = db.ExecuteDataSet(CommandType.Text, sql).Tables[0]; } Dictionary<string, AppLogOffCallBackUrl> dict = new Dictionary<string, AppLogOffCallBackUrl>(StringComparer.OrdinalIgnoreCase); foreach (DataRow row in table.Rows) { AppLogOffCallBackUrl au = new AppLogOffCallBackUrl(); au.AppID = row["APP_ID"].ToString(); au.LogOffCallBackUrl = row["APP_LOGOFF_URL"].ToString(); dict[au.AppID + "-" + au.LogOffCallBackUrl] = au; } List<AppLogOffCallBackUrl> list = new List<AppLogOffCallBackUrl>(); foreach (KeyValuePair<string, AppLogOffCallBackUrl> kv in dict) { list.Add(kv.Value); } return list; }