public Common.Message.SignOutResult Logout(Common.Message.SignOutMessage message) { SignOutResult result = new SignOutResult(); IdentityTokenGenerator generator = new IdentityTokenGenerator(); result.IdentityToken = generator.ExpireToken(message.IdentityToken); return(result); }
public Common.Message.AuthenticationResult Authenticate(Common.Message.SignInMessage message) { Common.Message.AuthenticationResult result = new Common.Message.AuthenticationResult(); var userAccount = ((ManagementAccountTDataAccess)this.dataAccess).CheckAccount(message.UserName, message.Password); if (userAccount != null) { IdentityTokenGenerator generator = new IdentityTokenGenerator(); var token = generator.GenerateToken(userAccount.MapToAccountDto(), message); result.IdentityToken = token; ManagementLogGenerator.GenerateManagementLog(userAccount.SecurityUserId, "Login", "ManagementService", 1, "success login", 0); } else { result.ErrorMessage = "اطلاعات حساب کاربری اشتباه است!"; ManagementLogGenerator.GenerateManagementLog(userAccount.SecurityUserId, "Login", "ManagementService", 0, "failed login", 0); } return(result); }
public Common.Message.AuthenticationResult Authenticate(Common.Message.SignInMessage message) { Common.Message.AuthenticationResult result = new Common.Message.AuthenticationResult(); SecurityUserBussiness userBs = new SecurityUserBussiness(); var userAccount = ((AccountTDataAccess)this.dataAccess).CheckAccount(message.UserName, int.Parse(message.ClientId)); if (userAccount != null) { var user = userBs.GetSingle(it => it.UserId == userAccount.UserId); if (user == null || user.IsLocked) { result.ErrorMessage = " کاربر بطور موقت قفل است!"; UserLogGenerator.GenerateUserLog("-1", "-1", "", message.ClientId, "Authenticate", message.UserName, "faild login.user not exist"); return(result); } if (userAccount.IsEnabled) { if (userAccount.IsActiveDirectory > 0) { //TODO: Active directory check } else { if (userAccount.ExpiredDate == null || userAccount.ExpiredDate > DateTime.Now) { string hashed = ISE.Framework.Server.Common.Security.EncryptionAlgorithm.CreateHMACMD5(message.PlainPassword, message.UserName); if (userAccount.Password.Equals(hashed)) { IdentityTokenGenerator generator = new IdentityTokenGenerator(); var token = generator.GenerateToken(userAccount, message); result.IdentityToken = token; UserLogGenerator.GenerateUserLog(token.SessionId, token.SubjectId, userAccount.AccountId.ToString(), message.ClientId, "Authenticate", message.UserName, "success login"); } else { result.ErrorMessage = "رمز عبور اشتباه است"; UserLogGenerator.GenerateUserLog("-1", userAccount.UserId.ToString(), userAccount.AccountId.ToString(), message.ClientId, "Authenticate", message.UserName, "failed login.incorrect password."); } } else { result.ErrorMessage = "کاربر منقضی شده است!"; UserLogGenerator.GenerateUserLog("-1", userAccount.UserId.ToString(), userAccount.AccountId.ToString(), message.ClientId, "Authenticate", message.UserName, "failed login.expired account."); } } } else { result.ErrorMessage = " حساب کاربری غیرفعال است!"; UserLogGenerator.GenerateUserLog("-1", "-1", "", message.ClientId, "Authenticate", message.UserName, "faild login.user not exist"); } } else { result.ErrorMessage = "اطلاعات حساب کاربری اشتباه است!"; UserLogGenerator.GenerateUserLog("-1", "-1", "", message.ClientId, "Authenticate", message.UserName, "faild login.user not exist"); } return(result); }