public Collection<? extends GrantedAuthority> getUserAuthorities(IdentityMessage identity) {

        Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();


        for (String group : identity.getGroups()) {

            Collection<? extends GrantedAuthority> a = roles.get(group);

            if (a == null) continue;

            authorities.addAll(a);
        }

        return authorities;
    }