/** @since Servlet 3.0 */
  @Override
  public boolean authenticate(HttpServletResponse response) throws IOException, ServletException {
    WebApp webApp = getWebApp();

    if (webApp == null)
      throw new ServletException(
          L.l("No authentication mechanism is configured for '{0}'", getWebApp()));

    // server/1aj{0,1}
    Authenticator auth = webApp.getConfiguredAuthenticator();

    if (auth == null)
      throw new ServletException(
          L.l("No authentication mechanism is configured for '{0}'", getWebApp()));

    Login login = webApp.getLogin();

    if (login == null)
      throw new ServletException(
          L.l("No authentication mechanism is configured for '{0}'", getWebApp()));

    Principal principal = login.login(this, response, true);

    if (principal != null) return true;

    return false;
  }
  /** Returns the Principal representing the logged in user. */
  public Principal getUserPrincipal() {
    requestLogin();

    Principal user;
    user = (Principal) getAttribute(AbstractLogin.LOGIN_NAME);

    if (user != null) return user;

    WebApp webApp = getWebApp();
    if (webApp == null) return null;

    // If the authenticator can find the user, return it.
    Login login = webApp.getLogin();

    if (login != null) {
      user = login.getUserPrincipal(this);

      if (user != null) {
        getResponse().setPrivateCache(true);
      } else {
        // server/123h, server/1920
        // distinguishes between setPrivateCache and setPrivateOrResinCache
        // _response.setPrivateOrResinCache(true);
      }
    }

    return user;
  }
  /** Returns the path to be used as the servlet name. */
  private Path getPagePath(String pathName) {
    Path rootDir = _webApp.getRootDirectory();
    String realPath = _webApp.getRealPath(pathName);
    Path path = rootDir.lookupNative(realPath);

    if (path.isFile() && path.canRead()) return path;

    java.net.URL url;
    ClassLoader loader = _webApp.getClassLoader();
    if (loader != null) {
      url = _webApp.getClassLoader().getResource(pathName);

      String name = url != null ? url.toString() : null;

      path = null;
      if (url != null && (name.endsWith(".jar") || name.endsWith(".zip")))
        path = JarPath.create(Vfs.lookup(url.toString())).lookup(pathName);
      else if (url != null) path = Vfs.lookup(url.toString());

      if (path != null && path.isFile() && path.canRead()) return path;
    }

    url = ClassLoader.getSystemResource(pathName);
    String name = url != null ? url.toString() : null;

    path = null;
    if (url != null && (name.endsWith(".jar") || name.endsWith(".zip")))
      path = JarPath.create(Vfs.lookup(url.toString())).lookup(pathName);
    else if (url != null) path = Vfs.lookup(url.toString());

    if (path != null && path.isFile() && path.canRead()) return path;
    else return null;
  }
Beispiel #4
0
 public void _jspService(
     javax.servlet.http.HttpServletRequest request,
     javax.servlet.http.HttpServletResponse response)
     throws java.io.IOException, javax.servlet.ServletException {
   com.caucho.server.webapp.WebApp _jsp_application = _caucho_getApplication();
   javax.servlet.ServletContext application = _jsp_application;
   com.caucho.jsp.PageContextImpl pageContext =
       _jsp_application
           .getJspApplicationContext()
           .allocatePageContext(
               this, _jsp_application, request, response, null, null, 8192, true, false);
   javax.servlet.jsp.PageContext _jsp_parentContext = pageContext;
   javax.servlet.jsp.JspWriter out = pageContext.getOut();
   final javax.el.ELContext _jsp_env = pageContext.getELContext();
   javax.servlet.ServletConfig config = getServletConfig();
   javax.servlet.Servlet page = this;
   response.setContentType("text/html;charset=UTF-8");
   request.setCharacterEncoding("UTF-8");
   try {
     out.write(_jsp_string0, 0, _jsp_string0.length);
   } catch (java.lang.Throwable _jsp_e) {
     pageContext.handlePageException(_jsp_e);
   } finally {
     _jsp_application.getJspApplicationContext().freePageContext(pageContext);
   }
 }
 public void init(ServletConfig config) throws ServletException {
   com.caucho.server.webapp.WebApp webApp =
       (com.caucho.server.webapp.WebApp) config.getServletContext();
   super.init(config);
   com.caucho.jsp.TaglibManager manager = webApp.getJspApplicationContext().getTaglibManager();
   com.caucho.jsp.PageContextImpl pageContext = new com.caucho.jsp.PageContextImpl(webApp, this);
 }
