Skip to content

Commit

Permalink
Issue #5272 WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Bartel <janb@webtide.com>
  • Loading branch information
janbartel committed Nov 11, 2020
1 parent a80983f commit 97f39c0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public class User
{

private UserPrincipal _userPrincipal;
protected UserPrincipal _userPrincipal;
protected List<String> _roleNames = new ArrayList<>();
protected boolean _rolesLoaded = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;

import javax.management.relation.RoleStatus;
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand All @@ -43,6 +46,8 @@
import org.eclipse.jetty.security.AbstractLoginService;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.RolePrincipal;
import org.eclipse.jetty.security.UserPrincipal;
import org.eclipse.jetty.security.authentication.DigestAuthenticator;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
Expand Down Expand Up @@ -86,7 +91,7 @@ public class DigestPostTest
public static class TestLoginService extends AbstractLoginService
{
protected Map<String, UserPrincipal> users = new HashMap<>();
protected Map<String, String[]> roles = new HashMap<>();
protected Map<String, List<RolePrincipal>> roles = new HashMap<>();

public TestLoginService(String name)
{
Expand All @@ -97,21 +102,16 @@ public void putUser(String username, Credential credential, String[] rolenames)
{
UserPrincipal userPrincipal = new UserPrincipal(username, credential);
users.put(username, userPrincipal);
roles.put(username, rolenames);
if (rolenames != null)
roles.put(username, Arrays.stream(rolenames).map(RolePrincipal::new).collect(Collectors.toList()));
}

/**
* @see org.eclipse.jetty.security.AbstractLoginService#loadRoleInfo(org.eclipse.jetty.security.AbstractLoginService.UserPrincipal)
*/
@Override
protected String[] loadRoleInfo(UserPrincipal user)
protected List<RolePrincipal> loadRoleInfo(UserPrincipal user)
{
return roles.get(user.getName());
}

/**
* @see org.eclipse.jetty.security.AbstractLoginService#loadUserInfo(java.lang.String)
*/
@Override
protected UserPrincipal loadUserInfo(String username)
{
Expand Down

0 comments on commit 97f39c0

Please sign in to comment.