01: package com.sun.portal.search.admin;
02:
03: import java.io.*;
04: import java.util.logging.Logger;
05: import java.util.logging.Level;
06:
07: import com.iplanet.jato.view.*;
08: import com.iplanet.jato.*;
09: import com.iplanet.jato.model.Model;
10: import com.iplanet.jato.view.event.*;
11: import com.sun.portal.log.common.PortalLogger;
12:
13: import javax.servlet.http.*;
14:
15: /**
16: * <p>Title: </p>
17: * <p>Description: </p>
18: * <p>Copyright: Copyright (c) 2002</p>
19: * <p>Company: </p>
20: * @author unascribed
21: * @version 1.0
22: */
23:
24: public class ConfigViewBean extends ViewBeanBase {
25: public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/Config.jsp";
26: public static final String PAGE_NAME = "Config";
27:
28: // Create a logger for this class
29: private static Logger debugLogger = PortalLogger
30: .getLogger(ConfigViewBean.class);
31:
32: public ConfigViewBean() {
33: super (PAGE_NAME);
34: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
35: }
36:
37: public void beginDisplay(DisplayEvent parm1)
38: throws com.iplanet.jato.model.ModelControlException {
39: String configName = (String) this .getRequestContext()
40: .getRequest().getParameter("name");
41: if (configName == null) {
42: return;
43: }
44: debugLogger.log(Level.FINER, "PDST_CSPSA0009", configName);
45: if (configName.indexOf("..") >= 0) {
46: //only limit access file under config directory
47: return;
48: }
49: String fileName = CSConfig.getServerRoot() + File.separator
50: + "config" + File.separator + configName;
51: try {
52: BufferedReader in = null;
53: String line;
54: in = new BufferedReader(new InputStreamReader(
55: new FileInputStream(fileName), "UTF-8"));
56: this .getRequestContext().getResponse().setContentType(
57: "text/plain;charset=UTF-8");
58: PrintWriter out = this .getRequestContext().getResponse()
59: .getWriter();
60:
61: while ((line = in.readLine()) != null) {
62: out.println(line);
63: }
64: } catch (Exception e) {
65: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e);
66: }
67:
68: }
69:
70: }
|