Beispiel #6
0
  private void normalizeId() {
    if (_urlPrefix == null) return;

    WebApp application = (WebApp) getServletContext();
    String hostName = "localhost"; // application.getHost();
    String contextPath = application.getContextPath();

    if (_urlPrefix.startsWith("/")) {
      _servletId = _urlPrefix;
      _urlPrefix = application.getURL() + _urlPrefix;
    } else if (_urlPrefix.startsWith("http://")) {
      int p = _urlPrefix.indexOf('/', "http://".length());

      String uri = _urlPrefix;
      if (p > 0) uri = _urlPrefix.substring(p);
      else uri = "";

      if (uri.startsWith(contextPath)) _servletId = uri.substring(contextPath.length());
      else if (_servletId == null) _servletId = uri;
    } else if (_urlPrefix.startsWith("https://")) {
      int p = _urlPrefix.indexOf('/', "https://".length());

      String uri = _urlPrefix;
      if (p > 0) uri = _urlPrefix.substring(p);
      else uri = "";

      if (uri.startsWith(contextPath)) _servletId = uri.substring(contextPath.length());
      else if (_servletId == null) _servletId = uri;
    } else if (_urlPrefix.startsWith("cron:")) {
      _urlPrefix = application.getURL() + _servletId;
    } else _servletId = _urlPrefix;

    if (_servletId.equals("")) _servletId = "/";
  }
  /**
   * Returns true if the user represented by the current request plays the named role.
   *
   * @param role the named role to test.
   * @return true if the user plays the role.
   */
  public boolean isUserInRole(String role) {
    ServletInvocation invocation = getInvocation();

    if (invocation == null) {
      if (getRequest() != null) return getRequest().isUserInRole(role);
      else return false;
    }

    HashMap<String, String> roleMap = invocation.getSecurityRoleMap();

    if (roleMap != null) {
      String linkRole = roleMap.get(role);

      if (linkRole != null) role = linkRole;
    }

    String runAs = getRunAs();

    if (runAs != null) return runAs.equals(role);

    WebApp webApp = getWebApp();

    Principal user = getUserPrincipal();

    if (user == null) {
      if (log.isLoggable(Level.FINE)) log.fine(this + " no user for isUserInRole");

      return false;
    }

    RoleMapManager roleManager = webApp != null ? webApp.getRoleMapManager() : null;

    if (roleManager != null) {
      Boolean result = roleManager.isUserInRole(role, user);

      if (result != null) {
        if (log.isLoggable(Level.FINE)) log.fine(this + " userInRole(" + role + ")->" + result);

        return result;
      }
    }

    Login login = webApp == null ? null : webApp.getLogin();

    boolean inRole = login != null && login.isUserInRole(user, role);

    if (log.isLoggable(Level.FINE)) {
      if (login == null) log.fine(this + " no Login for isUserInRole");
      else if (user == null) log.fine(this + " no user for isUserInRole");
      else if (inRole) log.fine(this + " " + user + " is in role: " + role);
      else log.fine(this + " failed " + user + " in role: " + role);
    }

    return inRole;
  }
  public void
  _jspService(javax.servlet.http.HttpServletRequest request,
              javax.servlet.http.HttpServletResponse response)
    throws java.io.IOException, javax.servlet.ServletException
  {
    javax.servlet.http.HttpSession session = request.getSession(true);
    com.caucho.server.webapp.WebApp _jsp_application = _caucho_getApplication();
    javax.servlet.ServletContext application = _jsp_application;
    com.caucho.jsp.PageContextImpl pageContext = _jsp_application.getJspApplicationContext().allocatePageContext(this, _jsp_application, request, response, null, session, 8192, true, false);
    javax.servlet.jsp.PageContext _jsp_parentContext = pageContext;
    javax.servlet.jsp.JspWriter out = pageContext.getOut();
    final javax.el.ELContext _jsp_env = pageContext.getELContext();
    javax.servlet.ServletConfig config = getServletConfig();
    javax.servlet.Servlet page = this;
    response.setContentType("text/html;charset=EUC-KR");
    request.setCharacterEncoding("EUC-KR");
    try {
      out.write(_jsp_string0, 0, _jsp_string0.length);
      
	String filename = request.getParameter("filename");
	String downname = request.getParameter("downname");
	FormDataDownload formData = new FormDataDownload(response, new File(filename), null, null);
	try
	{
		formData.download();
	}catch(FileNotFoundException e)
	{
		
      out.write(_jsp_string1, 0, _jsp_string1.length);
      out.print(( e ));
      out.write(_jsp_string2, 0, _jsp_string2.length);
      
		return;
	}catch(IOException e)
	{
		
      out.write(_jsp_string3, 0, _jsp_string3.length);
      out.print(( e ));
      out.write(_jsp_string4, 0, _jsp_string4.length);
      
		return;
	}catch(Exception e)
	{
		System.out.println("Exception Error~~" + e);
	}

      out.write('\n');
    } catch (java.lang.Throwable _jsp_e) {
      pageContext.handlePageException(_jsp_e);
    } finally {
      _jsp_application.getJspApplicationContext().freePageContext(pageContext);
    }
  }
 public void caucho_init(ServletConfig config) {
   try {
     com.caucho.server.webapp.WebApp webApp =
         (com.caucho.server.webapp.WebApp) config.getServletContext();
     init(config);
     if (com.caucho.jsp.JspManager.getCheckInterval() >= 0)
       _caucho_depends.setCheckInterval(com.caucho.jsp.JspManager.getCheckInterval());
     _jsp_pageManager = webApp.getJspApplicationContext().getPageManager();
     com.caucho.jsp.TaglibManager manager = webApp.getJspApplicationContext().getTaglibManager();
     com.caucho.jsp.PageContextImpl pageContext =
         new com.caucho.jsp.InitPageContextImpl(webApp, this);
   } catch (Exception e) {
     throw com.caucho.config.ConfigException.create(e);
   }
 }
  @Override
  public boolean login(boolean isFail) {
    try {
      WebApp webApp = getWebApp();

      if (webApp == null) {
        if (log.isLoggable(Level.FINE)) log.finer("authentication failed, no web-app found");

        getResponse().sendError(HttpServletResponse.SC_FORBIDDEN);

        return false;
      }

      // If the authenticator can find the user, return it.
      Login login = webApp.getLogin();

      if (login != null) {
        Principal user = login.login(this, getResponse(), isFail);

        return user != null;
        /*
        if (user == null)
          return false;

        setAttribute(AbstractLogin.LOGIN_NAME, user);

        return true;
        */
      } else if (isFail) {
        if (log.isLoggable(Level.FINE))
          log.finer("authentication failed, no login module found for " + webApp);

        getResponse().sendError(HttpServletResponse.SC_FORBIDDEN);

        return false;
      } else {
        // if a non-failure, then missing login is fine

        return false;
      }
    } catch (IOException e) {
      log.log(Level.FINE, e.toString(), e);

      return false;
    }
  }
