package be.iminds.ilabt.jfed;

import be.iminds.ilabt.jfed.lowlevel.TestbedInfoSource;
import be.iminds.ilabt.jfed.lowlevel.authority.AuthorityFinder;

import be.iminds.ilabt.jfed.lowlevel.authority.JFedTestbedInfoSource;
import be.iminds.ilabt.jfed.preferences.JFedPreferences;
import be.iminds.ilabt.jfed.util.JFedTrustStore;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;

import javax.inject.Singleton;

public class BasicTestbedInfoModule extends AbstractModule {
    public BasicTestbedInfoModule() {
    }

    @Override
    protected void configure() {
    }

    @Provides
    @Singleton
    private AuthorityFinder provideAuthorityFinder(TestbedInfoSource testbedInfoSource, JFedPreferences jFedPreferences) {
        return new AuthorityFinder(testbedInfoSource, jFedPreferences);
    }

    @Provides
    @Singleton
    private TestbedInfoSource provideTestbedInfoSource(JFedTestbedInfoSource jFedTestbedInfoSource, JFedTrustStore trustStore) {
        TestbedInfoSource testbedInfoSource = jFedTestbedInfoSource.get();
        trustStore.addAuthorityCerts(testbedInfoSource);
        return testbedInfoSource;
    }
}
