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:
saksham 2012-06-04 18:45:11 +05:30 committed by Alena Prokharchyk
parent 810151586b
commit f6d16d0ab5
5 changed files with 13 additions and 7 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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()) {

View File

@ -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;
}