Package com.adito.boot

Examples of com.adito.boot.ContextKey


     * @see com.adito.wizard.forms.AbstractWizardForm#init(com.adito.wizard.AbstractWizardSequence)
     */
    public void init(AbstractWizardSequence sequence, HttpServletRequest request) throws Exception {
        try {
            if(sequence.getAttribute(ATTR_SOCKS_PROXY_HOSTNAME, null) == null) {
                socksProxyHostname = Property.getProperty(new ContextKey("proxies.socksProxyHost"));
                if(socksProxyHostname.equals("")) {
                    socksProxyUsername = "";
                    socksProxyPort = "";
                    socksProxyPassword = "";
                }
                else {
                    useSOCKSProxy = true;
                    socksProxyUsername = Property.getProperty(new ContextKey("proxies.socksProxyUser"));
                    socksProxyPassword = Property.getProperty(new ContextKey("proxies.socksProxyPassword"));
                    socksProxyPort = Property.getProperty(new ContextKey("proxies.socksProxyPort"));
                }                   
            }
            else {
                useSOCKSProxy = ((String)sequence.getAttribute(ATTR_USE_SOCKS_PROXY,
                    String.valueOf(Property.getProperty(new ContextKey("webServer.port"))))).equals("true");
                socksProxyHostname = (String)sequence.getAttribute(ATTR_SOCKS_PROXY_HOSTNAME, "");
                socksProxyPort = (String)sequence.getAttribute(ATTR_SOCKS_PROXY_PORT, "");
                socksProxyUsername = (String)sequence.getAttribute(ATTR_SOCKS_PROXY_USERNAME, "");
                socksProxyPassword = (String)sequence.getAttribute(ATTR_SOCKS_PROXY_PASSWORD, "");
            }

            if(sequence.getAttribute(ATTR_HTTP_PROXY_HOSTNAME, null) == null) {
                httpProxyHostname = Property.getProperty(new ContextKey("proxies.http.proxyHost"));
                httpNonProxyHosts = Property.getPropertyList(new ContextKey("proxies.http.nonProxyHosts"));
                if(httpProxyHostname.equals("")) {
                    httpProxyUsername = "";
                    httpProxyPort = "";
                    httpProxyPassword = "";
                    httpNonProxyHosts.clear();
                }
                else {
                    useHTTPProxy = true;
                    httpProxyUsername = Property.getProperty(new ContextKey("proxies.http.proxyUser"));
                    httpProxyPassword = Property.getProperty(new ContextKey("proxies.http.proxyPassword"));
                    httpProxyPort = Property.getProperty(new ContextKey("proxies.http.proxyPort"));
                }                   
            }
            else {
                useHTTPProxy = ((String)sequence.getAttribute(ATTR_USE_HTTP_PROXY,
                    String.valueOf(Property.getPropertyBoolean(new ContextKey("webServer.port"))))).equals("true");
                httpProxyHostname = (String)sequence.getAttribute(ATTR_HTTP_PROXY_HOSTNAME, "");
                httpProxyPort = (String)sequence.getAttribute(ATTR_HTTP_PROXY_PORT, "");
                httpProxyUsername = (String)sequence.getAttribute(ATTR_HTTP_PROXY_USERNAME, "");
                httpProxyPassword = (String)sequence.getAttribute(ATTR_HTTP_PROXY_PASSWORD, "");
                httpNonProxyHosts = (PropertyList)sequence.getAttribute(ATTR_HTTP_NON_PROXY_HOSTS, null);
View Full Code Here


     * @see com.adito.wizard.forms.AbstractWizardForm#init(com.adito.wizard.AbstractWizardSequence,
     *      javax.servlet.http.HttpServletRequest)
     */
    public void init(AbstractWizardSequence sequence, HttpServletRequest request) throws Exception {
        try {
            port = (String) sequence.getAttribute(ATTR_WEB_SERVER_PORT, Property.getProperty(new ContextKey("webServer.port")));
            protocol = (String) sequence.getAttribute(ATTR_WEB_SERVER_PROTOCOL, Property.getProperty(new ContextKey(
                            "webServer.protocol")));
            listeningInterfaces = (String) sequence.getAttribute(ATTR_LISTENING_INTERFACES, Property.getProperty(new ContextKey(
                            "webServer.bindAddress")));
            String validExternalHostnamesAsTextFieldText = (String) sequence.getAttribute(ATTR_VALID_EXTERNAL_HOSTS, Property
                            .getProperty(new SystemConfigKey("webServer.validExternalHostnames")));
            validExternalHostnames.setAsPropertyText(validExternalHostnamesAsTextFieldText);
            invalidHostnameAction = (String) sequence.getAttribute(ATTR_INVALID_HOSTNAME_ACTION, Property
View Full Code Here

             * Configure HTTP proxy. Supported by both Java API and Maverick
             * HTTP.
             */
            SessionInfo sessionInfo = getSessionInfo(request);
            if (useHTTPProxy) {
                Property.setProperty(new ContextKey("proxies.http.proxyHost"), (String) seq.getAttribute(
                    ConfigureProxiesForm.ATTR_HTTP_PROXY_HOSTNAME, ""), sessionInfo);
                Property.setProperty(new ContextKey("proxies.http.proxyPort"), (String) seq.getAttribute(
                    ConfigureProxiesForm.ATTR_HTTP_PROXY_PORT, ""), sessionInfo);
                Property.setProperty(new ContextKey("proxies.http.proxyUser"), (String) seq.getAttribute(
                    ConfigureProxiesForm.ATTR_HTTP_PROXY_USERNAME, ""), sessionInfo);
                Property.setProperty(new ContextKey("proxies.http.proxyPassword"), (String) seq.getAttribute(
                    ConfigureProxiesForm.ATTR_HTTP_PROXY_PASSWORD, ""), sessionInfo);
                Property.setProperty(new ContextKey("proxies.http.nonProxyHosts"), ((PropertyList) seq.getAttribute(
                    ConfigureProxiesForm.ATTR_HTTP_NON_PROXY_HOSTS, null)), sessionInfo);
            } else {
                Property.setProperty(new ContextKey("proxies.http.proxyHost"), "", sessionInfo);
                Property.setProperty(new ContextKey("proxies.http.proxyPort"), 1080, sessionInfo);
                Property.setProperty(new ContextKey("proxies.http.proxyUser"), "", sessionInfo);
                Property.setProperty(new ContextKey("proxies.http.proxyPassword"), "", sessionInfo);
                Property.setProperty(new ContextKey("proxies.http.nonProxyHosts"), PropertyList.EMPTY_LIST, sessionInfo);
            }
            return new WizardActionStatus(WizardActionStatus.COMPLETED_OK, "installation.install.status.proxiesConfigured");
        } catch (Exception e) {
            log.error("Failed to configure web server.", e);
            return new WizardActionStatus(WizardActionStatus.COMPLETED_WITH_ERRORS,
View Full Code Here

        Property.setProperty(new RealmKey("security.userDatabase", r), newDatabase, seq.getSession());
        return new WizardActionStatus(WizardActionStatus.COMPLETED_OK, "installation.install.status.userDatabaseConfigured");
    }

    WizardActionStatus webServer(AbstractWizardSequence seq) {
        Property.setProperty(new ContextKey("webServer.port"),
            (String) seq.getAttribute(WebServerForm.ATTR_WEB_SERVER_PORT, "443"), seq.getSession());
        Property.setProperty(new ContextKey("webServer.protocol"), (String) seq.getAttribute(
            WebServerForm.ATTR_WEB_SERVER_PROTOCOL, "https"), seq.getSession());
        PropertyList l = PropertyList.createFromTextFieldText((String) seq
                        .getAttribute(WebServerForm.ATTR_LISTENING_INTERFACES, ""));
        Property.setProperty(new ContextKey("webServer.bindAddress"), l, seq.getSession());
        l = PropertyList.createFromTextFieldText((String) seq.getAttribute(WebServerForm.ATTR_VALID_EXTERNAL_HOSTS, ""));
        Property.setProperty(new SystemConfigKey("webServer.validExternalHostnames"), l, seq.getSession());
        Property.setProperty(new SystemConfigKey("webServer.invalidHostnameAction"), (String) seq.getAttribute(
            WebServerForm.ATTR_INVALID_HOSTNAME_ACTION, "none"), seq.getSession());
        return new WizardActionStatus(WizardActionStatus.COMPLETED_OK, "installation.install.status.webServerConfigured");
View Full Code Here

            }

            String alias = InstallAction.SERVER_CERTIFICATE;
            String passphrase = (String) seq.getAttribute(SetKeyStorePasswordForm.ATTR_KEY_STORE_PASSWORD, null);
            if (passphrase != null && !passphrase.equals("")) {
                Property.setProperty(new ContextKey("webServer.keystore.sslCertificate.password"), passphrase, seq.getSession());
                mgr.setStorePassword(passphrase);
            }

            mgr.createKeyStore();
            String dname = "cn="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_HOSTNAME, ""))
                            + ", ou="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_ORGANISATIONAL_UNIT,
                                "")) + ", o="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_COMPANY, "")) + ", l="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_CITY, "")) + ", st="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_STATE, "")) + ", c="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_COUNTRY_CODE, ""));
            mgr.createKey(alias, dname);
            Property.setProperty(new ContextKey("webServer.keyStoreType"), KeyStoreManager.TYPE_JKS.getName(), null);
            Property.setProperty(new ContextKey("webServer.alias"), alias, null);

            CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.KEYSTORE_CERTIFICATE_CREATED, alias, null).addAttribute(
                CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_ALIAS, alias).addAttribute(CreateNewCertificateForm.ATTR_HOSTNAME,
                (String) seq.getAttribute(CreateNewCertificateForm.ATTR_HOSTNAME, "")).addAttribute(
                CreateNewCertificateForm.ATTR_ORGANISATIONAL_UNIT,
View Full Code Here

                  log.error("Could not find first alias", ex);
                }
               
            }

            Property.setProperty(new ContextKey("webServer.alias"), alias, null);
            Property.setProperty(new ContextKey("webServer.keystore.sslCertificate.password"), passphrase, null);
            CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.KEYSTORE_IMPORTED, null, null).addAttribute(
                CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_ALIAS, alias).addAttribute(CreateNewCertificateForm.ATTR_HOSTNAME,
                (String) seq.getAttribute(CreateNewCertificateForm.ATTR_HOSTNAME, "")).addAttribute(
                CreateNewCertificateForm.ATTR_ORGANISATIONAL_UNIT,
                (String) seq.getAttribute(CreateNewCertificateForm.ATTR_ORGANISATIONAL_UNIT, "")).addAttribute(
View Full Code Here

            }

            // Configure any HTTP / HTTPS / SOCKS proxy servers
            configureProxyServers();

            PropertyList l = contextConfiguration.retrievePropertyList(new ContextKey("webServer.bindAddress"));
            getBootProgressMonitor().updateMessage("Creating server lock");
            getBootProgressMonitor().updateProgress(6);
            serverLock = new ServerLock((String) l.get(0));
            if (serverLock.isLocked()) {
                if (!isSetupMode()) {
View Full Code Here

    }

    private void registerKeyStores() throws Exception {
        getBootProgressMonitor().updateMessage("Registering key stores");
        getBootProgressMonitor().updateProgress(7);
        String defaultKeyStorePassword = contextConfiguration.retrieveProperty(new ContextKey(
                        "webServer.keystore.sslCertificate.password"));
        KeyStoreManager.registerKeyStore(KeyStoreManager.DEFAULT_KEY_STORE, "keystore", true, defaultKeyStorePassword,
            KeyStoreManager.getKeyStoreType(contextConfiguration.retrieveProperty(new ContextKey("webServer.keyStoreType"))));

        KeyStoreManager.registerKeyStore(KeyStoreManager.SERVER_AUTHENTICATION_CERTIFICATES_KEY_STORE, "keystore", true,
            "adito", KeyStoreManager.TYPE_JKS);
        KeyStoreManager.registerKeyStore(KeyStoreManager.TRUSTED_SERVER_CERTIFICATES_KEY_STORE, "keystore", true, "adito",
            KeyStoreManager.TYPE_JKS);
View Full Code Here

        log = LogFactory.getLog(Main.class);
    }

    private void startHttpServer() throws Exception {

        int port = contextConfiguration.retrievePropertyInt(new ContextKey("webServer.httpRedirectPort"));
        if (port <= 0) {
            if (log.isInfoEnabled())
                log.info("HTTP redirect port " + port + " is invalid");
            return;
        }
       
        String bind = contextConfiguration.retrieveProperty(new ContextKey("webServer.bindAddress"));
        PropertyList l = new PropertyList(bind.equals("") ? "0.0.0.0" : bind);
        insecureServer = new Server();
        for (Iterator<String> i = l.iterator(); i.hasNext();) {
            String address = i.next();
            if (log.isInfoEnabled())
                log.info("Adding listener on " + address + ":" + port);
            SocketListener listener = new SocketListener();
            listener.setHost(address);
            listener.setPort(port);
            listener.setMinThreads(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.minThreads")));
            listener.setMaxThreads(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.maxThreads")));
            listener.setMaxIdleTimeMs(0);
            listener.setLowResourcePersistTimeMs(2000);
            listener.setAcceptQueueSize(0);
            listener.setPoolName("P2");
            insecureServer.addListener(listener);
View Full Code Here

        server = createServer();

        // SunJsseListener listener = new SunJsseListener();
        String keystorePassword = contextConfiguration
                        .retrieveProperty(new ContextKey("webServer.keystore.sslCertificate.password"));
        if (keystorePassword.equals("")) {
            throw new Exception(
                            "Private key / certificate password has not been set. Please run the Installation Wizard.");
        }

        actualPort = defaultPort == -1 ? contextConfiguration.retrievePropertyInt(new ContextKey("webServer.port")) : defaultPort;
        String bind = contextConfiguration.retrieveProperty(new ContextKey("webServer.bindAddress"));
        listeners = new ArrayList<SocketListener>();
        PropertyList l = new PropertyList(bind.equals("") ? "0.0.0.0" : bind);
        for (Iterator<String> i = l.iterator(); i.hasNext();) {
            String address = i.next();
            if (log.isInfoEnabled())
                log.info("Adding listener on " + address + ":" + actualPort);
            if (!serverLock.isStarted()) {
                serverLock.start(actualPort);
            }
            SocketListener listener = null;
            if (contextConfiguration.retrieveProperty(new ContextKey("webServer.protocol")).equals("http")) {
                listener = new SocketListener();
                log.warn("The server is configured to listen for plain HTTP connections.");
            } else {
                listener = new CustomJsseListener(keystorePassword);
                MsieSslHandler sslHandler = new MsieSslHandler();
                sslHandler.setUserAgentSubString("MSIE 5");
                listener.setHttpHandler(sslHandler);
            }
            listener.setPort(actualPort);
            listener.setMinThreads(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.minThreads")));
            listener.setMaxThreads(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.maxThreads")));
            listener.setMaxIdleTimeMs(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.maxIdleTimeMs")));
            listener.setHost(address);
            listener.setBufferSize(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.bufferSize")));
            listener.setBufferReserve(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.bufferReserve")));
            listener.setTcpNoDelay(contextConfiguration.retrievePropertyBoolean(new ContextKey("webServer.tcpNoDelay")));
            listener.setThreadsPriority(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.threadPriority")));
            listeners.add(listener);

            listener.setLowResourcePersistTimeMs(contextConfiguration.retrievePropertyInt(new ContextKey(
                            "webServer.lowResourcePersistTimeMs")));
            listener.setPoolName("main");
            server.addListener(listener);
        }
       
        // Add the context
        getBootProgressMonitor().updateMessage("Creating web application");
        getBootProgressMonitor().updateProgress(9);
        httpContext = new CustomHttpContext(server, "/", useDevConfig, bootLoader);
        httpContext.setRedirectNullPath(false);
        server.addContext(httpContext);

        // Dunny servlet handler for faking HttpServletRequest,
        // HttpServletResponse
        servletHandler = new ServletHandler();
        servletHandler.initialize(httpContext);
        servletHandler.start();

        // Add the webapp
        webappContext = new CustomWebApplicationContext(useDevConfig, bootLoader);
        addLifecycleListener(webappContext);

        server.addContext(webappContext);
        webappContext.setRedirectNullPath(false);

        // Configure the server
        server.setRequestsPerGC(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.requestsPerGC")));
        server.setTrace(false);

        // Set the request log
        if (contextConfiguration.retrievePropertyBoolean(new ContextKey("webServer.requestLog"))) {
            NCSARequestLog requestLog = new NCSARequestLog(jettyLog);
            requestLog.setRetainDays(90);
            requestLog.setAppend(true);
            requestLog.setExtended(false);
            requestLog.setBuffered(false);
View Full Code Here

TOP

Related Classes of com.adito.boot.ContextKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.