Java Code Examples for org.apache.tomcat.util.res.StringManager

The following examples show how to use org.apache.tomcat.util.res.StringManager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: tomcatsrc   Source File: ManagerServlet.java    License: Apache License 2.0 6 votes vote down vote up
private void writeDeployResult(PrintWriter writer, StringManager smClient,
        String name, String displayPath) {
    Context deployed = (Context) host.findChild(name);
    if (deployed != null && deployed.getConfigured() &&
            deployed.getState().isAvailable()) {
        writer.println(smClient.getString(
                "managerServlet.deployed", displayPath));
    } else if (deployed!=null && !deployed.getState().isAvailable()) {
        writer.println(smClient.getString(
                "managerServlet.deployedButNotStarted", displayPath));
    } else {
        // Something failed
        writer.println(smClient.getString(
                "managerServlet.deployFailed", displayPath));
    }
}
 
Example 2
Source Project: Tomcat8-Source-Read   Source File: HTMLManagerServlet.java    License: MIT License 6 votes vote down vote up
/**
 * Find potential memory leaks caused by web application reload.
 *
 * @see ManagerServlet#findleaks(boolean, PrintWriter, StringManager)
 *
 * @param smClient  StringManager for the client's locale
 *
 * @return message String
 */
protected String findleaks(StringManager smClient) {

    StringBuilder msg = new StringBuilder();

    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);

    super.findleaks(false, printWriter, smClient);

    String writerText = stringWriter.toString();

    if (writerText.length() > 0) {
        if (!writerText.startsWith("FAIL -")) {
            msg.append(smClient.getString(
                    "htmlManagerServlet.findleaksList"));
        }
        msg.append(writerText);
    } else {
        msg.append(smClient.getString("htmlManagerServlet.findleaksNone"));
    }

    return msg.toString();
}
 
Example 3
Source Project: tomcatsrc   Source File: HTMLManagerServlet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Removes an attribute from an HttpSession
 * @param cn Name of the application hosting the session from which the
 *           attribute is to be removed
 * @param sessionId
 * @param attributeName
 * @param smClient  StringManager for the client's locale
 * @return true if there was an attribute removed, false otherwise
 * @throws IOException 
 */
protected boolean removeSessionAttribute(ContextName cn, String sessionId,
        String attributeName, StringManager smClient) throws IOException {
    HttpSession session =
        getSessionForNameAndId(cn, sessionId, smClient).getSession();
    if (null == session) {
        // Shouldn't happen, but let's play nice...
        if (debug >= 1) {
            log("WARNING: can't remove attribute '" + attributeName + "' for null session " + sessionId);
        }
        return false;
    }
    boolean wasPresent = (null != session.getAttribute(attributeName));
    try {
        session.removeAttribute(attributeName);
    } catch (IllegalStateException ise) {
        if (debug >= 1) {
            log("Can't remote attribute '" + attributeName + "' for invalidated session id " + sessionId);
        }
    }
    return wasPresent;
}
 
Example 4
Source Project: Tomcat8-Source-Read   Source File: HTMLManagerServlet.java    License: MIT License 6 votes vote down vote up
/**
 * Removes an attribute from an HttpSession
 * @param cn Name of the application hosting the session from which the
 *           attribute is to be removed
 * @param sessionId the session id
 * @param attributeName the attribute name
 * @param smClient  StringManager for the client's locale
 * @return true if there was an attribute removed, false otherwise
 */
protected boolean removeSessionAttribute(ContextName cn, String sessionId,
        String attributeName, StringManager smClient) {
    HttpSession session =
        getSessionForNameAndId(cn, sessionId, smClient).getSession();
    if (null == session) {
        // Shouldn't happen, but let's play nice...
        if (debug >= 1) {
            log("WARNING: can't remove attribute '" + attributeName + "' for null session " + sessionId);
        }
        return false;
    }
    boolean wasPresent = (null != session.getAttribute(attributeName));
    try {
        session.removeAttribute(attributeName);
    } catch (IllegalStateException ise) {
        if (debug >= 1) {
            log("Can't remote attribute '" + attributeName + "' for invalidated session id " + sessionId);
        }
    }
    return wasPresent;
}
 
