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


Java SslContextFactory.setKeyStorePassword方法代码示例

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


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

示例1: customize

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
@Override
public void customize(Server server) {
    // HTTPS Configuration
    HttpConfiguration httpsConfig = new HttpConfiguration();
    httpsConfig.setSecureScheme("https");
    httpsConfig.setSecurePort(8443);
    httpsConfig.addCustomizer(new SecureRequestCustomizer());

    // SSL Context Factory for HTTPS and HTTP/2
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStoreResource(newClassPathResource("keystore"));
    sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
    sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
    sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);

    // SSL Connection Factory
    SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, "h2");

    // HTTP/2 Connector
    ServerConnector http2Connector = new ServerConnector(server, ssl, new HTTP2ServerConnectionFactory(httpsConfig));
    http2Connector.setPort(8443);
    server.addConnector(http2Connector);
}
 
开发者ID:thinline72,项目名称:rpc-example,代码行数:24,代码来源:JettyHttp2ServerConfig.java

示例2: createConnector

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
/**
 * Creates a server connector.
 *
 * If an HTTPS key store is configured, returns a SSL connector for HTTPS.
 *
 * Otherwise, returns a normal HTTP connector by default.
 *
 * @param server The server.
 * @return The server connector.
 */
@SuppressWarnings("squid:S2095")
private ServerConnector createConnector(final Server server) {
    final String keyStorePath = (String) configuration.get(MinijaxProperties.SSL_KEY_STORE_PATH);

    if (keyStorePath == null || keyStorePath.isEmpty()) {
        // Normal HTTP
        return new ServerConnector(server);
    }

    final String keyStorePassword = (String) configuration.get(MinijaxProperties.SSL_KEY_STORE_PASSWORD);
    final String keyManagerPassword = (String) configuration.get(MinijaxProperties.SSL_KEY_MANAGER_PASSWORD);

    final HttpConfiguration https = new HttpConfiguration();
    https.addCustomizer(new SecureRequestCustomizer());

    final SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(Minijax.class.getClassLoader().getResource(keyStorePath).toExternalForm());
    sslContextFactory.setKeyStorePassword(keyStorePassword);
    sslContextFactory.setKeyManagerPassword(keyManagerPassword);

    return new ServerConnector(server,
            new SslConnectionFactory(sslContextFactory, "http/1.1"),
            new HttpConnectionFactory(https));
}
 
开发者ID:minijax,项目名称:minijax,代码行数:35,代码来源:Minijax.java

示例3: setupSSL

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private void setupSSL(Server server,HttpConfiguration http_config) {
	SslContextFactory sslContextFactory = new SslContextFactory();
	
	if (sslKeyStoreFile!=null)
		sslContextFactory.setKeyStorePath(sslKeyStoreFile);
	else if (sslKeyStore!=null)
		sslContextFactory.setKeyStore(sslKeyStore);
	else {
		log.log(Level.SEVERE,"Error while configuring SSL connection. Missing KeyStore!");
		return;
	}
	sslContextFactory.setKeyStorePassword(new String(sslKeyStorePassword));
	sslContextFactory.setExcludeCipherSuites("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");
	HttpConfiguration https_config = new HttpConfiguration(http_config);
	https_config.addCustomizer(new SecureRequestCustomizer());
	ServerConnector sslConnector = new ServerConnector(server,
		new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
		new HttpConnectionFactory(https_config));
	sslConnector.setPort(daemonPortSecure);
	server.addConnector(sslConnector);
}
 
开发者ID:gustavohbf,项目名称:robotoy,代码行数:27,代码来源:WebServer.java

示例4: addHttpsConnector

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
public static void addHttpsConnector(Server server, int port) throws IOException, URISyntaxException {

        String keyStoreFile = resourceAsFile("ssltest-keystore.jks").getAbsolutePath();
        SslContextFactory sslContextFactory = new SslContextFactory(keyStoreFile);
        sslContextFactory.setKeyStorePassword("changeit");

        String trustStoreFile = resourceAsFile("ssltest-cacerts.jks").getAbsolutePath();
        sslContextFactory.setTrustStorePath(trustStoreFile);
        sslContextFactory.setTrustStorePassword("changeit");

        HttpConfiguration httpsConfig = new HttpConfiguration();
        httpsConfig.setSecureScheme("https");
        httpsConfig.setSecurePort(port);
        httpsConfig.addCustomizer(new SecureRequestCustomizer());

        ServerConnector connector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(httpsConfig));
        connector.setPort(port);

        server.addConnector(connector);
    }
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:21,代码来源:TestUtils.java

