Skip to content

Commit

Permalink
Issue #5272 More cleanup; fixed demo-jaas.mod
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 17, 2020
1 parent 17371fa commit 608a0c7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
5 changes: 2 additions & 3 deletions demos/demo-jaas-webapp/src/main/config/modules/demo-jaas.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ jdbc
jsp
annotations
ext
demo-realm

[files]
basehome:modules/demo.d/demo-jaas.xml|webapps/demo-jaas.xml
basehome:modules/demo.d/demo-login.conf|etc/demo-login.conf
basehome:modules/demo.d/demo-login.properties|etc/demo-login.properties
maven://org.eclipse.jetty.demos/demo-jaas-webapp/${jetty.version}/war|webapps/demo-jaas.war

[ini-template]
[ini]
# Enable security via jaas, and configure it
jetty.jaas.login.conf=etc/demo-login.conf
jetty.jaas.login.conf?=etc/demo-login.conf
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,14 @@ public UserIdentity login(final String username, final Object credentials, final
}
catch (Exception e)
{
LOG.trace("IGNORED", e);
if (LOG.isDebugEnabled())
LOG.debug("Login error", e);
}
finally
{
INSTANCE.remove();
}

return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public abstract class AbstractLoginModule implements LoginModule
private JAASUser currentUser;
private Subject subject;

public abstract class JAASUser
public abstract static class JAASUser
{
private UserPrincipal _user;
private final UserPrincipal _user;
private List<JAASRole> _roles;

public JAASUser(UserPrincipal u)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ private void setupPropertyUserStore(Map<String, ?> options)
@Override
public JAASUser getUser(String userName) throws Exception
{
LOG.debug("Checking PropertyUserStore {} for {}", _store.getConfig(), userName);
if (LOG.isDebugEnabled())
LOG.debug("Checking PropertyUserStore {} for {}", _store.getConfig(), userName);
UserPrincipal up = _store.getUserPrincipal(userName);
if (up == null)
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import org.eclipse.jetty.server.UserIdentity;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.security.Credential;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -107,7 +106,7 @@ public UserIdentity login(String username, Object credentials, ServletRequest re
userPrincipal.configureSubject(subject);
if (roles != null)
{
roles.stream().forEach(p ->
roles.forEach(p ->
{
p.configureForSubject(subject);
roleNames.add(p.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package org.eclipse.jetty.security;

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
Expand Down Expand Up @@ -57,11 +56,13 @@ public class JDBCLoginService extends AbstractLoginService
protected Connection _con;

/**
* JDBCKnownUser
* JDBCUserPrincipal
*
* A UserPrincipal with extra jdbc key info.
*/
public class JDBCUserPrincipal extends UserPrincipal
{
int _userKey;
final int _userKey;

public JDBCUserPrincipal(String name, Credential credential, int key)
{
Expand All @@ -76,25 +77,21 @@ public int getUserKey()
}

public JDBCLoginService()
throws IOException
{
}

public JDBCLoginService(String name)
throws IOException
{
setName(name);
}

public JDBCLoginService(String name, String config)
throws IOException
{
setName(name);
setConfig(config);
}

public JDBCLoginService(String name, IdentityService identityService, String config)
throws IOException
{
setName(name);
setIdentityService(identityService);
Expand Down

0 comments on commit 608a0c7

Please sign in to comment.