Search in sources :

Example 1 with GitlabManagerPrivileged

use of de.catma.repository.git.managers.GitlabManagerPrivileged in project catma by forTEXT.

the class LocalUserLoginService method loggedInFromThirdParty.

@Override
public IRemoteGitManagerRestricted loggedInFromThirdParty(String identifier, String provider, String email, String name) throws IOException {
    IRemoteGitManagerPrivileged gitlabManagerPrivileged = new GitlabManagerPrivileged();
    Pair<GitUser, String> userAndToken = gitlabManagerPrivileged.acquireImpersonationToken(identifier, provider, email, name);
    api = iRemoteGitManagerFactory.createFromImpersonationToken(userAndToken.getSecond());
    return api;
}
Also used : IRemoteGitManagerPrivileged(de.catma.repository.git.interfaces.IRemoteGitManagerPrivileged) GitlabManagerPrivileged(de.catma.repository.git.managers.GitlabManagerPrivileged) GitUser(de.catma.repository.git.GitUser)

Example 2 with GitlabManagerPrivileged

use of de.catma.repository.git.managers.GitlabManagerPrivileged in project catma by forTEXT.

the class LocalUserLoginService method login.

@Override
public IRemoteGitManagerRestricted login(String username, String password) throws IOException {
    String user = System.getProperty("user.name");
    Pair<GitUser, String> userTokenPair = new GitlabManagerPrivileged().acquireImpersonationToken(user, "catma", user + "@catma.de", user);
    api = iRemoteGitManagerFactory.createFromImpersonationToken(userTokenPair.getSecond());
    return api;
}
Also used : GitlabManagerPrivileged(de.catma.repository.git.managers.GitlabManagerPrivileged) GitUser(de.catma.repository.git.GitUser)

Example 3 with GitlabManagerPrivileged

use of de.catma.repository.git.managers.GitlabManagerPrivileged in project catma by forTEXT.

the class Vaadin8InitializationService method newEntryPage.

@Override
public Component newEntryPage(EventBus eventBus, LoginService loginService, HazelCastService hazelcastService, SqliteService sqliteService) throws IOException {
    IRemoteGitManagerRestricted api = loginService.getAPI();
    if (api != null) {
        GitProjectManager projectManager = new GitProjectManager(CATMAPropertyKey.GitBasedRepositoryBasePath.getValue(), api, // noop deletion handler
        (projectId) -> {
        }, acquireBackgroundService(), eventBus);
        hazelcastService.start();
        GitlabManagerPrivileged gitlabManagerPrivileged = new GitlabManagerPrivileged();
        boolean termsOfUseConsentGiven = gitlabManagerPrivileged.updateLastLoginAndGetTermsOfUseConsent(api.getUser());
        return new MainView(projectManager, new CatmaHeader(eventBus, loginService, gitlabManagerPrivileged), eventBus, api, loginService, termsOfUseConsentGiven, consent -> gitlabManagerPrivileged.setTermsOfUseConsentGiven(api.getUser(), consent));
    } else {
        return new NotLoggedInMainView(this, loginService, hazelcastService, sqliteService, eventBus);
    }
}
Also used : CatmaHeader(de.catma.ui.module.main.CatmaHeader) GitProjectManager(de.catma.repository.git.GitProjectManager) IRemoteGitManagerRestricted(de.catma.repository.git.interfaces.IRemoteGitManagerRestricted) GitlabManagerPrivileged(de.catma.repository.git.managers.GitlabManagerPrivileged) NotLoggedInMainView(de.catma.ui.module.main.NotLoggedInMainView) MainView(de.catma.ui.module.main.MainView) NotLoggedInMainView(de.catma.ui.module.main.NotLoggedInMainView)

Example 4 with GitlabManagerPrivileged

use of de.catma.repository.git.managers.GitlabManagerPrivileged in project catma by forTEXT.

the class GitlabLoginService method loggedInFromThirdParty.

@Override
public IRemoteGitManagerRestricted loggedInFromThirdParty(String identifier, String provider, String email, String name) throws IOException {
    IRemoteGitManagerPrivileged gitlabManagerPrivileged = new GitlabManagerPrivileged();
    Pair<GitUser, String> userAndToken = gitlabManagerPrivileged.acquireImpersonationToken(identifier, provider, email, name);
    api = iRemoteGitManagerFactory.createFromImpersonationToken(userAndToken.getSecond());
    logLoginEvent("third party");
    return api;
}
Also used : IRemoteGitManagerPrivileged(de.catma.repository.git.interfaces.IRemoteGitManagerPrivileged) GitlabManagerPrivileged(de.catma.repository.git.managers.GitlabManagerPrivileged) GitUser(de.catma.repository.git.GitUser)

Example 5 with GitlabManagerPrivileged

use of de.catma.repository.git.managers.GitlabManagerPrivileged in project catma by forTEXT.

the class GitProjectHandlerTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    // create a fake CATMA user which we'll use to instantiate GitlabManagerRestricted (using the corresponding impersonation token) & JGitRepoManager
    Integer randomUserId = Integer.parseInt(RandomStringUtils.randomNumeric(3));
    String username = String.format("testuser-%s", randomUserId);
    String email = String.format("%s@catma.de", username);
    String name = String.format("Test User %s", randomUserId);
    gitlabManagerPrivileged = new GitlabManagerPrivileged();
    String impersonationToken = gitlabManagerPrivileged.acquireImpersonationToken(username, "catma", email, name).getSecond();
    EventBus mockEventBus = mock(EventBus.class);
    BackgroundService mockBackgroundService = mock(BackgroundService.class);
    gitlabManagerRestricted = new GitlabManagerRestricted(mockEventBus, mockBackgroundService, impersonationToken);
}
Also used : BackgroundService(de.catma.backgroundservice.BackgroundService) GitlabManagerPrivileged(de.catma.repository.git.managers.GitlabManagerPrivileged) GitlabManagerRestricted(de.catma.repository.git.managers.GitlabManagerRestricted) EventBus(com.google.common.eventbus.EventBus) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

GitlabManagerPrivileged (de.catma.repository.git.managers.GitlabManagerPrivileged)6 GitUser (de.catma.repository.git.GitUser)3 EventBus (com.google.common.eventbus.EventBus)2 BackgroundService (de.catma.backgroundservice.BackgroundService)2 IRemoteGitManagerPrivileged (de.catma.repository.git.interfaces.IRemoteGitManagerPrivileged)2 GitlabManagerRestricted (de.catma.repository.git.managers.GitlabManagerRestricted)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 GitProjectManager (de.catma.repository.git.GitProjectManager)1 IRemoteGitManagerRestricted (de.catma.repository.git.interfaces.IRemoteGitManagerRestricted)1 CatmaHeader (de.catma.ui.module.main.CatmaHeader)1 MainView (de.catma.ui.module.main.MainView)1 NotLoggedInMainView (de.catma.ui.module.main.NotLoggedInMainView)1