示例5: getSSLConnectionFactory

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private SslConnectionFactory getSSLConnectionFactory() {
    Resource keyStoreResource = null;
    try {
        keyStoreResource = Resource.newClassPathResource("localhost");
        System.out.println(keyStoreResource);
    } catch (Exception ex) {
        Logger.getLogger(EventServer.class.getName()).log(Level.SEVERE, null, ex);
    }

    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStoreResource(keyStoreResource);
    sslContextFactory.setKeyStorePassword(keyStorePassword);
    sslContextFactory.setKeyManagerPassword(keyManagerPassword);
    return new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString());
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:16,代码来源:EventServer.java

示例6: configureSslPasswords

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private void configureSslPasswords(SslContextFactory factory, Ssl ssl) {
    if (ssl.getKeyStorePassword() != null) {
        factory.setKeyStorePassword(ssl.getKeyStorePassword());
    }

    if (ssl.getKeyPassword() != null) {
        factory.setKeyManagerPassword(ssl.getKeyPassword());
    }
}
 
开发者ID:gdrouet,项目名称:nightclazz-spring5,代码行数:10,代码来源:CustomJettyReactiveWebServerFactory.java

示例7: setupConnectors

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private void setupConnectors() {
	Configuration conf = Configuration.getInstance();

	HttpConfiguration http = new HttpConfiguration();
	http.addCustomizer(new SecureRequestCustomizer());
	http.setSecureScheme("https");

	ServerConnector connector = new ServerConnector(server);
	connector.addConnectionFactory(new HttpConnectionFactory(http));
	connector.setPort(port);
	
	if(conf.getPropertyAsBoolean("ui.ssl.enabled", false)) {
		int httpsPort = conf.getPropertyAsInteger("ui.ssl.port", 443);
		
		http.setSecurePort(httpsPort);

		HttpConfiguration https = new HttpConfiguration();
		https.addCustomizer(new SecureRequestCustomizer());
		
		SslContextFactory sslContextFactory = new SslContextFactory();
		sslContextFactory.setKeyStorePath(conf.getProperty("ui.ssl.keystore.path"));
		sslContextFactory.setKeyStorePassword(conf.getProperty("ui.ssl.keystore.password"));
		sslContextFactory.setKeyManagerPassword(conf.getProperty("ui.ssl.keymanager.password"));
		
		ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(https));
		sslConnector.setPort(httpsPort);
		server.addConnector(sslConnector);
	}

	server.addConnector(connector);
}
 
开发者ID:denkbar,项目名称:step,代码行数:32,代码来源:ControllerServer.java

示例8: setUp

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    PullHttpChangeIngestorCommonTest.init();

    SslContextFactory ssl = new SslContextFactory();

    ssl.setKeyStorePath("./src/test/resources/localhost-ks.jks");
    ssl.setKeyStorePassword("localtest");
    ssl.setKeyStoreType("JKS");
    ssl.setTrustStorePath("./src/test/resources/localhost-ts.jks");
    ssl.setTrustStorePassword("localtest");
    ssl.setTrustStoreType("JKS");
    ssl.setNeedClientAuth(true);

    // build the connector
    final ServerConnector https = new ServerConnector(jetty, ssl);

    // set host and port
    https.setPort(0);
    https.setHost("localhost");

    // Severely taxed environments may have significant delays when executing.
    https.setIdleTimeout(30000L);

    // add the connector
    jetty.addConnector(https);

    jetty.start();

    Thread.sleep(1000);

    if (!jetty.isStarted()) {
        throw new IllegalStateException("Jetty server not started");
    }
}
 
开发者ID:apache,项目名称:nifi-minifi,代码行数:36,代码来源:PullHttpChangeIngestorSSLTest.java

