private Future<DeviceUser> authenticate(final DeviceCredentials credentials, final Span currentSpan) {
final Future<DeviceUser> result = Future.future();
usernamePasswordAuthProvider.authenticate(credentials, handler -> {
if (handler.succeeded()) {
final DeviceUser authenticatedDevice = handler.result();
currentSpan.log("device authenticated");
LOG.debug("successfully authenticated device [tenant-id: {}, auth-id: {}, device-id: {}]",
authenticatedDevice.getTenantId(), credentials.getAuthId(),
authenticatedDevice.getDeviceId());
result.complete(authenticatedDevice);
} else {
LOG.debug("Failed to authenticate device [tenant-id: {}, auth-id: {}] ",
credentials.getTenantId(), credentials.getAuthId(), handler.cause());
result.fail(handler.cause());
}
});
return result;
}