当前位置: 首页>>代码示例>>Java>>正文


Java SslSocketConnector.setPort方法代码示例

本文整理汇总了Java中org.eclipse.jetty.server.ssl.SslSocketConnector.setPort方法的典型用法代码示例。如果您正苦于以下问题:Java SslSocketConnector.setPort方法的具体用法?Java SslSocketConnector.setPort怎么用?Java SslSocketConnector.setPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.server.ssl.SslSocketConnector的用法示例。


在下文中一共展示了SslSocketConnector.setPort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildSslListener

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Creates a SSLListener with all the default options. The listener will use all the default options.
 * @param address - The address the listener will listen to.
 * @param port - The port the listener will listen to.
 * @return - Newly created listener
 * @throws UnknownHostException
 */
public static SslSocketConnector buildSslListener(String address, int port) throws UnknownHostException {
    int listeners = 0;
    if (_server != null) {
        listeners = _server.getConnectors().length;
    }

    SslSocketConnector ssl = new SslSocketConnector();
    ssl.setProvider(_secMan.getSecurityProvider());
    //ssl.setCipherSuites(_secMan.getSupprtedSSLCipherSuites()); Removed in Jetty 5->6 port.
    ssl.setHost(address);
    ssl.setPort(port);
    ssl.setWantClientAuth(false); // Don't care about client authentication.
    ssl.setPassword(KeyStoreProvider.DEFAULT_KEYSTORE_PASSWORD);
    ssl.setKeyPassword(KeyStoreProvider.DEFAULT_KEYSTORE_PASSWORD);
    ssl.setKeystoreType(KeyStore.getDefaultType());
    ssl.setKeystore(KeyStoreProvider.getKeyStoreLocation());
    ssl.setName("SSL Listener-" + ++listeners);

    return ssl;
}
 
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:28,代码来源:I2PControlController.java

示例2: startHttps

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
 * This implementation is based on http://blog.denevell.org/jetty-9-ssl-https.html
 *
 * @throws Exception
 */
private void startHttps() throws Exception {
  _server = new Server();

  SslContextFactory sslContextFactory = new SslContextFactory(_args.jks);
  sslContextFactory.setKeyStorePassword(_args.jks_pass);

  SslSocketConnector httpsConnector = new SslSocketConnector(sslContextFactory);

  if (getIp() != null) {
    httpsConnector.setHost(getIp());
  }
  httpsConnector.setPort(getPort());

  createServer(httpsConnector);
}
 
开发者ID:h2oai,项目名称:h2o-3,代码行数:21,代码来源:AbstractHTTPD.java

示例3: enableSSL

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Enables SSL
 * 
 */
private void enableSSL() {
    String keyStorePath = this.getFile().getParent() + "/data/" + keystoreFile;
    try (FileInputStream keyStoreInputStream = new FileInputStream(keyStorePath)) {
        KeyStore keyStore = KeyStore.getInstance(keystoreType);
        keyStore.load(keyStoreInputStream, keystorePassword.toCharArray());
        SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setKeyStore(keyStore);
        sslContextFactory.setKeyStorePassword(keystorePassword);
        sslContextFactory.setKeyStoreType(keystoreType);
        SslSocketConnector sslConnector = new SslSocketConnector(sslContextFactory);
        sslConnector.setPort(sslPort);
        sslConnector.setMaxIdleTime(30000);
        LOG.info("Webserver now listens on SSL port {}", sslPort);
        server.addConnector(sslConnector);
    } catch (Exception ex) {
        LOG.error("Cannot load java keystore for reason: ", Freedomotic.getStackTraceInfo(ex));
    }
}
 
开发者ID:freedomotic,项目名称:freedomotic,代码行数:23,代码来源:ApplicationServer.java

示例4: main

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
    // server.getContainer().addEventListener(mBeanContainer);
    // mBeanContainer.start();

    server.setHandler(bb);

    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
 
开发者ID:sparsick,项目名称:ansible-docker-talk,代码行数:65,代码来源:Start.java

示例5: main

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8090);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
    // server.getContainer().addEventListener(mBeanContainer);
    // mBeanContainer.start();

    server.setHandler(bb);

    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:65,代码来源:Start.java