Beispiel #11
0
 public void init(ServletConfig config) throws ServletException {
   com.caucho.server.webapp.WebApp webApp =
       (com.caucho.server.webapp.WebApp) config.getServletContext();
   super.init(config);
   com.caucho.jsp.TaglibManager manager = webApp.getJspApplicationContext().getTaglibManager();
   manager.addTaglibFunctions(_jsp_functionMap, "c", "http://java.sun.com/jstl/core");
   manager.addTaglibFunctions(_jsp_functionMap, "fmt", "http://java.sun.com/jstl/fmt");
   manager.addTaglibFunctions(_jsp_functionMap, "fn", "http://java.sun.com/jstl/functions");
   manager.addTaglibFunctions(_jsp_functionMap, "mytld", "/tld/MyTld");
   com.caucho.jsp.PageContextImpl pageContext = new com.caucho.jsp.PageContextImpl(webApp, this);
   _caucho_expr_0 = com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.id}");
   _caucho_expr_1 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.category}");
   _caucho_expr_2 = com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.city}");
   _caucho_expr_3 = com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.siteId}");
   _caucho_expr_4 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.service}");
   _caucho_expr_5 = com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.group}");
   _caucho_expr_6 = com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.url1}");
   _caucho_expr_7 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.startTime}");
   _caucho_expr_8 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.endTime}");
   _caucho_expr_9 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.orgPrice}");
   _caucho_expr_10 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.sellPrice}");
   _caucho_expr_11 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.discount}");
   _caucho_expr_12 = com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.title}");
   _caucho_expr_13 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.address}");
   _caucho_expr_14 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.userCount}");
   _caucho_expr_15 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.viewFlag==1}");
   _caucho_expr_16 = com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.phone}");
   _caucho_expr_17 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.webSite}");
   _caucho_expr_18 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.trafficInfo}");
   _caucho_expr_19 = com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.biefe}");
   _caucho_expr_20 =
       com.caucho.jsp.JspUtil.createExpr(pageContext.getELContext(), "${obj.ifTest==0}");
 }
  private String getCharEncoding() {
    if (_charEncoding != null && !"".equals(_charEncoding)) return _charEncoding;

    String charEncoding = _charEncoding;

    if (_charEncoding == null || "".equals(_charEncoding)) charEncoding = null;

    if (charEncoding == null) {
      // XXX performance?
      WebApp webApp = WebApp.getCurrent();

      if (webApp.getJsp() != null) charEncoding = webApp.getJsp().getPageEncoding();

      if (charEncoding == null) charEncoding = webApp.getCharacterEncoding();
    }

    return charEncoding;
  }
  /** @since Servlet 3.0 */
  @Override
  public void login(String username, String password) throws ServletException {
    WebApp webApp = getWebApp();

    Authenticator auth = webApp.getConfiguredAuthenticator();

    if (auth == null)
      throw new ServletException(
          L.l("No authentication mechanism is configured for '{0}'", getWebApp()));

    // server/1aj0
    Login login = webApp.getLogin();

    if (login == null)
      throw new ServletException(L.l("No login mechanism is configured for '{0}'", getWebApp()));

    if (!login.isPasswordBased())
      throw new ServletException(
          L.l("Authentication mechanism '{0}' does not support password authentication", login));

    removeAttribute(Login.LOGIN_USER);
    removeAttribute(Login.LOGIN_PASSWORD);

    Principal principal = login.getUserPrincipal(this);

    if (principal != null)
      throw new ServletException(L.l("UserPrincipal object has already been established"));

    setAttribute(Login.LOGIN_USER, username);
    setAttribute(Login.LOGIN_PASSWORD, password);

    try {
      login.login(this, getResponse(), false);
    } finally {
      removeAttribute(Login.LOGIN_USER);
      removeAttribute(Login.LOGIN_PASSWORD);
    }

    principal = login.getUserPrincipal(this);

    if (principal == null) throw new ServletException("can't authenticate a user");
  }
