コード例 #1
0
        internal static string Authenticate(string authenticationCookie, bool impersonater = false)
        {
            AuthenticationInfo ai = null;
            var srv = AddinsFactory.CreateSessionAuthenticationAddin();

            try
            {
                ai = srv.GetAuthenticationInfo(authenticationCookie);
            }
            catch (Exception ex)
            {
                throw new ServiceAuthenticationException(ex.Message);
            }

            if (srv.IsTimedOut(ai))
            {
                throw new ServiceAuthenticationException("Timed-out");
            }

            if (impersonater && !string.IsNullOrEmpty(ai.ImpersonatedUserName))
            {
                return(ai.ImpersonatedUserName);
            }
            else
            {
                return(ai.UserName);
            }
        }
コード例 #2
0
        internal static string Authorize(string authenticationCookie, Permission permission)
        {
            AuthenticationInfo ai = null;
            var srv = AddinsFactory.CreateSessionAuthenticationAddin();

            try
            {
                ai = srv.GetAuthenticationInfo(authenticationCookie);
            }
            catch (Exception ex)
            {
                throw new ServiceAuthenticationException(ex.Message);
            }

            if (srv.IsTimedOut(ai))
            {
                throw new ServiceAuthenticationException("Timed-out");
            }

            if (!srv.HasPermission(ai, permission))
            {
                throw new ServiceAuthenticationException("Not Authenticated");
            }

            //passed
            return(ai.UserName);
        }
コード例 #3
0
        internal static string Authenticate(string authenticationCookie)
        {
            AuthenticationInfo ai = null;
            var srv = AddinsFactory.CreateSessionAuthenticationAddin();

            try
            {
                ai = srv.GetAuthenticationInfo(authenticationCookie);
            }
            catch (Exception ex)
            {
                throw new ServiceAuthenticationException(ex.Message);
            }

            if (srv.IsTimedOut(ai))
            {
                throw new ServiceAuthenticationException("Timed-out");
            }

            return(ai.UserName);
        }