示例6: startWebServer

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Creates and starts an embedded web server on JVM-assigned HTTP and HTTPS ports.
 * Each response has a body that indicates how many bytes were received with a message like
 * "Received x bytes\n".
 *
 * @param enableHttps if true, an HTTPS connector will be added to the web server
 * @return Instance of Server
 */
public static Server startWebServer(boolean enableHttps) {
    final Server httpServer = new Server(0);

    httpServer.setHandler(new AbstractHandler() {
        public void handle(String target, Request baseRequest,
                HttpServletRequest request, HttpServletResponse response)
                throws IOException, ServletException {
            if (request.getRequestURI().contains("hang")) {
                System.out.println("Hanging as requested");
                try {
                    Thread.sleep(90000);
                } catch (InterruptedException ie) {
                    System.out.println("Stopped hanging due to interruption");
                }
            }
            
            long numberOfBytesRead = 0;
            InputStream in = new BufferedInputStream(request
                    .getInputStream());
            while (in.read() != -1) {
                numberOfBytesRead += 1;
            }
            System.out.println("Done reading # of bytes: "
                    + numberOfBytesRead);
            response.setStatus(HttpServletResponse.SC_OK);
            baseRequest.setHandled(true);
            byte[] content = ("Received " + numberOfBytesRead + " bytes\n").getBytes();
            response.addHeader("Content-Length", Integer.toString(content.length));
            response.getOutputStream().write(content);
        }
    });
    if (enableHttps) {
        // Add SSL connector
        org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory = new org.eclipse.jetty.util.ssl.SslContextFactory();

        SelfSignedSslEngineSource contextSource = new SelfSignedSslEngineSource();
        SSLContext sslContext = contextSource.getSslContext();

        sslContextFactory.setSslContext(sslContext);
        SslSocketConnector connector = new SslSocketConnector(
                sslContextFactory);
        connector.setPort(0);
        /*
         * <p>Ox: For some reason, on OS X, a non-zero timeout can causes
         * sporadic issues. <a href="http://stackoverflow.com/questions
         * /16191236/tomcat-startup-fails
         * -due-to-java-net-socketexception-invalid-argument-on-mac-o">This
         * StackOverflow thread</a> has some insights into it, but I don't
         * quite get it.</p>
         * 
         * <p>This can cause problems with Jetty's SSL handshaking, so I
         * have to set the handshake timeout and the maxIdleTime to 0 so
         * that the SSLSocket has an infinite timeout.</p>
         */
        connector.setHandshakeTimeout(0);
        connector.setMaxIdleTime(0);
        httpServer.addConnector(connector);
    }

    try {
        httpServer.start();
    } catch (Exception e) {
        throw new RuntimeException("Error starting Jetty web server", e);
    }

    return httpServer;
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:76,代码来源:TestUtils.java

示例7: startWebServerWithResponse

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Creates and starts an embedded web server on JVM-assigned HTTP and HTTPS ports.
 * Each response has a body that contains the specified contents.
 *
 * @param enableHttps if true, an HTTPS connector will be added to the web server
 * @param content The response the server will return
 * @return Instance of Server
 */
public static Server startWebServerWithResponse(boolean enableHttps, final byte[] content) {
    final Server httpServer = new Server(0);
    httpServer.setHandler(new AbstractHandler() {
        public void handle(String target, Request baseRequest,
                           HttpServletRequest request, HttpServletResponse response)
                throws IOException, ServletException {
            if (request.getRequestURI().contains("hang")) {
                System.out.println("Hanging as requested");
                try {
                    Thread.sleep(90000);
                } catch (InterruptedException ie) {
                    System.out.println("Stopped hanging due to interruption");
                }
            }

            long numberOfBytesRead = 0;
            InputStream in = new BufferedInputStream(request
                    .getInputStream());
            while (in.read() != -1) {
                numberOfBytesRead += 1;
            }
            System.out.println("Done reading # of bytes: "
                    + numberOfBytesRead);
            response.setStatus(HttpServletResponse.SC_OK);
            baseRequest.setHandled(true);

            response.addHeader("Content-Length", Integer.toString(content.length));
            response.getOutputStream().write(content);
        }
    });
    if (enableHttps) {
        // Add SSL connector
        org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory = new org.eclipse.jetty.util.ssl.SslContextFactory();

        SelfSignedSslEngineSource contextSource = new SelfSignedSslEngineSource();
        SSLContext sslContext = contextSource.getSslContext();

        sslContextFactory.setSslContext(sslContext);
        SslSocketConnector connector = new SslSocketConnector(
                sslContextFactory);
        connector.setPort(0);
        /*
         * <p>Ox: For some reason, on OS X, a non-zero timeout can causes
         * sporadic issues. <a href="http://stackoverflow.com/questions
         * /16191236/tomcat-startup-fails
         * -due-to-java-net-socketexception-invalid-argument-on-mac-o">This
         * StackOverflow thread</a> has some insights into it, but I don't
         * quite get it.</p>
         *
         * <p>This can cause problems with Jetty's SSL handshaking, so I
         * have to set the handshake timeout and the maxIdleTime to 0 so
         * that the SSLSocket has an infinite timeout.</p>
         */
        connector.setHandshakeTimeout(0);
        connector.setMaxIdleTime(0);
        httpServer.addConnector(connector);
    }

    try {
        httpServer.start();
    } catch (Exception e) {
        throw new RuntimeException("Error starting Jetty web server", e);
    }

    return httpServer;
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:75,代码来源:TestUtils.java

示例8: startWebServer

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Creates and starts embedded web server that is running on given port,
 * including an SSL connector on the other given port. Each response has a
 * body that indicates how many bytes were received with a message like
 * "Received x bytes\n".
 * 
 * @param port
 *            The port
 * @param sslPort
 *            (optional) The ssl port
 * @return Instance of Server
 * @throws Exception
 *             if failed to start
 */
public static Server startWebServer(final int port, final Integer sslPort)
        throws Exception {
    final Server httpServer = new Server(port);
    httpServer.setHandler(new AbstractHandler() {
        public void handle(String target, Request baseRequest,
                HttpServletRequest request, HttpServletResponse response)
                throws IOException, ServletException {
            if (request.getRequestURI().contains("hang")) {
                System.out.println("Hanging as requested");
                try {
                    Thread.sleep(90000);
                } catch (InterruptedException ie) {
                    System.out.println("Stopped hanging due to interruption");
                }
            }
            
            long numberOfBytesRead = 0;
            InputStream in = new BufferedInputStream(request
                    .getInputStream());
            while (in.read() != -1) {
                numberOfBytesRead += 1;
            }
            System.out.println("Done reading # of bytes: "
                    + numberOfBytesRead);
            response.setStatus(HttpServletResponse.SC_OK);
            baseRequest.setHandled(true);
            byte[] content = ("Received " + numberOfBytesRead + " bytes\n").getBytes();
            response.addHeader("Content-Length", Integer.toString(content.length));
            response.getOutputStream().write(content);
        }
    });
    if (sslPort != null) {
        // Add SSL connector
        org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory = new org.eclipse.jetty.util.ssl.SslContextFactory();

        SelfSignedSslEngineSource contextSource = new SelfSignedSslEngineSource();
        SSLContext sslContext = contextSource.getSslContext();

        sslContextFactory.setSslContext(sslContext);
        SslSocketConnector connector = new SslSocketConnector(
                sslContextFactory);
        connector.setPort(sslPort);
        /*
         * <p>Ox: For some reason, on OS X, a non-zero timeout can causes
         * sporadic issues. <a href="http://stackoverflow.com/questions
         * /16191236/tomcat-startup-fails
         * -due-to-java-net-socketexception-invalid-argument-on-mac-o">This
         * StackOverflow thread</a> has some insights into it, but I don't
         * quite get it.</p>
         * 
         * <p>This can cause problems with Jetty's SSL handshaking, so I
         * have to set the handshake timeout and the maxIdleTime to 0 so
         * that the SSLSocket has an infinite timeout.</p>
         */
        connector.setHandshakeTimeout(0);
        connector.setMaxIdleTime(0);
        httpServer.addConnector(connector);
    }
    httpServer.start();
    return httpServer;
}
 
开发者ID:Elitward,项目名称:LittleProxy,代码行数:76,代码来源:TestUtils.java

示例9: startWebServerWithResponse

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Creates and starts embedded web server that is running on given port,
 * including an SSL connector on the other given port. Each response has a
 * body that contains the specified contents.
 *
 * @param port
 *            The port
 * @param sslPort
 *            (optional) The ssl port
 * @param content
 *            The response the server will return
 * @return Instance of Server
 * @throws Exception
 *             if failed to start
 */
public static Server startWebServerWithResponse(final int port, final Integer sslPort, final byte[] content)
        throws Exception {
    final Server httpServer = new Server(port);
    httpServer.setHandler(new AbstractHandler() {
        public void handle(String target, Request baseRequest,
                           HttpServletRequest request, HttpServletResponse response)
                throws IOException, ServletException {
            if (request.getRequestURI().contains("hang")) {
                System.out.println("Hanging as requested");
                try {
                    Thread.sleep(90000);
                } catch (InterruptedException ie) {
                    System.out.println("Stopped hanging due to interruption");
                }
            }

            long numberOfBytesRead = 0;
            InputStream in = new BufferedInputStream(request
                    .getInputStream());
            while (in.read() != -1) {
                numberOfBytesRead += 1;
            }
            System.out.println("Done reading # of bytes: "
                    + numberOfBytesRead);
            response.setStatus(HttpServletResponse.SC_OK);
            baseRequest.setHandled(true);

            response.addHeader("Content-Length", Integer.toString(content.length));
            response.getOutputStream().write(content);
        }
    });
    if (sslPort != null) {
        // Add SSL connector
        org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory = new org.eclipse.jetty.util.ssl.SslContextFactory();

        SelfSignedSslEngineSource contextSource = new SelfSignedSslEngineSource();
        SSLContext sslContext = contextSource.getSslContext();

        sslContextFactory.setSslContext(sslContext);
        SslSocketConnector connector = new SslSocketConnector(
                sslContextFactory);
        connector.setPort(sslPort);
        /*
         * <p>Ox: For some reason, on OS X, a non-zero timeout can causes
         * sporadic issues. <a href="http://stackoverflow.com/questions
         * /16191236/tomcat-startup-fails
         * -due-to-java-net-socketexception-invalid-argument-on-mac-o">This
         * StackOverflow thread</a> has some insights into it, but I don't
         * quite get it.</p>
         *
         * <p>This can cause problems with Jetty's SSL handshaking, so I
         * have to set the handshake timeout and the maxIdleTime to 0 so
         * that the SSLSocket has an infinite timeout.</p>
         */
        connector.setHandshakeTimeout(0);
        connector.setMaxIdleTime(0);
        httpServer.addConnector(connector);
    }
    httpServer.start();
    return httpServer;
}
 
开发者ID:Elitward,项目名称:LittleProxy,代码行数:77,代码来源:TestUtils.java

示例10: deployWebApp

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
private void deployWebApp() {
    try {
        Server server = new Server();
        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
        connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
        connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
        connector.setHost(getHost());
        connector.setPort(getPort());
        if (isHttpsEnabled()) {
            connector.setConfidentialPort(getHttpsPort());
        }
        server.addConnector(connector);

        if (isHttpsEnabled()) {
            SslSocketConnector sslConnector = new SslSocketConnector();
            sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
            sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
            sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
            sslConnector.setHost(getHost());
            sslConnector.setPort(getHttpsPort());
            sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
            sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
            server.addConnector(sslConnector);
        }

        WebAppContext context = new WebAppContext();
        context.setTempDirectory(getJettyDirectory());
        context.setContextPath(getContextPath());
        context.setWar(getWar());

        if (isHttpsEnabled()) {
            ConstraintMapping constraintMapping = new ConstraintMapping();
            Constraint constraint = new Constraint();
            constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
            constraintMapping.setPathSpec("/");
            constraintMapping.setConstraint(constraint);
            ConstraintSecurityHandler csh = (ConstraintSecurityHandler) context.getSecurityHandler();
            csh.setConstraintMappings(new ConstraintMapping[]{constraintMapping});
        } 

        server.setHandler(context);
        server.start();

        System.err.println("FutureSonic running on: " + getUrl());
        if (isHttpsEnabled()) {
            System.err.println("                and: " + getHttpsUrl());
        }

    } catch (Throwable x) {
        x.printStackTrace();
        exception = x;
    }
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:55,代码来源:SubsonicDeployer.java

示例11: deployWebApp

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void deployWebApp() {
       try {
           Server server = new Server();
           SelectChannelConnector connector = new SelectChannelConnector();
           connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
           connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
           connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
           connector.setHost(getHost());
           connector.setPort(getPort());
           if (isHttpsEnabled()) {
               connector.setConfidentialPort(getHttpsPort());
           }
           server.addConnector(connector);

           if (isHttpsEnabled()) {
               SslSocketConnector sslConnector = new SslSocketConnector();
               SslContextFactory sslContextFactory = sslConnector.getSslContextFactory();
               sslContextFactory = sslConnector.getSslContextFactory();
               sslContextFactory.setExcludeCipherSuites(
                       new String[] {
                           "SSL_RSA_WITH_DES_CBC_SHA",
                           "SSL_DHE_RSA_WITH_DES_CBC_SHA",
                           "SSL_DHE_DSS_WITH_DES_CBC_SHA",
                           "SSL_RSA_EXPORT_WITH_RC4_40_MD5",
                           "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
                           "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
                           "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"
                       });
               sslContextFactory.addExcludeProtocols(new String[]{"SSLv3","SSLv2Hello"});
               sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
               sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
               sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
               sslConnector.setHost(getHost());
               sslConnector.setPort(getHttpsPort());
               sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
               sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
               server.addConnector(sslConnector);
           }

           WebAppContext context = new WebAppContext();
           context.setTempDirectory(getJettyDirectory());
           context.setContextPath(getContextPath());
           context.setWar(getWar());
           context.setOverrideDescriptor("/web-jetty.xml");

           if (isHttpsEnabled()) {

               // Allow non-https for streaming and cover art (for Chromecast, UPnP etc)
               ((ConstraintSecurityHandler) context.getSecurityHandler()).setConstraintMappings(new ConstraintMapping[]{
                       createConstraintMapping("/stream", Constraint.DC_NONE),
                       createConstraintMapping("/coverArt.view", Constraint.DC_NONE),
                       createConstraintMapping("/", Constraint.DC_CONFIDENTIAL)
               });
           } 

           server.setHandler(context);
           server.start();

           System.err.println("Madsonic running on: " + getUrl());
           if (isHttpsEnabled()) {
           System.err.println("                and: " + getHttpsUrl());
           }

       } catch (Throwable x) {
           x.printStackTrace();
           exception = x;
       }
   }
 
开发者ID:MadMarty,项目名称:madsonic-server-5.1,代码行数:70,代码来源:MadsonicDeployer.java

示例12: deployWebApp

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
private void deployWebApp() {
    try {
        Server server = new Server();
        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
        connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
        connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
        connector.setHost(getHost());
        connector.setPort(getPort());
        if (isHttpsEnabled()) {
            connector.setConfidentialPort(getHttpsPort());
        }
        server.addConnector(connector);

        if (isHttpsEnabled()) {
            SslSocketConnector sslConnector = new SslSocketConnector();
            sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
            sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
            sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
            sslConnector.setHost(getHost());
            sslConnector.setPort(getHttpsPort());
            sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
            sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
            server.addConnector(sslConnector);
        }

        WebAppContext context = new WebAppContext();
        context.setTempDirectory(getJettyDirectory());
        context.setContextPath(getContextPath());
        context.setWar(getWar());

        if (isHttpsEnabled()) {
            ConstraintMapping constraintMapping = new ConstraintMapping();
            Constraint constraint = new Constraint();
            constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
            constraintMapping.setPathSpec("/");
            constraintMapping.setConstraint(constraint);
            ConstraintSecurityHandler csh = (ConstraintSecurityHandler) context.getSecurityHandler();
            csh.setConstraintMappings(new ConstraintMapping[]{constraintMapping});
        } 

        server.setHandler(context);
        server.start();

        System.err.println("Madsonic running on: " + getUrl());
        if (isHttpsEnabled()) {
            System.err.println("                and: " + getHttpsUrl());
        }

    } catch (Throwable x) {
        x.printStackTrace();
        exception = x;
    }
}
 
开发者ID:MadMarty,项目名称:madsonic-server-5.0,代码行数:55,代码来源:SubsonicDeployer.java

示例13: main

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/test/webapp");

    // START JMX SERVER
    // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
    // server.getContainer().addEventListener(mBeanContainer);
    // mBeanContainer.start();

    server.setHandler(bb);

    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
 
开发者ID:martin-g,项目名称:wicket-memcached-data-store,代码行数:65,代码来源:Start.java

示例14: main

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

  Server server = new Server();
  SocketConnector connector = new SocketConnector();

  // Set some timeout options to make debugging easier.
  connector.setMaxIdleTime(timeout);
  connector.setSoLingerTime(-1);
  connector.setPort(8080);
  server.addConnector(connector);

  Resource keystore = Resource.newClassPathResource("/keystore");
  if (keystore != null && keystore.exists()) {
    // if a keystore for a SSL certificate is available, start a SSL
    // connector on port 8443.
    // By default, the quickstart comes with a Apache Wicket Quickstart
    // Certificate that expires about half way september 2021. Do not
    // use this certificate anywhere important as the passwords are
    // available in the source.

    connector.setConfidentialPort(8443);

    SslContextFactory factory = new SslContextFactory();
    factory.setKeyStoreResource(keystore);
    factory.setKeyStorePassword("wicket");
    factory.setTrustStoreResource(keystore);
    factory.setKeyManagerPassword("wicket");
    SslSocketConnector sslConnector = new SslSocketConnector(factory);
    sslConnector.setMaxIdleTime(timeout);
    sslConnector.setPort(8443);
    sslConnector.setAcceptors(4);
    server.addConnector(sslConnector);

    System.out.println("SSL access to the quickstart has been enabled on port 8443");
    System.out.println("You can access the application using SSL on https://localhost:8443");
    System.out.println();
  }

  WebAppContext bb = new WebAppContext();
  bb.setServer(server);
  bb.setContextPath("/examples-java-wicket");
  bb.setWar("src/main/webapp");

  // START JMX SERVER
  // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
  // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
  // server.getContainer().addEventListener(mBeanContainer);
  // mBeanContainer.start();

  server.setHandler(bb);

  try {
    System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
    server.start();
    System.in.read();
    System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
    server.stop();
    server.join();
  }
  catch (Exception e) {
    e.printStackTrace();
    System.exit(1);
  }
}
 
开发者ID:olle,项目名称:serverside-todomvc,代码行数:66,代码来源:Start.java

示例15: main

import org.eclipse.jetty.server.ssl.SslSocketConnector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8081);
    server.addConnector(connector);

    // check if a keystore for a SSL certificate is available, and
    // if so, start a SSL connector on port 8443. By default, the
    // quickstart comes with a Apache Wicket Quickstart Certificate
    // that expires about half way september 2021. Do not use this
    // certificate anywhere important as the passwords are available
    // in the source.

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/test/webapp");

    // START JMX SERVER
    // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
    // server.getContainer().addEventListener(mBeanContainer);
    // mBeanContainer.start();

    server.setHandler(bb);
    
    //TOGGLE between these two method to experiment different reloading strategies
    // Autoreload builds and reload the classes automatically
    setAutoReloadProperties();
    // WatchClasses watch the target dir for reloading (build with your IDE or maven)
    //setWatchClassesProperties();
    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
 
开发者ID:code-troopers,项目名称:wicket-hot-reload,代码行数:70,代码来源:Start.java


注:本文中的org.eclipse.jetty.server.ssl.SslSocketConnector.setPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。