本文整理汇总了Java中org.eclipse.jetty.util.ssl.SslContextFactory.setCertAlias方法的典型用法代码示例。如果您正苦于以下问题:Java SslContextFactory.setCertAlias方法的具体用法?Java SslContextFactory.setCertAlias怎么用?Java SslContextFactory.setCertAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.util.ssl.SslContextFactory
的用法示例。
在下文中一共展示了SslContextFactory.setCertAlias方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureSsl
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
/**
* Configure the SSL connection.
* @param factory the Jetty {@link SslContextFactory}.
* @param ssl the ssl details.
*/
protected void configureSsl(SslContextFactory factory, Ssl ssl) {
factory.setProtocol(ssl.getProtocol());
configureSslClientAuth(factory, ssl);
configureSslPasswords(factory, ssl);
factory.setCertAlias(ssl.getKeyAlias());
if (ssl.getCiphers() != null) {
factory.setIncludeCipherSuites(ssl.getCiphers());
}
if (ssl.getEnabledProtocols() != null) {
factory.setIncludeProtocols(ssl.getEnabledProtocols());
}
if (getSslStoreProvider() != null) {
try {
factory.setKeyStore(getSslStoreProvider().getKeyStore());
factory.setTrustStore(getSslStoreProvider().getTrustStore());
}
catch (Exception ex) {
throw new IllegalStateException("Unable to set SSL store", ex);
}
}
else {
configureSslKeyStore(factory, ssl);
configureSslTrustStore(factory, ssl);
}
}
示例2: configureSsl
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
/**
* Configure the SSL connection.
*
* @param factory the Jetty {@link SslContextFactory}.
* @param ssl the ssl details.
*/
protected void configureSsl(SslContextFactory factory, Ssl ssl) {
factory.setProtocol(ssl.getProtocol());
configureSslClientAuth(factory, ssl);
configureSslPasswords(factory, ssl);
factory.setCertAlias(ssl.getKeyAlias());
if (!ObjectUtils.isEmpty(ssl.getCiphers())) {
factory.setIncludeCipherSuites(ssl.getCiphers());
factory.setExcludeCipherSuites();
}
if (ssl.getEnabledProtocols() != null) {
factory.setIncludeProtocols(ssl.getEnabledProtocols());
}
if (getSslStoreProvider() != null) {
try {
factory.setKeyStore(getSslStoreProvider().getKeyStore());
factory.setTrustStore(getSslStoreProvider().getTrustStore());
} catch (Exception ex) {
throw new IllegalStateException("Unable to set SSL store", ex);
}
} else {
configureSslKeyStore(factory, ssl);
configureSslTrustStore(factory, ssl);
}
}
示例3: configureSsl
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
/**
* Configure the SSL connection.
* @param factory the Jetty {@link SslContextFactory}.
* @param ssl the ssl details.
*/
protected void configureSsl(SslContextFactory factory, Ssl ssl) {
factory.setProtocol(ssl.getProtocol());
configureSslClientAuth(factory, ssl);
configureSslPasswords(factory, ssl);
factory.setCertAlias(ssl.getKeyAlias());
if (!ObjectUtils.isEmpty(ssl.getCiphers())) {
factory.setIncludeCipherSuites(ssl.getCiphers());
factory.setExcludeCipherSuites();
}
if (ssl.getEnabledProtocols() != null) {
factory.setIncludeProtocols(ssl.getEnabledProtocols());
}
if (getSslStoreProvider() != null) {
try {
factory.setKeyStore(getSslStoreProvider().getKeyStore());
factory.setTrustStore(getSslStoreProvider().getTrustStore());
}
catch (Exception ex) {
throw new IllegalStateException("Unable to set SSL store", ex);
}
}
else {
configureSslKeyStore(factory, ssl);
configureSslTrustStore(factory, ssl);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:32,代码来源:JettyEmbeddedServletContainerFactory.java
示例4: 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);
}
示例5: run
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
public static Server run(ResourceConfig application, Properties properties, int port, String originFilter,
String aliasName, File keystoreFile, String password, String frontendRoot, String apiPathPattern, boolean copyWebDir) {
try {
QueuedThreadPool threadPool = new QueuedThreadPool(
Integer.valueOf(properties.getProperty("jetty.maxThreads")),
Integer.valueOf(properties.getProperty("jetty.minThreads")),
Integer.valueOf(properties.getProperty("jetty.idleTimeout")),
new ArrayBlockingQueue<>(Integer.valueOf(properties.getProperty("jetty.maxQueueSize"))));
Server server = new Server(threadPool);
HttpConfiguration config = new HttpConfiguration();
if (keystoreFile != null) {
log.info("Jetty runner {}. SSL enabled.", application.getClass());
SslContextFactory sslFactory = new SslContextFactory();
sslFactory.setCertAlias(aliasName);
String path = keystoreFile.getAbsolutePath();
if (!keystoreFile.exists()) {
log.error("Couldn't load keystore file: {}", path);
return null;
}
sslFactory.setKeyStorePath(path);
sslFactory.setKeyStorePassword(password);
sslFactory.setKeyManagerPassword(password);
sslFactory.setTrustStorePath(path);
sslFactory.setTrustStorePassword(password);
config.setSecureScheme("https");
config.setSecurePort(port);
config.addCustomizer(new SecureRequestCustomizer());
ServerConnector https = new ServerConnector(server,
new SslConnectionFactory(sslFactory, "http/1.1"),
new HttpConnectionFactory(config));
https.setPort(port);
server.setConnectors(new Connector[]{https});
} else {
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(config));
http.setPort(port);
server.setConnectors(new Connector[]{http});
}
Handler handler = ContainerFactory.createContainer(JettyHttpContainer.class, application);
if (originFilter != null)
handler = new CrossDomainFilter(handler, originFilter);
if (frontendRoot != null) {
WebAppContext htmlHandler = new WebAppContext();
htmlHandler.setResourceBase(frontendRoot);
htmlHandler.setCopyWebDir(copyWebDir);
Map<Pattern, Handler> pathToHandler = new HashMap<>();
pathToHandler.put(Pattern.compile(apiPathPattern), handler);
SessionManager sm = new HashSessionManager();
SessionHandler sh = new SessionHandler(sm);
htmlHandler.setSessionHandler(sh);
DefaultServlet defaultServlet = new DefaultServlet();
ServletHolder holder = new ServletHolder(defaultServlet);
holder.setInitParameter("useFileMappedBuffer", Boolean.toString(!copyWebDir));
holder.setInitParameter("cacheControl", "no-store,no-cache,must-revalidate,max-age=-1,public");
htmlHandler.addServlet(holder, "/");
handler = new RequestsRouter(htmlHandler, pathToHandler, frontendRoot);
}
server.setHandler(handler);
server.start();
while (!server.isStarted()) {
Thread.sleep(50);
}
log.info("Jetty server started {} on port {}", application.getClass(), port);
return server;
} catch (Exception e) {
log.error(String.format("Jetty start failed %s.", application.getClass()), e);
return null;
}
}
示例6: getSslContainer
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
@Override
public WebSocketContainer getSslContainer(Properties config) {
// With jetty, can't directly use ContainerProvider.getWebSocketContainer()
// as it's "too late" to inject SslContextFactory into the mix.
String trustStore = config.getProperty("ws.trustStore",
System.getProperty("javax.net.ssl.trustStore"));
String trustStorePassword = config.getProperty("ws.trustStorePassword",
System.getProperty("javax.net.ssl.trustStorePassword"));
String keyStore = config.getProperty("ws.keyStore",
System.getProperty("javax.net.ssl.keyStore"));
String keyStorePassword = config.getProperty("ws.keyStorePassword",
System.getProperty("javax.net.ssl.keyStorePassword"));
String keyPassword = config.getProperty("ws.keyPassword", keyStorePassword);
String certAlias = config.getProperty("ws.keyCertificateAlias", "default");
// create ClientContainer as usual
ClientContainer container = new ClientContainer();
// tweak before starting it
SslContextFactory scf = container.getClient().getSslContextFactory();
if (trustStore != null) {
// System.out.println("setting " + trustStore);
scf.setTrustStorePath(trustStore);
scf.setTrustStorePassword(trustStorePassword);
}
if (keyStore != null) {
// System.out.println("setting " + keyStore);
scf.setKeyStorePath(keyStore);
scf.setKeyStorePassword(keyStorePassword);
scf.setKeyManagerPassword(keyPassword);
scf.setCertAlias(certAlias);
}
// start as usual
try {
container.start();
return container;
}
catch (Exception e)
{
throw new RuntimeException("Unable to start Client Container", e);
}
}