Author: ivol37 at gmail.com
Date: Fri Jan  7 13:53:55 2011
New Revision: 578

Log:
[AMDATU-243] Added logging information of host/ip on which the request was 
received in the login gadget. Useful for a clustered setup.

Modified:
   
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp
   
trunk/amdatu-authorization/login-service/src/main/java/org/amdatu/authorization/login/service/service/LoginServiceImpl.java

Modified: 
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp
==============================================================================
--- 
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp  
    (original)
+++ 
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp  
    Fri Jan  7 13:53:55 2011
@@ -71,13 +71,14 @@
         gadgets.window.adjustHeight();
       }
 
-      function showLogoutBox(username) {
+      function showLogoutBox(username, hostname, hostip) {
         document.getElementById("login").style.visibility = "hidden";
         document.getElementById("login").style.display = "none";
         document.getElementById("logout").style.visibility = "";
         document.getElementById("logout").style.display = "";
         var userdiv = document.getElementById("logout");
-        userdiv.innerHTML = "<p>You are currently logged in as " + username + 
"<br/><br/>" +
+        userdiv.innerHTML = "<p>You are currently logged in as " + username +
+          " on " + hostname + " (" + hostip + ")<br/><br/>" +
           "<input type='submit' value='Logout' onclick='javascript:logout()' 
/></p>";
         gadgets.window.adjustHeight();
       }
@@ -97,7 +98,7 @@
           async:true,
           success: function(response) {
               if (response.result != null && response.result == 'ok') {
-                showLogoutBox(response.username);
+                showLogoutBox(response.username, response.hostname, 
response.hostid);
               } else {
                 var errorMsg = "An unexpected error occurred";
                 if (response.msg) {
@@ -146,7 +147,7 @@
           async:true,
           success: function(response) {
               if (response.username != null) {
-                showLogoutBox(response.username);
+                showLogoutBox(response.username, response.hostname, 
response.hostid);
               } else {
                 showLoginBox();
               }

Modified: 
trunk/amdatu-authorization/login-service/src/main/java/org/amdatu/authorization/login/service/service/LoginServiceImpl.java
==============================================================================
--- 
trunk/amdatu-authorization/login-service/src/main/java/org/amdatu/authorization/login/service/service/LoginServiceImpl.java
 (original)
+++ 
trunk/amdatu-authorization/login-service/src/main/java/org/amdatu/authorization/login/service/service/LoginServiceImpl.java
 Fri Jan  7 13:53:55 2011
@@ -144,15 +144,17 @@
             String userName = getUserName(request);
             if (userName != null) {
                 jsonObject.append("username", userName);
+                jsonObject.append("hostname", request.getServerName());
+                jsonObject.append("hostid", request.getLocalAddr());
                 return Response.ok(jsonObject.toString(), 
MediaType.APPLICATION_JSON_TYPE).cacheControl(m_cacheControl)
-                    .build();
+                .build();
             }
         }
         catch (JSONException e) {
             m_logService.log(LogService.LOG_ERROR, "Could not retrieve current 
login status", e);
         }
         catch (TokenProviderException e) {
-         // If the token is invalid, the user is not logged in anymore, ignore 
this error
+            // If the token is invalid, the user is not logged in anymore, 
ignore this error
         }
         catch (InvalidTokenException e) {
             // If the token is invalid, the user is not logged in anymore, 
ignore this error
@@ -186,6 +188,8 @@
                     m_logService.log(LogService.LOG_INFO, "User '" + username 
+ "' logged in successfully");
                     jsonObject.append("result", "ok");
                     jsonObject.append("username", username);
+                    jsonObject.append("hostname", request.getServerName());
+                    jsonObject.append("hostid", request.getLocalAddr());
                     jsonObject.append("msg", "User '" + username + "' logged 
in successfully");
 
                 }

Reply via email to