Example 5
Source Project: Tomcat8-Source-Read   Source File: HostManagerServlet.java    License: MIT License 6 votes vote down vote up
/**
 * Add host with the given parameters.
 *
 * @param request The request
 * @param writer The output writer
 * @param name The host name
 * @param htmlMode Flag value
 * @param smClient StringManager for the client's locale
*/
protected void add(HttpServletRequest request, PrintWriter writer,
        String name, boolean htmlMode, StringManager smClient) {
    String aliases = request.getParameter("aliases");
    String appBase = request.getParameter("appBase");
    boolean manager = booleanParameter(request, "manager", false, htmlMode);
    boolean autoDeploy = booleanParameter(request, "autoDeploy", true, htmlMode);
    boolean deployOnStartup = booleanParameter(request, "deployOnStartup", true, htmlMode);
    boolean deployXML = booleanParameter(request, "deployXML", true, htmlMode);
    boolean unpackWARs = booleanParameter(request, "unpackWARs", true, htmlMode);
    boolean copyXML = booleanParameter(request, "copyXML", false, htmlMode);
    add(writer, name, aliases, appBase, manager,
        autoDeploy,
        deployOnStartup,
        deployXML,
        unpackWARs,
        copyXML,
        smClient);
}
 
Example 6
Source Project: Tomcat7.0.67   Source File: ManagerServlet.java    License: Apache License 2.0 6 votes vote down vote up
protected static boolean validateContextName(ContextName cn,
        PrintWriter writer, StringManager sm) {
    
    // ContextName should be non-null with a path that is empty or starts
    // with /
    if (cn != null &&
            (cn.getPath().startsWith("/") || cn.getPath().equals(""))) {
        return true;
    }
    
    String path = null;
    if (cn != null) {
        path = RequestUtil.filter(cn.getPath());
    }
    writer.println(sm.getString("managerServlet.invalidPath", path));
    return false;
}
 
Example 7
Source Project: Tomcat8-Source-Read   Source File: HostManagerServlet.java    License: MIT License 6 votes vote down vote up
/**
 * Persist the current configuration to server.xml.
 *
 * @param writer Writer to render to
 * @param smClient i18n resources localized for the client
 */
protected void persist(PrintWriter writer, StringManager smClient) {

    if (debug >= 1) {
        log(sm.getString("hostManagerServlet.persist"));
    }

    try {
        MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
        ObjectName oname = new ObjectName(engine.getDomain() + ":type=StoreConfig");
        platformMBeanServer.invoke(oname, "storeConfig", null, null);
        writer.println(smClient.getString("hostManagerServlet.persisted"));
    } catch (Exception e) {
        getServletContext().log(sm.getString("hostManagerServlet.persistFailed"), e);
        writer.println(smClient.getString("hostManagerServlet.persistFailed"));
        // catch InstanceNotFoundException when StoreConfig is not enabled instead of printing
        // the failure message
        if (e instanceof InstanceNotFoundException) {
            writer.println("Please enable StoreConfig to use this feature.");
        } else {
            writer.println(smClient.getString("hostManagerServlet.exception", e.toString()));
        }
        return;
    }
}
 
Example 8
Source Project: Tomcat8-Source-Read   Source File: ManagerServlet.java    License: MIT License 6 votes vote down vote up
private void writeDeployResult(PrintWriter writer, StringManager smClient,
        String name, String displayPath) {
    Context deployed = (Context) host.findChild(name);
    if (deployed != null && deployed.getConfigured() &&
            deployed.getState().isAvailable()) {
        writer.println(smClient.getString(
                "managerServlet.deployed", displayPath));
    } else if (deployed!=null && !deployed.getState().isAvailable()) {
        writer.println(smClient.getString(
                "managerServlet.deployedButNotStarted", displayPath));
    } else {
        // Something failed
        writer.println(smClient.getString(
                "managerServlet.deployFailed", displayPath));
    }
}
 
