// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/ShellException.java
// public class ShellException extends Exception {
// 
//     private static final long serialVersionUID = 7114130906989289480L;
// 
//     public ShellException(String message) {
//         super(message);
//     }
// 
//     public ShellException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/autoconfiguration/Constants.java
// public enum Constants {
// 
//     ;
//     public static final String USER = "__user";
//     public static final String HELP = "help";
//     public static final String USER_ROLES = "__userRoles";
//     public static final String EXECUTE = "__execute";
//     public static final String SHELL_BANNER = "__shellBanner";
// }
// 
// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/autoconfiguration/SshSessionContext.java
// public enum SshSessionContext {
// 
//     ;
// 
//     private static final ThreadLocal<Supplier<File>> USER_DIR_CONTEXT = new ThreadLocal<Supplier<File>>();
//     private static final ThreadLocal<Map<String, Object>> THREAD_CONTEXT = new ThreadLocal<Map<String, Object>>() {
//         @Override
//         protected Map<String, Object> initialValue() {
//             return new HashMap<>();
//         }
//     };
// 
//     public static void put(String key, Object value) {
//         THREAD_CONTEXT.get().put(key, value);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public static <E> E get(String key) {
//         return (E) THREAD_CONTEXT.get().get(key);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public static <E> E remove(String key) {
//         return (E) THREAD_CONTEXT.get().remove(key);
//     }
// 
//     public static boolean containsKey(String key) {
//         return THREAD_CONTEXT.get().containsKey(key);
//     }
// 
//     public static boolean isEmpty() {
//         return THREAD_CONTEXT.get().isEmpty();
//     }
// 
//     public static void clear() {
//         THREAD_CONTEXT.remove();
//         USER_DIR_CONTEXT.remove();
//     }
// 
//     public static void setUserDir(Supplier<File> userDirSupplier) {
//         USER_DIR_CONTEXT.set(userDirSupplier);
//     }
// 
//     public static File getUserDir() {
//         return USER_DIR_CONTEXT.get().get();
//     }
// }
// 
// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/autoconfiguration/SshdShellProperties.java
// @lombok.Data
// public static class Shell {
// 
//     private int port = 8022;
//     private boolean enabled = false;
//     private String username = "admin";
//     private String password;
//     private String publicKeyFile;
//     private String host = "127.0.0.1";
//     private String hostKeyFile = "hostKey.ser";
//     private final Prompt prompt = new Prompt();
//     private final Text text = new Text();
//     private final Auth auth = new Auth();
// 
//     @lombok.Data
//     public static class Prompt {
// 
//         private ColorType color = ColorType.BLACK;
//         private String title = "app";
//     }
// 
//     @lombok.Data
//     public static class Text {
// 
//         private ColorType color = ColorType.BLACK;
//         private ColorType highlightColor = ColorType.YELLOW;
//         private String usageInfoFormat = "%n%-35s%s";
//     }
// 
//     @lombok.Data
//     public static class Auth {
// 
//         public enum AuthType {
//             SIMPLE,
//             AUTH_PROVIDER
//         }
// 
//         private AuthType authType = AuthType.SIMPLE;
//         private String authProviderBeanName;
//     }
// }


