Changeset 4590
- Timestamp:
- 10/10/10 13:20:18 (14 years ago)
- Location:
- branches/UserManagement
- Files:
-
- 12 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UserManagement/HeuristicLab.Services.Authentication.DataTransfer/Membership.cs
r4589 r4590 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 2 using System.Runtime.Serialization; 6 3 … … 13 10 public Guid ApplicationId { get; set; } 14 11 [DataMember] 15 public Guid UserI D{ get; set; }12 public Guid UserId { get; set; } 16 13 [DataMember] 17 14 public string Password { get; set; } 18 [DataMember]19 public string PasswordFormat { get; set; }20 [DataMember]21 public string PasswordSalt { get; set; }22 [DataMember]23 public string MobilePIN { get; set; }15 // [DataMember] 16 // public string PasswordFormat { get; set; } 17 // [DataMember] 18 // public string PasswordSalt { get; set; } 19 // [DataMember] 20 // public string MobilePIN { get; set; } 24 21 [DataMember] 25 22 public string Email { get; set; } 26 23 [DataMember] 27 24 public string LoweredEmail { get; set; } 28 [DataMember]29 public string PasswordQuestion { get; set; }30 [DataMember]31 public string PasswordAnswer { get; set; }25 // [DataMember] 26 // public string PasswordQuestion { get; set; } 27 // [DataMember] 28 // public string PasswordAnswer { get; set; } 32 29 [DataMember] 33 30 public bool IsApproved { get; set; } 34 31 [DataMember] 35 public bool IsLo okedOut { get; set; }32 public bool IsLockedOut { get; set; } 36 33 [DataMember] 37 34 public DateTime CreateDate { get; set; } … … 42 39 [DataMember] 43 40 public DateTime LastLockoutDate { get; set; } 44 [DataMember]45 public int FailedPasswordAttemptCount { get; set; }46 [DataMember]47 public DateTime FailedPasswordAttemptWindowStart { get; set; }48 [DataMember]49 public int FailedPasswordAnswerAttemptCount { get; set; }50 [DataMember]51 public DateTime FailedPasswordAnswerAttemptWindowStart { get; set; }41 // [DataMember] 42 // public int FailedPasswordAttemptCount { get; set; } 43 // [DataMember] 44 // public DateTime FailedPasswordAttemptWindowStart { get; set; } 45 // [DataMember] 46 // public int FailedPasswordAnswerAttemptCount { get; set; } 47 // [DataMember] 48 // public DateTime FailedPasswordAnswerAttemptWindowStart { get; set; } 52 49 [DataMember] 53 50 public string Comment { get; set; } -
branches/UserManagement/HeuristicLab.Services.Authentication.DataTransfer/Role.cs
r4584 r4590 11 11 { 12 12 [DataMember] 13 public Guid Id { get; set; }13 public Guid ApplicationId { get; set; } 14 14 [DataMember] 15 public string Name { get; set; } 15 public Guid RoleId { get; set; } 16 [DataMember] 17 public string RoleName { get; set; } 18 [DataMember] 19 public string LoweredRoleName { get; set; } 20 [DataMember] 21 public string Description { get; set; } 16 22 } 17 23 } -
branches/UserManagement/HeuristicLab.Services.Authentication.DataTransfer/User.cs
r4584 r4590 10 10 public class User 11 11 { 12 13 [DataMember] 14 public Guid ApplicationId { get; set; } 12 15 [DataMember] 13 16 public Guid UserId { get; set; } 14 17 [DataMember] 15 public Guid ApplicationId{ get; set; }18 public string UserName { get; set; } 16 19 [DataMember] 17 public string UserName { get; set; } 20 public string LoweredUserName { get; set; } 21 [DataMember] 22 public string MobileAlias { get; set; } 23 [DataMember] 24 public bool IsAnonymous { get; set; } 18 25 [DataMember] 19 26 public DateTime LastActivityDate { get; set; } -
branches/UserManagement/HeuristicLab.Services.Authentication.TestClient/HeuristicLab.Services.Authentication.TestClient.csproj
r4584 r4590 38 38 <Reference Include="System.Core" /> 39 39 <Reference Include="System.Data.Services.Client" /> 40 <Reference Include="System.Drawing" /> 40 41 <Reference Include="System.ServiceModel" /> 42 <Reference Include="System.Windows.Forms" /> 41 43 <Reference Include="System.Xml.Linq" /> 42 44 <Reference Include="System.Data.DataSetExtensions" /> … … 46 48 </ItemGroup> 47 49 <ItemGroup> 50 <Compile Include="RoleDetail.cs"> 51 <SubType>Form</SubType> 52 </Compile> 53 <Compile Include="RoleDetail.Designer.cs"> 54 <DependentUpon>RoleDetail.cs</DependentUpon> 55 </Compile> 48 56 <Compile Include="TestClient.cs" /> 49 57 <Compile Include="Properties\AssemblyInfo.cs" /> 58 <Compile Include="UserDetail.cs"> 59 <SubType>Form</SubType> 60 </Compile> 61 <Compile Include="UserDetail.Designer.cs"> 62 <DependentUpon>UserDetail.cs</DependentUpon> 63 </Compile> 64 <Compile Include="UserManagement.cs"> 65 <SubType>Form</SubType> 66 </Compile> 67 <Compile Include="UserManagement.Designer.cs"> 68 <DependentUpon>UserManagement.cs</DependentUpon> 69 </Compile> 50 70 </ItemGroup> 51 71 <ItemGroup> … … 59 79 </ProjectReference> 60 80 </ItemGroup> 81 <ItemGroup> 82 <EmbeddedResource Include="RoleDetail.resx"> 83 <DependentUpon>RoleDetail.cs</DependentUpon> 84 </EmbeddedResource> 85 <EmbeddedResource Include="UserDetail.resx"> 86 <DependentUpon>UserDetail.cs</DependentUpon> 87 </EmbeddedResource> 88 <EmbeddedResource Include="UserManagement.resx"> 89 <DependentUpon>UserManagement.cs</DependentUpon> 90 </EmbeddedResource> 91 </ItemGroup> 92 <ItemGroup> 93 <None Include="Properties\DataSources\HeuristicLab.Services.Authentication.DataTransfer.Role.datasource" /> 94 <None Include="Properties\DataSources\HeuristicLab.Services.Authentication.DataTransfer.User.datasource" /> 95 </ItemGroup> 61 96 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 62 97 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
branches/UserManagement/HeuristicLab.Services.Authentication.TestClient/TestClient.cs
r4588 r4590 1 1 using System; 2 2 3 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using HeuristicLab.Services.Authentication; 6 using HeuristicLab.Services.Authentication.DataTransfer; 4 using System.Windows.Forms; 5 7 6 8 7 namespace HeuristicLab.Services.Authentication.TestClient … … 12 11 static void Main(string[] args) 13 12 { 13 14 Application.Run(new UserManagement()); 14 15 15 AuthenticationService auth = new AuthenticationService();16 //AuthenticationService auth = new AuthenticationService(); 16 17 17 try18 {19 IEnumerable<User> list = new List<User>();20 list = auth.GetUsers();21 foreach (var item in list)22 {23 Console.WriteLine("Item=" + item.UserName);24 }18 //try 19 //{ 20 // IEnumerable<User> list = new List<User>(); 21 // list = auth.GetUsers(); 22 // foreach (var item in list) 23 // { 24 // Console.WriteLine("Item=" + item.UserName); 25 // } 25 26 26 Console.WriteLine("Try to delete user...");27 // Console.WriteLine("Try to delete user..."); 27 28 28 User u = new User() { UserId = new Guid("e4abc6ae-c954-4efd-8108-e536226fd9c7")};29 auth.DeleteUser(u);29 // // User u = new User() { UserId = }; 30 // auth.DeleteUser(new Guid("e4abc6ae-c954-4efd-8108-e536226fd9c7")); 30 31 31 }32 catch (Exception e)33 {34 Console.WriteLine(e.Message);35 }36 Console.ReadLine();32 //} 33 //catch (Exception e) 34 //{ 35 // Console.WriteLine(e.Message); 36 //} 37 //Console.ReadLine(); 37 38 //ServiceClient client = new ServiceClient(); 38 39 //client.ClientCredentials.UserName.UserName = "Alice"; -
branches/UserManagement/HeuristicLab.Services.Authentication/AuthenticationService.cs
r4588 r4590 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using System.Text;5 4 using System.ServiceModel; 6 5 using HeuristicLab.Services.Authentication.DataTransfer; … … 14 13 { 15 14 #region User 16 public DataTransfer.User GetUser(Guid UserId) 15 16 public DataTransfer.User GetUser(Guid id) 17 17 { 18 18 … … 22 22 23 23 var User = from item in UserTable 24 where item.UserId == UserId24 where item.UserId == id 25 25 select item; 26 26 return Convert.ToDataTransfer((aspnet_User)User); … … 48 48 return UserList; 49 49 } 50 51 public void InsertUser(User user) 50 public bool InsertUser(User user) 52 51 { 53 52 // insert user 54 53 if (user != null) 55 54 { 56 57 58 59 55 using (UserManagementDataContext db = new UserManagementDataContext()) 60 56 { 61 aspnet_User userDa = Convert.ToEntity(user); 62 db.aspnet_Users.InsertOnSubmit(userDa); 63 db.SubmitChanges(); 57 try 58 { 59 aspnet_User userDa = Convert.ToEntity(user); 60 db.aspnet_Users.InsertOnSubmit(userDa); 61 db.SubmitChanges(); 62 } 63 catch (Exception e) 64 { 65 return false; 66 } 64 67 } 68 return true; 69 } 70 return false; 71 } 72 public bool DeleteUser(Guid id) 73 { 65 74 66 } 75 return false; 76 } 77 public bool UpdateUser(User user) 78 { 79 return false; 67 80 } 68 81 69 public void DeleteUser(User user) 70 { 71 if (user != null) 72 { 82 #endregion 73 83 74 84 85 #region Role 75 86 87 public Role GetRole(Guid id) 88 { 89 Role role = new Role(); 90 // ... 91 92 return role; 93 } 94 public IEnumerable<Role> GetRoles() 95 { 96 List<Role> RoleList = new List<Role>(); 97 98 using (UserManagementDataContext db = new UserManagementDataContext()) 99 { 100 Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>(); 101 102 var Roles = from item in RoleTable 103 select item; 104 foreach (var Role in Roles) 105 { 106 RoleList.Add(Convert.ToDataTransfer((aspnet_Role)Role)); 107 } 108 } 109 110 return RoleList; 111 } 112 public bool InsertRole(Role role) 113 { 114 if (role != null) 115 { 76 116 using (UserManagementDataContext db = new UserManagementDataContext()) 77 117 { 78 79 // membership 80 // profile 81 // users per role 82 // personalization per role 83 84 //////////////// 85 86 // servie mit id aufrufen, id mit datacontext holen und dann löschen ... 87 88 db.SubmitChanges(); 118 try 119 { 120 aspnet_Role roleDa = Convert.ToEntity(role); 121 db.aspnet_Roles.InsertOnSubmit(roleDa); 122 db.SubmitChanges(); 123 } 124 catch (Exception e) 125 { 126 return false; 127 } 89 128 } 90 129 return true; 91 130 } 131 return false; 132 } 133 public bool UpdateRole(Role role) 134 { 135 return false; 136 } 137 public bool DeleteRole(Guid id) 138 { 139 return false; 140 } 141 public bool AddRoleToUser(Guid roleId, Guid userId) 142 { 143 return false; 144 } 145 public bool RemoveRoleFromUser(Guid roleId, Guid userId) 146 { 147 return false; 148 } 149 public IEnumerable<Role> GetRolesForUser(Guid userId) 150 { 151 List<Role> roles = new List<Role>(); 152 return roles; 92 153 } 93 154 … … 95 156 } 96 157 } 158 -
branches/UserManagement/HeuristicLab.Services.Authentication/Convert.cs
r4588 r4590 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using HeuristicLab.Services.Authentication.DataAccess; 1 using HeuristicLab.Services.Authentication.DataAccess; 6 2 using HeuristicLab.Services.Authentication.DataTransfer; 7 3 … … 23 19 return new aspnet_User() 24 20 { 21 ApplicationId = source.ApplicationId, 25 22 UserId = source.UserId, 26 23 UserName = source.UserName, 27 LastActivityDate = source.LastActivityDate, 28 ApplicationId = source.ApplicationId, 24 LoweredUserName = source.LoweredUserName, 25 IsAnonymous = source.IsAnonymous, 26 LastActivityDate = source.LastActivityDate 29 27 }; 30 28 } … … 40 38 return new User() 41 39 { 42 UserName = source.UserName 40 ApplicationId = source.ApplicationId, 41 UserId = source.UserId, 42 UserName = source.UserName, 43 LoweredUserName = source.LoweredUserName, 44 IsAnonymous = source.IsAnonymous, 45 LastActivityDate = source.LastActivityDate 43 46 }; 44 47 } … … 53 56 if ((source != null) && (target != null)) 54 57 { 58 target.ApplicationId = source.ApplicationId; 59 target.UserId = source.UserId; 55 60 target.UserName = source.UserName; 56 } 57 58 } 59 60 61 #endregion 62 61 target.LoweredUserName = source.LoweredUserName; 62 target.IsAnonymous = source.IsAnonymous; 63 target.LastActivityDate = source.LastActivityDate; 64 } 65 66 } 67 68 69 #endregion 63 70 64 71 #region Application 65 72 73 /// <summary> 74 /// converts data transfer object to data access objet 75 /// </summary> 76 /// <param name="source">data transfer object</param> 77 /// <returns>data access object</returns> 78 public static aspnet_Application ToEntity(Application source) 79 { 80 if (source == null) return null; 81 return new aspnet_Application() 82 { 83 ApplicationId = source.ApplicationId, 84 ApplicationName = source.ApplicationName, 85 LoweredApplicationName = source.LoweredApplicationName, 86 Description = source.Description 87 }; 88 } 89 90 /// <summary> 91 /// converts data access object to data transfer object 92 /// </summary> 93 /// <param name="source">data access object</param> 94 /// <returns>data transfer object</returns> 95 public static Application ToDataTransfer(aspnet_Application source) 96 { 97 if (source == null) return null; 98 return new Application() 99 { 100 ApplicationId = source.ApplicationId, 101 ApplicationName = source.ApplicationName, 102 LoweredApplicationName = source.LoweredApplicationName, 103 Description = source.Description 104 }; 105 } 106 107 /// <summary> 108 /// converts data transfer object to data access object 109 /// </summary> 110 /// <param name="source">data transfer object</param> 111 /// <param name="target">data access object</param> 112 public static void ToEntity(Application source, aspnet_Application target) 113 { 114 if ((source != null) && (target != null)) 115 { 116 target.ApplicationId = source.ApplicationId; 117 target.ApplicationName = source.ApplicationName; 118 target.LoweredApplicationName = source.LoweredApplicationName; 119 target.Description = source.Description; 120 } 121 122 } 123 66 124 #endregion 67 125 68 126 #region Membership 69 127 128 /// <summary> 129 /// converts data transfer object to data access objet 130 /// </summary> 131 /// <param name="source">data transfer object</param> 132 /// <returns>data access object</returns> 133 public static aspnet_Membership ToEntity(Membership source) 134 { 135 if (source == null) return null; 136 return new aspnet_Membership() 137 { 138 ApplicationId = source.ApplicationId, 139 UserId = source.UserId, 140 Password = source.Password, 141 Email = source.Email, 142 LoweredEmail = source.LoweredEmail, 143 IsApproved = source.IsApproved, 144 IsLockedOut = source.IsLockedOut, 145 CreateDate = source.CreateDate, 146 LastLoginDate = source.LastLoginDate, 147 LastPasswordChangedDate = source.LastPasswordChangedDate, 148 LastLockoutDate = source.LastLockoutDate, 149 Comment = source.Comment 150 151 }; 152 } 153 154 /// <summary> 155 /// converts data access object to data transfer object 156 /// </summary> 157 /// <param name="source">data access object</param> 158 /// <returns>data transfer object</returns> 159 public static Membership ToDataTransfer(aspnet_Membership source) 160 { 161 if (source == null) return null; 162 return new Membership() 163 { 164 ApplicationId = source.ApplicationId, 165 UserId = source.UserId, 166 Password = source.Password, 167 Email = source.Email, 168 LoweredEmail = source.LoweredEmail, 169 IsApproved = source.IsApproved, 170 IsLockedOut = source.IsLockedOut, 171 CreateDate = source.CreateDate, 172 LastLoginDate = source.LastLoginDate, 173 LastPasswordChangedDate = source.LastPasswordChangedDate, 174 LastLockoutDate = source.LastLockoutDate, 175 Comment = source.Comment 176 }; 177 } 178 179 /// <summary> 180 /// converts data transfer object to data access object 181 /// </summary> 182 /// <param name="source">data transfer object</param> 183 /// <param name="target">data access object</param> 184 public static void ToEntity(Membership source, aspnet_Membership target) 185 { 186 if ((source != null) && (target != null)) 187 { 188 target.ApplicationId = source.ApplicationId; 189 target.UserId = source.UserId; 190 target.Password = source.Password; 191 target.Email = source.Email; 192 target.LoweredEmail = source.LoweredEmail; 193 target.IsApproved = source.IsApproved; 194 target.IsLockedOut = source.IsLockedOut; 195 target.CreateDate = source.CreateDate; 196 target.LastLoginDate = source.LastLoginDate; 197 target.LastPasswordChangedDate = source.LastPasswordChangedDate; 198 target.LastLockoutDate = source.LastLockoutDate; 199 target.Comment = source.Comment; 200 } 201 202 } 203 70 204 #endregion 71 205 72 206 #region Role 73 207 74 #endregion 75 76 #region User 208 /// <summary> 209 /// converts data transfer object to data access objet 210 /// </summary> 211 /// <param name="source">data transfer object</param> 212 /// <returns>data access object</returns> 213 public static aspnet_Role ToEntity(Role source) 214 { 215 if (source == null) return null; 216 return new aspnet_Role() 217 { 218 ApplicationId = source.ApplicationId, 219 RoleId = source.RoleId, 220 RoleName = source.RoleName, 221 LoweredRoleName = source.LoweredRoleName, 222 Description = source.Description 223 }; 224 } 225 226 /// <summary> 227 /// converts data access object to data transfer object 228 /// </summary> 229 /// <param name="source">data access object</param> 230 /// <returns>data transfer object</returns> 231 public static Role ToDataTransfer(aspnet_Role source) 232 { 233 if (source == null) return null; 234 return new Role() 235 { 236 ApplicationId = source.ApplicationId, 237 RoleId = source.RoleId, 238 RoleName = source.RoleName, 239 LoweredRoleName = source.LoweredRoleName, 240 Description = source.Description 241 }; 242 } 243 244 /// <summary> 245 /// converts data transfer object to data access object 246 /// </summary> 247 /// <param name="source">data transfer object</param> 248 /// <param name="target">data access object</param> 249 public static void ToEntity(Role source, aspnet_Role target) 250 { 251 if ((source != null) && (target != null)) 252 { 253 target.ApplicationId = source.ApplicationId; 254 target.RoleId = source.RoleId; 255 target.RoleName = source.RoleName; 256 target.LoweredRoleName = source.LoweredRoleName; 257 target.Description = source.Description; 258 } 259 260 } 77 261 78 262 #endregion -
branches/UserManagement/HeuristicLab.Services.Authentication/Interfaces/IAuthenticationService.cs
r4588 r4590 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Linq;4 using System.Text;5 3 using HeuristicLab.Services.Authentication.DataTransfer; 6 4 using System.ServiceModel; … … 13 11 { 14 12 #region User 13 15 14 [OperationContract] 16 15 User GetUser(Guid id); … … 20 19 21 20 [OperationContract] 22 void InsertUser(User user); 21 bool InsertUser(User user); 22 23 [OperationContract] 24 bool DeleteUser(Guid id); 25 26 [OperationContract] 27 bool UpdateUser(User user); 28 23 29 #endregion 24 30 31 #region Role 32 33 [OperationContract] 34 Role GetRole(Guid id); 35 36 [OperationContract] 37 IEnumerable<Role> GetRoles(); 38 39 [OperationContract] 40 bool InsertRole(Role role); 41 42 [OperationContract] 43 bool UpdateRole(Role role); 44 45 [OperationContract] 46 bool DeleteRole(Guid id); 47 48 [OperationContract] 49 bool AddRoleToUser(Guid roleId, Guid userId); 50 51 [OperationContract] 52 bool RemoveRoleFromUser(Guid roleId, Guid userId); 53 54 [OperationContract] 55 IEnumerable<Role> GetRolesForUser(Guid userId); 56 57 #endregion 25 58 } 26 59 }
Note: See TracChangeset
for help on using the changeset viewer.