Example 9
Source Project: Tomcat8-Source-Read   Source File: ManagerServlet.java    License: MIT License 6 votes vote down vote up
protected Map<String,List<String>> getConnectorCiphers(StringManager smClient) {
    Map<String,List<String>> result = new HashMap<>();

    Connector connectors[] = getConnectors();
    for (Connector connector : connectors) {
        if (Boolean.TRUE.equals(connector.getProperty("SSLEnabled"))) {
            SSLHostConfig[] sslHostConfigs = connector.getProtocolHandler().findSslHostConfigs();
            for (SSLHostConfig sslHostConfig : sslHostConfigs) {
                String name = connector.toString() + "-" + sslHostConfig.getHostName();
                /* Add cipher list, keep order but remove duplicates */
                result.put(name, new ArrayList<>(new LinkedHashSet<>(
                    Arrays.asList(sslHostConfig.getEnabledCiphers()))));
            }
        } else {
            ArrayList<String> cipherList = new ArrayList<>(1);
            cipherList.add(smClient.getString("managerServlet.notSslConnector"));
            result.put(connector.toString(), cipherList);
        }
    }
    return result;
}
 
Example 10
Source Project: tomcatsrc   Source File: ManagerServlet.java    License: Apache License 2.0 6 votes vote down vote up
protected static boolean validateContextName(ContextName cn,
        PrintWriter writer, StringManager sm) {
    
    // ContextName should be non-null with a path that is empty or starts
    // with /
    if (cn != null &&
            (cn.getPath().startsWith("/") || cn.getPath().equals(""))) {
        return true;
    }
    
    String path = null;
    if (cn != null) {
        path = RequestUtil.filter(cn.getPath());
    }
    writer.println(sm.getString("managerServlet.invalidPath", path));
    return false;
}
 
Example 11
Source Project: Tomcat7.0.67   Source File: HostManagerServlet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Render a list of the currently active Contexts in our virtual host.
 *
 * @param writer Writer to render to
 */
protected void list(PrintWriter writer, StringManager smClient) {

    if (debug >= 1) {
        log(sm.getString("hostManagerServlet.list", engine.getName()));
    }

    writer.println(smClient.getString("hostManagerServlet.listed",
            engine.getName()));
    Container[] hosts = engine.findChildren();
    for (int i = 0; i < hosts.length; i++) {
        Host host = (Host) hosts[i];
        String name = host.getName();
        String[] aliases = host.findAliases();
        StringBuilder buf = new StringBuilder();
        if (aliases.length > 0) {
            buf.append(aliases[0]);
            for (int j = 1; j < aliases.length; j++) {
                buf.append(',').append(aliases[j]);
            }
        }
        writer.println(smClient.getString("hostManagerServlet.listitem",
                                    name, buf.toString()));
    }
}
 
Example 12
Source Project: Tomcat7.0.67   Source File: HTMLManagerServlet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Find potential memory leaks caused by web application reload.
 *
 * @see ManagerServlet#findleaks(boolean, PrintWriter, StringManager) 
 * 
 * @param smClient  StringManager for the client's locale
 *
 * @return message String
 */
protected String findleaks(StringManager smClient) {

    StringBuilder msg = new StringBuilder();

    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);

    super.findleaks(false, printWriter, smClient);

    String writerText = stringWriter.toString();

    if (writerText.length() > 0) {
        if (!writerText.startsWith("FAIL -")) {
            msg.append(smClient.getString(
                    "htmlManagerServlet.findleaksList"));
        }
        msg.append(writerText);
    } else {
        msg.append(smClient.getString("htmlManagerServlet.findleaksNone"));
    }
    
    return msg.toString();
}
 
