using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.Security; namespace HeuristicLab.Services.Optimization.ControllerService.Mockup { public class MockupRoleProvider : RoleProvider { public override void AddUsersToRoles(string[] usernames, string[] roleNames) { } public override void CreateRole(string roleName) { } public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) { return true; } public override string[] FindUsersInRole(string roleName, string usernameToMatch) { return new string[] { "fschoeppl" }; } public override string[] GetAllRoles() { return new string[] { "Web User" }; } public override string[] GetRolesForUser(string username) { return new string[] { "Web User" }; } public override string[] GetUsersInRole(string roleName) { return new string[] { "fschoeppl" }; } public override bool IsUserInRole(string username, string roleName) { return true; } public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { } public override bool RoleExists(string roleName) { return roleName == "Web User"; } public override string ApplicationName { get; set; } } public class MockupMembershipProvider : MembershipProvider { private static MembershipUser testUser; static MockupMembershipProvider() { try { testUser = new MembershipUser("MockupMembershipProvider", "fschoeppl", "1", "fschoeppl", "Birthday of your mother?", "No comment", true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now); } catch (Exception e) { Console.WriteLine(e.Message); } } public override bool ChangePassword(string username, string oldPassword, string newPassword) { return true; } public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) { return true; } public override bool EnablePasswordReset { get { return true; } } public override bool EnablePasswordRetrieval { get { return true; } } public override string ApplicationName { get; set; } public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { var user = new MembershipUser("MockupMembershipProvider", username, providerUserKey, email, passwordQuestion, passwordAnswer, true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now); status = MembershipCreateStatus.Success; return user; } public override bool DeleteUser(string username, bool deleteAllRelatedData) { return true; } public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords) { var col = new MembershipUserCollection(); totalRecords = 0; if (emailToMatch == "fschoeppl") { totalRecords = 1; col.Add(testUser); } return col; } public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) { return FindUsersByEmail(usernameToMatch, pageIndex, pageSize, out totalRecords); } public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) { return FindUsersByEmail("fschoeppl", pageIndex, pageSize, out totalRecords); } public override int GetNumberOfUsersOnline() { return 1; } public override string GetPassword(string username, string answer) { if (username == "fschoeppl") return "fschoeppl"; return ""; } public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) { if (testUser.ProviderUserKey == providerUserKey) return testUser; return null; } public override MembershipUser GetUser(string username, bool userIsOnline) { if (testUser.UserName == username) return testUser; return null; } public override string GetUserNameByEmail(string email) { if (testUser.Email == email) return testUser.UserName; return null; } public override int MaxInvalidPasswordAttempts { get { return 100; } } public override int MinRequiredNonAlphanumericCharacters { get { return 0; } } public override int MinRequiredPasswordLength { get { return 1; } } public override int PasswordAttemptWindow { get { return 5; } } public override MembershipPasswordFormat PasswordFormat { get { return MembershipPasswordFormat.Clear; } } public override string PasswordStrengthRegularExpression { get { return ""; } } public override bool RequiresQuestionAndAnswer { get { return true; } } public override bool RequiresUniqueEmail { get { return false; } } public override string ResetPassword(string username, string answer) { return "fschoeppl"; } public override bool UnlockUser(string userName) { return true; } public override void UpdateUser(MembershipUser user) { } public override bool ValidateUser(string username, string password) { return username == "fschoeppl" && password == "fschoeppl"; } } }