Search in sources :

Example 1 with TransportInternal

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

the class AmqpSendHandler method onConnectionBound.

/**
     * Event handler for the connection bound event
     * @param event The proton event object
     */
@Override
public void onConnectionBound(Event event) {
    // Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_12_010: [The event handler shall set the SASL PLAIN authentication on the Transport using the given user name and sas token]
    // Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_12_011: [The event handler shall set ANONYMUS_PEER authentication mode on the domain of the Transport]
    Transport transport = event.getConnection().getTransport();
    if (transport != null) {
        if (this.iotHubServiceClientProtocol == IotHubServiceClientProtocol.AMQPS_WS) {
            WebSocketImpl webSocket = new WebSocketImpl();
            webSocket.configure(this.webSocketHostName, WEBSOCKET_PATH, 0, WEBSOCKET_SUB_PROTOCOL, null, null);
            ((TransportInternal) transport).addTransportLayer(webSocket);
        }
        Sasl sasl = transport.sasl();
        sasl.plain(this.userName, this.sasToken);
        SslDomain domain = makeDomain(SslDomain.Mode.CLIENT);
        domain.setPeerAuthentication(SslDomain.VerifyMode.ANONYMOUS_PEER);
        Ssl ssl = transport.ssl(domain);
    }
}
Also used : WebSocketImpl(com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl) TransportInternal(org.apache.qpid.proton.engine.impl.TransportInternal)

Example 2 with TransportInternal

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

the class AmqpsIotHubConnection method onConnectionBound.

/**
     * Event handler for the connection bound event. Sets Sasl authentication and proper authentication mode.
     * @param event The Proton Event object.
     */
@Override
public void onConnectionBound(Event event) {
    logger.LogDebug("Entered in method %s", logger.getMethodName());
    // Codes_SRS_AMQPSIOTHUBCONNECTION_15_030: [The event handler shall get the Transport (Proton) object from the event.]
    Transport transport = event.getConnection().getTransport();
    if (transport != null) {
        if (this.useWebSockets) {
            WebSocketImpl webSocket = new WebSocketImpl();
            webSocket.configure(this.hostName, WEB_SOCKET_PATH, 0, WEB_SOCKET_SUB_PROTOCOL, null, null);
            ((TransportInternal) transport).addTransportLayer(webSocket);
        }
        // Codes_SRS_AMQPSIOTHUBCONNECTION_15_031: [The event handler shall set the SASL_PLAIN authentication on the transport using the given user name and sas token.]
        Sasl sasl = transport.sasl();
        sasl.plain(this.userName, this.sasToken);
        SslDomain domain = makeDomain();
        transport.ssl(domain);
    }
    synchronized (openLock) {
        openLock.notifyLock();
    }
    logger.LogDebug("Exited from method %s", logger.getMethodName());
}
Also used : WebSocketImpl(com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl) TransportInternal(org.apache.qpid.proton.engine.impl.TransportInternal)

Example 3 with TransportInternal

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

the class AmqpFeedbackReceivedHandler method onConnectionBound.

@Override
public void onConnectionBound(Event event) {
    // Codes_SRS_SERVICE_SDK_JAVA_AMQPFEEDBACKRECEIVEDHANDLER_12_009: [The event handler shall set the SASL PLAIN authentication on the Transport using the given user name and sas token]
    // Codes_SRS_SERVICE_SDK_JAVA_AMQPFEEDBACKRECEIVEDHANDLER_12_010: [The event handler shall set ANONYMUS_PEER authentication mode on the domain of the Transport]
    Transport transport = event.getConnection().getTransport();
    if (transport != null) {
        if (this.iotHubServiceClientProtocol == IotHubServiceClientProtocol.AMQPS_WS) {
            WebSocketImpl webSocket = new WebSocketImpl();
            webSocket.configure(this.webSocketHostName, WEBSOCKET_PATH, 0, WEBSOCKET_SUB_PROTOCOL, null, null);
            ((TransportInternal) transport).addTransportLayer(webSocket);
        }
        Sasl sasl = transport.sasl();
        sasl.plain(this.userName, this.sasToken);
        SslDomain domain = makeDomain(SslDomain.Mode.CLIENT);
        domain.setPeerAuthentication(SslDomain.VerifyMode.ANONYMOUS_PEER);
        Ssl ssl = transport.ssl(domain);
    }
}
Also used : WebSocketImpl(com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl) TransportInternal(org.apache.qpid.proton.engine.impl.TransportInternal)

Example 4 with TransportInternal

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

the class AmqpFileUploadNotificationReceivedHandler method onConnectionBound.

@Override
public void onConnectionBound(Event event) {
    // Codes_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVEDHANDLER_25_019: [The event handler shall set the SASL PLAIN authentication on the Transport using the given user name and sas token]
    // Codes_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVEDHANDLER_25_010: [The event handler shall set ANONYMUS_PEER authentication mode on the domain of the Transport]
    Transport transport = event.getConnection().getTransport();
    if (transport != null) {
        if (this.iotHubServiceClientProtocol == IotHubServiceClientProtocol.AMQPS_WS) {
            // Codes_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVEDHANDLER_25_020: [** The event handler shall not initialize WebSocket if the protocol is AMQP **]
            WebSocketImpl webSocket = new WebSocketImpl();
            webSocket.configure(this.webSocketHostName, WEBSOCKET_PATH, 0, WEBSOCKET_SUB_PROTOCOL, null, null);
            ((TransportInternal) transport).addTransportLayer(webSocket);
        }
        Sasl sasl = transport.sasl();
        sasl.plain(this.userName, this.sasToken);
        SslDomain domain = makeDomain(SslDomain.Mode.CLIENT);
        domain.setPeerAuthentication(SslDomain.VerifyMode.ANONYMOUS_PEER);
        Ssl ssl = transport.ssl(domain);
    }
}
Also used : WebSocketImpl(com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl) TransportInternal(org.apache.qpid.proton.engine.impl.TransportInternal)

Aggregations

WebSocketImpl (com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl)4 TransportInternal (org.apache.qpid.proton.engine.impl.TransportInternal)4