Example 13
Source Project: Tomcat7.0.67   Source File: HTMLManagerServlet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Removes an attribute from an HttpSession
 * @param cn Name of the application hosting the session from which the
 *           attribute is to be removed
 * @param sessionId
 * @param attributeName
 * @param smClient  StringManager for the client's locale
 * @return true if there was an attribute removed, false otherwise
 * @throws IOException 
 */
protected boolean removeSessionAttribute(ContextName cn, String sessionId,
        String attributeName, StringManager smClient) throws IOException {
    HttpSession session =
        getSessionForNameAndId(cn, sessionId, smClient).getSession();
    if (null == session) {
        // Shouldn't happen, but let's play nice...
        if (debug >= 1) {
            log("WARNING: can't remove attribute '" + attributeName + "' for null session " + sessionId);
        }
        return false;
    }
    boolean wasPresent = (null != session.getAttribute(attributeName));
    try {
        session.removeAttribute(attributeName);
    } catch (IllegalStateException ise) {
        if (debug >= 1) {
            log("Can't remote attribute '" + attributeName + "' for invalidated session id " + sessionId);
        }
    }
    return wasPresent;
}
 
Example 14
Source Project: Tomcat7.0.67   Source File: HostManagerServlet.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Add host with the given parameters.
 *
 * @param request The request
 * @param writer The output writer
 * @param name The host name
 * @param htmlMode Flag value
 */
protected void add(HttpServletRequest request, PrintWriter writer,
        String name, boolean htmlMode, StringManager smClient) {
    String aliases = request.getParameter("aliases");
    String appBase = request.getParameter("appBase");
    boolean manager = booleanParameter(request, "manager", false, htmlMode);
    boolean autoDeploy = booleanParameter(request, "autoDeploy", true, htmlMode);
    boolean deployOnStartup = booleanParameter(request, "deployOnStartup", true, htmlMode);
    boolean deployXML = booleanParameter(request, "deployXML", true, htmlMode);
    boolean unpackWARs = booleanParameter(request, "unpackWARs", true, htmlMode);
    boolean copyXML = booleanParameter(request, "copyXML", false, htmlMode);
    add(writer, name, aliases, appBase, manager,
        autoDeploy,
        deployOnStartup,
        deployXML,                                       
        unpackWARs,
        copyXML,
        smClient);
}
 
Example 15
Source Project: Tomcat7.0.67   Source File: ManagerServlet.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated Use {@link StringManager#getManager(String, Enumeration)}.
 *             This method will be removed in Tomcat 8.
 */
@Deprecated
protected StringManager getStringManager(HttpServletRequest req) {
    Enumeration<Locale> requestedLocales = req.getLocales();
    while (requestedLocales.hasMoreElements()) {
        Locale locale = requestedLocales.nextElement();
        StringManager result = StringManager.getManager(Constants.Package,
                locale);
        if (result.getLocale().equals(locale)) {
            return result;
        }
    }
    // Return the default
    return sm;
}
 
Example 16
Source Project: tomcatsrc   Source File: Diagnostics.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve a JVM thread dump formatted
 * using the given StringManager.
 *
 * @param requestedSm the StringManager to use
 * @return the formatted JVM thread dump
 */
private static String getThreadDump(StringManager requestedSm) {
    StringBuilder sb = new StringBuilder();

    synchronized(timeformat) {
        sb.append(timeformat.format(new Date()));
    }
    sb.append(CRLF);

    sb.append(requestedSm.getString("diagnostics.threadDumpTitle"));
    sb.append(" ");
    sb.append(runtimeMXBean.getVmName());
    sb.append(" (");
    sb.append(runtimeMXBean.getVmVersion());
    String vminfo = System.getProperty(vminfoSystemProperty);
    if (vminfo != null) {
        sb.append(" " + vminfo);
    }
    sb.append("):" + CRLF);
    sb.append(CRLF);

    ThreadInfo[] tis = threadMXBean.dumpAllThreads(true, true);
    sb.append(getThreadDump(tis));

    sb.append(findDeadlock());
    return sb.toString();
}
 
Example 17
Source Project: Tomcat8-Source-Read   Source File: HTMLManagerServlet.java    License: MIT License 5 votes vote down vote up
protected String sslReload(String tlsHostName, StringManager smClient) {
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);

    super.sslReload(printWriter, tlsHostName, smClient);

    return stringWriter.toString();
}
 
