package com.atlassian.bitbucket.ssh;

import com.atlassian.bitbucket.ssh.validation.SshBaseUrl;
import org.hibernate.validator.constraints.Range;

import javax.annotation.Nullable;

/**
 * The SSH server configuration.
 * @see SshConfigurationService
 */
public interface SshConfiguration {

    /**
     * @return {@code true} if support for SSH access keys is enabled, {@code false} otherwise
     */
    boolean isAccessKeysEnabled();

    /**
     * @return {@code true} if the server is enabled, {@code false} otherwise
     */
    boolean isEnabled();

    /**
     * Retrieves the port where SSH listens for requests.
     * <p>
     * The port range here is restricted to 1024 and higher because, on Unix-like operating systems, binding to ports
     * below 1024 requires the process to be running with root access. Running with root access is not recommended, so
     * those ports are not allowed.
     *
     * @return the port to listen to for SSH requests
     */
    @Range(min = 1024, max = 65535)
    int getPort();

    /**
     * @return the SSH base URL if set, or {@code null} if not
     */
    @Nullable
    @SshBaseUrl
    String getBaseUrl();
}
