Beispiel #1
0
 protected void NotifyFailure(IAuthenticationToken token, AuthenticationException exception)
 {
     if (LoginFailed != null)
     {
         LoginFailed(this, new FailedLoginEventArgs(token, exception));
     }
 }
Beispiel #2
0
 public FailedLoginEventArgs(IAuthenticationToken token, AuthenticationException exception)
     : base(token)
 {
     if (exception == null)
     {
         throw new ArgumentNullException("exception");
     }
     _exception = exception;
 }
Beispiel #3
0
        public IAuthenticationInfo Authenticate(IAuthenticationToken token)
        {
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }

            Log.TraceFormat("Authentication attempt received for token [{0}]", token);
            try
            {
                IAuthenticationInfo info = DoAuthenticate(token);
                if (info == null)
                {
                    throw new AuthenticationException(
                              string.Format(Properties.Resources.NoAccountInformationForTokenMessage, token));
                }

                Log.DebugFormat("Authentication successful for token [{0}]. Returned account [{1}]", token, info);
                NotifySuccess(token, info);

                return(info);
            }
            catch (Exception e)
            {
                AuthenticationException ae = null;
                if (e is AuthenticationException)
                {
                    ae = (AuthenticationException)e;
                }
                if (ae == null)
                {
                    ae = new AuthenticationException(
                        string.Format(Properties.Resources.AuthenticationFailedForTokenMessage, token));
                }
                NotifyFailure(token, ae);

                throw ae;
            }
        }