Example 18
Source Project: Tomcat7.0.67   Source File: ManagerServlet.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Writes System OS and JVM properties.
 * @param writer Writer to render to
 */
protected void serverinfo(PrintWriter writer,  StringManager smClient) {
    if (debug >= 1)
        log("serverinfo");
    try {
        StringBuilder props = new StringBuilder();
        props.append("OK - Server info");
        props.append("\nTomcat Version: ");
        props.append(ServerInfo.getServerInfo());
        props.append("\nOS Name: ");
        props.append(System.getProperty("os.name"));
        props.append("\nOS Version: ");
        props.append(System.getProperty("os.version"));
        props.append("\nOS Architecture: ");
        props.append(System.getProperty("os.arch"));
        props.append("\nJVM Version: ");
        props.append(System.getProperty("java.runtime.version"));
        props.append("\nJVM Vendor: ");
        props.append(System.getProperty("java.vm.vendor"));
        writer.println(props.toString());
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        getServletContext().log("ManagerServlet.serverinfo",t);
        writer.println(smClient.getString("managerServlet.exception",
                t.toString()));
    }
}
 
Example 19
Source Project: Tomcat8-Source-Read   Source File: HTMLManagerServlet.java    License: MIT License 5 votes vote down vote up
protected Session getSessionForNameAndId(ContextName cn, String id,
        StringManager smClient) {

    List<Session> sessions = getSessionsForName(cn, smClient);
    if (sessions.isEmpty()) return null;
    for(Session session : sessions) {
        if (session.getId().equals(id)) {
            return session;
        }
    }
    return null;
}
 
Example 20
Source Project: Tomcat8-Source-Read   Source File: HTMLManagerServlet.java    License: MIT License 5 votes vote down vote up
/**
 * Display session details.
 *
 * @param req The Servlet request
 * @param resp The Servlet response
 * @param cn Name of the application for which the sessions will be listed
 * @param sessionId the session id
 * @param smClient StringManager for the client's locale
 * @throws ServletException Propagated Servlet error
 * @throws IOException An IO error occurred
 */
protected void displaySessionDetailPage(HttpServletRequest req,
        HttpServletResponse resp, ContextName cn, String sessionId,
        StringManager smClient) throws ServletException, IOException {
    Session session = getSessionForNameAndId(cn, sessionId, smClient);
    //strong>NOTE</strong> - This header will be overridden
    // automatically if a <code>RequestDispatcher.forward()</code> call is
    // ultimately invoked.
    resp.setHeader("Pragma", "No-cache"); // HTTP 1.0
    resp.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); // HTTP 1.1
    resp.setDateHeader("Expires", 0); // 0 means now
    req.setAttribute("currentSession", session);
    getServletContext().getRequestDispatcher(resp.encodeURL(sessionDetailJspPath)).include(req, resp);
}
 
Example 21
Source Project: Tomcat7.0.67   Source File: Diagnostics.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve a JVM thread dump formatted
 * using the given StringManager.
 *
 * @param requestedSm the StringManager to use
 * @return the formatted JVM thread dump
 */
private static String getThreadDump(StringManager requestedSm) {
    StringBuilder sb = new StringBuilder();

    synchronized(timeformat) {
        sb.append(timeformat.format(new Date()));
    }
    sb.append(CRLF);

    sb.append(requestedSm.getString("diagnostics.threadDumpTitle"));
    sb.append(" ");
    sb.append(runtimeMXBean.getVmName());
    sb.append(" (");
    sb.append(runtimeMXBean.getVmVersion());
    String vminfo = System.getProperty(vminfoSystemProperty);
    if (vminfo != null) {
        sb.append(" " + vminfo);
    }
    sb.append("):" + CRLF);
    sb.append(CRLF);

    ThreadInfo[] tis = threadMXBean.dumpAllThreads(true, true);
    sb.append(getThreadDump(tis));

    sb.append(findDeadlock());
    return sb.toString();
}
 
