class NamespaceSecurityHelper {

    public Set<String> getAuthorizedNamespaces(NamespacePermissionEnum... permissions)
    {
        Set<String> namespaces = new HashSet<>();
        if (SecurityContextHolder.getContext().getAuthentication() != null)
        {
            ApplicationUser applicationUser = getApplicationUser();
            if (applicationUser != null)
            {
                for (NamespaceAuthorization namespaceAuthorization : applicationUser.getNamespaceAuthorizations())
                {
                    if (namespaceAuthorization.getNamespacePermissions().containsAll(Arrays.asList(permissions)))
                    {
                        namespaces.add(namespaceAuthorization.getNamespace());
                    }
                }
            }
        }
        return namespaces;
    }

}