use of org.eclipse.hono.adapter.auth.device.TenantServiceBasedX509Authentication in project hono by eclipse.
the class LoraProtocolAdapter method setupAuthorization.
private void setupAuthorization(final Router router) {
final ChainAuthHandler authHandler = ChainAuthHandler.any();
authHandler.add(new X509AuthHandler(new TenantServiceBasedX509Authentication(getTenantClient(), tracer), Optional.ofNullable(clientCertAuthProvider).orElseGet(() -> new X509AuthProvider(getCredentialsClient(), tracer)), this::handleBeforeCredentialsValidation));
authHandler.add(new HonoBasicAuthHandler(Optional.ofNullable(usernamePasswordAuthProvider).orElseGet(() -> new UsernamePasswordAuthProvider(getCredentialsClient(), tracer)), getConfig().getRealm(), this::handleBeforeCredentialsValidation));
router.route().handler(authHandler);
}
use of org.eclipse.hono.adapter.auth.device.TenantServiceBasedX509Authentication in project hono by eclipse.
the class VertxBasedHttpProtocolAdapter method addRoutes.
@Override
protected void addRoutes(final Router router) {
if (getConfig().isAuthenticationRequired()) {
final ChainAuthHandler authHandler = ChainAuthHandler.any();
authHandler.add(new X509AuthHandler(new TenantServiceBasedX509Authentication(getTenantClient(), tracer), Optional.ofNullable(clientCertAuthProvider).orElseGet(() -> new X509AuthProvider(getCredentialsClient(), tracer)), this::handleBeforeCredentialsValidation));
authHandler.add(new HonoBasicAuthHandler(Optional.ofNullable(usernamePasswordAuthProvider).orElseGet(() -> new UsernamePasswordAuthProvider(getCredentialsClient(), tracer)), getConfig().getRealm(), this::handleBeforeCredentialsValidation));
addTelemetryApiRoutes(router, authHandler);
addEventApiRoutes(router, authHandler);
addCommandResponseRoutes(CommandConstants.COMMAND_ENDPOINT, router, authHandler);
} else {
log.warn("device authentication has been disabled");
log.warn("any device may publish data on behalf of all other devices");
addTelemetryApiRoutes(router, null);
addEventApiRoutes(router, null);
addCommandResponseRoutes(CommandConstants.COMMAND_ENDPOINT, router, null);
}
}
Aggregations