use of com.microsoft.azure.proton.transport.proxy.impl.ProxyHandlerImpl 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);
}
use of com.microsoft.azure.proton.transport.proxy.impl.ProxyHandlerImpl 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);
}
use of com.microsoft.azure.proton.transport.proxy.impl.ProxyHandlerImpl 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);
}
Aggregations