session-details.jsp 12.2 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3
<%--
  -	$Revision$
  -	$Date$
Bill Lynch's avatar
Bill Lynch committed
4
  -
5
  - Copyright (C) 2004-2008 Jive Software. All rights reserved.
Bill Lynch's avatar
Bill Lynch committed
6
  -
7 8 9 10 11 12 13 14 15 16 17
  - Licensed under the Apache License, Version 2.0 (the "License");
  - you may not use this file except in compliance with the License.
  - You may obtain a copy of the License at
  -
  -     http://www.apache.org/licenses/LICENSE-2.0
  -
  - Unless required by applicable law or agreed to in writing, software
  - distributed under the License is distributed on an "AS IS" BASIS,
  - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - See the License for the specific language governing permissions and
  - limitations under the License.
Matt Tucker's avatar
Matt Tucker committed
18
--%>
Bill Lynch's avatar
Bill Lynch committed
19

20
<%@ page import="org.jivesoftware.openfire.PresenceManager,
21 22
                 org.jivesoftware.openfire.SessionManager,
                 org.jivesoftware.openfire.session.ClientSession,
23
                 org.jivesoftware.openfire.session.LocalClientSession,
24 25
                 org.jivesoftware.openfire.user.User,
                 org.jivesoftware.openfire.user.UserManager,
26 27
                 org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.ParamUtils,
Sven Tantau's avatar
Sven Tantau committed
28
                 org.jivesoftware.util.StringUtils,
29 30
                 java.text.NumberFormat,
                 java.util.Collection"
Bill Lynch's avatar
Bill Lynch committed
31 32
    errorPage="error.jsp"
%>
Matt Tucker's avatar
Matt Tucker committed
33

34 35 36
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
37

Bill Lynch's avatar
Bill Lynch committed
38
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
39
<% webManager.init(request, response, session, application, out ); %>
Matt Tucker's avatar
Matt Tucker committed
40

41
<% // Get parameters
Matt Tucker's avatar
Matt Tucker committed
42 43 44 45 46 47 48 49 50
    String jid = ParamUtils.getParameter(request, "jid");

    // Handle a "go back" click:
    if (request.getParameter("back") != null) {
        response.sendRedirect("session-summary.jsp");
        return;
    }

    // Get the session & address objects
Derek DeMoro's avatar
Derek DeMoro committed
51
    SessionManager sessionManager = webManager.getSessionManager();
Derek DeMoro's avatar
Derek DeMoro committed
52
    JID address = new JID(jid);
