mirror of https://github.com/apache/cloudstack.git
CS-15018: Event USER.LOGIN should contain the client IP address. Changes made in accordance with the coding convention.
Reviewed-by: Alena Prokharchyk
This commit is contained in:
parent
810151586b
commit
f6d16d0ab5
|
|
@ -773,7 +773,7 @@ public class ApiServer implements HttpRequestHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public void loginUser(HttpSession session, String username, String password, Long domainId, String domainPath, Map<String, Object[]> requestParameters) throws CloudAuthenticationException {
|
||||
public void loginUser(HttpSession session, String username, String password, Long domainId, String domainPath, String loginIpAddress ,Map<String, Object[]> requestParameters) throws CloudAuthenticationException {
|
||||
// We will always use domainId first. If that does not exist, we will use domain name. If THAT doesn't exist
|
||||
// we will default to ROOT
|
||||
if (domainId == null) {
|
||||
|
|
@ -789,7 +789,7 @@ public class ApiServer implements HttpRequestHandler {
|
|||
}
|
||||
}
|
||||
|
||||
UserAccount userAcct = _accountMgr.authenticateUser(username, password, domainId, requestParameters);
|
||||
UserAccount userAcct = _accountMgr.authenticateUser(username, password, domainId, loginIpAddress, requestParameters);
|
||||
if (userAcct != null) {
|
||||
String timezone = userAcct.getTimezone();
|
||||
float offsetInHrs = 0f;
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ public class ApiServlet extends HttpServlet {
|
|||
if (username != null) {
|
||||
String pwd = ((password == null) ? null : password[0]);
|
||||
try {
|
||||
_apiServer.loginUser(session, username[0], pwd, domainId, domain, params);
|
||||
_apiServer.loginUser(session, username[0], pwd, domainId, domain, req.getRemoteAddr(), params);
|
||||
auditTrailSb.insert(0,
|
||||
"(userId=" + session.getAttribute("userid") + " accountId=" + ((Account) session.getAttribute("accountobj")).getId() + " sessionId=" + session.getId() + ")");
|
||||
String loginResponse = getLoginSuccessResponse(session, responseType);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public interface AccountManager extends AccountService {
|
|||
* made, and the signature itself in the single sign-on case
|
||||
* @return a user object, null if the user failed to authenticate
|
||||
*/
|
||||
UserAccount authenticateUser(String username, String password, Long domainId, Map<String, Object[]> requestParameters);
|
||||
UserAccount authenticateUser(String username, String password, Long domainId, String loginIpAddress, Map<String, Object[]> requestParameters);
|
||||
|
||||
/**
|
||||
* Locate a user by their apiKey
|
||||
|
|
|
|||
|
|
@ -1618,7 +1618,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserAccount authenticateUser(String username, String password, Long domainId, Map<String, Object[]> requestParameters) {
|
||||
public UserAccount authenticateUser(String username, String password, Long domainId, String loginIpAddress, Map<String, Object[]> requestParameters) {
|
||||
UserAccount user = null;
|
||||
if (password != null) {
|
||||
user = getUserAccount(username, password, domainId, requestParameters);
|
||||
|
|
@ -1720,7 +1720,13 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
|||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("User: " + username + " in domain " + domainId + " has successfully logged in");
|
||||
}
|
||||
EventUtils.saveEvent(user.getId(), user.getAccountId(), user.getDomainId(), EventTypes.EVENT_USER_LOGIN, "user has logged in");
|
||||
if (NetUtils.isValidIp(loginIpAddress)) {
|
||||
EventUtils.saveEvent(user.getId(), user.getAccountId(), user.getDomainId(), EventTypes.EVENT_USER_LOGIN,
|
||||
"user has logged in from IP Address " + loginIpAddress);
|
||||
} else {
|
||||
EventUtils.saveEvent(user.getId(), user.getAccountId(), user.getDomainId(), EventTypes.EVENT_USER_LOGIN,
|
||||
"user has logged in. The IP Address cannot be determined");
|
||||
}
|
||||
return user;
|
||||
} else {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ public class MockAccountManagerImpl implements Manager, AccountManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserAccount authenticateUser(String username, String password, Long domainId, Map<String, Object[]> requestParameters) {
|
||||
public UserAccount authenticateUser(String username, String password, Long domainId, String loginIpAddress, Map<String, Object[]> requestParameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue