diff --git a/datashare-app/src/main/java/org/icij/datashare/session/HashMapUser.java b/datashare-app/src/main/java/org/icij/datashare/session/HashMapUser.java index 78ff6e048..1c5072b47 100644 --- a/datashare-app/src/main/java/org/icij/datashare/session/HashMapUser.java +++ b/datashare-app/src/main/java/org/icij/datashare/session/HashMapUser.java @@ -17,7 +17,7 @@ import static org.apache.commons.collections4.map.UnmodifiableMap.unmodifiableMap; public class HashMapUser extends User implements net.codestory.http.security.User { - private static final String DATASHARE_INDICES_KEY = "datashare_indices"; + public static final String DATASHARE_PROJECTS_KEY = "datashare_projects"; final Map userMap; public HashMapUser(final Map userMap) { @@ -49,7 +49,7 @@ public String toJson() { } public List getProjects() { - return (List) ofNullable(userMap.get(DATASHARE_INDICES_KEY)).orElse(new LinkedList<>()); + return (List) ofNullable(userMap.get(DATASHARE_PROJECTS_KEY)).orElse(new LinkedList<>()); } public Map getMap() { @@ -66,7 +66,7 @@ public Map getMap() { public static HashMapUser local() { return localUser("local"); } public static HashMapUser localUser(String id) { - return new HashMapUser(new HashMap() {{ put("uid", id); put(DATASHARE_INDICES_KEY, singletonList(id + "-datashare"));}}) { + return new HashMapUser(new HashMap() {{ put("uid", id); put(DATASHARE_PROJECTS_KEY, singletonList(id + "-datashare"));}}) { @Override public String[] roles() { return new String[] {"local"};} }; } diff --git a/datashare-app/src/main/java/org/icij/datashare/session/YesCookieAuthFilter.java b/datashare-app/src/main/java/org/icij/datashare/session/YesCookieAuthFilter.java index eef3c6aa6..c862a2a15 100644 --- a/datashare-app/src/main/java/org/icij/datashare/session/YesCookieAuthFilter.java +++ b/datashare-app/src/main/java/org/icij/datashare/session/YesCookieAuthFilter.java @@ -37,7 +37,7 @@ protected Payload otherUri(String uri, Context context, PayloadSupplier nextFilt private User createUser(String userName) { HashMapUser user = new HashMapUser(new HashMap() {{ put("uid", userName); - put("datashare_projects", singletonList(project)); + put(HashMapUser.DATASHARE_PROJECTS_KEY, singletonList(project)); }}); ((RedisUsers)users).createUser(user); return user; diff --git a/datashare-app/src/test/java/org/icij/datashare/session/HashMapUserTest.java b/datashare-app/src/test/java/org/icij/datashare/session/HashMapUserTest.java index 87176d052..3c00f05aa 100644 --- a/datashare-app/src/test/java/org/icij/datashare/session/HashMapUserTest.java +++ b/datashare-app/src/test/java/org/icij/datashare/session/HashMapUserTest.java @@ -52,7 +52,7 @@ public void test_get_indices_for_local_user() { public void test_get_indices_for_external_user() { assertThat(new HashMapUser(new HashMap() {{ put("uid", "userid"); - put("datashare_indices", Collections.singletonList("external_index")); + put("datashare_projects", Collections.singletonList("external_index")); }}).getProjects()).containsExactly("external_index"); } }