Beispiel #14
0
  /** Initialize the server. */
  private void serverInit(CauchoRequest req) throws ServletException {
    if (_urlPrefix != null) return;

    WebApp app = (WebApp) getServletContext();

    // calculate the URL prefix
    _servletId = req.getServletPath();

    CharBuffer cb = CharBuffer.allocate();

    if (!"default".equals(app.getAdmin().getHost().getName())
        && !"".equals(app.getAdmin().getHost().getName())) {
      String hostName = app.getAdmin().getHost().getURL();

      cb.append(hostName);
      cb.append(app.getContextPath());
      cb.append(_servletId);
    } else {
      cb.append(req.getScheme());
      cb.append("://");
      cb.append(req.getServerName());
      cb.append(":");
      cb.append(req.getServerPort());
      cb.append(app.getContextPath());
      cb.append(_servletId);
    }

    _urlPrefix = cb.close();

    initProtocol();
  }
  public RequestDispatcher getRequestDispatcher(String path) {
    if (path == null || path.length() == 0) return null;
    else if (path.charAt(0) == '/') return getWebApp().getRequestDispatcher(path);
    else {
      CharBuffer cb = new CharBuffer();

      WebApp webApp = getWebApp();

      String servletPath = getPageServletPath();
      if (servletPath != null) cb.append(servletPath);
      String pathInfo = getPagePathInfo();
      if (pathInfo != null) cb.append(pathInfo);

      int p = cb.lastIndexOf('/');
      if (p >= 0) cb.setLength(p);
      cb.append('/');
      cb.append(path);

      if (webApp != null) return webApp.getRequestDispatcher(cb.toString());

      return null;
    }
  }
  public void _jspService(
      javax.servlet.http.HttpServletRequest request,
      javax.servlet.http.HttpServletResponse response)
      throws java.io.IOException, javax.servlet.ServletException {
    javax.servlet.http.HttpSession session = request.getSession(true);
    com.caucho.server.webapp.WebApp _jsp_application = _caucho_getApplication();
    javax.servlet.ServletContext application = _jsp_application;
    com.caucho.jsp.PageContextImpl pageContext =
        _jsp_application
            .getJspApplicationContext()
            .allocatePageContext(
                this, _jsp_application, request, response, null, session, 8192, true, false);
    javax.servlet.jsp.PageContext _jsp_parentContext = pageContext;
    javax.servlet.jsp.JspWriter out = pageContext.getOut();
    final javax.el.ELContext _jsp_env = pageContext.getELContext();
    javax.servlet.ServletConfig config = getServletConfig();
    javax.servlet.Servlet page = this;
    response.setContentType("text/html");
    try {

      response.setHeader("Pragma", "no-cache"); // HTTP 1.0
      response.setDateHeader("Expires", 0);
      response.setHeader("Cache-Control", "no-cache"); // HTTP 1.1

      String scmid = "";
      String scmnm = "";
      String usertype = "";
      String usergroup = "";
      // String scmsubids = "";
      String _adminid = "";
      String _adminname = "";
      String _admingroup = "";
      String _apessid = "";
      String _apessname = "";

      try {
        scmid = (String) session.getAttribute("scmid");
        _adminid = (String) session.getAttribute("adminid");

        if ((scmid == null || scmid.length() == 0 || scmid.equals("null"))
            && (_adminid == null || _adminid.length() == 0 || _adminid.equals("null"))) {
          response.sendRedirect("/login_first.html");
          return;
        }

        _adminname = (String) session.getAttribute("adminname");

        _apessid = (String) session.getAttribute("apessid");
        _apessname = (String) session.getAttribute("apessname");

        scmnm = (String) session.getAttribute("scmnm");

        usertype = (String) session.getAttribute("usertype");
        if (usertype == null) usertype = "";

        usergroup = (String) session.getAttribute("usergroup");
        if (usergroup == null) usergroup = "";

        // scmsubids = (String) session.getAttribute("scmsubids");
        // session.setMaxInactiveInterval(60*60);

      } catch (Exception e) {
        response.sendRedirect("/login_first.html");
        return;
      }

      out.write('\n');

      String id = request.getParameter("id");

      out.write(_jsp_string0, 0, _jsp_string0.length);
      out.print((id));
      out.write(_jsp_string1, 0, _jsp_string1.length);
      out.print((id));
      out.write(_jsp_string2, 0, _jsp_string2.length);
    } catch (java.lang.Throwable _jsp_e) {
      pageContext.handlePageException(_jsp_e);
    } finally {
      _jsp_application.getJspApplicationContext().freePageContext(pageContext);
    }
  }
  /**
   * Given a request and response, returns the compiled Page. For example, JspManager will return
   * the JspPage and XtpManager will return the XtpPage.
   *
   * @param req servlet request for generating the page.
   * @param res servlet response to any needed error messages.
   */
  private Page getSubPage(HttpServletRequest req, HttpServletResponse res) throws Exception {
    CauchoRequest cauchoRequest = null;

    initGetPage();

    /*
    if (! _webApp.isActive())
      throw new UnavailableException("JSP compilation unavailable during restart", 10);
    */

    if (req instanceof CauchoRequest) cauchoRequest = (CauchoRequest) req;

    String servletPath;

    if (cauchoRequest != null) servletPath = cauchoRequest.getPageServletPath();
    else servletPath = RequestAdapter.getPageServletPath(req);

    if (servletPath == null) servletPath = "/";

    String uri;

    if (cauchoRequest != null) uri = cauchoRequest.getPageURI();
    else uri = RequestAdapter.getPageURI(req);

    Path appDir = _webApp.getRootDirectory();

    String realPath;
    Path subcontext;

    ServletConfig config = null;

    String jspPath = (String) req.getAttribute("caucho.jsp.jsp-file");
    if (jspPath != null) {
      req.removeAttribute("caucho.jsp.jsp-file");

      subcontext = getPagePath(jspPath);

      return _manager.getPage(uri, jspPath, subcontext, config);
    }

    String pathInfo;

    if (cauchoRequest != null) pathInfo = cauchoRequest.getPagePathInfo();
    else pathInfo = RequestAdapter.getPagePathInfo(req);

    subcontext = getPagePath(servletPath);

    if (subcontext != null) return _manager.getPage(servletPath, subcontext);

    if (pathInfo == null) {
      realPath = _webApp.getRealPath(servletPath);
      subcontext = appDir.lookupNative(realPath);

      return _manager.getPage(servletPath, subcontext);
    }

    subcontext = getPagePath(servletPath + pathInfo);
    if (subcontext != null) return _manager.getPage(servletPath + pathInfo, subcontext);

    // If servlet path exists, can't use pathInfo to lookup servlet,
    // because /jsp/WEB-INF would be a security hole
    if (servletPath != null && !servletPath.equals("")) {
      // server/0035
      throw new FileNotFoundException(L.l("{0} was not found on this server.", uri));
      // return null;
    }

    subcontext = getPagePath(pathInfo);
    if (subcontext != null) return _manager.getPage(pathInfo, subcontext);

    subcontext = getPagePath(uri);
    if (subcontext == null)
      throw new FileNotFoundException(L.l("{0} was not found on this server.", uri));

    return _manager.getPage(uri, subcontext);
  }
 private void initGetPage() {
   // marks the listener array as used
   _webApp.getJspApplicationContext().getELListenerArray();
 }
  /** Returns the session manager. */
  protected final SessionManager getSessionManager() {
    WebApp webApp = getWebApp();

    if (webApp != null) return webApp.getSessionManager();
    else return null;
  }