示例9: prepareSsl

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private SslConnectionFactory prepareSsl(ALPNServerConnectionFactory alpn) {
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(
            Application.class.getResource("/keystore").toExternalForm());
    sslContextFactory.setKeyStorePassword("changeit");
    sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
    sslContextFactory.setUseCipherSuitesOrder(true);
    SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory,
            alpn.getProtocol());
    return ssl;
}
 
开发者ID:AndreasKl,项目名称:embedded-jetty-http2,代码行数:12,代码来源:Application.java

示例10: main

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
/**
 * Main entry point. Starts a Jetty server.
 *
 * @param args
 *            ignored.
 * @throws Exception
 *             if anything goes wrong.
 */
public static void main(final String[] args) throws Exception {
    // Configure logging to output to the console with default level of INFO
    BasicConfigurator.configure();

    Config.loadProperties();

    // Configure server and its associated servlets
    Server server = new Server();
    SslConnectionFactory sslConnectionFactory = new SslConnectionFactory();
    SslContextFactory sslContextFactory = sslConnectionFactory.getSslContextFactory();
    sslContextFactory.setKeyStorePath(System.getProperty("javax.net.ssl.keyStore"));
    sslContextFactory.setKeyStorePassword(System.getProperty("javax.net.ssl.keyStorePassword"));
    sslContextFactory.setIncludeCipherSuites(Sdk.SUPPORTED_CIPHER_SUITES);

    HttpConfiguration httpConf = new HttpConfiguration();
    httpConf.setSecurePort(PORT);
    httpConf.setSecureScheme(HTTPS_SCHEME);
    httpConf.addCustomizer(new SecureRequestCustomizer());
    HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(httpConf);

    ServerConnector serverConnector =
            new ServerConnector(server, sslConnectionFactory, httpConnectionFactory);
    serverConnector.setPort(PORT);

    Connector[] connectors = new Connector[1];
    connectors[0] = serverConnector;
    server.setConnectors(connectors);

    SkySpeechlet sky = new SkySpeechlet();
    discoverSkyBox(sky);

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    server.setHandler(context);
    context.addServlet(new ServletHolder(createServlet(sky)), "/sky");
    server.start();
    server.join();
}
 
开发者ID:bellissimo,项目名称:AlexaSky,代码行数:47,代码来源:Launcher.java

