Search in sources :

Example 1 with ProxyImpl

use of com.microsoft.azure.proton.transport.proxy.impl.ProxyImpl in project azure-iot-sdk-java by Azure.

the class AmqpFileUploadNotificationReceivedHandlerTest method onConnectionBoundCallFlowAndInitOkAmqps.

// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVEDHANDLER_25_009: [The event handler shall set the SASL PLAIN authentication on the Transport using the given user name and sas token]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVEDHANDLER_25_010: [The event handler shall set VERIFY_PEER authentication mode on the domain of the Transport]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVEDHANDLER_25_018: [The event handler shall initialize WebSocket if the protocol is AMQP_WS]
@Test
public void onConnectionBoundCallFlowAndInitOkAmqps() {
    // Arrange
    final String hostName = "aaa";
    final String userName = "bbb";
    final String sasToken = "ccc";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS_WS;
    Object amqpReceiveHandler = Deencapsulation.newInstance(AmqpFileUploadNotificationReceivedHandler.class, hostName, userName, sasToken, iotHubServiceClientProtocol, amqpFeedbackReceivedEvent, mockedProxyOptions, mockedSslContext);
    // Assert
    new Expectations() {

        {
            event.getConnection();
            result = connection;
            connection.getTransport();
            result = transportInternal;
            new ProxyImpl();
            result = mockedProxyImpl;
            new ProxyHandlerImpl();
            result = mockedProxyHandlerImpl;
            mockedProxyImpl.configure(anyString, (Map<String, String>) any, mockedProxyHandlerImpl, transportInternal);
            transportInternal.addTransportLayer(mockedProxyImpl);
            new WebSocketImpl(anyInt);
            result = webSocket;
            webSocket.configure(anyString, anyString, anyString, 443, anyString, null, null);
            transportInternal.addTransportLayer(webSocket);
            Proton.sslDomain();
            result = sslDomain;
            sslDomain.init(SslDomain.Mode.CLIENT);
            sslDomain.setPeerAuthentication(SslDomain.VerifyMode.VERIFY_PEER);
            transportInternal.ssl(sslDomain);
        }
    };
    // Act
    Deencapsulation.invoke(amqpReceiveHandler, "onConnectionBound", event);
}
Also used : Expectations(mockit.Expectations) ProxyHandlerImpl(com.microsoft.azure.proton.transport.proxy.impl.ProxyHandlerImpl) ProxyImpl(com.microsoft.azure.proton.transport.proxy.impl.ProxyImpl) WebSocketImpl(com.microsoft.azure.proton.transport.ws.impl.WebSocketImpl) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 2 with ProxyImpl

use of com.microsoft.azure.proton.transport.proxy.impl.ProxyImpl in project azure-iot-sdk-java by Azure.

the class AmqpConnectionHandler method addProxyLayer.

private void addProxyLayer(Transport transport, String hostName) {
    log.trace("Adding proxy layer to amqp_ws connection");
    ProxyImpl proxy = new ProxyImpl();
    final ProxyHandler proxyHandler = new ProxyHandlerImpl();
    proxy.configure(hostName + ":" + AmqpConnectionHandler.AMQPS_WS_PORT, null, proxyHandler, transport);
    ((TransportInternal) transport).addTransportLayer(proxy);
}
Also used : ProxyHandlerImpl(com.microsoft.azure.proton.transport.proxy.impl.ProxyHandlerImpl) ProxyImpl(com.microsoft.azure.proton.transport.proxy.impl.ProxyImpl) ProxyHandler(com.microsoft.azure.proton.transport.proxy.ProxyHandler) TransportInternal(org.apache.qpid.proton.engine.impl.TransportInternal)

Example 3 with ProxyImpl

use of com.microsoft.azure.proton.transport.proxy.impl.ProxyImpl in project azure-iot-sdk-java by Azure.

the class AmqpsIotHubConnection method addProxyLayer.

private void addProxyLayer(Transport transport, String hostName) {
    log.debug("Adding proxy layer to amqp transport");
    ProxyImpl proxy;
    if (proxySettings.getUsername() != null && proxySettings.getPassword() != null) {
        log.trace("Adding proxy username and password to amqp proxy configuration");
        ProxyConfiguration proxyConfiguration = new ProxyConfiguration(ProxyAuthenticationType.BASIC, proxySettings.getProxy(), proxySettings.getUsername(), new String(proxySettings.getPassword()));
        proxy = new ProxyImpl(proxyConfiguration);
    } else {
        log.trace("No proxy username and password will be used amqp proxy configuration");
        proxy = new ProxyImpl();
    }
    final ProxyHandler proxyHandler = new ProxyHandlerImpl();
    proxy.configure(hostName, null, proxyHandler, transport);
    ((TransportInternal) transport).addTransportLayer(proxy);
}
Also used : ProxyHandlerImpl(com.microsoft.azure.proton.transport.proxy.impl.ProxyHandlerImpl) ProxyImpl(com.microsoft.azure.proton.transport.proxy.impl.ProxyImpl) ProxyConfiguration(com.microsoft.azure.proton.transport.proxy.ProxyConfiguration) ProxyHandler(com.microsoft.azure.proton.transport.proxy.ProxyHandler) TransportInternal(org.apache.qpid.proton.engine.impl.TransportInternal)

Aggregations

ProxyHandlerImpl (com.microsoft.azure.proton.transport.proxy.impl.ProxyHandlerImpl)3 ProxyImpl (com.microsoft.azure.proton.transport.proxy.impl.ProxyImpl)3 ProxyHandler (com.microsoft.azure.proton.transport.proxy.ProxyHandler)2 TransportInternal (org.apache.qpid.proton.engine.impl.TransportInternal)2 ProxyConfiguration (com.microsoft.azure.proton.transport.proxy.ProxyConfiguration)1 WebSocketImpl (com.microsoft.azure.proton.transport.ws.impl.WebSocketImpl)1 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)1 Expectations (mockit.Expectations)1 Test (org.junit.Test)1