use of org.eclipse.jetty.security.PropertyUserStore in project jetty.project by eclipse.
the class PropertyFileLoginModule method setupPropertyUserStore.
private void setupPropertyUserStore(Map<String, ?> options) {
parseConfig(options);
if (_propertyUserStores.get(_filename) == null) {
PropertyUserStore propertyUserStore = new PropertyUserStore();
propertyUserStore.setConfig(_filename);
PropertyUserStore prev = _propertyUserStores.putIfAbsent(_filename, propertyUserStore);
if (prev == null) {
LOG.debug("setupPropertyUserStore: Starting new PropertyUserStore. PropertiesFile: " + _filename + " refreshInterval: " + _refreshInterval);
try {
propertyUserStore.start();
} catch (Exception e) {
LOG.warn("Exception while starting propertyUserStore: ", e);
}
}
}
}
use of org.eclipse.jetty.security.PropertyUserStore in project jetty.project by eclipse.
the class PropertyFileLoginModule method getUserInfo.
/**
*
*
* @param userName the user name
* @throws Exception if unable to get the user information
*/
public UserInfo getUserInfo(String userName) throws Exception {
PropertyUserStore propertyUserStore = _propertyUserStores.get(_filename);
if (propertyUserStore == null)
throw new IllegalStateException("PropertyUserStore should never be null here!");
LOG.debug("Checking PropertyUserStore " + _filename + " for " + userName);
UserIdentity userIdentity = propertyUserStore.getUserIdentity(userName);
if (userIdentity == null)
return null;
//TODO in future versions change the impl of PropertyUserStore so its not
//storing Subjects etc, just UserInfo
Set<Principal> principals = userIdentity.getSubject().getPrincipals();
List<String> roles = new ArrayList<String>();
for (Principal principal : principals) {
roles.add(principal.getName());
}
Credential credential = (Credential) userIdentity.getSubject().getPrivateCredentials().iterator().next();
LOG.debug("Found: " + userName + " in PropertyUserStore " + _filename);
return new UserInfo(userName, credential, roles);
}
Aggregations