package com.atlassian.bitbucket.internal.ssh.server;

import com.atlassian.bitbucket.auth.SshAuthenticationSuccessContext;
import com.atlassian.bitbucket.user.ApplicationUser;

import javax.annotation.Nonnull;

import static com.google.common.base.Preconditions.checkNotNull;

public class DefaultSshAuthenticationSuccessContext extends DefaultSshAuthenticationContext implements SshAuthenticationSuccessContext {

    private final String command;
    private final ApplicationUser user;

    public DefaultSshAuthenticationSuccessContext(@Nonnull SshAuthentication authenticationResult, @Nonnull String command) {
        super(checkNotNull(authenticationResult, "authenticationResult").getCredentials());

        this.command = checkNotNull("command", command);
        this.user = authenticationResult.getUser();
    }

    @Nonnull
    @Override
    public String getCommand() {
        return command;
    }

    @Nonnull
    @Override
    public ApplicationUser getUser() {
        return user;
    }
}