Example 22
Source Project: Tomcat7.0.67   Source File: HttpMessages.java    License: Apache License 2.0 5 votes vote down vote up
public static HttpMessages getInstance(Locale locale) {
    HttpMessages result = instances.get(locale);
    if (result == null) {
        StringManager sm = StringManager.getManager(
                "org.apache.tomcat.util.http.res", locale);
        if (Locale.getDefault().equals(sm.getLocale())) {
            result = DEFAULT;
        } else {
            result = new HttpMessages(sm);
        }
        instances.put(locale, result);
    }
    return result;
}
 
Example 23
Source Project: Tomcat8-Source-Read   Source File: HTMLHostManagerServlet.java    License: MIT License 5 votes vote down vote up
/**
 * Process a GET request for the specified resource.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet-specified error occurs
 */
@Override
public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
    throws IOException, ServletException {

    StringManager smClient = StringManager.getManager(
            Constants.Package, request.getLocales());

    // Identify the request parameters that we need
    String command = request.getPathInfo();

    // Prepare our output writer to generate the response message
    response.setContentType("text/html; charset=" + Constants.CHARSET);

    String message = "";
    // Process the requested command
    if (command == null) {
        // No command == list
    } else if (command.equals("/list")) {
        // Nothing to do - always generate list
    } else if (command.equals("/add") || command.equals("/remove") ||
            command.equals("/start") || command.equals("/stop") ||
            command.equals("/persist")) {
        message = smClient.getString(
                "hostManagerServlet.postCommand", command);
    } else {
        message = smClient.getString(
                "hostManagerServlet.unknownCommand", command);
    }

    list(request, response, message, smClient);
}
 
Example 24
Source Project: Tomcat8-Source-Read   Source File: HTMLHostManagerServlet.java    License: MIT License 5 votes vote down vote up
/**
 * Process a POST request for the specified resource.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet-specified error occurs
 */
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    StringManager smClient = StringManager.getManager(
            Constants.Package, request.getLocales());

    // Identify the request parameters that we need
    String command = request.getPathInfo();

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

    // Prepare our output writer to generate the response message
    response.setContentType("text/html; charset=" + Constants.CHARSET);

    String message = "";

    // Process the requested command
    if (command == null) {
        // No command == list
    } else if (command.equals("/add")) {
        message = add(request, name, smClient);
    } else if (command.equals("/remove")) {
        message = remove(name, smClient);
    } else if (command.equals("/start")) {
        message = start(name, smClient);
    } else if (command.equals("/stop")) {
        message = stop(name, smClient);
    } else if (command.equals("/persist")) {
        message = persist(smClient);
    } else {
        //Try GET
        doGet(request, response);
    }

    list(request, response, message, smClient);
}
 
Example 25
Source Project: Tomcat8-Source-Read   Source File: HTMLHostManagerServlet.java    License: MIT License 5 votes vote down vote up
/**
 * Add a host using the specified parameters.
 *
 * @param request The Servlet request
 * @param name Host name
 * @param smClient StringManager for the client's locale
 * @return output
 */
protected String add(HttpServletRequest request,String name,
        StringManager smClient) {

    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);

    super.add(request,printWriter,name,true, smClient);

    return stringWriter.toString();
}
 
