Search in sources :

Example 1 with SecuredRedirectHandler

use of org.eclipse.jetty.server.handler.SecuredRedirectHandler in project scheduling by ow2-proactive.

the class JettyStarter method deployWebApplications.

public List<String> deployWebApplications(String rmUrl, String schedulerUrl) {
    initializeRestProperties();
    setSystemPropertyIfNotDefined("rm.url", rmUrl);
    setSystemPropertyIfNotDefined("scheduler.url", schedulerUrl);
    if (WebProperties.WEB_DEPLOY.getValueAsBoolean()) {
        logger.info("Starting the web applications...");
        int httpPort = getJettyHttpPort();
        int httpsPort = 443;
        if (WebProperties.WEB_HTTPS_PORT.isSet()) {
            httpsPort = WebProperties.WEB_HTTPS_PORT.getValueAsInt();
        }
        boolean httpsEnabled = WebProperties.WEB_HTTPS.getValueAsBoolean();
        boolean redirectHttpToHttps = WebProperties.WEB_REDIRECT_HTTP_TO_HTTPS.getValueAsBoolean();
        int restPort = httpPort;
        String httpProtocol;
        String[] defaultVirtualHost;
        String[] httpVirtualHost = new String[] { "@" + HTTP_CONNECTOR_NAME };
        if (httpsEnabled) {
            httpProtocol = "https";
            defaultVirtualHost = new String[] { "@" + HTTPS_CONNECTOR_NAME };
            restPort = httpsPort;
        } else {
            defaultVirtualHost = httpVirtualHost;
            httpProtocol = "http";
        }
        Server server = createHttpServer(httpPort, httpsPort, httpsEnabled, redirectHttpToHttps);
        server.setStopAtShutdown(true);
        HandlerList handlerList = new HandlerList();
        if (httpsEnabled && redirectHttpToHttps) {
            ContextHandler redirectHandler = new ContextHandler();
            redirectHandler.setContextPath("/");
            redirectHandler.setHandler(new SecuredRedirectHandler());
            redirectHandler.setVirtualHosts(httpVirtualHost);
            handlerList.addHandler(redirectHandler);
        }
        addWarsToHandlerList(handlerList, defaultVirtualHost);
        server.setHandler(handlerList);
        String schedulerHost = ProActiveInet.getInstance().getHostname();
        return startServer(server, schedulerHost, restPort, httpProtocol);
    }
    return new ArrayList<>();
}
Also used : HandlerList(org.eclipse.jetty.server.handler.HandlerList) ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) Server(org.eclipse.jetty.server.Server) SecuredRedirectHandler(org.eclipse.jetty.server.handler.SecuredRedirectHandler) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 Server (org.eclipse.jetty.server.Server)1 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)1 HandlerList (org.eclipse.jetty.server.handler.HandlerList)1 SecuredRedirectHandler (org.eclipse.jetty.server.handler.SecuredRedirectHandler)1