Beispiel #20
0
  private void setEnvironment(ClientSocket stream, WriteStream ws, HttpServletRequest req)
      throws IOException {
    addHeader(stream, ws, "REQUEST_URI", req.getRequestURI());
    addHeader(stream, ws, "REQUEST_METHOD", req.getMethod());

    addHeader(stream, ws, "SERVER_SOFTWARE", "Resin/" + VersionFactory.getVersion());

    addHeader(stream, ws, "SERVER_NAME", req.getServerName());
    // addHeader(stream, ws, "SERVER_ADDR=" + req.getServerAddr());
    addHeader(stream, ws, "SERVER_PORT", String.valueOf(req.getServerPort()));

    addHeader(stream, ws, "REMOTE_ADDR", req.getRemoteAddr());
    addHeader(stream, ws, "REMOTE_HOST", req.getRemoteAddr());
    // addHeader(stream, ws, "REMOTE_PORT=" + req.getRemotePort());

    if (req.getRemoteUser() != null) addHeader(stream, ws, "REMOTE_USER", req.getRemoteUser());
    else addHeader(stream, ws, "REMOTE_USER", "");
    if (req.getAuthType() != null) addHeader(stream, ws, "AUTH_TYPE", req.getAuthType());

    addHeader(stream, ws, "GATEWAY_INTERFACE", "CGI/1.1");
    addHeader(stream, ws, "SERVER_PROTOCOL", req.getProtocol());
    if (req.getQueryString() != null) addHeader(stream, ws, "QUERY_STRING", req.getQueryString());
    else addHeader(stream, ws, "QUERY_STRING", "");

    String scriptPath = req.getServletPath();
    String pathInfo = req.getPathInfo();

    WebApp webApp = (WebApp) req.getServletContext();

    Path appDir = webApp.getAppDir();
    String realPath = webApp.getRealPath(scriptPath);

    if (!appDir.lookup(realPath).isFile() && pathInfo != null) scriptPath = scriptPath + pathInfo;

    /*
     * FastCGI (specifically quercus) uses the PATH_INFO and PATH_TRANSLATED
     * for the script path.
     */
    log.finer("STREAM file: " + webApp.getRealPath(scriptPath));

    addHeader(stream, ws, "PATH_INFO", req.getContextPath() + scriptPath);
    addHeader(stream, ws, "PATH_TRANSLATED", webApp.getRealPath(scriptPath));

    /* These are the values which would be sent to CGI.
    addHeader(stream, ws, "SCRIPT_NAME", req.getContextPath() + scriptPath);
    addHeader(stream, ws, "SCRIPT_FILENAME", app.getRealPath(scriptPath));

    if (pathInfo != null) {
      addHeader(stream, ws, "PATH_INFO", pathInfo);
      addHeader(stream, ws, "PATH_TRANSLATED", req.getRealPath(pathInfo));
    }
    else {
      addHeader(stream, ws, "PATH_INFO", "");
      addHeader(stream, ws, "PATH_TRANSLATED", "");
    }
    */

    int contentLength = req.getContentLength();
    if (contentLength < 0) addHeader(stream, ws, "CONTENT_LENGTH", "0");
    else addHeader(stream, ws, "CONTENT_LENGTH", String.valueOf(contentLength));

    ServletContext rootContext = webApp.getContext("/");

    if (rootContext != null) addHeader(stream, ws, "DOCUMENT_ROOT", rootContext.getRealPath("/"));

    CharBuffer cb = new CharBuffer();

    Enumeration e = req.getHeaderNames();
    while (e.hasMoreElements()) {
      String key = (String) e.nextElement();
      String value = req.getHeader(key);

      if (key.equalsIgnoreCase("content-length")) addHeader(stream, ws, "CONTENT_LENGTH", value);
      else if (key.equalsIgnoreCase("content-type")) addHeader(stream, ws, "CONTENT_TYPE", value);
      else if (key.equalsIgnoreCase("if-modified-since")) {
      } else if (key.equalsIgnoreCase("if-none-match")) {
      } else if (key.equalsIgnoreCase("authorization")) {
      } else if (key.equalsIgnoreCase("proxy-authorization")) {
      } else addHeader(stream, ws, convertHeader(cb, key), value);
    }
  }
