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


Java SslContextFactory.setTrustStoreResource方法代码示例

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


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

示例1: configureSslTrustStore

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private void configureSslTrustStore(SslContextFactory factory, Ssl ssl) {
	if (ssl.getTrustStorePassword() != null) {
		factory.setTrustStorePassword(ssl.getTrustStorePassword());
	}
	if (ssl.getTrustStore() != null) {
		try {
			URL url = ResourceUtils.getURL(ssl.getTrustStore());
			factory.setTrustStoreResource(Resource.newResource(url));
		}
		catch (IOException ex) {
			throw new EmbeddedServletContainerException(
					"Could not find trust store '" + ssl.getTrustStore() + "'", ex);
		}
	}
	if (ssl.getTrustStoreType() != null) {
		factory.setTrustStoreType(ssl.getTrustStoreType());
	}
	if (ssl.getTrustStoreProvider() != null) {
		factory.setTrustStoreProvider(ssl.getTrustStoreProvider());
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:JettyEmbeddedServletContainerFactory.java

示例2: configureSslTrustStore

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

    if (ssl.getTrustStore() != null) {
        try {
            URL url = ResourceUtils.getURL(ssl.getTrustStore());
            factory.setTrustStoreResource(Resource.newResource(url));
        } catch (IOException ex) {
            throw new WebServerException(
                    "Could not find trust store '" + ssl.getTrustStore() + "'", ex);
        }
    }

    if (ssl.getTrustStoreType() != null) {
        factory.setTrustStoreType(ssl.getTrustStoreType());
    }

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

示例3: main

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的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

示例4: main

import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的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


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