Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-security/src/main/java/org/eclipse/jetty/security/HashLoginService.java')
-rw-r--r--jetty-security/src/main/java/org/eclipse/jetty/security/HashLoginService.java91
1 files changed, 38 insertions, 53 deletions
diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/HashLoginService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/HashLoginService.java
index 5d606528ee..108ca0ad6f 100644
--- a/jetty-security/src/main/java/org/eclipse/jetty/security/HashLoginService.java
+++ b/jetty-security/src/main/java/org/eclipse/jetty/security/HashLoginService.java
@@ -19,6 +19,9 @@
package org.eclipse.jetty.security;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
import org.eclipse.jetty.security.PropertyUserStore.UserListener;
import org.eclipse.jetty.server.UserIdentity;
@@ -45,15 +48,15 @@ import org.eclipse.jetty.util.security.Credential;
* <p>
* If DIGEST Authentication is used, the password must be in a recoverable format, either plain text or OBF:.
*/
-public class HashLoginService extends MappedLoginService implements UserListener
+public class HashLoginService extends AbstractLoginService
{
private static final Logger LOG = Log.getLogger(HashLoginService.class);
- private PropertyUserStore _propertyUserStore;
- private String _config;
- private Resource _configResource;
- private Scanner _scanner;
- private boolean hotReload = false; // default is not to reload
+ protected PropertyUserStore _propertyUserStore;
+ protected String _config;
+ protected Resource _configResource;
+ protected boolean hotReload = false; // default is not to reload
+
/* ------------------------------------------------------------ */
public HashLoginService()
@@ -127,41 +130,45 @@ public class HashLoginService extends MappedLoginService implements UserListener
this.hotReload = enable;
}
- /* ------------------------------------------------------------ */
- /**
- * sets the refresh interval (in seconds)
- * @param sec the refresh interval
- * @deprecated use {@link #setHotReload(boolean)} instead
- */
- @Deprecated
- public void setRefreshInterval(int sec)
- {
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return refresh interval in seconds for how often the properties file should be checked for changes
- * @deprecated use {@link #isHotReload()} instead
- */
- @Deprecated
- public int getRefreshInterval()
- {
- return (hotReload)?1:0;
- }
+
/* ------------------------------------------------------------ */
@Override
- protected UserIdentity loadUser(String username)
+ protected String[] loadRoleInfo(UserPrincipal user)
{
- return null;
+ UserIdentity id = _propertyUserStore.getUserIdentity(user.getName());
+ if (id == null)
+ return null;
+
+
+ Set<RolePrincipal> roles = id.getSubject().getPrincipals(RolePrincipal.class);
+ if (roles == null)
+ return null;
+
+ List<String> list = new ArrayList<>();
+ for (RolePrincipal r:roles)
+ list.add(r.getName());
+
+ return list.toArray(new String[roles.size()]);
}
+
+
+
/* ------------------------------------------------------------ */
@Override
- public void loadUsers() throws IOException
+ protected UserPrincipal loadUserInfo(String userName)
{
- // TODO: Consider refactoring MappedLoginService to not have to override with unused methods
+ UserIdentity id = _propertyUserStore.getUserIdentity(userName);
+ if (id != null)
+ {
+ return (UserPrincipal)id.getUserPrincipal();
+ }
+
+ return null;
}
+
+
/* ------------------------------------------------------------ */
/**
@@ -180,7 +187,6 @@ public class HashLoginService extends MappedLoginService implements UserListener
_propertyUserStore = new PropertyUserStore();
_propertyUserStore.setHotReload(hotReload);
_propertyUserStore.setConfigPath(_config);
- _propertyUserStore.registerUserListener(this);
_propertyUserStore.start();
}
}
@@ -193,26 +199,5 @@ public class HashLoginService extends MappedLoginService implements UserListener
protected void doStop() throws Exception
{
super.doStop();
- if (_scanner != null)
- _scanner.stop();
- _scanner = null;
- }
-
- /* ------------------------------------------------------------ */
- @Override
- public void update(String userName, Credential credential, String[] roleArray)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("update: " + userName + " Roles: " + roleArray.length);
- putUser(userName,credential,roleArray);
- }
-
- /* ------------------------------------------------------------ */
- @Override
- public void remove(String userName)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("remove: " + userName);
- removeUser(userName);
}
}

Back to the top