Exemple #1
0
        /// <summary>
        /// Checks the authentication cookie and extract/returns the user name. If user is not authenticated it throws the appropriate exception
        /// </summary>
        /// <param name="authenticationService"></param>
        /// <param name="authenticationCookie"></param>
        /// <param name="userName"></param>
        /// <param name="extraOptions"></param>
        internal static void Authenticate(IAuthenticationAddin authenticationService, string authenticationCookie, out string userName, ExtraOptions extraOptions)
        {
            AuthenticationInfo info = null;

            try
            {
                info = authenticationService.GetAuthenticationInfo(authenticationCookie, null);
            }
            catch (Exception ex)
            {
                throw new ServiceAuthenticationException(ex.Message);
            }

            userName = "";

            if (null != info)
            {
                userName = info.UserName;

                if (authenticationService.IsTimedOut(info, null))
                {
                    throw new ServiceAuthenticationException("Timed-out");
                }
            }
            else
            {
                throw new ServiceAuthenticationException("Not Authenticated");
            }
        }
Exemple #2
0
 /// <summary>
 /// Checks if the user has permission to perform an operation and throws exception if not.
 /// </summary>
 /// <param name="authenticationService"></param>
 /// <param name="userName"></param>
 /// <param name="permission"></param>
 /// <param name="extraOptions"></param>
 private static void Authorize(IAuthenticationAddin authenticationService, string userName, Permission permission, ExtraOptions extraOptions)
 {
     if (!authenticationService.HasPermission(userName, permission.Name, null))
     {
         throw new ServiceAuthorizationException("Not enough permissions.");
     }
 }
 public AuthenticationService()
 {
     _addin = AddinsFactory.CreateAuthenticationAddin();
 }
Exemple #4
0
 public AuthHandler(AddinsFactory factory)
 {
     _auth = factory.CreateAuthenticationAddin();
 }
Exemple #5
0
 public WorklistService()
 {
     _Factory = new AddinsFactory();
     _AuthenticationService = _Factory.CreateAuthenticationAddin();
     _worklistAddin         = _Factory.CreateWorklistAddin();
 }