本文整理汇总了Java中io.vertx.core.http.ClientAuth类的典型用法代码示例。如果您正苦于以下问题:Java ClientAuth类的具体用法?Java ClientAuth怎么用?Java ClientAuth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientAuth类属于io.vertx.core.http包,在下文中一共展示了ClientAuth类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testbuildHttpServerOptionsRequest
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
@Test
public void testbuildHttpServerOptionsRequest() {
SSLOption option = SSLOption.buildFromYaml("rest.provider");
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
HttpServerOptions serverOptions = new HttpServerOptions();
new MockUp<SSLOption>() {
@Mock
public boolean isAuthPeer() {
return false;
}
};
VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:TestVertxTLSBuilder.java
示例2: configSSL
import io.vertx.core.http.ClientAuth; //导入依赖的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;
}
开发者ID:troopson,项目名称:etagate,代码行数:21,代码来源:OutServerVerticle.java
示例3: setSsl
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
private void setSsl(HttpServerOptions httpServerOptions) {
ApiConfig.SslConfig sslConfig = config.getSsl();
if (!sslConfig.isEnable()) {
return;
}
httpServerOptions.setSsl(true);
PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions()
.setKeyValue(Buffer.buffer(sslConfig.getSslKey()))
.setCertValue(Buffer.buffer(sslConfig.getSslCert()));
httpServerOptions.setPemKeyCertOptions(pemKeyCertOptions);
PemTrustOptions pemTrustOptions = new PemTrustOptions();
Arrays.stream(sslConfig.getSslTrustCerts())
.map(Object::toString)
.forEach(trustKey -> pemTrustOptions.addCertValue(Buffer.buffer(trustKey)));
if (!pemTrustOptions.getCertValues().isEmpty()) {
httpServerOptions.setPemTrustOptions(pemTrustOptions);
ClientAuth clientAuth = sslConfig.isSslRequireClientAuth() ?
ClientAuth.REQUIRED : ClientAuth.REQUEST;
httpServerOptions.setClientAuth(clientAuth);
}
}
开发者ID:Deutsche-Boerse-Risk,项目名称:DAVe,代码行数:23,代码来源:ApiVerticle.java
示例4: TCPSyslogServer
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
public TCPSyslogServer(int port, String clientAuth,
String trustStorePath, String trustStorePassword,
String keyStorePath, String keyStorePassword,
Async async){
this.port = port;
this.async = async;
nsOptions = new NetServerOptions()
.setReuseAddress(true)
.setHost("localhost")
.setClientAuth(ClientAuth.valueOf(clientAuth))
.setTrustStoreOptions(trustStorePath != null? new JksOptions().
setPath(trustStorePath).
setPassword(trustStorePassword): null)
.setKeyStoreOptions(keyStorePath != null? new JksOptions().
setPath(keyStorePath).
setPassword(keyStorePassword): null)
.setSsl(true);
}
开发者ID:oehf,项目名称:ipf-oht-atna,代码行数:19,代码来源:TCPSyslogServer.java
示例5: buildNetServerOptions
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
public static NetServerOptions buildNetServerOptions(SSLOption sslOption, SSLCustom sslCustom,
NetServerOptions netServerOptions) {
buildTCPSSLOptions(sslOption, sslCustom, netServerOptions);
if (sslOption.isAuthPeer()) {
netServerOptions.setClientAuth(ClientAuth.REQUIRED);
} else {
netServerOptions.setClientAuth(ClientAuth.REQUEST);
}
return netServerOptions;
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:11,代码来源:VertxTLSBuilder.java
示例6: testbuildHttpServerOptions
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
@Test
public void testbuildHttpServerOptions() {
SSLOption option = SSLOption.buildFromYaml("rest.provider");
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
HttpServerOptions serverOptions = new HttpServerOptions();
VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:10,代码来源:TestVertxTLSBuilder.java
示例7: addTlsTrustOptions
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
/**
* Copies TLS trust store configuration to a given set of server options.
* <p>
* The trust store configuration is taken from <em>config</em> and will
* be added only if the <em>ssl</em> flag is set on the given server options.
*
* @param serverOptions The options to add configuration to.
*/
protected final void addTlsTrustOptions(final NetServerOptions serverOptions) {
if (serverOptions.isSsl() && serverOptions.getTrustOptions() == null) {
TrustOptions trustOptions = getConfig().getTrustOptions();
if (trustOptions != null) {
serverOptions.setTrustOptions(trustOptions).setClientAuth(ClientAuth.REQUEST);
LOG.info("enabling TLS for client authentication");
}
}
}
开发者ID:eclipse,项目名称:hono,代码行数:20,代码来源:AbstractServiceBase.java
示例8: createOptionsForTls
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
private static ProtonServerOptions createOptionsForTls(final String certDir) {
ProtonServerOptions options = new ProtonServerOptions();
PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions();
pemKeyCertOptions.setCertPath(certDir + File.separator + "tls.crt");
pemKeyCertOptions.setKeyPath(certDir + File.separator + "tls.key");
options.setPemKeyCertOptions(pemKeyCertOptions);
options.setClientAuth(ClientAuth.REQUIRED);
options.setSsl(true);
PemTrustOptions pemTrustOptions = new PemTrustOptions();
pemTrustOptions.addCertPath(certDir + File.separator + "ca.crt");
options.setPemTrustOptions(pemTrustOptions);
return options;
}
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:14,代码来源:Main.java
示例9: getObject
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
@Override
public HttpServer getObject() throws Exception {
HttpServerOptions options = new HttpServerOptions();
// Binding port
options.setPort(httpServerConfiguration.getPort());
options.setHost(httpServerConfiguration.getHost());
// Netty pool buffers must be enabled by default
options.setUsePooledBuffers(true);
if (httpServerConfiguration.isSecured()) {
options.setSsl(httpServerConfiguration.isSecured());
options.setUseAlpn(httpServerConfiguration.isAlpn());
if (httpServerConfiguration.isClientAuth()) {
options.setClientAuth(ClientAuth.REQUIRED);
}
if (httpServerConfiguration.getTrustStorePath() != null) {
options.setTrustStoreOptions(new JksOptions()
.setPath(httpServerConfiguration.getTrustStorePath())
.setPassword(httpServerConfiguration.getTrustStorePassword()));
}
if (httpServerConfiguration.getKeyStorePath() != null) {
options.setKeyStoreOptions(new JksOptions()
.setPath(httpServerConfiguration.getKeyStorePath())
.setPassword(httpServerConfiguration.getKeyStorePassword()));
}
}
// Customizable configuration
options.setCompressionSupported(httpServerConfiguration.isCompressionSupported());
options.setIdleTimeout(httpServerConfiguration.getIdleTimeout());
options.setTcpKeepAlive(httpServerConfiguration.isTcpKeepAlive());
return vertx.createHttpServer(options);
}
开发者ID:gravitee-io,项目名称:gravitee-gateway,代码行数:40,代码来源:VertxHttpServerFactory.java
示例10: doClientCertificateTestImpl
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
private void doClientCertificateTestImpl(TestContext context, boolean supplyClientCert) throws InterruptedException,
ExecutionException {
Async async = context.async();
// Create a server that accept a connection and expects a client connection+session+receiver
ProtonServerOptions serverOptions = new ProtonServerOptions();
serverOptions.setSsl(true);
serverOptions.setClientAuth(ClientAuth.REQUIRED);
PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
serverOptions.setPfxKeyCertOptions(serverPfxOptions);
PfxOptions pfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
serverOptions.setPfxTrustOptions(pfxOptions);
protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);
// Try to connect the client
ProtonClientOptions clientOptions = new ProtonClientOptions();
clientOptions.setSsl(true);
clientOptions.setPfxTrustOptions(pfxOptions);
if (supplyClientCert) {
PfxOptions clientKeyPfxOptions = new PfxOptions().setPath(KEYSTORE_CLIENT).setPassword(PASSWORD);
clientOptions.setPfxKeyCertOptions(clientKeyPfxOptions);
}
ProtonClient client = ProtonClient.create(vertx);
client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
if (supplyClientCert) {
// Expect connect to succeed
context.assertTrue(res.succeeded());
} else {
// Expect connect to fail
context.assertFalse(res.succeeded());
}
async.complete();
});
async.awaitSuccess();
}
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:41,代码来源:ProtonClientSslTest.java
示例11: start
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
@Override
public void start() throws Exception {
address = MQTTSession.ADDRESS;
JsonObject conf = config();
localBridgePort = conf.getInteger("local_bridge_port", 7007);
idleTimeout = conf.getInteger("socket_idle_timeout", 120);
ssl_cert_key = conf.getString("ssl_cert_key");
ssl_cert = conf.getString("ssl_cert");
ssl_trust = conf.getString("ssl_trust");
// [TCP -> BUS] listen TCP publish to BUS
NetServerOptions opt = new NetServerOptions()
.setTcpKeepAlive(true)
.setIdleTimeout(idleTimeout)
.setPort(localBridgePort)
;
if(ssl_cert_key != null && ssl_cert != null && ssl_trust != null) {
opt.setSsl(true).setClientAuth(ClientAuth.REQUIRED)
.setPemKeyCertOptions(new PemKeyCertOptions()
.setKeyPath(ssl_cert_key)
.setCertPath(ssl_cert)
)
.setPemTrustOptions(new PemTrustOptions()
.addCertPath(ssl_trust)
)
;
}
netServer = vertx.createNetServer(opt);
netServer.connectHandler(sock -> {
final EventBusNetBridge ebnb = new EventBusNetBridge(sock, vertx.eventBus(), address);
sock.closeHandler(aVoid -> {
logger.info("Bridge Server - closed connection from client ip: " + sock.remoteAddress());
ebnb.stop();
});
sock.exceptionHandler(throwable -> {
logger.error("Bridge Server - Exception: " + throwable.getMessage(), throwable);
ebnb.stop();
});
logger.info("Bridge Server - new connection from client ip: " + sock.remoteAddress());
RecordParser parser = ebnb.initialHandhakeProtocolParser();
sock.handler(parser::handle);
}).listen();
}
开发者ID:GruppoFilippetti,项目名称:vertx-mqtt-broker,代码行数:52,代码来源:EventBusBridgeServerVerticle.java
示例12: start
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
@Override
public void start() {
ProtonServerOptions options = new ProtonServerOptions();
if (certDir != null) {
options.setSsl(true)
.setClientAuth(ClientAuth.REQUIRED)
.setPemKeyCertOptions(new PemKeyCertOptions()
.setKeyPath(new File(certDir, "tls.key").getAbsolutePath())
.setCertPath(new File(certDir, "tls.crt").getAbsolutePath()))
.setPemTrustOptions(new PemTrustOptions()
.addCertPath(new File(certDir, "ca.crt").getAbsolutePath()));
}
server = ProtonServer.create(vertx, options);
server.saslAuthenticatorFactory(saslAuthenticatorFactory);
server.connectHandler(connection -> {
connection.setContainer("queue-scheduler");
connection.openHandler(result -> {
connection.open();
connectionOpened(connection);
}).closeHandler(conn -> {
log.info("Broker connection " + connection.getRemoteContainer() + " closed");
executeBlocking(() -> schedulerState.brokerRemoved(getGroupId(connection), connection.getRemoteContainer()),
"Error removing broker");
connection.close();
connection.disconnect();
}).disconnectHandler(protonConnection -> {
log.info("Broker connection " + connection.getRemoteContainer() + " disconnected");
executeBlocking(() -> schedulerState.brokerRemoved(getGroupId(connection), connection.getRemoteContainer()),
"Error removing broker");
connection.disconnect();
});
});
server.listen(port, event -> {
if (event.succeeded()) {
log.info("QueueScheduler is up and running");
} else {
log.error("Error starting queue scheduler", event.cause());
}
});
}
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:43,代码来源:QueueScheduler.java
示例13: setClientAuth
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
@Override
public HttpTermOptions setClientAuth(ClientAuth clientAuth) {
return (HttpTermOptions) super.setClientAuth(clientAuth);
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:5,代码来源:HttpTermOptions.java
示例14: doClientCertificateTestImpl
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
private void doClientCertificateTestImpl(TestContext context, boolean supplyClientCert) throws InterruptedException,
ExecutionException {
Async async = context.async();
ProtonServerOptions serverOptions = new ProtonServerOptions();
serverOptions.setSsl(true);
serverOptions.setClientAuth(ClientAuth.REQUIRED);
PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
serverOptions.setPfxKeyCertOptions(serverPfxOptions);
PfxOptions pfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
serverOptions.setPfxTrustOptions(pfxOptions);
mockServer = new MockServer(vertx, conn -> {
handleBridgeStartupProcess(conn, context);
}, serverOptions);
// Try to start the bridge
AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
bridgeOptions.setSsl(true);
bridgeOptions.setPfxTrustOptions(pfxOptions);
if (supplyClientCert) {
PfxOptions clientKeyPfxOptions = new PfxOptions().setPath(KEYSTORE_CLIENT).setPassword(PASSWORD);
bridgeOptions.setPfxKeyCertOptions(clientKeyPfxOptions);
}
AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
bridge.start("localhost", mockServer.actualPort(), res -> {
if (supplyClientCert) {
// Expect start to succeed
context.assertTrue(res.succeeded(), "expected start to suceed due to supplying client certs");
} else {
// Expect start to fail
context.assertFalse(res.succeeded(), "expected start to fail due to withholding client cert");
}
async.complete();
});
async.awaitSuccess();
}
开发者ID:vert-x3,项目名称:vertx-amqp-bridge,代码行数:42,代码来源:AmqpBridgeSslTest.java
示例15: setClientAuth
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
@Override
public ProtonServerOptions setClientAuth(ClientAuth clientAuth) {
super.setClientAuth(clientAuth);
return this;
}
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:6,代码来源:ProtonServerOptions.java
示例16: start
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
@Override
public void start() throws Exception {
address = MQTTSession.ADDRESS;
JsonObject conf = config();
localBridgePort = conf.getInteger("local_bridge_port", 7007);
idleTimeout = conf.getInteger("socket_idle_timeout", 120);
ssl_cert_key = conf.getString("ssl_cert_key");
ssl_cert = conf.getString("ssl_cert");
ssl_trust = conf.getString("ssl_trust");
// [WebSocket -> BUS] listen WebSocket publish to BUS
HttpServerOptions opt = new HttpServerOptions()
.setTcpKeepAlive(true)
.setIdleTimeout(idleTimeout)
.setPort(localBridgePort)
;
if(ssl_cert_key != null && ssl_cert != null && ssl_trust != null) {
opt.setSsl(true).setClientAuth(ClientAuth.REQUIRED)
.setPemKeyCertOptions(new PemKeyCertOptions()
.setKeyPath(ssl_cert_key)
.setCertPath(ssl_cert)
)
.setPemTrustOptions(new PemTrustOptions()
.addCertPath(ssl_trust)
)
;
}
netServer = vertx.createHttpServer(opt);
netServer.websocketHandler(sock -> {
final EventBusWebsocketBridge ebnb = new EventBusWebsocketBridge(sock, vertx.eventBus(), address);
sock.closeHandler(aVoid -> {
logger.info("Bridge Server - closed connection from client ip: " + sock.remoteAddress());
ebnb.stop();
});
sock.exceptionHandler(throwable -> {
logger.error("Bridge Server - Exception: " + throwable.getMessage(), throwable);
ebnb.stop();
});
logger.info("Bridge Server - new connection from client ip: " + sock.remoteAddress());
RecordParser parser = ebnb.initialHandhakeProtocolParser();
sock.handler(parser::handle);
}).listen();
}
开发者ID:GruppoFilippetti,项目名称:vertx-mqtt-broker,代码行数:52,代码来源:EventBusBridgeWebsocketServerVerticle.java
示例17: bind
import io.vertx.core.http.ClientAuth; //导入依赖的package包/类
private void bind(int p, Handler<AsyncResult<Void>> completion) {
// Get port number.
final int thePort = pickAPort(port);
HttpServerOptions options = new HttpServerOptions();
if (ssl) {
options.setSsl(true);
options.setTrustStoreOptions(SSLServerContext.getTrustStoreOption(accessor));
options.setKeyStoreOptions(SSLServerContext.getKeyStoreOption(accessor));
if (authentication) {
options.setClientAuth(ClientAuth.REQUIRED);
}
}
if (hasCompressionEnabled()) {
options.setCompressionSupported(true);
}
if (configuration.getIntegerWithDefault("vertx.acceptBacklog", -1) != -1) {
options.setAcceptBacklog(configuration.getInteger("vertx.acceptBacklog"));
}
if (configuration.getIntegerWithDefault("vertx.maxWebSocketFrameSize", -1) != -1) {
options.setMaxWebsocketFrameSize(configuration.getInteger("vertx.maxWebSocketFrameSize"));
}
if (configuration.getStringArray("wisdom.websocket.subprotocols").length > 0) {
options.setWebsocketSubProtocols(configuration.get("wisdom.websocket.subprotocols"));
}
if (configuration.getStringArray("vertx.websocket-subprotocols").length > 0) {
options.setWebsocketSubProtocols(configuration.get("vertx.websocket-subprotocols"));
}
if (configuration.getIntegerWithDefault("vertx.receiveBufferSize", -1) != -1) {
options.setReceiveBufferSize(configuration.getInteger("vertx.receiveBufferSize"));
}
if (configuration.getIntegerWithDefault("vertx.sendBufferSize", -1) != -1) {
options.setSendBufferSize(configuration.getInteger("vertx.sendBufferSize"));
}
http = vertx.createHttpServer(options)
.requestHandler(new HttpHandler(vertx, accessor, this))
.websocketHandler(new WebSocketHandler(accessor, this));
http.listen(thePort, host, event -> {
if (event.succeeded()) {
logger.info("Wisdom is going to serve HTTP requests on port {}.", thePort);
port = thePort;
completion.handle(Future.succeededFuture());
} else if (port == 0) {
logger.debug("Cannot bind on port {} (port already used probably)", thePort, event.cause());
bind(0, completion);
} else {
logger.error("Cannot bind on port {} (port already used probably)", thePort, event.cause());
completion.handle(Future.failedFuture("Cannot bind on port " + thePort));
}
});
}
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:55,代码来源:Server.java
注:本文中的io.vertx.core.http.ClientAuth类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论