Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public int usersCount() {
}

public AuthenticationResult verifyPassword(String username, SecureString password, java.util.function.Supplier<User> user) {
char[] hash = users.get(username);
final char[] hash = users.get(username);
if (hash == null) {
return AuthenticationResult.notHandled();
}
Expand All @@ -91,7 +91,7 @@ public AuthenticationResult verifyPassword(String username, SecureString passwor
}

public boolean userExists(String username) {
return users != null && users.containsKey(username);
return users.containsKey(username);
}

public static Path resolveFile(Environment env) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@ int entriesCount() {
}

public String[] roles(String username) {
if (userRoles == null) {
return Strings.EMPTY_ARRAY;
}
String[] roles = userRoles.get(username);
return roles == null ? Strings.EMPTY_ARRAY : userRoles.get(username);
final String[] roles = userRoles.get(username);
return roles == null ? Strings.EMPTY_ARRAY : roles;
}

public static Path resolveFile(Environment env) {
Expand Down Expand Up @@ -160,11 +157,7 @@ public static Map<String, String[]> parseFile(Path path, @Nullable Logger logger
}

for (String user : roleUsers) {
List<String> roles = userToRoles.get(user);
if (roles == null) {
roles = new ArrayList<>();
userToRoles.put(user, roles);
}
List<String> roles = userToRoles.computeIfAbsent(user, k -> new ArrayList<>());
roles.add(role);
}
}
Expand All @@ -185,11 +178,7 @@ public static void writeFile(Map<String, String[]> userToRoles, Path path) {
HashMap<String, List<String>> roleToUsers = new HashMap<>();
for (Map.Entry<String, String[]> entry : userToRoles.entrySet()) {
for (String role : entry.getValue()) {
List<String> users = roleToUsers.get(role);
if (users == null) {
users = new ArrayList<>();
roleToUsers.put(role, users);
}
List<String> users = roleToUsers.computeIfAbsent(role, k -> new ArrayList<>());
users.add(entry.getKey());
}
}
Expand Down