Repository: incubator-ranger Updated Branches: refs/heads/master a263431a5 -> 52ae98191
RANGER-375 : Show better error messages during failed login Signed-off-by: Velmurugan Periasamy <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/52ae9819 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/52ae9819 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/52ae9819 Branch: refs/heads/master Commit: 52ae9819161e9c3cd42df4315db94baab992da3c Parents: a263431 Author: Gautam Borad <[email protected]> Authored: Tue Apr 7 14:04:31 2015 +0530 Committer: Velmurugan Periasamy <[email protected]> Committed: Tue Apr 7 10:00:32 2015 -0400 ---------------------------------------------------------------------- .../java/org/apache/ranger/biz/AssetMgr.java | 26 +++++++++++++++----- .../RangerAuthFailureHandler.java | 13 +++++++--- .../ranger/service/AuthSessionService.java | 1 - .../org/apache/ranger/view/VXAuthSession.java | 22 ----------------- security-admin/src/main/webapp/login.jsp | 2 +- .../main/webapp/scripts/prelogin/XAPrelogin.js | 2 ++ .../reports/LoginSessionDetail_tmpl.html | 4 --- 7 files changed, 33 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/52ae9819/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java index 5aa22fa..1c076c5 100644 --- a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java +++ b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java @@ -1753,6 +1753,9 @@ public class AssetMgr extends AssetMgrBase { Long count=xTrxLogService .searchXTrxLogsCount(searchCriteria); vXTrxLogList.setTotalCount(count); + + List<VXTrxLog> newList = validateXXTrxLogList(vXTrxLogList.getVXTrxLogs()); + vXTrxLogList.setVXTrxLogs(newList); return vXTrxLogList; } @@ -1799,9 +1802,22 @@ public class AssetMgr extends AssetMgrBase { List<XXTrxLog> xTrxLogList = rangerDaoManager.getXXTrxLog() .findByTransactionId(transactionId); VXTrxLogList vXTrxLogList = new VXTrxLogList(); - List<VXTrxLog> vXTrxLogs = vXTrxLogList.getVXTrxLogs(); - for (XXTrxLog xTrxLog : xTrxLogList) { - VXTrxLog vXTrxLog = xTrxLogService.populateViewBean(xTrxLog); + List<VXTrxLog> trxLogList = new ArrayList<VXTrxLog>(); + + for(XXTrxLog xTrxLog : xTrxLogList) { + trxLogList.add(xTrxLogService.populateViewBean(xTrxLog)); + } + + List<VXTrxLog> vXTrxLogs = validateXXTrxLogList(trxLogList); + vXTrxLogList.setVXTrxLogs(vXTrxLogs); + return vXTrxLogList; + } + public List<VXTrxLog> validateXXTrxLogList(List<VXTrxLog> xTrxLogList) { + + List<VXTrxLog> vXTrxLogs = new ArrayList<VXTrxLog>(); + for (VXTrxLog xTrxLog : xTrxLogList) { + VXTrxLog vXTrxLog = new VXTrxLog(); + vXTrxLog = xTrxLog; if(vXTrxLog.getPreviousValue()==null || vXTrxLog.getPreviousValue().equalsIgnoreCase("null")){ vXTrxLog.setPreviousValue(""); } @@ -1845,10 +1861,8 @@ public class AssetMgr extends AssetMgrBase { } vXTrxLogs.add(vXTrxLog); } - vXTrxLogList.setVXTrxLogs(vXTrxLogs); - return vXTrxLogList; + return vXTrxLogs; } - /* * (non-Javadoc) * http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/52ae9819/security-admin/src/main/java/org/apache/ranger/security/web/authentication/RangerAuthFailureHandler.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/security/web/authentication/RangerAuthFailureHandler.java b/security-admin/src/main/java/org/apache/ranger/security/web/authentication/RangerAuthFailureHandler.java index d3c188b..bdef13a 100644 --- a/security-admin/src/main/java/org/apache/ranger/security/web/authentication/RangerAuthFailureHandler.java +++ b/security-admin/src/main/java/org/apache/ranger/security/web/authentication/RangerAuthFailureHandler.java @@ -79,10 +79,17 @@ ExceptionMappingAuthenticationFailureHandler { response.setHeader("Cache-Control", "no-cache"); String jsonResp = ""; try { + String msg = exception.getMessage(); VXResponse vXResponse = new VXResponse(); - vXResponse.setStatusCode(HttpServletResponse.SC_UNAUTHORIZED); - vXResponse.setMsgDesc("Bad Credentials"); - + if(msg!=null && !msg.isEmpty()){ + if(msg.equalsIgnoreCase("Bad credentials")){ + vXResponse.setStatusCode(HttpServletResponse.SC_UNAUTHORIZED); + vXResponse.setMsgDesc("The username or password you entered is incorrect.."); + }else{ + vXResponse.setStatusCode(HttpServletResponse.SC_UNAUTHORIZED); + vXResponse.setMsgDesc("Unable to connect to DB.."); + } + } jsonResp = jsonUtil.writeObjectAsString(vXResponse); response.getWriter().write(jsonResp); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/52ae9819/security-admin/src/main/java/org/apache/ranger/service/AuthSessionService.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/service/AuthSessionService.java b/security-admin/src/main/java/org/apache/ranger/service/AuthSessionService.java index c590bbc..28f934d 100644 --- a/security-admin/src/main/java/org/apache/ranger/service/AuthSessionService.java +++ b/security-admin/src/main/java/org/apache/ranger/service/AuthSessionService.java @@ -163,7 +163,6 @@ public class AuthSessionService extends viewObj.setAuthStatus(resource.getAuthStatus()); viewObj.setAuthType(resource.getAuthType()); viewObj.setDeviceType(resource.getDeviceType()); - viewObj.setExtSessionId(resource.getExtSessionId()); viewObj.setId(resource.getId()); viewObj.setRequestIP(resource.getRequestIP()); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/52ae9819/security-admin/src/main/java/org/apache/ranger/view/VXAuthSession.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/view/VXAuthSession.java b/security-admin/src/main/java/org/apache/ranger/view/VXAuthSession.java index 6835456..e3eec59 100644 --- a/security-admin/src/main/java/org/apache/ranger/view/VXAuthSession.java +++ b/security-admin/src/main/java/org/apache/ranger/view/VXAuthSession.java @@ -76,10 +76,6 @@ public class VXAuthSession extends VXDataObject implements java.io.Serializable */ protected String familyScreenName; /** - * External session id. Mostly Spring/HTTP session - */ - protected String extSessionId; - /** * Date and time of authentication */ @JsonSerialize(using=JsonDateSerializer.class) @@ -272,23 +268,6 @@ public class VXAuthSession extends VXDataObject implements java.io.Serializable } /** - * This method sets the value to the member attribute <b>extSessionId</b>. - * You cannot set null to the attribute. - * @param extSessionId Value to set member attribute <b>extSessionId</b> - */ - public void setExtSessionId( String extSessionId ) { - this.extSessionId = extSessionId; - } - - /** - * Returns the value for the member attribute <b>extSessionId</b> - * @return String - value of member attribute <b>extSessionId</b>. - */ - public String getExtSessionId( ) { - return this.extSessionId; - } - - /** * This method sets the value to the member attribute <b>authTime</b>. * You cannot set null to the attribute. * @param authTime Value to set member attribute <b>authTime</b> @@ -478,7 +457,6 @@ public class VXAuthSession extends VXDataObject implements java.io.Serializable str += "lastName={" + lastName + "} "; str += "publicScreenName={" + publicScreenName + "} "; str += "familyScreenName={" + familyScreenName + "} "; - str += "extSessionId={" + extSessionId + "} "; str += "authTime={" + authTime + "} "; str += "authStatus={" + authStatus + "} "; str += "authType={" + authType + "} "; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/52ae9819/security-admin/src/main/webapp/login.jsp ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/login.jsp b/security-admin/src/main/webapp/login.jsp index 33fc339..1faae6a 100644 --- a/security-admin/src/main/webapp/login.jsp +++ b/security-admin/src/main/webapp/login.jsp @@ -70,7 +70,7 @@ <label><i class="icon-lock"></i> Password:</label> <input type="password" name="password" id="password" tabindex="2" autocomplete="off"> </div> - <span id="errorBox" class="help-inline" style="color:white;display:none;">The username or password you entered is incorrect.. + <span id="errorBox" class="help-inline" style="color:white;display:none;"><span class="errorMsg"></span> <i class="icon-warning-sign" style="color:#ae2817;"></i> </span> <span id="errorBoxUnsynced" class="help-inline" style="color:white;display:none;">User is not available in HDP Admin Tool. Please contact your Administrator. http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/52ae9819/security-admin/src/main/webapp/scripts/prelogin/XAPrelogin.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/prelogin/XAPrelogin.js b/security-admin/src/main/webapp/scripts/prelogin/XAPrelogin.js index 530babf..0ffd272 100644 --- a/security-admin/src/main/webapp/scripts/prelogin/XAPrelogin.js +++ b/security-admin/src/main/webapp/scripts/prelogin/XAPrelogin.js @@ -84,6 +84,8 @@ function doLogin() { $('#errorBox').hide(); $('#errorBoxUnsynced').show(); } else { + var resp = JSON.parse(jqXHR.responseText); + $('#errorBox .errorMsg').text(resp.msgDesc); $('#errorBox').show(); $('#errorBoxUnsynced').hide(); } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/52ae9819/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html b/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html index e0aec02..376967c 100644 --- a/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html +++ b/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html @@ -21,10 +21,6 @@ <table class="table table-bordered table-condensed"> <tbody> <tr> - <th>{{tt 'lbl.sessionId'}}</th> - <td>{{extSessionId}}</td> - </tr> - <tr> <th>{{tt 'lbl.loginId'}}</th> <td>{{loginId}}</td> </tr>
