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; }
final String tenantId = tenantTracker.result().getTenantId(); final SubjectDnCredentials credentials = SubjectDnCredentials.create(tenantId, deviceCert.getSubjectX500Principal()); getCertificateAuthProvider().authenticate(credentials, currentSpan.context(), completer); return null; }).otherwise(t -> {
getUsernamePasswordAuthProvider().authenticate(credentials, currentSpan.context(), completer); } else { completer.handle(Future.failedFuture(new CredentialException(