use of com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl 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);
}
}
use of com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl in project azure-iot-sdk-java by Azure.
the class AmqpSendHandlerTest method onConnectionBound_call_flow_and_init_ok_amqp_ws.
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_12_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_AMQPSENDHANDLER_12_010: [The event handler shall set ANONYMUS_PEER authentication mode on the domain of the Transport]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_12_024: [The event handler shall initialize WebSocket if the protocol is AMQP_WS]
@Test
public void onConnectionBound_call_flow_and_init_ok_amqp_ws() {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
String hostAddr = hostName + ":443";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS_WS;
AmqpSendHandler amqpSendHandler = new AmqpSendHandler(hostName, userName, sasToken, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
event.getConnection();
result = connection;
connection.getTransport();
result = transportInternal;
new WebSocketImpl();
result = webSocket;
webSocket.configure(anyString, anyString, 0, anyString, null, null);
transportInternal.addTransportLayer(webSocket);
sasl.plain(anyString, anyString);
Proton.sslDomain();
result = sslDomain;
sslDomain.init(SslDomain.Mode.CLIENT);
sslDomain.setPeerAuthentication(SslDomain.VerifyMode.ANONYMOUS_PEER);
transportInternal.ssl(sslDomain);
}
};
// Act
amqpSendHandler.onConnectionBound(event);
}
use of com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl 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());
}
use of com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl 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);
}
}
use of com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl 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);
}
}
Aggregations