Search in sources :

Example 1 with SslDomain

use of org.apache.qpid.proton.engine.SslDomain in project azure-service-bus-java by Azure.

the class ConnectionHandler method onConnectionBound.

@Override
public void onConnectionBound(Event event) {
    TRACE_LOGGER.debug("onConnectionBound: hostname:{}", event.getConnection().getHostname());
    Transport transport = event.getTransport();
    SslDomain domain = makeDomain(SslDomain.Mode.CLIENT);
    transport.ssl(domain);
    Sasl sasl = transport.sasl();
    sasl.setMechanisms("ANONYMOUS");
}
Also used : SslDomain(org.apache.qpid.proton.engine.SslDomain) Sasl(org.apache.qpid.proton.engine.Sasl) Transport(org.apache.qpid.proton.engine.Transport)

Example 2 with SslDomain

use of org.apache.qpid.proton.engine.SslDomain in project azure-service-bus-java by Azure.

the class ConnectionHandler method makeDomain.

private static SslDomain makeDomain(SslDomain.Mode mode) {
    SslDomain domain = Proton.sslDomain();
    domain.init(mode);
    // TODO: VERIFY_PEER_NAME support
    domain.setPeerAuthentication(SslDomain.VerifyMode.ANONYMOUS_PEER);
    return domain;
}
Also used : SslDomain(org.apache.qpid.proton.engine.SslDomain)

Example 3 with SslDomain

use of org.apache.qpid.proton.engine.SslDomain in project azure-iot-sdk-java by Azure.

the class AmqpConnectionHandler method onConnectionBound.

/**
 * Event handler for the connection bound event
 * @param event The proton event object
 */
@Override
public void onConnectionBound(Event event) {
    Transport transport = event.getConnection().getTransport();
    if (transport != null) {
        if (this.iotHubServiceClientProtocol == IotHubServiceClientProtocol.AMQPS_WS) {
            WebSocketImpl webSocket = new WebSocketImpl(MAX_MESSAGE_PAYLOAD_SIZE);
            webSocket.configure(this.hostName, WEB_SOCKET_PATH, WEB_SOCKET_QUERY, AMQPS_WS_PORT, WEB_SOCKET_SUB_PROTOCOL, null, null);
            ((TransportInternal) transport).addTransportLayer(webSocket);
        }
        // Note that this does not mean that the connection will not be authenticated. This simply defers authentication
        // to the claims based security model that IoT Hub implements wherein the client sends the authentication token
        // over the CBS link rather than doing a sasl.plain(username, password) call at this point.
        transport.sasl().setMechanisms("ANONYMOUS");
        SslDomain domain = makeDomain();
        domain.setPeerAuthentication(SslDomain.VerifyMode.VERIFY_PEER);
        transport.ssl(domain);
        if (this.proxyOptions != null) {
            addProxyLayer(transport, this.hostName);
        }
    }
}
Also used : SslDomain(org.apache.qpid.proton.engine.SslDomain) WebSocketImpl(com.microsoft.azure.proton.transport.ws.impl.WebSocketImpl) TransportInternal(org.apache.qpid.proton.engine.impl.TransportInternal) Transport(org.apache.qpid.proton.engine.Transport)

Example 4 with SslDomain

use of org.apache.qpid.proton.engine.SslDomain in project azure-iot-sdk-java by Azure.

the class AmqpConnectionHandler method makeDomain.

/**
 * Create Proton SslDomain object from Address using the given Ssl mode
 * @return The created Ssl domain
 */
private SslDomain makeDomain() {
    SslDomain domain = Proton.sslDomain();
    try {
        if (this.sslContext == null) {
            // Need the base trusted certs for IotHub in our ssl context. IotHubSSLContext handles that
            domain.setSslContext(new IotHubSSLContext().getSSLContext());
        } else {
            // Custom SSLContext set by user from service client options
            domain.setSslContext(this.sslContext);
        }
    } catch (Exception e) {
        this.savedException = e;
    }
    domain.init(SslDomain.Mode.CLIENT);
    return domain;
}
Also used : SslDomain(org.apache.qpid.proton.engine.SslDomain) IotHubSSLContext(com.microsoft.azure.sdk.iot.deps.auth.IotHubSSLContext) IOException(java.io.IOException) IotHubException(com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)

Aggregations

SslDomain (org.apache.qpid.proton.engine.SslDomain)4 Transport (org.apache.qpid.proton.engine.Transport)2 WebSocketImpl (com.microsoft.azure.proton.transport.ws.impl.WebSocketImpl)1 IotHubSSLContext (com.microsoft.azure.sdk.iot.deps.auth.IotHubSSLContext)1 IotHubException (com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)1 IOException (java.io.IOException)1 Sasl (org.apache.qpid.proton.engine.Sasl)1 TransportInternal (org.apache.qpid.proton.engine.impl.TransportInternal)1