Hello,
I posted a question about CDI in task listeners yesterday. I got a very quick answer which perfectly solved my problem. After being successfully injected, the identity service (see the previous question to understand the context, please) was returning wrong results of queries, e.g.:
identityService.createGroupQuery().list();
returned 0 groups.
I was trying to figure it out for a few hours, then I came with an idea that there could have been some problem with permissions. So I tried this:
List<String> groups = new ArrayList<>();
groups.add("camunda-admin");
identityService.setAuthentication("admin", groups); //consider admin as a user with proper permission
List<Group> groups = identityService.createGroupQuery().list();
identityService.clearAuthentication();
With authentication being set, the groups
variable contained all existing groups correctly.
It is working now. But I don’t understand the behavior completely. When I create the query inside a bean (and by that I mean, for example, service task with such expression as ${bean.query()}
) there is no need to specify any authentication and it returns correct results.
I add that I use LDAP identity service on JBoss application server.
In advance, thank you for an explanation.