Java Code Examples for io.vertx.core.net.NetSocket#isSsl()

The following examples show how to use io.vertx.core.net.NetSocket#isSsl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HonoSaslAuthenticator.java    From hono with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void init(final NetSocket socket, final ProtonConnection protonConnection, final Transport transport) {

    LOG.debug("initializing SASL authenticator");
    this.protonConnection = protonConnection;
    this.sasl = transport.sasl();
    sasl.server();
    sasl.allowSkip(false);
    sasl.setMechanisms(authenticationService.getSupportedSaslMechanisms());
    if (socket.isSsl() && Arrays.asList(authenticationService.getSupportedSaslMechanisms())
            .contains(AuthenticationConstants.MECHANISM_EXTERNAL)) {
        LOG.debug("client connected using TLS, extracting client certificate chain");
        try {
            final Certificate cert = socket.sslSession().getPeerCertificates()[0];
            if (cert instanceof X509Certificate) {
                clientCertificate = (X509Certificate) cert;
            }
        } catch (final SSLPeerUnverifiedException e) {
            LOG.debug("could not extract client certificate chain, maybe client uses other mechanism than SASL EXTERNAL");
        }
    }
}
 
Example 2
Source File: AmqpAdapterSaslAuthenticatorFactory.java    From hono with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void init(final NetSocket socket, final ProtonConnection protonConnection, final Transport transport) {
    LOG.trace("initializing SASL authenticator");
    this.protonConnection = protonConnection;
    this.sasl = transport.sasl();
    sasl.server();
    sasl.allowSkip(false);
    sasl.setMechanisms(getSupportedMechanisms());
    if (socket.isSsl()) {
        LOG.trace("client connected through a secured port");
        sslSession = socket.sslSession();
    }
}