Commit 03c05a79 authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Added internet address so session summary won't crash.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/branches@5832 b35dd754-fafc-0310-a699-88a17e54d16e
parent 85cf4166
......@@ -542,11 +542,13 @@ public class SessionManager extends BasicModule {
return session;
}
public HttpSession createClientHttpSession(StreamID id) throws UnauthorizedException {
public HttpSession createClientHttpSession(InetAddress address, StreamID id)
throws UnauthorizedException
{
if (serverName == null) {
throw new UnauthorizedException("Server not initialized");
}
HttpSession session = new HttpSession(serverName, id);
HttpSession session = new HttpSession(serverName, address, id);
Connection conn = session.getConnection();
conn.init(session);
conn.registerCloseListener(clientSessionListener, session);
......
......@@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.net.InetAddress;
/**
* Handles requests to the HTTP Bind service.
......@@ -149,7 +150,8 @@ public class HttpBindServlet extends HttpServlet {
try {
HttpConnection connection = new HttpConnection(rid, request.isSecure());
connection.setSession(sessionManager.createSession(rootNode, connection));
InetAddress address = InetAddress.getByName(request.getRemoteAddr());
connection.setSession(sessionManager.createSession(address, rootNode, connection));
respond(response, connection);
}
catch (UnauthorizedException e) {
......
......@@ -48,9 +48,9 @@ public class HttpSession extends ClientSession {
private boolean isClosed;
private int inactivityTimeout;
public HttpSession(String serverName, StreamID streamID) {
public HttpSession(String serverName, InetAddress address, StreamID streamID) {
super(serverName, null, streamID);
conn = new HttpVirtualConnection();
conn = new HttpVirtualConnection(address);
}
void addConnection(HttpConnection connection, boolean isPoll) throws HttpBindException,
......@@ -375,12 +375,18 @@ public class HttpSession extends ClientSession {
*/
public static class HttpVirtualConnection extends VirtualConnection {
private InetAddress address;
public HttpVirtualConnection(InetAddress address) {
this.address = address;
}
public void closeVirtualConnection() {
((HttpSession)session).closeConnection();
}
public InetAddress getInetAddress() {
return null;
return address;
}
public void systemShutdown() {
......
......@@ -21,6 +21,7 @@ import org.dom4j.*;
import java.util.*;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
/**
*
......@@ -75,7 +76,8 @@ public class HttpSessionManager {
return sessionMap.get(streamID);
}
public HttpSession createSession(Element rootNode, HttpConnection connection)
public HttpSession createSession(InetAddress address, Element rootNode,
HttpConnection connection)
throws UnauthorizedException, HttpBindException
{
// TODO Check if IP address is allowed to connect to the server
......@@ -89,7 +91,7 @@ public class HttpSessionManager {
int wait = getIntAttribute(rootNode.attributeValue("wait"), 60);
int hold = getIntAttribute(rootNode.attributeValue("hold"), 1);
HttpSession session = createSession();
HttpSession session = createSession(address);
session.setWait(wait);
session.setHold(hold);
session.setSecure(connection.isSecure());
......@@ -112,11 +114,11 @@ public class HttpSessionManager {
return session;
}
private HttpSession createSession() throws UnauthorizedException {
private HttpSession createSession(InetAddress address) throws UnauthorizedException {
// Create a ClientSession for this user.
StreamID streamID = SessionManager.getInstance().nextStreamID();
// Send to the server that a new client session has been created
HttpSession session = sessionManager.createClientHttpSession(streamID);
HttpSession session = sessionManager.createClientHttpSession(address, streamID);
// Register that the new session is associated with the specified stream ID
sessionMap.put(streamID.getID(), session);
session.addSessionCloseListener(new SessionListener() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment