Changeset 1737 for trunk/sources/HeuristicLab.Security.Core/3.2
- Timestamp:
- 05/04/09 19:42:18 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Security.Core/3.2/PermissionManager.cs
r1736 r1737 8 8 using HeuristicLab.DataAccess.Interfaces; 9 9 using HeuristicLab.PluginInfrastructure; 10 using System.Security.Cryptography; 10 11 11 12 namespace HeuristicLab.Security.Core { … … 19 20 Object locker = new Object(); 20 21 21 22 private static string getMd5Hash(string input) { 23 // Create a new instance of the MD5CryptoServiceProvider object. 24 MD5 md5Hasher = MD5.Create(); 25 26 // Convert the input string to a byte array and compute the hash. 27 byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input)); 28 29 // Create a new Stringbuilder to collect the bytes 30 // and create a string. 31 StringBuilder sBuilder = new StringBuilder(); 32 33 // Loop through each byte of the hashed data 34 // and format each one as a hexadecimal string. 35 for (int i = 0; i < data.Length; i++) { 36 sBuilder.Append(data[i].ToString("x2")); 37 } 38 39 // Return the hexadecimal string. 40 return sBuilder.ToString(); 41 } 42 22 43 /// <summary> 23 44 /// If a session exists for this userName then it is returned, otherwise the given password … … 34 55 session = factory.GetSessionForCurrentThread(); 35 56 57 password = getMd5Hash(password); 58 36 59 IUserAdapter userAdapter = session.GetDataAdapter<User, IUserAdapter>(); 37 60 User user = userAdapter.GetByLogin(userName); 38 61 39 if (user.Password.CompareTo(password) == 0) { 62 if (user != null && 63 user.Password.Equals(password)) { 40 64 Guid newSessionId = Guid.NewGuid(); 41 65 lock (locker) … … 105 129 return Guid.Empty; 106 130 } 107 108 public void TestServer() {109 }110 131 } 111 132 }
Note: See TracChangeset
for help on using the changeset viewer.