using System; using System.Security.Principal; using MonNamespace_Business; using System.Collections.Generic; namespace MonNamespace_Security { public class SecurityManager { public int ErrorReason { get; private set; } public int Authenticate(string userName, string password) { //TODO : appel du service wcf pour l'authentification return monservice.ValidateUserAuthentication(userName, password); } public UserPrincipal ConstructUserPrincipal(IIdentity identity) { string userLogin = identity.Name; if ((userLogin.Length > 0)) { //appel du service wcf pour l'authentification a la place du manager USERManager myUserManager = new USERManager(); USER data = myUserManager.GetUSERByLogin(userLogin); List roles = myUserManager.GetUSERRolesByLogin(userLogin); var userIdentity = new UserIdentity(data.USER_ID, userLogin, identity.IsAuthenticated, identity.AuthenticationType) { FirstName = data.USER_FIRST_NAME, LastName = data.USER_LAST_NAME, Roles = roles }; return new UserPrincipal(userIdentity); } else { return null; } } } }