All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.visallo.web.WebServer Maven / Gradle / Ivy

The newest version!
package org.visallo.web;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.converters.FileConverter;
import org.visallo.core.cmdline.CommandLineTool;

import java.io.File;

public abstract class WebServer extends CommandLineTool {
    public static final int DEFAULT_SERVER_PORT = 8080;
    public static final int DEFAULT_HTTPS_SERVER_PORT = 8443;
    public static final String DEFAULT_CONTEXT_PATH = "";
    public static final String DEFAULT_KEYSTORE_TYPE = "JKS";

    @Parameter(names = {"--port"}, arity = 1, description = "The port to run the HTTP connector on")
    private int httpPort = DEFAULT_SERVER_PORT;

    @Parameter(names = {"--httpsPort"}, arity = 1, description = "The port to run the HTTPS connector on")
    private int httpsPort = DEFAULT_HTTPS_SERVER_PORT;

    @Parameter(names = {"--keyStoreType"}, arity = 1, description = "Keystore type (JKS, PKCS12)")
    private String keyStoreType = DEFAULT_KEYSTORE_TYPE;

    @Parameter(names = {"--keyStorePath"}, required = true, arity = 1, converter = FileConverter.class, description = "Path to the keystore used for SSL")
    private File keyStorePath;

    @Parameter(names = {"--keyStorePassword"}, required = true, arity = 1, description = "Keystore password")
    private String keyStorePassword;

    @Parameter(names = {"--trustStoreType"}, arity = 1, description = "Truststore type (JKS, PKCS12)")
    private String trustStoreType;

    @Parameter(names = {"--trustStorePath"}, arity = 1, converter = FileConverter.class, description = "Path to the truststore used for SSL")
    private File trustStorePath;

    @Parameter(names = {"--trustStorePassword"}, arity = 1, description = "Truststore password")
    private String trustStorePassword;

    @Parameter(names = {"--requireClientCert"}, description = "require client certificate")
    private boolean requireClientCert = false;

    @Parameter(names = {"--wantClientCert"}, description = "want client certificate, but don't require it")
    private boolean wantClientCert = false;

    @Parameter(names = {"--webAppDir"}, required = true, arity = 1, converter = FileConverter.class, description = "Path to the webapp directory")
    private File webAppDir;

    @Parameter(names = {"--contextPath"}, arity = 1, description = "Context path for the webapp")
    private String contextPath = DEFAULT_CONTEXT_PATH;

    public int getHttpPort() {
        return httpPort;
    }

    public int getHttpsPort() {
        return httpsPort;
    }

    public String getKeyStoreType() {
        return keyStoreType;
    }

    public String getTrustStoreType() {
        return trustStoreType != null ? trustStoreType : keyStoreType;
    }

    public File getKeyStorePath() {
        return keyStorePath;
    }

    public String getKeyStorePassword() {
        return keyStorePassword;
    }

    public File getTrustStorePath() {
        return trustStorePath != null ? trustStorePath : keyStorePath;
    }

    public String getTrustStorePassword() {
        return trustStorePassword != null ? trustStorePassword : keyStorePassword;
    }

    public boolean getRequireClientCert() {
        return requireClientCert;
    }

    public boolean getWantClientCert() {
        return wantClientCert;
    }

    public String getContextPath() {
        return contextPath;
    }

    public File getWebAppDir() {
        return webAppDir;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy