public static DocsPaWR.ValidationResult ValidateLogin(string userName, string idAmm, string sessionId) { DocsPaWR.ValidationResult result = DocsPaWR.ValidationResult.APPLICATION_ERROR; try { result = wss.ValidateLogin(userName, idAmm, sessionId); } catch (Exception exception) { // DocsPaUtils.LogsManagement.Debugger.Write("Impossibile validare la sessione.", exception); result = DocsPaWR.ValidationResult.APPLICATION_ERROR; Debugger.Write("Errore nel ValidateLogin: " + exception.Message); } return(result); }
public void CheckSessionValidity() { try { DocsPaWR.Utente usr = (DocsPAWA.DocsPaWR.Utente)Session["userData"]; DocsPaWR.ValidationResult vr = UserManager.ValidateLogin(usr.userId, usr.idAmministrazione, Session.SessionID); switch (vr) { case DocsPAWA.DocsPaWR.ValidationResult.OK: sessionValid = true; sessionMsg = null; break; case DocsPAWA.DocsPaWR.ValidationResult.SESSION_DROPPED: sessionValid = false; sessionMsg = SESSION_DROPPED_MSG; break; case DocsPAWA.DocsPaWR.ValidationResult.SESSION_EXPIRED: sessionValid = false; sessionMsg = SESSION_EXPIRED_MSG; break; default: sessionValid = false; sessionMsg = SESSION_ERROR_MSG; break; } } catch (Exception) { sessionValid = false; sessionMsg = SESSION_ERROR_MSG; } if (!sessionValid) { string url = this.GetBaseUrl() + "/Login.aspx?error=" + sessionMsg; Response.Redirect(url, true); } }
public static void CheckSession() { //Verifica sessione scaduta string MessageType = String.Empty; if (UIManager.UserManager.GetUserInSession() == null) { MessageType = "1"; ILog logger = LogManager.GetLogger(typeof(AdministrationManager)); logger.Debug("Sessione scaduta"); } else { if (HttpContext.Current.Session["OpenDirectLink"] != null && !string.IsNullOrEmpty(HttpContext.Current.Session["OpenDirectLink"].ToString())) { //Accesso diretto al link del documento } else { //Verifica multiutenza Utente utente = UIManager.UserManager.GetUserInSession(); InfoUtente delegato = UserManager.getDelegato(); if (utente != null) { //if (delegato != null) //{ // DocsPaWR.ValidationResult resultValidationPage = UserManager.ValidateLogin(delegato.userId, delegato.idAmministrazione, utente.sessionID); // if (resultValidationPage == DocsPaWR.ValidationResult.SESSION_DROPPED) // { // MessageType = "2"; // ILog logger = LogManager.GetLogger(typeof(AdministrationManager)); // logger.Debug("L'utente si è connesso da un'altra postazione."); // } //} //else //{ DocsPaWR.ValidationResult resultValidationPage = UserManager.ValidateLogin(utente.userId, utente.idAmministrazione, utente.sessionID); if (resultValidationPage == DocsPaWR.ValidationResult.SESSION_DROPPED) { MessageType = "2"; ILog logger = LogManager.GetLogger(typeof(AdministrationManager)); logger.Debug("L'utente si è connesso da un'altra postazione."); } //} } } } //Verifico se la pagina chiamante è una popup o una basepage if (!string.IsNullOrEmpty(MessageType)) { string UrlCall = HttpContext.Current.Request.Url.AbsolutePath.ToString().ToLower(); if (UrlCall.IndexOf("/popup/", 0) > 0) { if (UrlCall.IndexOf("/popup/addkeyword", 0) > 0) { RedirectPage(MessageType, "Step1"); } else { RedirectPage(MessageType, "Step2"); } } else { RedirectPage(MessageType, "StepStop"); } } }
/// <summary> /// Verifica se la sessione corrente è relativa al sito accessibile /// </summary> /// <param name="ctx"></param> /// <returns></returns> //private bool OnSitoAccessibile(HttpContext ctx) //{ // return (ctx.Request.Path.ToLower().IndexOf("sitoaccessibile") >= 0); //} //bool IsAdminTool(HttpContext ctx) //{ // return (ctx.Request.Path.ToLower().IndexOf("admintool") >= 0); //} public void OnPreRequestHandler(object obj, EventArgs args) { HttpApplication app = (HttpApplication)obj; HttpContext ctx = app.Context; // Modifica per integrazione con portale ANAS //if (ctx.Request.Url.AbsolutePath.ToLower().IndexOf("portal_docspa.aspx") > 0) //return; // Modifica per evitare Pagina sessione scaduta quando passo di nuovo su login subito dopo logoff. if (ctx.Request.Url.AbsolutePath.ToLower().IndexOf("login.aspx") > 0) { return; } // Evito ricorsione su pagina di uscita //if (ctx.Request.Url.AbsolutePath.ToLower().IndexOf("exit.aspx") > 0) // return; if (ctx.Session != null) { if (ctx.Session.IsNewSession) { string cookieHeader = ctx.Request.Headers["Cookie"]; if ((null != cookieHeader) && (cookieHeader.IndexOf("ASP.NET_SessionId") >= 0)) { string path = GetAppPath(ctx); //if (!IsAdminTool(ctx)) //{ // if (this.OnSitoAccessibile(ctx)) // path += ("SitoAccessibile/SessionAborted.aspx?result=" + DocsPaWR.ValidationResult.SESSION_EXPIRED); // else path += ("SessionAborted.aspx?result=" + DocsPaWR.ValidationResult.SESSION_EXPIRED); //} //else //{ // path += "AdminTool/login.htm"; //} System.Diagnostics.Debug.WriteLine("§§§§§.... [Nuova Sessione con Cookie] ....§§§§§"); System.Diagnostics.Debug.WriteLine("§§§§§.... [ABORT!] ....§§§§§"); System.Diagnostics.Debug.WriteLine("§§§§§.... [Path] : " + ctx.Request.Path + " ....§§§§§"); //Logger.log("Sessione Scaduta, ultima pagina chiamata pagina: " + ctx.Request.Path); ctx.Response.Redirect(path.ToString()); } } else { DocsPaWR.Utente utente = (DocsPaWR.Utente)ctx.Session["userData"]; if (utente != null) { DocsPaWR.ValidationResult resultValidationPage = UserManager.ValidateLogin(utente.userId, utente.idAmministrazione, ctx.Session.SessionID); if (resultValidationPage == DocsPaWR.ValidationResult.SESSION_DROPPED) { string path = GetAppPath(ctx); //if (!IsAdminTool(ctx)) //{ // if (this.OnSitoAccessibile(ctx)) // path += ("SitoAccessibile/SessionAborted.aspx?result=" + DocsPaWR.ValidationResult.SESSION_DROPPED); // else path += ("SessionAborted.aspx?result=" + DocsPaWR.ValidationResult.SESSION_DROPPED); //} //else //{ // path += "AdminTool/login.htm"; //} ctx.Session["userData"] = null; System.Diagnostics.Debug.WriteLine("§§§§§.... [Sessione esistente con dati utente] ....§§§§§"); System.Diagnostics.Debug.WriteLine("§§§§§.... [ABORT!] ....§§§§§"); System.Diagnostics.Debug.WriteLine("§§§§§.... [Path] : " + path + " ....§§§§§"); ctx.Response.Redirect(path); } } } } }