Beispiel #21
0
  public void _jspService(
      javax.servlet.http.HttpServletRequest request,
      javax.servlet.http.HttpServletResponse response)
      throws java.io.IOException, javax.servlet.ServletException {
    javax.servlet.http.HttpSession session = request.getSession(true);
    com.caucho.server.webapp.WebApp _jsp_application = _caucho_getApplication();
    javax.servlet.ServletContext application = _jsp_application;
    com.caucho.jsp.PageContextImpl pageContext =
        _jsp_application
            .getJspApplicationContext()
            .allocatePageContext(
                this, _jsp_application, request, response, null, session, 8192, true, false);
    javax.servlet.jsp.PageContext _jsp_parentContext = pageContext;
    javax.servlet.jsp.JspWriter out = pageContext.getOut();
    final javax.el.ELContext _jsp_env = pageContext.getELContext();
    javax.servlet.ServletConfig config = getServletConfig();
    javax.servlet.Servlet page = this;
    response.setContentType("text/html; charset=utf-8");
    request.setCharacterEncoding("UTF-8");
    dms.tag.CategorySelectTag _jsp_CategorySelectTag_0 = null;
    dms.tag.CitySelectTag _jsp_CitySelectTag_1 = null;
    dms.tag.DomainSelectTag _jsp_DomainSelectTag_2 = null;
    dms.tag.ServiceSelectTag _jsp_ServiceSelectTag_3 = null;
    dms.tag.GroupSelectTag _jsp_GroupSelectTag_4 = null;
    org.apache.taglibs.standard.tag.rt.fmt.FormatDateTag _jsp_FormatDateTag_5 = null;
    try {
      out.write(_jsp_string0, 0, _jsp_string0.length);
      _caucho_expr_0.print(out, _jsp_env, false);
      out.write(_jsp_string1, 0, _jsp_string1.length);
      if (_jsp_CategorySelectTag_0 == null) {
        _jsp_CategorySelectTag_0 = new dms.tag.CategorySelectTag();
        _jsp_CategorySelectTag_0.setPageContext(pageContext);
        _jsp_CategorySelectTag_0.setParent((javax.servlet.jsp.tagext.Tag) null);
        _jsp_CategorySelectTag_0.setName("category");
      }

      _jsp_CategorySelectTag_0.setCatId(new java.lang.Long(_caucho_expr_1.evalLong(_jsp_env)));
      _jsp_CategorySelectTag_0.doStartTag();
      out.write(_jsp_string2, 0, _jsp_string2.length);
      if (_jsp_CitySelectTag_1 == null) {
        _jsp_CitySelectTag_1 = new dms.tag.CitySelectTag();
        _jsp_CitySelectTag_1.setPageContext(pageContext);
        _jsp_CitySelectTag_1.setParent((javax.servlet.jsp.tagext.Tag) null);
        _jsp_CitySelectTag_1.setName("city");
      }

      _jsp_CitySelectTag_1.setCityId(new java.lang.Long(_caucho_expr_2.evalLong(_jsp_env)));
      _jsp_CitySelectTag_1.doStartTag();
      out.write(_jsp_string3, 0, _jsp_string3.length);
      if (_jsp_DomainSelectTag_2 == null) {
        _jsp_DomainSelectTag_2 = new dms.tag.DomainSelectTag();
        _jsp_DomainSelectTag_2.setPageContext(pageContext);
        _jsp_DomainSelectTag_2.setParent((javax.servlet.jsp.tagext.Tag) null);
        _jsp_DomainSelectTag_2.setName("siteId");
      }

      _jsp_DomainSelectTag_2.setDomainId(new java.lang.Long(_caucho_expr_3.evalLong(_jsp_env)));
      _jsp_DomainSelectTag_2.doStartTag();
      out.write(_jsp_string4, 0, _jsp_string4.length);
      if (_jsp_ServiceSelectTag_3 == null) {
        _jsp_ServiceSelectTag_3 = new dms.tag.ServiceSelectTag();
        _jsp_ServiceSelectTag_3.setPageContext(pageContext);
        _jsp_ServiceSelectTag_3.setParent((javax.servlet.jsp.tagext.Tag) null);
        _jsp_ServiceSelectTag_3.setName("service");
      }

      _jsp_ServiceSelectTag_3.setService(new java.lang.Long(_caucho_expr_4.evalLong(_jsp_env)));
      _jsp_ServiceSelectTag_3.doStartTag();
      out.write(_jsp_string5, 0, _jsp_string5.length);
      if (_jsp_GroupSelectTag_4 == null) {
        _jsp_GroupSelectTag_4 = new dms.tag.GroupSelectTag();
        _jsp_GroupSelectTag_4.setPageContext(pageContext);
        _jsp_GroupSelectTag_4.setParent((javax.servlet.jsp.tagext.Tag) null);
        _jsp_GroupSelectTag_4.setName("group");
      }

      _jsp_GroupSelectTag_4.setGroup(new java.lang.Long(_caucho_expr_5.evalLong(_jsp_env)));
      _jsp_GroupSelectTag_4.doStartTag();
      out.write(_jsp_string6, 0, _jsp_string6.length);
      _caucho_expr_6.print(out, _jsp_env, false);
      out.write(_jsp_string7, 0, _jsp_string7.length);
      if (_jsp_FormatDateTag_5 == null) {
        _jsp_FormatDateTag_5 = new org.apache.taglibs.standard.tag.rt.fmt.FormatDateTag();
        _jsp_FormatDateTag_5.setPageContext(pageContext);
        _jsp_FormatDateTag_5.setParent((javax.servlet.jsp.tagext.Tag) null);
        _jsp_FormatDateTag_5.setPattern("yy-MM-dd HH:mm:ss");
      }

      _jsp_FormatDateTag_5.setValue((java.util.Date) _caucho_expr_7.evalObject(_jsp_env));
      _jsp_FormatDateTag_5.doEndTag();
      out.write(_jsp_string8, 0, _jsp_string8.length);
      _jsp_FormatDateTag_5.setValue((java.util.Date) _caucho_expr_8.evalObject(_jsp_env));
      _jsp_FormatDateTag_5.doEndTag();
      out.write(_jsp_string9, 0, _jsp_string9.length);
      _caucho_expr_9.print(out, _jsp_env, false);
      out.write(_jsp_string10, 0, _jsp_string10.length);
      _caucho_expr_10.print(out, _jsp_env, false);
      out.write(_jsp_string11, 0, _jsp_string11.length);
      _caucho_expr_11.print(out, _jsp_env, false);
      out.write(_jsp_string12, 0, _jsp_string12.length);
      _caucho_expr_12.print(out, _jsp_env, false);
      out.write(_jsp_string13, 0, _jsp_string13.length);
      _caucho_expr_13.print(out, _jsp_env, false);
      out.write(_jsp_string14, 0, _jsp_string14.length);
      _caucho_expr_14.print(out, _jsp_env, false);
      out.write(_jsp_string15, 0, _jsp_string15.length);
      if (_caucho_expr_15.evalBoolean(_jsp_env)) {
        out.write(_jsp_string16, 0, _jsp_string16.length);
      } else {
        out.write(_jsp_string17, 0, _jsp_string17.length);
      }
      out.write(_jsp_string18, 0, _jsp_string18.length);
      _caucho_expr_16.print(out, _jsp_env, false);
      out.write(_jsp_string19, 0, _jsp_string19.length);
      _caucho_expr_17.print(out, _jsp_env, false);
      out.write(_jsp_string20, 0, _jsp_string20.length);
      _caucho_expr_18.print(out, _jsp_env, false);
      out.write(_jsp_string21, 0, _jsp_string21.length);
      _caucho_expr_19.print(out, _jsp_env, false);
      out.write(_jsp_string22, 0, _jsp_string22.length);
      if (_caucho_expr_20.evalBoolean(_jsp_env)) {
        out.write(_jsp_string23, 0, _jsp_string23.length);
      } else {
        out.write(_jsp_string24, 0, _jsp_string24.length);
      }
      out.write(_jsp_string25, 0, _jsp_string25.length);
    } catch (java.lang.Throwable _jsp_e) {
      pageContext.handlePageException(_jsp_e);
    } finally {
      if (_jsp_CategorySelectTag_0 != null) _jsp_CategorySelectTag_0.release();
      if (_jsp_CitySelectTag_1 != null) _jsp_CitySelectTag_1.release();
      if (_jsp_DomainSelectTag_2 != null) _jsp_DomainSelectTag_2.release();
      if (_jsp_ServiceSelectTag_3 != null) _jsp_ServiceSelectTag_3.release();
      if (_jsp_GroupSelectTag_4 != null) _jsp_GroupSelectTag_4.release();
      if (_jsp_FormatDateTag_5 != null) _jsp_FormatDateTag_5.release();
      _jsp_application.getJspApplicationContext().freePageContext(pageContext);
    }
  }
  public String getRealPath(String uri) {
    WebApp webApp = getWebApp();

    return webApp.getRealPath(uri);
  }