package be.iminds.ilabt.jfed.util;

/**
 * ExtraInfoCallback: This class is used whenever some function needs extra info.
 * It is a bit aof a HACK, which keeps separation between experimenter GUI (and other GUIS) and core library,
 * but does enable user feedback
 *
 * Supported feedback hacks:
 *   - federation API SA project to use
 */
public class ExtraInfoCallback {
    public static class NoAccountException extends RuntimeException { }

    public interface AnyLoginCallback {
        /** return null if user has no account or provides none. */
        JFedPasswordManager.LoginInfo getLogin(String serviceName, String friendlyName);
    }

    private static AnyLoginCallback anyLoginCallback;

    public static JFedPasswordManager.LoginInfo getAnyLogin(String serviceName, String friendlyName) {
        assert anyLoginCallback != null;
        return anyLoginCallback.getLogin(serviceName, friendlyName);
    }

    public static void setAnyLoginCallback(AnyLoginCallback anyLoginCallback) {
        ExtraInfoCallback.anyLoginCallback = anyLoginCallback;
    }

}
