Search in sources :

Example 1 with PropertyUserStore

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);
            }
        }
    }
}
Also used : PropertyUserStore(org.eclipse.jetty.security.PropertyUserStore)

Example 2 with PropertyUserStore

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);
}
Also used : PropertyUserStore(org.eclipse.jetty.security.PropertyUserStore) Credential(org.eclipse.jetty.util.security.Credential) UserIdentity(org.eclipse.jetty.server.UserIdentity) ArrayList(java.util.ArrayList) Principal(java.security.Principal)

Aggregations

PropertyUserStore (org.eclipse.jetty.security.PropertyUserStore)2 Principal (java.security.Principal)1 ArrayList (java.util.ArrayList)1 UserIdentity (org.eclipse.jetty.server.UserIdentity)1 Credential (org.eclipse.jetty.util.security.Credential)1