本文整理汇总了Java中io.vertx.core.net.JksOptions类的典型用法代码示例。如果您正苦于以下问题:Java JksOptions类的具体用法?Java JksOptions怎么用?Java JksOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JksOptions类属于io.vertx.core.net包,在下文中一共展示了JksOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepare
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
@Before
public void prepare(TestContext context) {
vertx = Vertx.vertx();
JsonObject dbConf = new JsonObject()
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_URL, "jdbc:hsqldb:mem:testdb;shutdown=true")
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_MAX_POOL_SIZE, 4);
vertx.deployVerticle(new WikiDatabaseVerticle(),
new DeploymentOptions().setConfig(dbConf), context.asyncAssertSuccess());
vertx.deployVerticle(new HttpServerVerticle(), context.asyncAssertSuccess());
webClient = WebClient.create(vertx, new WebClientOptions()
.setDefaultHost("localhost")
.setDefaultPort(8080)
.setSsl(true)
.setTrustOptions(new JksOptions().setPath("server-keystore.jks").setPassword("secret")));
}
示例2: prepare
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
@Before
public void prepare(TestContext context) {
vertx = Vertx.vertx();
JsonObject dbConf = new JsonObject()
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_URL, "jdbc:hsqldb:mem:testdb;shutdown=true")
.put(WikiDatabaseVerticle.CONFIG_WIKIDB_JDBC_MAX_POOL_SIZE, 4);
vertx.deployVerticle(new WikiDatabaseVerticle(),
new DeploymentOptions().setConfig(dbConf), context.asyncAssertSuccess());
vertx.deployVerticle(new HttpServerVerticle(), context.asyncAssertSuccess());
// tag::test-https[]
webClient = WebClient.create(vertx, new WebClientOptions()
.setDefaultHost("localhost")
.setDefaultPort(8080)
.setSsl(true) // <1>
.setTrustOptions(new JksOptions().setPath("server-keystore.jks").setPassword("secret"))); // <2>
// end::test-https[]
}
示例3: testDifferentCharset
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
@Test
public void testDifferentCharset(TestContext context) throws Exception {
termHandler = term -> {
term.write("\u20AC");
term.close();
};
startShell(new SSHTermOptions().setDefaultCharset("ISO_8859_1").setPort(5000).setHost("localhost").setKeyPairOptions(
new JksOptions().setPath("src/test/resources/server-keystore.jks").setPassword("wibble")).
setAuthOptions(new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(
new JsonObject().put("properties_path", "classpath:test-auth.properties"))));
Session session = createSession("paulo", "secret", false);
session.connect();
Channel channel = session.openChannel("shell");
channel.connect();
InputStream in = channel.getInputStream();
int b = in.read();
context.assertEquals(63, b);
}
示例4: configSSL
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
private HttpServerOptions configSSL(JsonObject conf) {
String ssl_keystore= conf.getString("ssl.keystore");
String keystore_pass = conf.getString("ssl.keystore.pass");
String ssl_client_keystore= conf.getString("ssl.client.keystore");
String client_keystore_pass = conf.getString("ssl.client.keystore.pass");
HttpServerOptions options = new HttpServerOptions();
options.setCompressionSupported(true);
if(S.isNotBlank(ssl_keystore) && S.isNotBlank(keystore_pass)){
options.setSsl(true).setKeyStoreOptions(
new JksOptions().setPath(ssl_keystore).setPassword(keystore_pass));
if(S.isNotBlank(ssl_client_keystore) && S.isNotBlank(client_keystore_pass))
options.setClientAuth(ClientAuth.REQUIRED).setTrustStoreOptions(
new JksOptions().setPath(ssl_client_keystore).setPassword(client_keystore_pass));
}
return options;
}
示例5: clientSslClientTruststoreTest
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
@Test
public void clientSslClientTruststoreTest(TestContext context) {
this.context = context;
URL trustStore = this.getClass().getResource("/tls/client-truststore.jks");
JksOptions jksOptions = new JksOptions().setPath(trustStore.getPath());
MqttClientOptions clientOptions = new MqttClientOptions()
.setSsl(true)
.setTrustStoreOptions(jksOptions);
MqttClient client = MqttClient.create(vertx, clientOptions);
client.exceptionHandler(t -> context.assertTrue(false));
Async async = context.async();
client.connect(MQTT_SERVER_TLS_PORT, MQTT_SERVER_HOST, s -> client.disconnect(d -> async.countDown()));
async.await();
}
示例6: testLoginByCert_usingPemConfig
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
/**
* Tests authentication with the cert auth backend using PEM file
*/
@Test
public void testLoginByCert_usingPemConfig(TestContext tc) throws VaultException {
JsonObject config = new JsonObject();
config.put("host", process.getHost());
config.put("port", process.getPort());
config.put("ssl", true);
PemKeyCertOptions options = new PemKeyCertOptions()
.addCertPath("target/vault/config/ssl/client-cert.pem")
.addKeyPath("target/vault/config/ssl/client-privatekey.pem");
config.put("pemKeyCertOptions", options.toJson());
PemTrustOptions trust = new PemTrustOptions()
.addCertPath("target/vault/config/ssl/cert.pem");
config.put("pemTrustStoreOptions", trust.toJson());
JksOptions jks = new JksOptions()
.setPath("target/vault/config/ssl/truststore.jks");
config.put("trustStoreOptions", jks.toJson());
client = new SlimVaultClient(vertx, config);
checkWeCanLoginAndAccessRestrictedSecrets(tc);
}
示例7: testLoginByCert_usingJKSConfig
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
/**
* Tests authentication with the cert auth backend using PEM file
*/
@Test
public void testLoginByCert_usingJKSConfig(TestContext tc) throws VaultException {
JsonObject config = new JsonObject();
config.put("host", process.getHost());
config.put("port", process.getPort());
config.put("ssl", true);
JksOptions options = new JksOptions();
options.setPassword("password").setPath("target/vault/config/ssl/keystore.jks");
config.put("keyStoreOptions", options.toJson());
JksOptions jks = new JksOptions()
.setPassword("password")
.setPath("target/vault/config/ssl/truststore.jks");
config.put("trustStoreOptions", jks.toJson());
client = new SlimVaultClient(vertx, config);
checkWeCanLoginAndAccessRestrictedSecrets(tc);
}
示例8: getRetrieverConfiguration
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
@Override
protected JsonObject getRetrieverConfiguration() {
JsonObject config = new JsonObject();
config.put("host", process.getHost());
config.put("port", process.getPort());
config.put("ssl", true);
PemKeyCertOptions options = new PemKeyCertOptions()
.addCertPath("target/vault/config/ssl/client-cert.pem")
.addKeyPath("target/vault/config/ssl/client-privatekey.pem");
config.put("pemKeyCertOptions", options.toJson());
PemTrustOptions trust = new PemTrustOptions()
.addCertPath("target/vault/config/ssl/cert.pem");
config.put("pemTrustStoreOptions", trust.toJson());
JksOptions jks = new JksOptions()
.setPath("target/vault/config/ssl/truststore.jks");
config.put("trustStoreOptions", jks.toJson());
config.put("auth-backend", "cert");
return config;
}
示例9: VertxHttpServer
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
public VertxHttpServer(MapWrap config) {
port = config.asInt("port", DEFAULT_PORT);
observableListenersByTag = new HashMap<>();
// Setup vertx
vertx = Vertx.vertx();
vertx.deployVerticle(this);
if (config.exists("keyStorePath") ) {
httpServer = vertx.createHttpServer(new HttpServerOptions().setSsl(true)
.setKeyStoreOptions(
new JksOptions().
setPath(config.asString("keyStorePath")).
setPassword(config.asString("keyStorePassword"))
));
} else {
httpServer = vertx.createHttpServer();
}
router = Router.router(vertx);
}
示例10: SMTPConnectionPool
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
SMTPConnectionPool(Vertx vertx, MailConfig config) {
this.config = config;
this.vertx = vertx;
maxSockets = config.getMaxPoolSize();
keepAlive = config.isKeepAlive();
NetClientOptions netClientOptions = new NetClientOptions().setSsl(config.isSsl()).setTrustAll(config.isTrustAll());
if ((config.isSsl() || config.getStarttls() != StartTLSOptions.DISABLED) && !config.isTrustAll()) {
// we can use HTTPS verification, which matches the requirements for SMTPS
netClientOptions.setHostnameVerificationAlgorithm("HTTPS");
}
if (config.getKeyStore() != null) {
// assume that password could be null if the keystore doesn't use one
netClientOptions.setTrustStoreOptions(new JksOptions().setPath(config.getKeyStore())
.setPassword(config.getKeyStorePassword()));
}
netClient = vertx.createNetClient(netClientOptions);
}
示例11: runSSHServiceWithShiro
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
public void runSSHServiceWithShiro(Vertx vertx) throws Exception {
ShellService service = ShellService.create(vertx,
new ShellServiceOptions().setSSHOptions(
new SSHTermOptions().
setHost("localhost").
setPort(5000).
setKeyPairOptions(new JksOptions().
setPath("server-keystore.jks").
setPassword("wibble")
).
setAuthOptions(new ShiroAuthOptions().
setType(ShiroAuthRealmType.PROPERTIES).
setConfig(new JsonObject().
put("properties_path", "file:/path/to/my/auth.properties"))
)
)
);
service.start();
}
示例12: runSSHServiceWithMongo
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
public void runSSHServiceWithMongo(Vertx vertx) throws Exception {
ShellService service = ShellService.create(vertx,
new ShellServiceOptions().setSSHOptions(
new SSHTermOptions().
setHost("localhost").
setPort(5000).
setKeyPairOptions(new JksOptions().
setPath("server-keystore.jks").
setPassword("wibble")
).
setAuthOptions(new MongoAuthOptions().setConfig(new JsonObject().
put("connection_string", "mongodb://localhost:27018"))
)
)
);
service.start();
}
示例13: runSSHServiceWithJDBC
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
public void runSSHServiceWithJDBC(Vertx vertx) throws Exception {
ShellService service = ShellService.create(vertx,
new ShellServiceOptions().setSSHOptions(
new SSHTermOptions().
setHost("localhost").
setPort(5000).
setKeyPairOptions(new JksOptions().
setPath("server-keystore.jks").
setPassword("wibble")
).
setAuthOptions(new JDBCAuthOptions().setConfig(new JsonObject()
.put("url", "jdbc:hsqldb:mem:test?shutdown=true")
.put("driver_class", "org.hsqldb.jdbcDriver"))
)
)
);
service.start();
}
示例14: testExternalAuthProviderFails
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
@Test
public void testExternalAuthProviderFails(TestContext context) throws Exception {
AtomicInteger count = new AtomicInteger();
authProvider = (authInfo, resultHandler) -> {
count.incrementAndGet();
resultHandler.handle(Future.failedFuture("not authenticated"));
};
termHandler = term -> {
context.fail();
};
startShell(new SSHTermOptions().setPort(5000).setHost("localhost").setKeyPairOptions(
new JksOptions().setPath("src/test/resources/server-keystore.jks").setPassword("wibble")));
Session session = createSession("paulo", "anothersecret", false);
try {
session.connect();
context.fail("Was not expected to login");
} catch (JSchException e) {
assertEquals("Auth cancel", e.getMessage());
}
context.assertEquals(1, count.get());
}
示例15: testKeymapFromFilesystem
import io.vertx.core.net.JksOptions; //导入依赖的package包/类
@Test
public void testKeymapFromFilesystem() throws Exception {
URL url = TermServer.class.getResource(SSHTermOptions.DEFAULT_INPUTRC);
File f = new File(url.toURI());
termHandler = Term::close;
startShell(new SSHTermOptions().setIntputrc(f.getAbsolutePath()).setPort(5000).setHost("localhost").setKeyPairOptions(
new JksOptions().setPath("src/test/resources/server-keystore.jks").setPassword("wibble")).
setAuthOptions(new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig(
new JsonObject().put("properties_path", "classpath:test-auth.properties"))));
Session session = createSession("paulo", "secret", false);
session.connect();
Channel channel = session.openChannel("shell");
channel.connect();
}