use of javax.enterprise.inject.spi.ProcessSessionBean in project Payara by payara.
the class CdiExtension method findRoles.
/**
* Find all the roles used by the <code>@RolesAllowed</code> annotation, so these can be programmatically
* declared later on.
*/
public <T> void findRoles(@Observes ProcessManagedBean<T> eventIn, BeanManager beanManager) {
// JDK8 u60 workaround
ProcessManagedBean<T> event = eventIn;
if (event instanceof ProcessSessionBean) {
// @RolesAllowed on session beans is already handled
return;
}
List<Annotated> annotatedElements = new ArrayList<>(event.getAnnotatedBeanClass().getMethods());
annotatedElements.add(event.getAnnotatedBeanClass());
for (Annotated annotated : annotatedElements) {
RolesAllowed rolesAllowed = annotated.getAnnotation(RolesAllowed.class);
if (rolesAllowed != null) {
roles.addAll(Arrays.asList(rolesAllowed.value()));
}
}
}
use of javax.enterprise.inject.spi.ProcessSessionBean in project Payara by payara.
the class JwtAuthCdiExtension method findRoles.
/**
* Find all the roles used by the <code>@RolesAllowed</code> annotation, so these can be programmatically
* declared later on.
*/
public <T> void findRoles(@Observes ProcessManagedBean<T> eventIn, BeanManager beanManager) {
// JDK8 u60 workaround
ProcessManagedBean<T> event = eventIn;
if (event instanceof ProcessSessionBean) {
// @RolesAllowed on session beans is already handled
return;
}
List<Annotated> annotatedElements = new ArrayList<>(event.getAnnotatedBeanClass().getMethods());
annotatedElements.add(event.getAnnotatedBeanClass());
for (Annotated annotated : annotatedElements) {
RolesAllowed rolesAllowed = annotated.getAnnotation(RolesAllowed.class);
if (rolesAllowed != null) {
roles.addAll(Arrays.asList(rolesAllowed.value()));
}
}
}
Aggregations