Fix codestyle
This commit is contained in:
parent
8f6319d979
commit
7330b1eead
@ -10,6 +10,7 @@ import java.util.Map;
|
||||
* Copyright 2013 Ryan Michela
|
||||
*/
|
||||
public class ConfigPasswordAuthenticator implements PasswordAuthenticator {
|
||||
|
||||
private Map<String, Integer> failCounts = new HashMap<String, Integer>();
|
||||
|
||||
@Override
|
||||
|
@ -4,15 +4,16 @@ package com.ryanmichela.sshd;
|
||||
* Copyright 2013 Ryan Michela
|
||||
*/
|
||||
|
||||
import jline.console.completer.Completer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import jline.console.completer.Completer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ConsoleCommandCompleter implements Completer {
|
||||
|
||||
public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) {
|
||||
Waitable<List<String>> waitable = new Waitable<List<String>>() {
|
||||
@Override
|
||||
|
@ -14,12 +14,14 @@ import java.io.OutputStream;
|
||||
* Copyright 2013 Ryan Michela
|
||||
*/
|
||||
public class ConsoleCommandFactory implements CommandFactory {
|
||||
|
||||
@Override
|
||||
public Command createCommand(String command) {
|
||||
return new ConsoleCommand(command);
|
||||
}
|
||||
|
||||
public class ConsoleCommand implements Command {
|
||||
|
||||
private String command;
|
||||
|
||||
private InputStream in;
|
||||
@ -50,7 +52,8 @@ public class ConsoleCommandFactory implements CommandFactory {
|
||||
@Override
|
||||
public void start(Environment environment) throws IOException {
|
||||
try {
|
||||
SshdPlugin.instance.getLogger().info("[U: " + environment.getEnv().get(Environment.ENV_USER) + "] " + command);
|
||||
SshdPlugin.instance.getLogger()
|
||||
.info("[U: " + environment.getEnv().get(Environment.ENV_USER) + "] " + command);
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
} catch (Exception e) {
|
||||
SshdPlugin.instance.getLogger().severe("Error processing command from SSH -" + e.getMessage());
|
||||
|
@ -54,20 +54,29 @@ public class ConsoleLogFormatter extends Formatter {
|
||||
// ORIGINAL CODE FROM org.bukkit.craftbukkit.command.ColouredConsoleSender
|
||||
final Map<ChatColor, String> replacements = new EnumMap<>(ChatColor.class);
|
||||
|
||||
replacements.put(ChatColor.BLACK, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.BLACK).boldOff().toString());
|
||||
replacements.put(ChatColor.DARK_BLUE, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.BLUE).boldOff().toString());
|
||||
replacements.put(ChatColor.DARK_GREEN, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.GREEN).boldOff().toString());
|
||||
replacements.put(ChatColor.DARK_AQUA, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.CYAN).boldOff().toString());
|
||||
replacements.put(ChatColor.DARK_RED, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.RED).boldOff().toString());
|
||||
replacements.put(ChatColor.DARK_PURPLE, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.MAGENTA).boldOff().toString());
|
||||
replacements.put(ChatColor.GOLD, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.YELLOW).boldOff().toString());
|
||||
replacements
|
||||
.put(ChatColor.BLACK, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.BLACK).boldOff().toString());
|
||||
replacements
|
||||
.put(ChatColor.DARK_BLUE, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.BLUE).boldOff().toString());
|
||||
replacements.put(ChatColor.DARK_GREEN,
|
||||
Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.GREEN).boldOff().toString());
|
||||
replacements
|
||||
.put(ChatColor.DARK_AQUA, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.CYAN).boldOff().toString());
|
||||
replacements
|
||||
.put(ChatColor.DARK_RED, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.RED).boldOff().toString());
|
||||
replacements.put(ChatColor.DARK_PURPLE,
|
||||
Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.MAGENTA).boldOff().toString());
|
||||
replacements
|
||||
.put(ChatColor.GOLD, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.YELLOW).boldOff().toString());
|
||||
replacements.put(ChatColor.GRAY, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.WHITE).boldOff().toString());
|
||||
replacements.put(ChatColor.DARK_GRAY, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.BLACK).bold().toString());
|
||||
replacements
|
||||
.put(ChatColor.DARK_GRAY, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.BLACK).bold().toString());
|
||||
replacements.put(ChatColor.BLUE, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.BLUE).bold().toString());
|
||||
replacements.put(ChatColor.GREEN, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.GREEN).bold().toString());
|
||||
replacements.put(ChatColor.AQUA, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.CYAN).bold().toString());
|
||||
replacements.put(ChatColor.RED, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.RED).bold().toString());
|
||||
replacements.put(ChatColor.LIGHT_PURPLE, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.MAGENTA).bold().toString());
|
||||
replacements.put(ChatColor.LIGHT_PURPLE,
|
||||
Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.MAGENTA).bold().toString());
|
||||
replacements.put(ChatColor.YELLOW, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.YELLOW).bold().toString());
|
||||
replacements.put(ChatColor.WHITE, Ansi.ansi().a(Ansi.Attribute.RESET).fg(Ansi.Color.WHITE).bold().toString());
|
||||
replacements.put(ChatColor.MAGIC, Ansi.ansi().a(Ansi.Attribute.BLINK_SLOW).toString());
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.ryanmichela.sshd;
|
||||
|
||||
import org.apache.sshd.common.SshException;
|
||||
import jline.console.ConsoleReader;
|
||||
|
||||
import org.apache.sshd.common.SshException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@ -12,6 +11,7 @@ import java.util.logging.*;
|
||||
* Copyright 2013 Ryan Michela
|
||||
*/
|
||||
public class FlushyStreamHandler extends StreamHandler {
|
||||
|
||||
private ConsoleReader reader;
|
||||
|
||||
public FlushyStreamHandler(OutputStream out, Formatter formatter, ConsoleReader reader) {
|
||||
|
@ -13,6 +13,7 @@ import java.security.spec.RSAPublicKeySpec;
|
||||
* Copyright 2013 Ryan Michela
|
||||
*/
|
||||
public class PemDecoder extends java.io.BufferedReader {
|
||||
|
||||
private static final String BEGIN = "^-+\\s*BEGIN.+";
|
||||
private static final String END = "^-+\\s*END.+";
|
||||
private static final String COMMENT = "Comment:";
|
||||
|
@ -12,6 +12,7 @@ import java.security.PublicKey;
|
||||
* Copyright 2013 Ryan Michela
|
||||
*/
|
||||
public class PublicKeyAuthenticator implements PublickeyAuthenticator {
|
||||
|
||||
private File authorizedKeysDir;
|
||||
|
||||
public PublicKeyAuthenticator(File authorizedKeysDir) {
|
||||
@ -39,10 +40,13 @@ public class PublicKeyAuthenticator implements PublickeyAuthenticator {
|
||||
SshdPlugin.instance.getLogger().severe("Failed to parse PEM file. " + keyFile.getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SshdPlugin.instance.getLogger().severe("Failed to process public key " + keyFile.getAbsolutePath() + ". " + e.getMessage());
|
||||
SshdPlugin.instance.getLogger()
|
||||
.severe("Failed to process public key " + keyFile.getAbsolutePath() + ". " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
SshdPlugin.instance.getLogger().warning("Could not locate public key for " + username + ". Make sure the user's key is named the same as their user name without a file extension.");
|
||||
SshdPlugin.instance.getLogger().warning("Could not locate public key for " + username +
|
||||
". Make sure the user's key is named the same as their user name " +
|
||||
"without a file extension.");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -8,6 +8,7 @@ import java.lang.reflect.Modifier;
|
||||
* Copyright 2013 Ryan Michela
|
||||
*/
|
||||
public class ReflectionUtil {
|
||||
|
||||
public static void setProtectedValue(Object o, String field, Object newValue) {
|
||||
setProtectedValue(o.getClass(), o, field, newValue);
|
||||
}
|
||||
@ -87,8 +88,7 @@ public class ReflectionUtil {
|
||||
Method m = c.getDeclaredMethod(method, pTypes);
|
||||
m.setAccessible(true);
|
||||
return m.invoke(o, args);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
System.out.println("*** " + c.getName() + "." + method + "(): " + ex);
|
||||
return null;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import java.util.logging.Level;
|
||||
* Copyright 2013 Ryan Michela
|
||||
*/
|
||||
public class SshdPlugin extends JavaPlugin {
|
||||
|
||||
private SshServer sshd;
|
||||
public static SshdPlugin instance;
|
||||
|
||||
|
@ -14,6 +14,7 @@ import java.util.logging.StreamHandler;
|
||||
* Copyright 2014 Ryan Michela
|
||||
*/
|
||||
public class StreamHandlerAppender implements Appender {
|
||||
|
||||
private StreamHandler streamHandler;
|
||||
private UUID uuid;
|
||||
|
||||
|
@ -6,11 +6,13 @@ import java.util.concurrent.ExecutionException;
|
||||
* Copyright 2013 Ryan Michela
|
||||
*/
|
||||
public abstract class Waitable<T> implements Runnable {
|
||||
|
||||
private enum Status {
|
||||
WAITING,
|
||||
RUNNING,
|
||||
FINISHED,
|
||||
}
|
||||
|
||||
Throwable t = null;
|
||||
T value = null;
|
||||
Status status = Status.WAITING;
|
||||
|
Loading…
Reference in New Issue
Block a user