コード例 #1
0
        public static String getSessionToken(SessionTokenInformation sessionTokenInfo)
        {
            if (sessionTokenInfo == null)
            {
                throw new SessionTokenInfoException("SessionTokenInfo doesn't exist on Session!");
            }

            return(sessionTokenInfo.Session.SessionToken);
        }
コード例 #2
0
        public static SessionSecurityTicket getSessionSecurityTicket(SessionTokenInformation sessionTokenInfo)
        {
            if (sessionTokenInfo == null)
            {
                throw new SessionTokenInfoException("SessionTokenInfo doesn't exist on Session!");
            }

            SessionSecurityTicket ticket = new SessionSecurityTicket();

            ticket.AccountID     = sessionTokenInfo.Account.AccountID;
            ticket.TenantID      = sessionTokenInfo.Account.TenantID;
            ticket.SessionTicket = sessionTokenInfo.Session.SessionToken;

            return(ticket);
        }
コード例 #3
0
ファイル: BaseVerification.cs プロジェクト: OlafMd/MedCon1.0
        public SessionSecurityTicket VerifySessionToken(String SessionToken)
        {
            var authService = InfrastructureFactory.CreateAuthenticationService();

            var verificationResult = authService.VerifyToken(SessionToken);

            if (verificationResult.Status == CASResponseCode.OK)
            {
                SessionTokenInformation result = authService.GetSessionTokenInformation(SessionToken);
                return(SessionTokenInformationUtil.getSessionSecurityTicket(result));
            }
            else
            {
                var fault = new VerificationFault();
                fault.Message = "Session token is not valid";

                throw new FaultException <VerificationFault>(fault);
            }
        }
コード例 #4
0
        public SessionSecurityTicket Verify(String SessionToken)
        {
            var authService = InfrastructureFactory.CreateAuthenticationService();

            var verificationResult = authService.VerifyToken(SessionToken);

            if (verificationResult.Status == CASResponseCode.OK)
            {
                try {
                    SessionTokenInformation result = authService.GetSessionTokenInformation(SessionToken);
                    return(SessionTokenInformationUtil.getSessionSecurityTicket(result));
                }catch (Exception) {
                    throw new VerificationException(VerificationException.VerificationException_Message);
                }
            }
            else
            {
                throw new VerificationException(VerificationException.VerificationException_Message);
            }
        }
コード例 #5
0
        public SessionTokenInformation GetSessionTicket()
        {
            SessionTokenInformation sessionTokenInfo = SessionGlobal.Instance.SessionTokenInfo;

            return(sessionTokenInfo);
        }
コード例 #6
0
        public String GetSessionToken()
        {
            SessionTokenInformation sessionTokenInfo = SessionGlobal.Instance.SessionTokenInfo;

            return(sessionTokenInfo.Session.SessionToken);
        }
コード例 #7
0
        public SessionTokenInformation Authentication(bool urlSessionEnabled, int timeout)
        {
            SessionTokenInformation retVal = null;

            var bopSession = InfrastructureFactory.CreateSessionManager();
            var session    = SessionGlobal.Instance.SessionTokenInfo;

            if (session != null && session.Session != null && session.Session.SessionToken != null)
            {
                var status = VerifyToken();

                if (status != CASResponseCode.OK)
                {
                    //check if there is new token value in cookie
                    SessionTokenInformation sessionDataResp = bopSession.GetSessionData(HttpContext.Current.Request, urlSessionEnabled);

                    if (sessionDataResp != null && sessionDataResp.Session != null && sessionDataResp.Session.SessionToken != null)
                    {
                        //If session token and token from cookie are different check if one from cookie is valid
                        if (sessionDataResp.Session.SessionToken.Equals(session.Session.SessionToken) == false)
                        {
                            var status2 = VerifyToken(sessionDataResp.Session.SessionToken);
                            if (status2 == CASResponseCode.OK)
                            {
                                retVal = sessionDataResp;
                                SessionGlobal.Instance.SessionTokenInfo = sessionDataResp;

                                var service = BOp.Infrastructure.InfrastructureFactory.CreateAuthenticationService();
                                BOp.Infrastructure.Authentication.AccountCompaniesResult res = service.GetAccountCompanies(SessionGlobal.Instance.SessionTokenInfo.Session.SessionToken);

                                SessionGlobal.Instance.Companies = res.Companies;
                            }
                        }
                    }
                    else
                    {
                        FormsAuthentication.SignOut();
                        HttpContext.Current.Session.Clear();
                        HttpContext.Current.Session.Abandon();
                        string redirectURL = bopSession.CreateSignInURL(HttpContext.Current.Request.Url.ToString(), timeout, "EN", urlSessionEnabled);
                        HttpContext.Current.Response.Redirect(redirectURL, true);
                    }
                }
                else
                {
                    CheckSubscription();
                }
            }
            else
            {
                FormsAuthentication.SignOut();
                SessionTokenInformation sessionDataResp = bopSession.GetSessionData(HttpContext.Current.Request, urlSessionEnabled);
                if (sessionDataResp.Status == CASResponseCode.OK)
                {
                    SessionGlobal.Instance.SessionTokenInfo = sessionDataResp;

                    var service = BOp.Infrastructure.InfrastructureFactory.CreateAuthenticationService();
                    BOp.Infrastructure.Authentication.AccountCompaniesResult res = service.GetAccountCompanies(SessionGlobal.Instance.SessionTokenInfo.Session.SessionToken);

                    SessionGlobal.Instance.Companies = res.Companies;

                    CheckSubscription();
                }
                else
                {
                    string redirectURL = bopSession.CreateSignInURL(HttpContext.Current.Request.Url.ToString(), timeout, "EN", urlSessionEnabled);
                    HttpContext.Current.Response.Redirect(redirectURL, true);
                }
            }

            return(retVal);
        }
