Ejemplo n.º 1
0
 /// <summary>
 /// GetCredentialByCredentialId method implementation
 /// </summary>
 public MFAUserCredential GetCredentialByCredentialId(MFAWebAuthNUser user, string credentialId)
 {
     try
     {
         List <MFAUserCredential> _creds = _mfacredusers.GetData();
         return(_creds.FirstOrDefault(s => s.UserId.SequenceEqual(user.Id) && (HexaEncoding.GetHexStringFromByteArray(s.Descriptor.Id)).Equals(credentialId)));
     }
     catch (Exception ex)
     {
         DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000);
         throw new Exception(ex.Message);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// GetMFAUser method implementation
        /// </summary>
        public override MFAUser GetMFAUser(string upn)
        {
            if (string.IsNullOrEmpty(upn))
            {
                return(null);
            }
            List <MFAUser> _lst = _mfausers.GetData();

            return(_lst.FirstOrDefault(s => s.UPN.ToLower().Equals(upn.ToLower())));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// HasStoredCertificate method implementation
        /// </summary>
        public override string GetUserKey(string upn)
        {
            string result = string.Empty;

            try
            {
                List <MFAUserKeys> _lst = _mfakeysusers.GetData();
                MFAUserKeys        _itm = _lst.FirstOrDefault(s => s.UserName.ToLower().Equals(upn.ToLower()) && (!string.IsNullOrEmpty(s.UserKey)));
                if (_itm != null)
                {
                    result = _itm.UserKey;
                }
            }
            catch (Exception ex)
            {
                DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000);
                throw new Exception(ex.Message);
            }
            return(result);
        }
        /// <summary>
        /// GetUserCertificate method implementation
        /// </summary>
        public override X509Certificate2 GetUserCertificate(string upn, string password)
        {
            X509Certificate2 result = null;

            try
            {
                List <MFAUserKeys> _lst = _mfakeysusers.GetData();
                MFAUserKeys        _itm = _lst.FirstOrDefault(s => s.UserName.ToLower().Equals(upn.ToLower()) && (!string.IsNullOrEmpty(s.UserCertificate)));
                if (_itm != null)
                {
                    X509Certificate2 cert = new X509Certificate2(Convert.FromBase64String(_itm.UserCertificate), password, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.EphemeralKeySet);
                    result = cert;
                }
            }
            catch (Exception ex)
            {
                DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000);
                throw new Exception(ex.Message);
            }
            return(result);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// IsMFAUserRegistered method implementation
 /// </summary>
 private bool IsMFAUserRegistered(string upn)
 {
     try
     {
         if (string.IsNullOrEmpty(upn))
         {
             return(false);
         }
         List <MFAUser> _lst = _mfausers.GetData();
         return(_lst.FirstOrDefault(s => s.UPN.ToLower().Equals(upn.ToLower())) != null);
     }
     catch (Exception ex)
     {
         DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000);
         return(false);
     }
 }