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