コード例 #8
0
        public SessionTokenInformation Authentication(bool urlSessionEnabled, int timeout)
        {
            SessionTokenInformation retVal = null;
            var    bopSession = InfrastructureFactory.CreateSessionManager();
            var    session    = SessionGlobal.Instance.SessionTokenInfo;
            var    lastUrl    = GetLastURL(HttpContext.Current.Request.Url.AbsoluteUri);
            string redirect   = bopSession.CreateSignInURL(lastUrl, timeout, "EN", urlSessionEnabled);

            if (session != null && session.Session != null && session.Session.SessionToken != null)
            {
                var status = VerifyToken();

                if (status != CASResponseCode.OK)
                {
                    //check if there is new token value in cookie
                    SessionTokenInformation sessionDataResp = bopSession.GetSessionData(HttpContext.Current.Request, urlSessionEnabled);

                    if (sessionDataResp != null && sessionDataResp.Session != null && sessionDataResp.Session.SessionToken != null)
                    {
                        //If session token and token from cookie are different check if one from cookie is valid
                        if (sessionDataResp.Session.SessionToken.Equals(session.Session.SessionToken) == false)
                        {
                            var status2 = VerifyToken(sessionDataResp.Session.SessionToken);
                            if (status2 == CASResponseCode.OK)
                            {
                                retVal = sessionDataResp;
                                SessionGlobal.Instance.SessionTokenInfo = sessionDataResp;

                                var service = BOp.Infrastructure.InfrastructureFactory.CreateAuthenticationService();
                                BOp.Infrastructure.Authentication.AccountCompaniesResult res = service.GetAccountCompanies(SessionGlobal.Instance.SessionTokenInfo.Session.SessionToken);

                                SessionGlobal.Instance.Companies = res.Companies;
                            }
                        }
                    }
                    else
                    {
                        FormsAuthentication.SignOut();
                        HttpContext.Current.Session.Clear();
                        HttpContext.Current.Session.Abandon();
                        string redirectURL = bopSession.CreateSignInURL(HttpContext.Current.Request.Url.ToString(), timeout, "EN", urlSessionEnabled);
                        HttpContext.Current.Response.Redirect(redirectURL, false);
                    }
                }
                else
                {
                    if (LoginURL == null)
                    {
                        LoginURL = redirect;
                    }

                    if (!CheckSubscription())
                    {
                        string redirectURL = bopSession.CreateSignInURL(HttpContext.Current.Request.Url.ToString(), timeout, "EN", urlSessionEnabled);
                        HttpContext.Current.Response.Redirect(redirectURL, true);
                    }
                }
            }
            else
            {
                SessionTokenInformation sessionDataResp = bopSession.GetSessionData(HttpContext.Current.Request, urlSessionEnabled);

                if (sessionDataResp.Status == CASResponseCode.OK)
                {
                    FormsAuthentication.SignOut();
                    SessionGlobal.Instance.SessionTokenInfo = sessionDataResp;

                    var service = BOp.Infrastructure.InfrastructureFactory.CreateAuthenticationService();
                    BOp.Infrastructure.Authentication.AccountCompaniesResult res = service.GetAccountCompanies(SessionGlobal.Instance.SessionTokenInfo.Session.SessionToken);

                    SessionGlobal.Instance.Companies = res.Companies;
                    if (LoginURL == null)
                    {
                        LoginURL = redirect;
                    }

                    if (!CheckSubscription())
                    {
                        string redirectURL = bopSession.CreateSignInURL(HttpContext.Current.Request.Url.ToString(), timeout, "EN", urlSessionEnabled);
                        return(sessionDataResp);// HttpContext.Current.Response.Redirect(redirectURL, true);
                    }
                }
                else
                {
                    string redirectURL = bopSession.CreateSignInURL(HttpContext.Current.Request.Url.ToString(), timeout, "EN", urlSessionEnabled);
                    //HttpContext.Current.Response.Redirect(redirectURL, true);
                    //save login URL into session
                    if (LoginURL == null)
                    {
                        LoginURL = redirect;
                    }

                    var    fullURL  = VirtualPathUtility.ToAbsolute("~/UserManagement/LogOutOnExpiredSession?url=");
                    string urlLocal = fullURL + HttpContext.Current.Request.Url.ToString() + "&urlSessionEnabled=" + urlSessionEnabled;
                    HttpContext.Current.Response.Redirect(redirectURL, true);
                }
            }


            return(retVal);
        }