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


Java SslSocketConnector.setPort方法代码示例

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


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

示例1: createJettyServer

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
private Server createJettyServer() {
  try {
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket(0, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType(keyStoreType);
      c.setKeyPassword(keyStorePassword);
      server.setConnectors(new Connector[] {c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not stop embedded servlet container, " + ex.getMessage(), ex);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestJettyHelper.java

示例2: addSslListener

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Configure an ssl listener on the server.
 * @param addr address to listen on
 * @param sslConf conf to retrieve ssl options
 * @param needCertsAuth whether x509 certificate authentication is required
 */
public void addSslListener(InetSocketAddress addr, Configuration sslConf,
    boolean needCertsAuth) throws IOException {
  if (webServer.isStarted()) {
    throw new IOException("Failed to add ssl listener");
  }
  if (needCertsAuth) {
    // setting up SSL truststore for authenticating clients
    System.setProperty("javax.net.ssl.trustStore", sslConf.get(
        "ssl.server.truststore.location", ""));
    System.setProperty("javax.net.ssl.trustStorePassword", sslConf.get(
        "ssl.server.truststore.password", ""));
    System.setProperty("javax.net.ssl.trustStoreType", sslConf.get(
        "ssl.server.truststore.type", "jks"));
  }
  SslSocketConnector sslListener = new SslSocketConnector();
  sslListener.setHost(addr.getHostName());
  sslListener.setPort(addr.getPort());
  sslListener.setKeystore(sslConf.get("ssl.server.keystore.location"));
  sslListener.setPassword(sslConf.get("ssl.server.keystore.password", ""));
  sslListener.setKeyPassword(sslConf.get("ssl.server.keystore.keypassword", ""));
  sslListener.setKeystoreType(sslConf.get("ssl.server.keystore.type", "jks"));
  sslListener.setNeedClientAuth(needCertsAuth);
  webServer.addConnector(sslListener);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:HttpServer.java

示例3: createJettyServer

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
private Server createJettyServer() {
  try {
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket(0, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType(keyStoreType);
      c.setKeyPassword(keyStorePassword);
      server.setConnectors(new Connector[] {c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not start embedded servlet container, " + ex.getMessage(), ex);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:TestJettyHelper.java

示例4: addSslListener

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Configure an ssl listener on the server for shuffle.
 *
 * @param addr address to listen on.
 * @param sslFactory SSLFactory to use.
 */
public void addSslListener(InetSocketAddress addr, final SSLFactory sslFactory)
  throws IOException {
  if (webServer.isStarted()) {
    throw new IOException("Failed to add ssl listener");
  }

  SslSocketConnector sslListener = new SslSocketConnector() {
    @Override
    protected SSLServerSocketFactory createFactory() throws Exception {
      return sslFactory.createSSLServerSocketFactory();
    }
  };

  sslListener.setHost(addr.getHostName());
  sslListener.setPort(addr.getPort());
  webServer.addConnector(sslListener);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:24,代码来源:TaskTracker.java

示例5: addSslListener

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Configure an ssl listener on the server.
 * @param addr address to listen on
 * @param sslConf conf to retrieve ssl options
 * @param needClientAuth whether client authentication is required
 */
public void addSslListener(InetSocketAddress addr, Configuration sslConf,
    boolean needClientAuth) throws IOException {
  if (webServer.isStarted()) {
    throw new IOException("Failed to add ssl listener");
  }
  if (needClientAuth) {
    // setting up SSL truststore for authenticating clients
    System.setProperty("javax.net.ssl.trustStore", sslConf.get(
        "ssl.server.truststore.location", ""));
    System.setProperty("javax.net.ssl.trustStorePassword", sslConf.get(
        "ssl.server.truststore.password", ""));
    System.setProperty("javax.net.ssl.trustStoreType", sslConf.get(
        "ssl.server.truststore.type", "jks"));
  }
  SslSocketConnector sslListener = new SslSocketConnector();
  sslListener.setHost(addr.getAddress().getHostAddress());
  sslListener.setPort(addr.getPort());
  sslListener.setKeystore(sslConf.get("ssl.server.keystore.location"));
  sslListener.setPassword(sslConf.get("ssl.server.keystore.password", ""));
  sslListener.setKeyPassword(sslConf.get("ssl.server.keystore.keypassword", ""));
  sslListener.setKeystoreType(sslConf.get("ssl.server.keystore.type", "jks"));
  sslListener.setNeedClientAuth(needClientAuth);
  webServer.addConnector(sslListener);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:31,代码来源:HttpServer.java

示例6: startServer

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Start the server, including a handler that responds with registered
 * files, removes registered files on request, and gives 404 otherwise.
 * Connection to this web host only possible with the shared certificate.
 */
protected void startServer() {
    server = new Server();

    //This sets up a secure connector
    SslSocketConnector connector = new SslSocketConnector();
    connector.setKeystore(KEYSTORE_PATH);
    connector.setPassword(KEYSTORE_PASSWORD);
    connector.setKeyPassword(KEY_PASSWORD);
    connector.setTruststore(KEYSTORE_PATH);
    connector.setTrustPassword(KEYSTORE_PASSWORD);
    connector.setNeedClientAuth(true);
    connector.setPort(port);

    //This initialises the server.        
    server.addConnector(connector);
    server.addHandler(new HTTPRemoteFileRegistryHandler());
    try {
        server.start();
    } catch (Exception e) {
        throw new IOFailure("Cannot start HTTPSRemoteFile registry", e);
    }
}
 
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:28,代码来源:HTTPSRemoteFileRegistry.java

示例7: startJetty

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
@BeforeClass
public static void startJetty() throws Exception {
    port = PortFactory.findFreePort();
    server = new Server();
    SslSocketConnector sslSocketConnector = new SslSocketConnector();
    sslSocketConnector.setKeystore("src/test/resources/keystore");
    sslSocketConnector.setKeyPassword("password");
    sslSocketConnector.setPort(port);
    server.setConnectors(new Connector[]{sslSocketConnector});
    server.addHandler(new AbstractHandler() {
        public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException {
            response.setStatus(Response.Status.OK.getStatusCode());
            Request base_request = request instanceof Request ? (Request) request : HttpConnection.getCurrentConnection().getRequest();
            base_request.setHandled(true);
        }
    });
    server.start();
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:19,代码来源:GitLabConnectionConfigSSLTest.java

示例8: addSslListener

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Configure an ssl listener on the server.
 * @param addr address to listen on
 * @param sslConf conf to retrieve ssl options
 * @param needClientAuth whether client authentication is required
 */
public void addSslListener(InetSocketAddress addr, Configuration sslConf,
    boolean needClientAuth) throws IOException {
  if (webServer.isStarted()) {
    throw new IOException("Failed to add ssl listener");
  }
  if (needClientAuth) {
    // setting up SSL truststore for authenticating clients
    System.setProperty("javax.net.ssl.trustStore", sslConf.get(
        "ssl.server.truststore.location", ""));
    System.setProperty("javax.net.ssl.trustStorePassword", sslConf.get(
        "ssl.server.truststore.password", ""));
    System.setProperty("javax.net.ssl.trustStoreType", sslConf.get(
        "ssl.server.truststore.type", "jks"));
  }
  SslSocketConnector sslListener = new SslSocketConnector();
  sslListener.setHost(addr.getHostName());
  sslListener.setPort(addr.getPort());
  sslListener.setKeystore(sslConf.get("ssl.server.keystore.location"));
  sslListener.setPassword(sslConf.get("ssl.server.keystore.password", ""));
  sslListener.setKeyPassword(sslConf.get("ssl.server.keystore.keypassword", ""));
  sslListener.setKeystoreType(sslConf.get("ssl.server.keystore.type", "jks"));
  sslListener.setNeedClientAuth(needClientAuth);
  webServer.addConnector(sslListener);
}
 
开发者ID:iVCE,项目名称:RDFS,代码行数:31,代码来源:HttpServer.java

示例9: createJettyServer

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
private static Server createJettyServer(String keyStore, String password, int inPort) {
  try {
    boolean ssl = keyStore != null;
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket((inPort < 0) ? 0 : inPort, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType("jks");
      c.setKeyPassword(password);
      server.setConnectors(new Connector[]{c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not start embedded servlet container, "
        + ex.getMessage(), ex);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:MiniKMS.java

示例10: setUp

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
	this.servletTester = new ServletTester();
	this.servletTester.addServlet(AppletServiceServlet.class, "/");

	Security.addProvider(new BouncyCastleProvider());

	KeyPair keyPair = generateKeyPair();
	DateTime notBefore = new DateTime();
	DateTime notAfter = notBefore.plusMonths(1);
	X509Certificate certificate = generateSelfSignedCertificate(keyPair, "CN=localhost", notBefore, notAfter);
	File tmpP12File = File.createTempFile("ssl-", ".p12");
	LOG.debug("p12 file: " + tmpP12File.getAbsolutePath());
	persistKey(tmpP12File, keyPair.getPrivate(), certificate, "secret".toCharArray(), "secret".toCharArray());

	SslSocketConnector sslSocketConnector = new SslSocketConnector();
	sslSocketConnector.setKeystore(tmpP12File.getAbsolutePath());
	sslSocketConnector.setTruststore(tmpP12File.getAbsolutePath());
	sslSocketConnector.setTruststoreType("pkcs12");
	sslSocketConnector.setKeystoreType("pkcs12");
	sslSocketConnector.setPassword("secret");
	sslSocketConnector.setKeyPassword("secret");
	sslSocketConnector.setTrustPassword("secret");
	sslSocketConnector.setMaxIdleTime(30000);
	int sslPort = getFreePort();
	sslSocketConnector.setPort(sslPort);
	this.servletTester.getContext().getServer().addConnector(sslSocketConnector);
	this.sslLocation = "https://localhost:" + sslPort + "/";

	this.servletTester.start();
	this.location = this.servletTester.createSocketConnector(true);

	SSLContext sslContext = SSLContext.getInstance("TLS");
	TrustManager trustManager = new TestTrustManager(certificate);
	sslContext.init(null, new TrustManager[] { trustManager }, null);
	SSLContext.setDefault(sslContext);
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:38,代码来源:AppletServiceServletTest.java

示例11: setUp

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
	this.servletTester = new ServletTester();
	this.servletHolder = this.servletTester.addServlet(AppletServiceServlet.class, "/");

	Security.addProvider(new BouncyCastleProvider());

	KeyPair keyPair = generateKeyPair();
	DateTime notBefore = new DateTime();
	DateTime notAfter = notBefore.plusMonths(1);
	this.certificate = generateSelfSignedCertificate(keyPair, "CN=localhost", notBefore, notAfter);
	File tmpP12File = File.createTempFile("ssl-", ".p12");
	LOG.debug("p12 file: " + tmpP12File.getAbsolutePath());
	persistKey(tmpP12File, keyPair.getPrivate(), this.certificate, "secret".toCharArray(), "secret".toCharArray());

	SslSocketConnector sslSocketConnector = new SslSocketConnector();
	sslSocketConnector.setKeystore(tmpP12File.getAbsolutePath());
	sslSocketConnector.setTruststore(tmpP12File.getAbsolutePath());
	sslSocketConnector.setTruststoreType("pkcs12");
	sslSocketConnector.setKeystoreType("pkcs12");
	sslSocketConnector.setPassword("secret");
	sslSocketConnector.setKeyPassword("secret");
	sslSocketConnector.setTrustPassword("secret");
	sslSocketConnector.setMaxIdleTime(30000);
	int sslPort = getFreePort();
	sslSocketConnector.setPort(sslPort);
	this.servletTester.getContext().getServer().addConnector(sslSocketConnector);
	this.sslLocation = "https://localhost:" + sslPort + "/";

	this.servletTester.start();

	SSLContext sslContext = SSLContext.getInstance("TLS");
	TrustManager trustManager = new TestTrustManager(this.certificate);
	sslContext.init(null, new TrustManager[] { trustManager }, null);
	SSLContext.setDefault(sslContext);
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:37,代码来源:ControllerTest.java

示例12: getSSLConnector

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
private Connector getSSLConnector() {
  SslSocketConnector sslConnector = new SslSocketConnector();
  sslConnector.setPort(getPort());
  sslConnector.setKeyPassword(getHttpsHost().getKeyStorePassword());
  sslConnector.setKeystore(getHttpsHost().getKeyStorePath());
  sslConnector.setTruststore(getHttpsHost().getTrustStorePath());
  sslConnector.setTrustPassword(getHttpsHost().getTrustStorePassword());
  return sslConnector;
}
 
开发者ID:pulsarIO,项目名称:jetstream,代码行数:10,代码来源:JettyServer.java

示例13: getSslSocketConnector

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
private static SslSocketConnector getSslSocketConnector(String hostname) {

        String password = "changeit";
        SslSocketConnector conn = new SslSocketConnector();
        conn.setPort(8443);
        File userHome = new File(System.getProperty("user.home"));
        File geoserverDir = new File(userHome, ".geoserver");
        if (geoserverDir.exists() == false)
            geoserverDir.mkdir();
        File keyStoreFile = new File(geoserverDir, "keystore.jks");
        try {
            assureSelfSignedServerCertificate(hostname, keyStoreFile, password);
        } catch (Exception e) {
            log.log(Level.WARNING, "NO SSL available", e);
            return null;
        }
        conn.setKeystore(keyStoreFile.getAbsolutePath());
        conn.setKeyPassword(password);
        conn.setPassword(password);
        File javaHome = new File(System.getProperty("java.home"));
        File cacerts = new File(javaHome, "lib");
        cacerts = new File(cacerts, "security");
        cacerts = new File(cacerts, "cacerts");

        if (cacerts.exists() == false)
            return null;
        conn.setTruststore(cacerts.getAbsolutePath());
        conn.setTrustPassword("changeit");
        return conn;
    }
 
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:31,代码来源:Start.java

示例14: addSslListener

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
/**
 * Configure an ssl listener on the server.
 * @param addr address to listen on
 * @param keystore location of the keystore
 * @param storPass password for the keystore
 * @param keyPass password for the key
 * @deprecated Use {@link #addSslListener(InetSocketAddress, Configuration, boolean)}
 */
@Deprecated
public void addSslListener(InetSocketAddress addr, String keystore,
    String storPass, String keyPass) throws IOException {
  if (webServer.isStarted()) {
    throw new IOException("Failed to add ssl listener");
  }
  SslSocketConnector sslListener = new SslSocketConnector();
  sslListener.setHost(addr.getHostName());
  sslListener.setPort(addr.getPort());
  sslListener.setKeystore(keystore);
  sslListener.setPassword(storPass);
  sslListener.setKeyPassword(keyPass);
  webServer.addConnector(sslListener);
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:23,代码来源:HttpServer.java

示例15: createJettyServer

import org.mortbay.jetty.security.SslSocketConnector; //导入方法依赖的package包/类
private Server createJettyServer() {
  try {
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket(0, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnector();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType(keyStoreType);
      c.setKeyPassword(keyStorePassword);
      server.setConnectors(new Connector[] {c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not stop embedded servlet container, " + ex.getMessage(), ex);
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:27,代码来源:TestJettyHelper.java


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