/*
 * @author Ranides Atterwim {@literal <ranides@gmail.com>}
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.credentials;

import java.net.URI;
import net.ranides.assira.collection.prototype.GenericMap;
import net.ranides.assira.collection.query.CQuery;

/**
 * Container for user credentials.
 * Offers two functionalities: find users by query & find users by matching URI
 *
 * For example, maven credential for "servers" can be represented by this store:
 *  - "find by query" will search by "username" directly inside "settings.xml"
 *  - "find by URL" will search inside "pom.xml" for "server.id" matching URL
 *    then it will use this "server.id" to load credentials from "settings.xml"
 *
 * @author Ranides Atterwim {@literal <ranides@gmail.com>}
 */
public interface UserStore {

    /**
     * Find all users matching specified ID.
     * Quite often credentials are associated with specific domain, you can use this function
     * to find them.
     *
     * @param uri uri
     * @return list of matching users
     */
    CQuery<GenericMap<String>> find(URI uri);

    /**
     * Find all users matching query.
     * Most probably, userstore will return users with "login" identical to specified argument.
     * Please note, that this semantic is not guaranteed.
     * For example, some stores would support wildcards, check emails, full names, aliases, etc
     *
     * @param query query
     * @return list of matching users
     */
    CQuery<GenericMap<String>> find(String query);
    
}