示例11: configureSslContextFactory

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
protected void configureSslContextFactory(SslContextFactory sslContextFactory) {
    sslContextFactory.setKeyManagerPassword(pwd);
    sslContextFactory.setKeyStorePassword(pwd);
    URL keyStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
    try {
        sslContextFactory.setKeyStorePath(keyStoreUrl.toURI().getPath());
    } catch (URISyntaxException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    sslContextFactory.setTrustStoreType("JKS");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:HttpsAsyncRouteTest.java

示例12: configureSslPasswords

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private void configureSslPasswords(SslContextFactory factory, Ssl ssl) {
	if (ssl.getKeyStorePassword() != null) {
		factory.setKeyStorePassword(ssl.getKeyStorePassword());
	}
	if (ssl.getKeyPassword() != null) {
		factory.setKeyManagerPassword(ssl.getKeyPassword());
	}
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:9,代码来源:JettyEmbeddedServletContainerFactory.java

示例13: createServer

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private Server createServer(URI endpointURI, boolean needClientAuth) {
    if ("ws".equals(endpointURI.getScheme())) {
        return new Server(endpointURI.getPort());
    }
    else if ("wss".equals(endpointURI.getScheme())) {
        // see http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyConnectors.java
        //     http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java
        
        Server server = new Server();
        
        SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setKeyStorePath(getStorePath("serverKeyStore.jks"));
        sslContextFactory.setKeyStorePassword("passw0rd");
        sslContextFactory.setKeyManagerPassword("passw0rd");
        sslContextFactory.setCertAlias("default");
        sslContextFactory.setNeedClientAuth(needClientAuth);
        sslContextFactory.setTrustStorePath(getStorePath("serverTrustStore.jks"));
        sslContextFactory.setTrustStorePassword("passw0rd");
        
        HttpConfiguration httpsConfig = new HttpConfiguration();
        httpsConfig.addCustomizer(new SecureRequestCustomizer());
        
        ServerConnector https= new ServerConnector(server,
                new SslConnectionFactory(sslContextFactory,
                        HttpVersion.HTTP_1_1.asString()),
                new HttpConnectionFactory(httpsConfig));
        https.setPort(endpointURI.getPort());
        
        server.addConnector(https);
        return server;
    }
    else
        throw new IllegalArgumentException("unrecognized uri: "+endpointURI);
}
 
开发者ID:quarks-edge,项目名称:quarks,代码行数:35,代码来源:WebSocketServerEcho.java

示例14: NetworkAssistantHttpsEngine

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
public NetworkAssistantHttpsEngine(int port) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
	this.port = port;

	this.server = new Server();
	this.server.setSendServerVersion(false);

	SslContextFactory contextFactory = new SslContextFactory(true);

	// this looks like fun, doesn't it?!?
	// contextFactory.setKeyStorePath() would be easier, but it can't handle
	// paths from within the jar..
	// ..and contextFactory.setKeyStoreInputStream() is deprecated
	final String keyStorePath = "/mpo/dayon/common/security/X509";
	final String keyStorePass = "spasspass";
	KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
	keyStore.load(NetworkAssistantHttpsEngine.class.getResourceAsStream(keyStorePath), keyStorePass.toCharArray());

	contextFactory.setKeyStore(keyStore);
	contextFactory.setKeyStorePassword(keyStorePass);
	this.acceptor = new MySocketConnector(contextFactory);

	this.server.setConnectors(new Connector[] { this.acceptor });

	final HandlerList httpHandlers = new HandlerList();
	{
		final File jnlp = SystemUtilities.getOrCreateAppDirectory("jnlp");
		if (jnlp == null) {
			throw new RuntimeException("No JNLP directory!");
		}

		httpHandlers.addHandler(handler = new MyHttpHandler(jnlp.getAbsolutePath()));
	}

	this.server.setHandler(httpHandlers);
}
 
开发者ID:RetGal,项目名称:Dayon,代码行数:36,代码来源:NetworkAssistantHttpsEngine.java

示例15: configureServerForHttp2

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
/**
 * Configure the http2 server.
 *
 * @param server the server
 * @return the server
 */
@VisibleForTesting
Server configureServerForHttp2(Server server) {
  // HTTP Configuration
  HttpConfiguration http11Config = new HttpConfiguration();
  http11Config.setSecureScheme("https");
  http11Config.setSecurePort(httpsPort);

  // SSL Context Factory for HTTPS and HTTP/2
  SslContextFactory sslContextFactory = new SslContextFactory();
  sslContextFactory.setKeyStoreResource(newClassPathResource("sample.jks"));
  sslContextFactory.setKeyStorePassword("secret");
  sslContextFactory.setKeyManagerPassword("secret");
  sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
  sslContextFactory.setUseCipherSuitesOrder(true);

  // HTTPS Configuration
  HttpConfiguration httpsConfig = new HttpConfiguration(http11Config);
  httpsConfig.addCustomizer(new SecureRequestCustomizer());

  // HTTP/2 Connection Factory
  HTTP2ServerConnectionFactory h2 = new HTTP2ServerConnectionFactory(httpsConfig);

  NegotiatingServerConnectionFactory.checkProtocolNegotiationAvailable();
  ALPNServerConnectionFactory alpnServerConnectionFactory = new ALPNServerConnectionFactory();
  alpnServerConnectionFactory.setDefaultProtocol("h2");
  alpnServerConnectionFactory.getALPNProcessor();

  // SSL Connection Factory
  SslConnectionFactory sslConnectionFactory =
      new SslConnectionFactory(sslContextFactory,
          alpnServerConnectionFactory.getProtocol());

  // HTTP/2 Connector
  ServerConnector http2Connector =
      new ServerConnector(server, sslConnectionFactory, alpnServerConnectionFactory, h2,
          new HttpConnectionFactory(httpsConfig));
  http2Connector.setPort(httpPort);
  server.addConnector(http2Connector);

  return server;
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:48,代码来源:ApplicationConfig.java


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