import sshd.shell.springboot.autoconfiguration.Constants;
import sshd.shell.springboot.autoconfiguration.SshSessionContext;
import sshd.shell.springboot.autoconfiguration.SshdShellProperties.Shell;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.function.IntConsumer;
import java.util.regex.Matcher;
import org.jline.reader.Completer;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.UserInterruptException;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
import org.jline.utils.AttributedStringBuilder;
import org.jline.utils.AttributedStyle;
import sshd.shell.springboot.ShellException;
                AttributedStyle.DEFAULT.background(properties.getText().getHighlightColor().value));
        SshSessionContext.put(ConsoleIO.TERMINAL, terminal);
    }

    private AttributedStyle getStyle(ColorType color) {
        // This check is done to allow for default contrasting color texts to be shown on black or white screens
        return color == ColorType.BLACK || color == ColorType.WHITE
                ? AttributedStyle.DEFAULT
                : AttributedStyle.DEFAULT.foreground(color.value);
    }

    private void processInputs(LineReader reader, IntConsumer exitCallback) {
        try {
            processUserInput(reader, exitCallback);
        } catch (UserInterruptException ex) {
            // Need not concern with this exception
            log.warn("[{}] Ctrl-C interrupt", SshSessionContext.<String>get(Constants.USER));
            exitCallback.accept(1);
        }
    }

    private void processUserInput(LineReader reader, IntConsumer exitCallback) {
        while (true) {
            try {
                handleUserInput(reader.readLine(prompt).trim());
            } catch (InterruptedException ex) {
                Thread.interrupted();
                ConsoleIO.writeOutput(ex.getMessage());
                exitCallback.accept(0);
                break;
// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/ShellException.java
// public class ShellException extends Exception {
// 
//     private static final long serialVersionUID = 7114130906989289480L;
// 
//     public ShellException(String message) {
//         super(message);
//     }
// 
//     public ShellException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/autoconfiguration/Constants.java
// public enum Constants {
// 
//     ;
//     public static final String USER = "__user";
//     public static final String HELP = "help";
//     public static final String USER_ROLES = "__userRoles";
//     public static final String EXECUTE = "__execute";
//     public static final String SHELL_BANNER = "__shellBanner";
// }
// 
// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/autoconfiguration/SshSessionContext.java
// public enum SshSessionContext {
// 
//     ;
// 
//     private static final ThreadLocal<Supplier<File>> USER_DIR_CONTEXT = new ThreadLocal<Supplier<File>>();
//     private static final ThreadLocal<Map<String, Object>> THREAD_CONTEXT = new ThreadLocal<Map<String, Object>>() {
//         @Override
//         protected Map<String, Object> initialValue() {
//             return new HashMap<>();
//         }
//     };
// 
//     public static void put(String key, Object value) {
//         THREAD_CONTEXT.get().put(key, value);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public static <E> E get(String key) {
//         return (E) THREAD_CONTEXT.get().get(key);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public static <E> E remove(String key) {
//         return (E) THREAD_CONTEXT.get().remove(key);
//     }
// 
//     public static boolean containsKey(String key) {
//         return THREAD_CONTEXT.get().containsKey(key);
//     }
// 
//     public static boolean isEmpty() {
//         return THREAD_CONTEXT.get().isEmpty();
//     }
// 
//     public static void clear() {
//         THREAD_CONTEXT.remove();
//         USER_DIR_CONTEXT.remove();
//     }
// 
//     public static void setUserDir(Supplier<File> userDirSupplier) {
//         USER_DIR_CONTEXT.set(userDirSupplier);
//     }
// 
//     public static File getUserDir() {
//         return USER_DIR_CONTEXT.get().get();
//     }
// }
// 
// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/autoconfiguration/SshdShellProperties.java
// @lombok.Data
// public static class Shell {
// 
//     private int port = 8022;
//     private boolean enabled = false;
//     private String username = "admin";
//     private String password;
//     private String publicKeyFile;
//     private String host = "127.0.0.1";
//     private String hostKeyFile = "hostKey.ser";
//     private final Prompt prompt = new Prompt();
//     private final Text text = new Text();
//     private final Auth auth = new Auth();
// 
//     @lombok.Data
//     public static class Prompt {
// 
//         private ColorType color = ColorType.BLACK;
//         private String title = "app";
//     }
// 
//     @lombok.Data
//     public static class Text {
// 
//         private ColorType color = ColorType.BLACK;
//         private ColorType highlightColor = ColorType.YELLOW;
//         private String usageInfoFormat = "%n%-35s%s";
//     }
// 
//     @lombok.Data
//     public static class Auth {
// 
//         public enum AuthType {
//             SIMPLE,
//             AUTH_PROVIDER
//         }
// 
//         private AuthType authType = AuthType.SIMPLE;
//         private String authProviderBeanName;
//     }
// }


// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/console/TerminalProcessor.java
import sshd.shell.springboot.autoconfiguration.Constants;
import sshd.shell.springboot.autoconfiguration.SshSessionContext;
import sshd.shell.springboot.autoconfiguration.SshdShellProperties.Shell;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.function.IntConsumer;
import java.util.regex.Matcher;
import org.jline.reader.Completer;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.UserInterruptException;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
import org.jline.utils.AttributedStringBuilder;
import org.jline.utils.AttributedStyle;
import sshd.shell.springboot.ShellException;

                AttributedStyle.DEFAULT.background(properties.getText().getHighlightColor().value));
        SshSessionContext.put(ConsoleIO.TERMINAL, terminal);
    }

    private AttributedStyle getStyle(ColorType color) {
        // This check is done to allow for default contrasting color texts to be shown on black or white screens
        return color == ColorType.BLACK || color == ColorType.WHITE
                ? AttributedStyle.DEFAULT
                : AttributedStyle.DEFAULT.foreground(color.value);
    }

    private void processInputs(LineReader reader, IntConsumer exitCallback) {
        try {
            processUserInput(reader, exitCallback);
        } catch (UserInterruptException ex) {
            // Need not concern with this exception
            log.warn("[{}] Ctrl-C interrupt", SshSessionContext.<String>get(Constants.USER));
            exitCallback.accept(1);
        }
    }

    private void processUserInput(LineReader reader, IntConsumer exitCallback) {
        while (true) {
            try {
                handleUserInput(reader.readLine(prompt).trim());
            } catch (InterruptedException ex) {
                Thread.interrupted();
                ConsoleIO.writeOutput(ex.getMessage());
                exitCallback.accept(0);
                break;
            } catch (ShellException | IllegalArgumentException ex) {