53 54 55
    org.jivesoftware.openfire.session.ClientSession currentSess = sessionManager.getSession(address);
    boolean isAnonymous = webManager.getXMPPServer().isLocal(address) &&
            !UserManager.getInstance().isRegisteredUser(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
56

57 58 59 60 61 62
    // No current session found
    if (currentSess == null) {
        response.sendRedirect("session-summary.jsp");
        return;
    }

Matt Tucker's avatar
Matt Tucker committed
63
    // Get a presence manager
Derek DeMoro's avatar
Derek DeMoro committed
64
    PresenceManager presenceManager = webManager.getPresenceManager();
Matt Tucker's avatar
Matt Tucker committed
65 66 67 68

    // Get user object
    User user = null;
    if (!isAnonymous) {
Derek DeMoro's avatar
Derek DeMoro committed
69
        user = webManager.getUserManager().getUser(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
70 71 72 73
    }

    // Handle a "message" click:
    if (request.getParameter("message") != null) {
74
        response.sendRedirect("user-message.jsp?username=" + URLEncoder.encode(user.getUsername(), "UTF-8"));
Matt Tucker's avatar
Matt Tucker committed
75 76 77 78
        return;
    }

    // See if there are multiple sessions for this user:
79
    Collection<ClientSession> sessions = null;
Derek DeMoro's avatar
Derek DeMoro committed
80
    int sessionCount = sessionManager.getSessionCount(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
81
    if (!isAnonymous && sessionCount > 1) {
Derek DeMoro's avatar
Derek DeMoro committed
82
        sessions = sessionManager.getSessions(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
83 84 85 86
    }

    // Number dateFormatter for all numbers on this page:
    NumberFormat numFormatter = NumberFormat.getNumberInstance();
87 88

    pageContext.setAttribute("address", address);
Matt Tucker's avatar
Matt Tucker committed
89 90
%>

91 92 93 94 95 96
<html>
    <head>
        <title><fmt:message key="session.details.title"/></title>
        <meta name="pageID" content="session-summary"/>
    </head>
    <body>
Matt Tucker's avatar
Matt Tucker committed
97 98

<p>
99
<fmt:message key="session.details.info">
100
    <fmt:param value="<b>${fn:escapeXml(address)}</b>" />
Tom Evans's avatar
Tom Evans committed
101
    <fmt:param value="<b>${empty address.node ? '' : fn:escapeXml(address)}</b>" />
102 103
</fmt:message>

Matt Tucker's avatar
Matt Tucker committed
104 105 106
</p>

<div class="jive-table">
Bill Lynch's avatar
Bill Lynch committed
107 108 109 110
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
111
            <fmt:message key="session.details.title" />
Bill Lynch's avatar
Bill Lynch committed
112 113 114 115 116 117
        </th>
    </tr>
</thead>
<tbody>
    <tr>
        <td class="c1">
118
            <fmt:message key="session.details.session_id" />
Bill Lynch's avatar
Bill Lynch committed
119 120
        </td>
        <td>
Sven Tantau's avatar
Sven Tantau committed
121
            <%= StringUtils.escapeHTMLTags(address.toString()) %>
Bill Lynch's avatar
Bill Lynch committed
122 123 124 125
        </td>
    </tr>
    <tr>
        <td class="c1">
126
            <fmt:message key="session.details.username" />
Bill Lynch's avatar
Bill Lynch committed
127 128
        </td>
        <td>
Derek DeMoro's avatar
Derek DeMoro committed
129
            <%  String n = address.getNode(); %>
130
            <%  if (isAnonymous) { %>
Bill Lynch's avatar
Bill Lynch committed
131

Sven Tantau's avatar
Sven Tantau committed
132
                <i> <fmt:message key="session.details.anonymous" /> </i> - <%= address.getResource()==null?"":StringUtils.escapeHTMLTags(address.getResource()) %>
Bill Lynch's avatar
Bill Lynch committed
133 134 135

            <%  } else { %>

Sven Tantau's avatar
Sven Tantau committed
136
                <a href="user-properties.jsp?username=<%= URLEncoder.encode(n, "UTF-8") %>"><%= StringUtils.escapeHTMLTags(JID.unescapeNode(n)) %></a>
137
                - <%= address.getResource()==null?"":StringUtils.escapeForXML(address.getResource()) %>
Bill Lynch's avatar
Bill Lynch committed
138 139 140 141

            <%  } %>
        </td>
    </tr>
142 143 144 145 146 147 148 149 150 151 152 153
    <tr>
        <td class="c1">
            <fmt:message key="session.details.node" />
        </td>
        <td>
            <% if (currentSess instanceof LocalClientSession) { %>
             <fmt:message key="session.details.local" />
            <% } else { %>
             <fmt:message key="session.details.remote" />
            <% } %>
        </td>
    </tr>
Bill Lynch's avatar
Bill Lynch committed
154 155
    <tr>
        <td class="c1">
156
            <fmt:message key="session.details.status" />:
Bill Lynch's avatar
Bill Lynch committed
157 158 159 160 161 162
        </td>
        <td>
            <%
                int status = currentSess.getStatus();
                if (status == Session.STATUS_CLOSED) {
            %>
163
                <fmt:message key="session.details.close" />
Bill Lynch's avatar
Bill Lynch committed
164 165 166 167 168

            <%
                } else if (status == Session.STATUS_CONNECTED) {
            %>

169
                <fmt:message key="session.details.connect" />
Bill Lynch's avatar
Bill Lynch committed
170 171 172 173 174

            <%
                } else if (status == Session.STATUS_AUTHENTICATED) {
            %>

175
                <fmt:message key="session.details.authenticated" />
Bill Lynch's avatar
Bill Lynch committed
176 177 178 179 180

            <%
                } else {
            %>

181
                <fmt:message key="session.details.unknown" />
Bill Lynch's avatar
Bill Lynch committed
182 183 184 185 186 187 188 189

            <%
                }
            %>
        </td>
    </tr>
    <tr>
        <td class="c1">
190
            <fmt:message key="session.details.presence" />:
Bill Lynch's avatar
Bill Lynch committed
191 192 193
        </td>
        <td>
            <%
Derek DeMoro's avatar
Derek DeMoro committed
194
                Presence.Show show = currentSess.getPresence().getShow();
195 196
                String statusTxt = currentSess.getPresence().getStatus();
                if (statusTxt != null) {
Sven Tantau's avatar
Sven Tantau committed
197
                    statusTxt = " -- " + StringUtils.escapeHTMLTags(statusTxt);
198 199 200 201
                }
                else {
                    statusTxt = "";
                }
202 203 204 205 206 207
                if (!currentSess.getPresence().isAvailable()) {
            %>
                <img src="images/user-clear-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="user.properties.offline" />" alt="<fmt:message key="user.properties.offline" />">
                <fmt:message key="user.properties.offline" />
            <%
                } else if (show == Presence.Show.away) {
Bill Lynch's avatar
Bill Lynch committed
208
            %>
209
                <img src="images/im_away.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.away" />" alt="<fmt:message key="session.details.away" />">
210
                <fmt:message key="session.details.away" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
211 212

            <%
Derek DeMoro's avatar
Derek DeMoro committed
213
                } else if (show == Presence.Show.chat) {
Bill Lynch's avatar
Bill Lynch committed
214
            %>
215
                <img src="images/im_free_chat.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.chat_available" />" alt="<fmt:message key="session.details.chat_available" />">
216
                <fmt:message key="session.details.chat_available" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
217
            <%
Derek DeMoro's avatar
Derek DeMoro committed
218
                } else if (show == Presence.Show.dnd) {
Bill Lynch's avatar
Bill Lynch committed
219 220
            %>

221
                <img src="images/im_dnd.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.not_disturb" />" alt="<fmt:message key="session.details.not_disturb" />">
222
                <fmt:message key="session.details.not_disturb" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
223 224

            <%
Derek DeMoro's avatar
Derek DeMoro committed
225
                } else if (show == null) {
Bill Lynch's avatar
Bill Lynch committed
226 227
            %>

228
                <img src="images/im_available.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.online" />" alt="<fmt:message key="session.details.online" />">
229
                <fmt:message key="session.details.online" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
230 231

            <%
Derek DeMoro's avatar
Derek DeMoro committed
232
                } else if (show == Presence.Show.xa) {
Bill Lynch's avatar
Bill Lynch committed
233 234
            %>

235
                <img src="images/im_away.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.extended" />" alt="<fmt:message key="session.details.extended" />">
236
                <fmt:message key="session.details.extended" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
237 238 239 240 241

            <%
                } else {
            %>

242
                <fmt:message key="session.details.unknown" />
Bill Lynch's avatar
Bill Lynch committed
243 244 245 246 247 248

            <%
                }
            %>
        </td>
    </tr>
249 250 251 252 253 254 255 256
    <tr>
        <td class="c1">
            <fmt:message key="session.details.priority" />
        </td>
        <td>
            <%= currentSess.getPresence().getPriority() %>
        </td>
    </tr>
Bill Lynch's avatar
Bill Lynch committed
257 258
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
259
            <fmt:message key="session.details.session_created" />
Bill Lynch's avatar
Bill Lynch committed
260 261
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
262
            <%= JiveGlobals.formatDateTime(currentSess.getCreationDate()) %>
Bill Lynch's avatar
Bill Lynch committed
263 264 265 266
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
267
            <fmt:message key="session.details.last_active" />
Bill Lynch's avatar
Bill Lynch committed
268 269
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
270
            <%= JiveGlobals.formatDateTime(currentSess.getLastActiveDate()) %>
Bill Lynch's avatar
Bill Lynch committed
271 272 273 274
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
275
            <fmt:message key="session.details.statistics" />
Bill Lynch's avatar
Bill Lynch committed
276 277
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
278
            <fmt:message key="session.details.received" />
Bill Lynch's avatar
Bill Lynch committed
279 280 281 282 283
            <%= numFormatter.format(currentSess.getNumClientPackets()) %>/<%= numFormatter.format(currentSess.getNumServerPackets()) %>
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
284
            <fmt:message key="session.details.hostname" />
Bill Lynch's avatar
Bill Lynch committed
285 286
        </td>
        <td>
287 288 289 290 291 292 293
            <% try { %>
                <%= currentSess.getHostAddress() %>
                /
                <%= currentSess.getHostName() %>
            <% } catch (java.net.UnknownHostException e) { %>
                Invalid session/connection
            <% } %>
Bill Lynch's avatar
Bill Lynch committed
294 295 296
        </td>
    </tr>
</tbody>
Matt Tucker's avatar
Matt Tucker committed
297 298 299 300 301 302 303
</table>
</div>

<%  // Show a list of multiple user sessions if there is more than 1 session:
    if (sessionCount > 1) {
%>
    <p>
304
    <b><fmt:message key="session.details.multiple_session" /></b>
Matt Tucker's avatar
Matt Tucker committed
305 306 307 308 309 310
    </p>

    <div class="jive-table">
    <table cellpadding="3" cellspacing="1" border="0" width="100%">
    <tr>
        <th>&nbsp;</th>
311 312
        <th><fmt:message key="session.details.name" /></th>
        <th><fmt:message key="session.details.resource" /></th>
313
        <th nowrap colspan="2"><fmt:message key="session.details.status" /></th>
314
        <th nowrap colspan="2"><fmt:message key="session.details.if_presence" /></th>
315
        <th><fmt:message key="session.details.priority" /></th>
316 317
        <th nowrap><fmt:message key="session.details.clientip" /></th>
        <th nowrap><fmt:message key="session.details.close_connect" /></th>
Matt Tucker's avatar
Matt Tucker committed
318 319 320 321
    </tr>

    <%  int count = 0;
        String linkURL = "session-details.jsp";
322
        for (ClientSession sess : sessions) {
Matt Tucker's avatar
Matt Tucker committed
323 324 325
            count++;
            boolean current = sess.getAddress().equals(address);
    %>
326
        <%@ include file="session-row.jspf" %>
Matt Tucker's avatar
Matt Tucker committed
327 328 329 330 331 332 333 334 335 336 337 338 339 340

    <%  } %>

    </table>
    </div>

    <br>

    <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
        <td width="1%" nowrap>

            <div class="jive-table">
            <table cellpadding="0" cellspacing="0" border="0">
341
            <tr class="jive-current"><td><img src="images/blank.gif" width="12" height="12" border="0" alt=""></td></tr>
Matt Tucker's avatar
Matt Tucker committed
342 343 344 345 346 347
            </table>
            </div>

        </td>
        <td width="99%">

348
            &nbsp; = <fmt:message key="session.details.session_detail" />
Matt Tucker's avatar
Matt Tucker committed
349 350 351 352 353 354 355 356 357 358

        </td>
    </tr>
    </table>

<%  } %>

<br>

<form action="session-details.jsp">
359
<input type="hidden" name="jid" value="<%= URLEncoder.encode(jid, "UTF-8") %>">
Matt Tucker's avatar
Matt Tucker committed
360
<center>
Bill Lynch's avatar
Bill Lynch committed
361 362 363 364 365
<%--<%  if (!isAnonymous && presenceManager.isAvailable(user)) { %>--%>
<%----%>
<%--    <input type="submit" name="message" value="Message this Session">--%>
<%----%>
<%--<%  } %>--%>
Matt Tucker's avatar
Matt Tucker committed
366
<input type="submit" name="back" value="<fmt:message key="session.details.back_button" />">   
Matt Tucker's avatar
Matt Tucker committed
367 368 369
</center>
</form>

370
    </body>
Sven Tantau's avatar
Sven Tantau committed
371
</html>