use of jakarta.enterprise.event.Observes in project helidon by oracle.
the class JwtAuthCdiExtension method registerProvider.
void registerProvider(@Observes @Initialized(ApplicationScoped.class) @Priority(PLATFORM_BEFORE + 5) Object event, BeanManager bm) {
// Security extension to update and check builder
SecurityCdiExtension security = bm.getExtension(SecurityCdiExtension.class);
if (security.securityBuilder().hasProvider(JwtAuthProviderService.PROVIDER_NAME)) {
return;
}
// JAX-RS extension to get to applications to see if we are needed
JaxRsCdiExtension jaxrs = bm.getExtension(JaxRsCdiExtension.class);
boolean notNeeded = jaxrs.applicationsToRun().stream().map(JaxRsApplication::applicationClass).flatMap(Optional::stream).map(clazz -> clazz.getAnnotation(LoginConfig.class)).filter(Objects::nonNull).map(LoginConfig::authMethod).noneMatch("MP-JWT"::equals);
if (notNeeded) {
return;
}
security.securityBuilder().addProvider(JwtAuthProvider.create(config), JwtAuthProviderService.PROVIDER_NAME);
}
Aggregations