Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Web/Mockup/MockupMembershipProvider.cs @ 12817

Last change on this file since 12817 was 9166, checked in by fschoepp, 11 years ago

#1888:

  • Model: OptimizationScenario may be a tree of algorithms (and problems)
  • Model: Renamed InputParameters to ProblemParameters (as they are the parameters of a problem)
  • Model: Added JobExecutionDetails which contain Repetitions + Group (resource to use)
  • ScenarioParser parses the new XML scenario files
  • Website + Model: You are now able to add/remove rows from a table (no JavaScript involved yet)
  • Website + Controller: Added repetitions (enables batch jobs) and group (resource to use) to OaaS which will be used by the controller to schedule the job
  • Website: Updated templates to use new model structure
  • Website + Scenarios: Added the new algorithm Benchmark Algorithm
  • Controller: Added a singleton to make the (Azure/Mockup)-DAL exchangeable
  • Controller: Added mockup classes for DAL + IScenarioManager
  • Website/Result Page: Line Diagrams will be added via JavaScript, crawling their data using AJAX
  • Website: Most configuration parameters can be set in the ServiceDefinition directly
  • Added a mockup for the Membership classes: These can be used if no network connection is available or if other parts of the app shall be tested
  • Scenarios: Updated TSP mappings to new xsd
File size: 5.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Web.Security;
6
7namespace HeuristicLab.Services.Optimization.ControllerService.Mockup {
8  public class MockupRoleProvider : RoleProvider {
9    public override void AddUsersToRoles(string[] usernames, string[] roleNames) {     
10    }
11
12    public override void CreateRole(string roleName) {     
13    }
14
15    public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) {
16      return true;
17    }
18
19    public override string[] FindUsersInRole(string roleName, string usernameToMatch) {
20      return new string[] { "fschoeppl" };
21    }
22
23    public override string[] GetAllRoles() {
24      return new string[] { "Web User" };
25    }
26
27    public override string[] GetRolesForUser(string username) {
28      return new string[] { "Web User" };
29    }
30
31    public override string[] GetUsersInRole(string roleName) {
32      return new string[] { "fschoeppl" };
33    }
34
35    public override bool IsUserInRole(string username, string roleName) {
36      return true;
37    }
38
39    public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) {     
40    }
41
42    public override bool RoleExists(string roleName) {
43      return roleName == "Web User";
44    }
45
46    public override string ApplicationName {
47      get; set;
48    }
49  }
50
51  public class MockupMembershipProvider : MembershipProvider {
52    private static MembershipUser testUser;
53
54    static MockupMembershipProvider() {
55      try {
56        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);
57      }
58      catch (Exception e) {
59        Console.WriteLine(e.Message);
60      }
61    }
62
63    public override bool ChangePassword(string username, string oldPassword, string newPassword) {
64      return true;
65    }
66
67    public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) {
68      return true;
69    }
70
71    public override bool EnablePasswordReset {
72      get { return true; }
73    }
74
75    public override bool  EnablePasswordRetrieval
76    {
77      get { return true; }
78    }
79
80    public override string ApplicationName {
81      get;
82      set;
83    }
84
85    public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) {
86      var user = new MembershipUser("MockupMembershipProvider", username, providerUserKey, email, passwordQuestion, passwordAnswer, true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now);
87      status = MembershipCreateStatus.Success;
88      return user;
89    }
90
91    public override bool DeleteUser(string username, bool deleteAllRelatedData) {
92      return true;
93    }
94
95    public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords) {
96      var col = new MembershipUserCollection();
97      totalRecords = 0;
98      if (emailToMatch == "fschoeppl") {
99        totalRecords = 1;
100        col.Add(testUser);
101      }
102      return col;
103    }
104
105    public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) {
106      return FindUsersByEmail(usernameToMatch, pageIndex, pageSize, out totalRecords);
107    }
108
109    public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) {
110      return FindUsersByEmail("fschoeppl", pageIndex, pageSize, out totalRecords);
111    }
112
113    public override int GetNumberOfUsersOnline() {
114      return 1;
115    }
116
117    public override string GetPassword(string username, string answer) {
118      if (username == "fschoeppl")
119        return "fschoeppl";
120      return "";
121    }
122
123    public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) {
124      if (testUser.ProviderUserKey == providerUserKey)
125        return testUser;
126      return null;
127    }
128
129    public override MembershipUser GetUser(string username, bool userIsOnline) {
130      if (testUser.UserName == username)
131        return testUser;
132      return null;
133    }
134
135    public override string GetUserNameByEmail(string email) {
136      if (testUser.Email == email)
137        return testUser.UserName;
138      return null;
139    }
140
141    public override int MaxInvalidPasswordAttempts {
142      get { return 100; }
143    }
144
145    public override int MinRequiredNonAlphanumericCharacters {
146      get { return 0; }
147    }
148
149    public override int MinRequiredPasswordLength {
150      get { return 1; }
151    }
152
153    public override int PasswordAttemptWindow {
154      get { return 5; }
155    }
156
157    public override MembershipPasswordFormat PasswordFormat {
158      get { return MembershipPasswordFormat.Clear; }
159    }
160
161    public override string PasswordStrengthRegularExpression {
162      get { return ""; }
163    }
164
165    public override bool RequiresQuestionAndAnswer {
166      get { return true; }
167    }
168
169    public override bool RequiresUniqueEmail {
170      get { return false; }
171    }
172
173    public override string ResetPassword(string username, string answer) {
174      return "fschoeppl";
175    }
176
177    public override bool UnlockUser(string userName) {
178      return true;
179    }
180
181    public override void UpdateUser(MembershipUser user) {
182    }
183
184    public override bool ValidateUser(string username, string password) {
185      return username == "fschoeppl" && password == "fschoeppl";
186    }
187
188  }
189}
Note: See TracBrowser for help on using the repository browser.