Custom IDM configuration

For some reason or another it seems like the custom implementation of idm has stopped working. I really dont see what is wrong as it has worked in past and is similar to the LDAP example.

Here is Engine configuration:

@Component
class FlowableConfigurationConfigurer implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {
    @Override
    void configure(SpringProcessEngineConfiguration engineConfiguration) {
        //IDM Service
        engineConfiguration.setIdmEngineConfigurator(new CustomIdentityConfigurator())
    }
}


class CustomIdentityConfigurator extends IdmEngineConfigurator {
    @Override
    public void configure(AbstractEngineConfiguration engineConfiguration) {
        super.configure(engineConfiguration)
        getIdmEngineConfiguration(engineConfiguration)
                .setIdmIdentityService(new CustomIdentityService());
    }

    protected static IdmEngineConfiguration getIdmEngineConfiguration(AbstractEngineConfiguration engineConfiguration) {
        return (IdmEngineConfiguration) engineConfiguration.getEngineConfigurations().
                get(EngineConfigurationConstants.KEY_IDM_ENGINE_CONFIG);
    }
}


@Service
class CustomIdentityService extends IdmIdentityServiceImpl {
    @Override
    GroupQuery createGroupQuery() {
        new CustomGroupQuery()
    }
}

class CustomGroupQuery extends GroupQueryImpl {
    @Override
    long executeCount(CommandContext commandContext) {
        return executeQuery().size()
    }
    @Override
    List<Group> executeList(CommandContext commandContext) {
        return executeQuery()
    }
    static List<Group> executeQuery() {
        log.info("Gettting authorities for user: ${SecurityContextHolder.getContext().getAuthentication().getPrincipal()}")
        def groups = []
        def authorities = SecurityContextHolder.getContext().getAuthentication().authorities
        authorities.each {
            GrantedAuthority grantedAuthority ->
                log.debug("authority: ${grantedAuthority.authority}")
                groups.add(new GroupEntityImpl(id: grantedAuthority.authority))
        }
        groups
    }
}

The configure method is be called and the engineConfiguration.setIdmEngineConfigurator(new CustomIdentityConfigurator()) is being executed. But the it never fires the CustomGroupQuery as I was expecting when working with taskService. The executeQuery method at one time was being called when getting task, but now I cannot figure out why it is not.

I was expecting that the CustomGroupQuery to be executed when the following API is called:

def tasksQuery = taskService.createTaskQuery().
        includeProcessVariables().
        includeTaskLocalVariables().taskCandidateOrAssigned(SecurityContextHolder.getContext().getAuthentication().name)

Hi @tjmac

Your CustomGroupdQuery is not called, because the Groups of the passed User Id are fetched directly within SQL query.

Have a look here:

Regards,
Simon