/// <summary> /// Initializes a new instance of the <see cref="UserFactory" /> class. /// </summary> /// <param name="statusChecker">The status checker.</param> /// <param name="passwordValidator">The password validator.</param> /// <param name="symmetricKeyStore">The symmetric key store.</param> /// <param name="entityContextFactory">The entity context factory.</param> public UserFactory(IMembershipStatusChecker statusChecker, IPasswordValidator passwordValidator, ISymmetricKeyStore symmetricKeyStore, IEntityContextFactory entityContextFactory) { _statusChecker = statusChecker; _passwordValidator = passwordValidator; _symmetricKeyStore = symmetricKeyStore; _entityContextFactory = entityContextFactory; }
/// <summary> /// Determines whether the correct security answer is submitted. /// </summary> /// <param name="user">The user.</param> /// <param name="submittedAnswer">The submitted answer.</param> /// <param name="symmetricKeyStore">The symmetric key store.</param> /// <returns> /// <c>true</c> if the correct security answer is submitted.; otherwise, <c>false</c>. /// </returns> public static bool IsCorrectSecurityAnswer(this User user, string submittedAnswer, ISymmetricKeyStore symmetricKeyStore) { if (string.IsNullOrEmpty(submittedAnswer)) { return false; } var encryptedSecurityAnswer = SymmetricUtility.Encrypt(submittedAnswer, symmetricKeyStore.ReadKey(), symmetricKeyStore.ReadIV()); if (string.Compare(encryptedSecurityAnswer, user.SecurityAnswer, StringComparison.Ordinal) != 0) { return false; } return true; }
public EncryptedSettingsManager(IEntityContextFactory entityContextFactory, IOrgUnitContextStorage orgUnitContextStorage, ISymmetricKeyStore symmetricKeyStore) : base(entityContextFactory, orgUnitContextStorage) { _symmetricKeyStore = symmetricKeyStore; }