Пример #1
0
 /// <summary>
 /// Persists an authorisation code identifier along with the userId making
 /// the authorisation attempt.
 /// </summary>
 public static void PersistAuthorisationAttempt(AuthorisationAttempt authAttempt)
 {
     _authAttemptRepo.Add(authAttempt.AttemptIdentifier, authAttempt);
 }
Пример #2
0
        /// <summary>
        /// Creates an AuthAttempt structure to hold information
        /// about the current session/auth attempt/user.
        /// </summary>
        private AuthorisationAttempt CreateAuthAttempt()
        {
            AuthorisationAttempt attempt = new AuthorisationAttempt();

            //Construct random string to identify this authorisation attempt
            //The authorisation server will echo this back to us so we can
            //tie an authorisation attempt with a session/user.
            byte[] buffer = new byte[32];
            RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
            crypto.GetBytes(buffer);

            string stateIdentifier = Convert.ToBase64String(buffer);

            attempt.AttemptIdentifier = stateIdentifier;
            attempt.UserId = GetLoggedInUserId();

            return attempt;
        }