1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Web.Security;
|
---|
6 |
|
---|
7 | namespace 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 | }
|
---|