class AcmPluginManager implements ApplicationContextAware, ApplicationListener<AbstractContextHolderEvent> {

    public List<String> getRolesForPrivilege(String privilege)
    {
        // iterate over the role-to-privileges map; if the value list includes this privilege, the role (i.e. the
        // map key) is included in the return list.
        List<String> retval = new LinkedList<>();

        for (Map.Entry<String, List<String>> roleToPrivileges : configurablePrivilegesByRole.entrySet())
        {
            if (roleToPrivileges.getValue() != null && roleToPrivileges.getValue().contains(privilege)
                    && !retval.contains(roleToPrivileges.getKey()))
            {
                retval.add(roleToPrivileges.getKey());
            }
        }

        return retval;
    }

}