01: package com.ericdaugherty.sshwebproxy;
02:
03: import org.apache.commons.logging.Log;
04: import org.apache.commons.logging.LogFactory;
05:
06: import javax.servlet.http.HttpServlet;
07: import javax.servlet.http.HttpServletRequest;
08:
09: /**
10: * Common Servlet base class. Implements common functions.
11: *
12: * @author Eric Daugherty
13: */
14: public class SshBaseServlet extends HttpServlet implements SshConstants {
15:
16: //***************************************************************
17: // Variables
18: //***************************************************************
19:
20: /** Logger */
21: private static final Log log = LogFactory
22: .getLog(SshBaseServlet.class);
23:
24: //***************************************************************
25: // Helper Methods
26: //***************************************************************
27:
28: /**
29: * Returns the SshConnection that is associated with this request, or null
30: * if the session can not be found.
31: *
32: * @param request
33: * @param sshSession
34: * @return the requested SshSession, or null.
35: */
36: protected SshConnection getConnection(HttpServletRequest request,
37: SshSession sshSession) {
38: String connectionInfo = request
39: .getParameter(PARAMETER_CONNECTION);
40: SshConnection sshConnection = null;
41: if (connectionInfo != null
42: && connectionInfo.trim().length() > 0) {
43: sshConnection = sshSession.getSshConnection(connectionInfo);
44: }
45:
46: return sshConnection;
47: }
48: }
|