Example 26
Source Project: Tomcat8-Source-Read   Source File: ManagerServlet.java    License: MIT License 5 votes vote down vote up
protected void sslReload(PrintWriter writer, String tlsHostName, StringManager smClient) {
    Connector connectors[] = getConnectors();
    boolean found = false;
    for (Connector connector : connectors) {
        if (Boolean.TRUE.equals(connector.getProperty("SSLEnabled"))) {
            ProtocolHandler protocol = connector.getProtocolHandler();
            if (protocol instanceof AbstractHttp11Protocol<?>) {
                AbstractHttp11Protocol<?> http11Protoocol = (AbstractHttp11Protocol<?>) protocol;
                if (tlsHostName == null || tlsHostName.length() == 0) {
                    found = true;
                    http11Protoocol.reloadSslHostConfigs();
                } else {
                    SSLHostConfig[] sslHostConfigs = http11Protoocol.findSslHostConfigs();
                    for (SSLHostConfig sslHostConfig : sslHostConfigs) {
                        if (sslHostConfig.getHostName().equalsIgnoreCase(tlsHostName)) {
                            found = true;
                            http11Protoocol.reloadSslHostConfig(tlsHostName);
                        }
                    }
                }
            }
        }
    }
    if (found) {
        if (tlsHostName == null || tlsHostName.length() == 0) {
            writer.println(smClient.getString("managerServlet.sslReloadAll"));
        } else {
            writer.println(smClient.getString("managerServlet.sslReload", tlsHostName));
        }
    } else {
        writer.println(smClient.getString("managerServlet.sslReloadFail"));
    }
}
 
Example 27
Source Project: Tomcat8-Source-Read   Source File: ManagerServlet.java    License: MIT License 5 votes vote down vote up
protected void sslConnectorCiphers(PrintWriter writer, StringManager smClient) {
    writer.println(smClient.getString("managerServlet.sslConnectorCiphers"));
    Map<String,List<String>> connectorCiphers = getConnectorCiphers(smClient);
    for (Map.Entry<String,List<String>> entry : connectorCiphers.entrySet()) {
        writer.println(entry.getKey());
        for (String cipher : entry.getValue()) {
            writer.print("  ");
            writer.println(cipher);
        }
    }
}
 
Example 28
Source Project: scipio-erp   Source File: LoginServices.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean TomcatSSOLogin(HttpServletRequest request, String userName, String currentPassword) {
    try {
        request.login(userName, currentPassword);
    } catch (ServletException e) {
        StringManager sm = StringManager.getManager("org.apache.catalina.connector");
        if (sm.getString("coyoteRequest.alreadyAuthenticated").equals(e.getMessage())){
            return true;
        } else {
            Debug.logError(e, module);
            return false;
        }
    }
    return true;
}
 
Example 29
Source Project: tomcatsrc   Source File: ManagerServlet.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 * Extract the expiration request parameter
 *
 * @param cn
 * @param req
 */
protected void expireSessions(PrintWriter writer, ContextName cn,
        HttpServletRequest req, StringManager smClient) {
    int idle = -1;
    String idleParam = req.getParameter("idle");
    if (idleParam != null) {
        try {
            idle = Integer.parseInt(idleParam);
        } catch (NumberFormatException e) {
            log("Could not parse idle parameter to an int: " + idleParam);
        }
    }
    sessions(writer, cn, idle, smClient);
}
 
Example 30
Source Project: Tomcat7.0.67   Source File: HTMLHostManagerServlet.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Process a GET request for the specified resource.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet-specified error occurs
 */
@Override
public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
    throws IOException, ServletException {

    StringManager smClient = StringManager.getManager(
            Constants.Package, request.getLocales());

    // Identify the request parameters that we need
    String command = request.getPathInfo();

    // Prepare our output writer to generate the response message
    response.setContentType("text/html; charset=" + Constants.CHARSET);

    String message = "";
    // Process the requested command
    if (command == null) {
        // No command == list
    } else if (command.equals("/list")) {
        // Nothing to do - always generate list
    } else if (command.equals("/add") || command.equals("/remove") ||
            command.equals("/start") || command.equals("/stop")) {
        message = smClient.getString(
                "hostManagerServlet.postCommand", command);
    } else {
        message = smClient.getString(
                "hostManagerServlet.unknownCommand", command);
    }

    list(request, response, message, smClient);
}