diff --git a/Sponge-SSHD.iml b/Sponge-SSHD.iml
new file mode 100644
index 0000000..9b2687e
--- /dev/null
+++ b/Sponge-SSHD.iml
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+ SPONGE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index edca522..7491322 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,175 +1,189 @@
-
- 4.0.0
- com.ryanmichela
- sshd
- Minecraft-SSHD: The SSH daemon for Minecraft servers.
- 1.3.7
- https://github.com/Justasic/Minecraft-SSHD/
+
+ 4.0.0
-
- 1.8
- UTF-8
-
+ com.ryanmichela
+ Sponge-SSHD
+ 1.3.7
+ jar
+ Sponge-SSHD
+ Sponge port for Minecraft-SSHD. SSH for your minecraft server!
+ https://github.com/Justasic/Minecraft-SSHD/
-
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/groups/public
-
-
+
+ UTF-8
+ 1.8
+ 1.8
+
-
-
-
- GPL2
- http://www.gnu.org/licenses/gpl-2.0.html
-
-
+
+
+ sponge
+ https://repo.spongepowered.org/maven
+
+
-
-
-
- org.bukkit
- bukkit
- 1.14.4-R0.1-SNAPSHOT
-
+
-
- org.apache.sshd
- sshd-core
- 2.3.0
- compile
- jar
-
+
+
+ org.apache.sshd
+ sshd-core
+ 2.3.0
+ compile
+ jar
+
-
- org.apache.sshd
- sshd-mina
- 2.3.0
-
+
+ org.apache.sshd
+ sshd-mina
+ 2.3.0
+
-
- org.apache.sshd
- sshd-common
- 2.3.0
- compile
- jar
-
+
+ org.apache.sshd
+ sshd-common
+ 2.3.0
+ compile
+ jar
+
-
- org.apache.sshd
- sshd-sftp
- 2.3.0
-
+
+ org.apache.sshd
+ sshd-sftp
+ 2.3.0
+
-
- net.i2p.crypto
- eddsa
- 0.3.0
-
-
-
- org.apache.mina
- mina-core
- 2.1.3
-
+
+ net.i2p.crypto
+ eddsa
+ 0.3.0
+
+
+
+ org.apache.mina
+ mina-core
+ 2.1.3
+
-
- org.slf4j
- slf4j-api
- 1.7.28
-
-
-
- org.slf4j
- slf4j-jdk14
- 1.7.28
-
+
+ org.slf4j
+ slf4j-api
+ 1.7.28
+
+
+
+ org.slf4j
+ slf4j-jdk14
+ 1.7.28
+
-
- jline
- jline
- 2.12.1
-
+
+ jline
+ jline
+ 2.12.1
+
-
- org.apache.logging.log4j
- log4j-core
- 2.0
- provided
-
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.0
+ provided
+
-
- org.apache.logging.log4j
- log4j-api
- 2.1
- provided
-
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.1
+ provided
+
-
- commons-codec
- commons-codec
- 1.10
- provided
-
-
+
+ commons-codec
+ commons-codec
+ 1.10
+ provided
+
+
+
+ org.spongepowered
+ spongeapi
+ 7.1.0
+ provided
+
+
+
+ pl.project13.maven
+ git-commit-id-plugin
+ 3.0.1
+ maven-plugin
+
+
-
-
- clean package
+
+
+ clean package
+
+ ${project.name}-${project.version}-${git.commit.id.abbrev}
-
-
- .
- true
- ${basedir}/src/main/resources
-
- plugin.yml
- config.yml
- motd.txt
-
-
-
+
+
+
+
+ pl.project13.maven
+ git-commit-id-plugin
+ 2.2.5
-
-
- maven-assembly-plugin
- 3.1.1
-
-
- package
-
- single
-
-
-
-
- ${project.name}-${project.version}
- false
-
- jar-with-dependencies
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
-
- 1.8
- true
-
-
-
-
-
- jar
+
+ ${project.basedir}/.git
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.2.1
+
+
+ package
+
+ shade
+
+
+ true
+
+
+
+ *:*:*:*
+
+ META-INF/*.RSA
+ META-INF/*.SF
+ META-INF/*.DSA
+
+
+
+ true
+ ${java.io.tmpdir}/dependency-reduced-pom.xml
+
+
+
+
+
+
+ org.codehaus.mojo
+ templating-maven-plugin
+ 1.0-alpha-3
+
+
+ filter-src
+
+ filter-sources
+
+
+
+
+
+
diff --git a/src/main/java/com/ryanmichela/sshd/MkpasswdCommand.java b/src/main/java/com/ryanmichela/sshd/MkpasswdCommand.java
index f4d3408..c071ffc 100644
--- a/src/main/java/com/ryanmichela/sshd/MkpasswdCommand.java
+++ b/src/main/java/com/ryanmichela/sshd/MkpasswdCommand.java
@@ -1,14 +1,23 @@
package com.ryanmichela.sshd;
+/*
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
-
+*/
import java.util.Arrays;
import com.ryanmichela.sshd.Cryptography;
import com.ryanmichela.sshd.SshdPlugin;
+import org.spongepowered.api.command.CommandException;
+import org.spongepowered.api.command.CommandResult;
+import org.spongepowered.api.command.CommandSource;
+import org.spongepowered.api.command.args.CommandContext;
+import org.spongepowered.api.command.spec.CommandExecutor;
+import org.spongepowered.api.entity.living.player.Player;
+import org.spongepowered.api.event.command.TabCompleteEvent;
+import org.spongepowered.api.text.Text;
class MkpasswdCommand implements CommandExecutor
{
@@ -19,16 +28,16 @@ class MkpasswdCommand implements CommandExecutor
// or hash leakages from the user to other connected users. Plus this syntax will show how
// to both use the command and what hashes we support which is important for people who don't
// know how to RTFM. - Justin
- private void SendSyntax(CommandSender sender, boolean invalid)
+ private void SendSyntax(CommandSource sender, boolean invalid)
{
if (invalid)
- sender.sendMessage("\u00A7cInvalid Syntax\u00A7r");
- sender.sendMessage("\u00A7a/mkpasswd \u00A7r");
- sender.sendMessage("\u00A79Supported Hashes: SHA256, PBKDF2, BCRYPT, PLAIN\u00A7r");
+ // So, to send a message in sponge, you must use "Text.of()" for some reason.
+ sender.sendMessage(Text.of("\u00A7cInvalid Syntax\u00A7r"));
+ sender.sendMessage(Text.of("\u00A7a/mkpasswd \u00A7r"));
+ sender.sendMessage(Text.of("\u00A79Supported Hashes: SHA256, PBKDF2, BCRYPT, PLAIN\u00A7r"));
}
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
+ public boolean onCommand(CommandSource sender, TabCompleteEvent.Command command, String label, String[] args)
{
// If we're not mkpasswd, just fuck off.
if (!label.equalsIgnoreCase("mkpasswd"))
@@ -51,7 +60,7 @@ class MkpasswdCommand implements CommandExecutor
return true;
}
- boolean hasperm = (sender instanceof Player) ? ((Player)sender).hasPermission("sshd.mkpasswd") : true;
+ boolean hasperm = (!(sender instanceof Player)) || ((Player) sender).hasPermission("sshd.mkpasswd");
if (hasperm)
{
@@ -62,7 +71,7 @@ class MkpasswdCommand implements CommandExecutor
if (algoritm.equalsIgnoreCase("PLAIN"))
{
// I mean c'mon...
- sender.sendMessage("Bro really? it's literally your unencrypted password...");
+ sender.sendMessage(Text.of("Bro really? it's literally your unencrypted password..."));
return true;
}
else if (algoritm.equalsIgnoreCase("pbkdf2"))
@@ -77,16 +86,23 @@ class MkpasswdCommand implements CommandExecutor
return true;
}
- sender.sendMessage("\u00A79Your Hash: " + hash + "\u00A7r");
+ sender.sendMessage(Text.of("\u00A79Your Hash: " + hash + "\u00A7r"));
}
catch (Exception e)
{
// We're console, just print the stack trace.
e.printStackTrace();
- sender.sendMessage("\u00A7cAn error occured. Please check console for details.\u00A7r");
+ sender.sendMessage(Text.of("\u00A7cAn error occured. Please check console for details.\u00A7r"));
}
}
return true;
}
+
+ // so sponge needed this, still figuring out the sponge API ~ Zach
+ @Override
+ public CommandResult execute(CommandSource src, CommandContext args) throws CommandException
+ {
+ return null;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/ryanmichela/sshd/PublicKeyAuthenticator.java b/src/main/java/com/ryanmichela/sshd/PublicKeyAuthenticator.java
index 36b5027..a36cca7 100644
--- a/src/main/java/com/ryanmichela/sshd/PublicKeyAuthenticator.java
+++ b/src/main/java/com/ryanmichela/sshd/PublicKeyAuthenticator.java
@@ -1,6 +1,5 @@
package com.ryanmichela.sshd;
-import org.apache.commons.lang.ArrayUtils;
import org.apache.sshd.common.config.keys.AuthorizedKeyEntry;
import org.apache.sshd.common.config.keys.PublicKeyEntryResolver;
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
@@ -27,7 +26,7 @@ public class PublicKeyAuthenticator implements PublickeyAuthenticator
{
byte[] keyBytes = key.getEncoded();
File keyFile = new File(authorizedKeysDir, username);
- Integer tries = SshdPlugin.instance.getConfig().getInt("LoginRetries");
+ Integer tries = SshdPlugin.instance.LoginRetries;
if (keyFile.exists())
{
@@ -68,12 +67,12 @@ public class PublicKeyAuthenticator implements PublickeyAuthenticator
}
catch (Exception e)
{
- SshdPlugin.instance.getLogger().severe("Failed to process public key " + keyFile.getAbsolutePath() + " " + e.getMessage());
+ SshdPlugin.instance.getLogger().error("Failed to process public key " + keyFile.getAbsolutePath() + " " + e.getMessage());
}
}
else
{
- SshdPlugin.instance.getLogger().warning("Could not locate public key for " + username
+ SshdPlugin.instance.getLogger().error("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.");
}
diff --git a/src/main/java/com/ryanmichela/sshd/SshdPlugin.java b/src/main/java/com/ryanmichela/sshd/SshdPlugin.java
index d82da58..b3ac356 100644
--- a/src/main/java/com/ryanmichela/sshd/SshdPlugin.java
+++ b/src/main/java/com/ryanmichela/sshd/SshdPlugin.java
@@ -1,10 +1,16 @@
package com.ryanmichela.sshd;
+import com.ryanmichela.sshd.utils.Config;
+import org.spongepowered.api.Sponge;
+import org.spongepowered.api.command.spec.CommandSpec;
+import org.spongepowered.api.plugin.Plugin;
+import org.spongepowered.api.event.Listener;
+import org.spongepowered.api.event.game.state.GameStartedServerEvent;
+
import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory;
-import org.bukkit.plugin.java.JavaPlugin;
import com.ryanmichela.sshd.ConsoleShellFactory;
import com.ryanmichela.sshd.MkpasswdCommand;
@@ -17,53 +23,62 @@ import java.nio.file.Files;
import java.util.Collections;
import java.util.logging.Level;
-/**
- * Copyright 2013 Ryan Michela
- */
-public
-class SshdPlugin extends JavaPlugin
+import com.google.inject.Inject;
+import org.slf4j.Logger;
+import org.spongepowered.api.text.Text;
+
+@Plugin(id = "spongesshd", name = "Sponge-SSHD", version = "1.3.7", description = "Sponge port for Minecraft-SSHD. SSH for your minecraft server!")
+public class SshdPlugin
{
+ String ListenAddress = "";
+ Integer Port = 1025;
+ String Mode = "";
+ Boolean EnableSFTP = true;
+ Integer LoginRetries = 3;
+ String PasswordType = "";
+ // Credentials
- private SshServer sshd;
- public static SshdPlugin instance;
+ private File modConfigFolder;
+ CommandSpec MkpasswdCommand = CommandSpec.builder()
+ .description(Text.of("Make a SSHD password hash"))
+ .permission("sshd.mkpasswd")
+ .build();
- @Override public void onLoad()
+ public File getDataFolder()
+ {
+ return modConfigFolder;
+ }
+
+ private SshServer sshd;
+ public static SshdPlugin instance;
+
+ @Inject
+ public Logger logger;
+
+ public Config config;
+ @Listener
+ public void onServerStart(GameStartedServerEvent event)
{
- saveDefaultConfig();
- File authorizedKeys = new File(getDataFolder(), "authorized_keys");
- if (!authorizedKeys.exists())
- authorizedKeys.mkdirs();
+ instance = this;
+ // Parse our config
+ config = new Config();
+ config.setup();
- try
- {
- File motd = new File(getDataFolder(), "motd.txt");
- if (!motd.exists())
- {
- InputStream link = (getClass().getResourceAsStream("/motd.txt"));
- Files.copy(link, motd.getAbsoluteFile().toPath());
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
+ // Now include it in our dealio here
+ this.Mode = config.configNode.getNode("Mode").getString();
+ this.PasswordType = config.configNode.getNode("PasswordType").getString();
+ this.ListenAddress = config.configNode.getNode("ListenAddress").getString();
+ this.Port = config.configNode.getNode("Port").getInt();
+ this.LoginRetries = config.configNode.getNode("LoginRetries").getInt();
+ this.EnableSFTP = config.configNode.getNode("EnableSFTP").getBoolean();
- // Don't go any lower than INFO or SSHD will cause a stack overflow exception.
- // SSHD will log that it wrote bites to the output stream, which writes
- // bytes to the output stream - ad nauseaum.
- getLogger().setLevel(Level.INFO);
- }
-
- @Override public void onEnable()
- {
- instance = this;
sshd = SshServer.setUpDefaultServer();
- sshd.setPort(getConfig().getInt("Port", 1025));
- String host = getConfig().getString("ListenAddress", "all");
+ sshd.setPort(this.Port);
+ String host = this.ListenAddress;
sshd.setHost(host.equals("all") ? null : host);
- File hostKey = new File(getDataFolder(), "hostkey");
+ File hostKey = new File(getDataFolder(), "hostkey");
File authorizedKeys = new File(getDataFolder(), "authorized_keys");
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(hostKey.toPath()));
@@ -71,14 +86,17 @@ class SshdPlugin extends JavaPlugin
sshd.setPasswordAuthenticator(new ConfigPasswordAuthenticator());
sshd.setPublickeyAuthenticator(new PublicKeyAuthenticator(authorizedKeys));
- if (getConfig().getBoolean("EnableSFTP"))
+
+
+ if (this.EnableSFTP)
{
sshd.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory()));
sshd.setFileSystemFactory(
- new VirtualFileSystemFactory(FileSystems.getDefault().getPath(getDataFolder().getAbsolutePath()).getParent().getParent()));
+ new VirtualFileSystemFactory(FileSystems.getDefault().getPath(getDataFolder().getAbsolutePath()).getParent().getParent()));
}
- this.getCommand("mkpasswd").setExecutor(new MkpasswdCommand());
+ Sponge.getCommandManager().register(instance, MkpasswdCommand, "mkpasswd");
+ //this.getCommand("mkpasswd").setExecutor(new MkpasswdCommand());
sshd.setCommandFactory(new ConsoleCommandFactory());
try
@@ -87,19 +105,14 @@ class SshdPlugin extends JavaPlugin
}
catch (IOException e)
{
- getLogger().log(Level.SEVERE, "Failed to start SSH server! ", e);
+ getLogger().error("Failed to start SSH server! ", e);
}
+
+ logger.info("Successfully running ExamplePlugin!!!");
}
- @Override public void onDisable()
+ public Logger getLogger()
{
- try
- {
- sshd.stop();
- }
- catch (Exception e)
- {
- // do nothing
- }
+ return logger;
}
}
diff --git a/src/main/java/com/ryanmichela/sshd/implementations/SSHDCommandSender.java b/src/main/java/com/ryanmichela/sshd/implementations/SSHDCommandSender.java
index 19a7cdf..193b213 100644
--- a/src/main/java/com/ryanmichela/sshd/implementations/SSHDCommandSender.java
+++ b/src/main/java/com/ryanmichela/sshd/implementations/SSHDCommandSender.java
@@ -1,29 +1,17 @@
package com.ryanmichela.sshd.implementations;
import com.ryanmichela.sshd.SshdPlugin;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Server;
-import org.bukkit.command.CommandSender;
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.conversations.Conversation;
-import org.bukkit.conversations.ConversationAbandonedEvent;
-import org.bukkit.conversations.ManuallyAbandonedConversationCanceller;
-import org.bukkit.permissions.PermissibleBase;
-import org.bukkit.permissions.Permission;
-import org.bukkit.permissions.PermissionAttachment;
-import org.bukkit.permissions.PermissionAttachmentInfo;
-import org.bukkit.plugin.Plugin;
-
import com.ryanmichela.sshd.ConsoleShellFactory;
import com.ryanmichela.sshd.ConsoleLogFormatter;
+import org.spongepowered.api.command.CommandSource;
import java.io.IOException;
import java.util.Arrays;
import java.util.Set;
import java.util.logging.Level;
-public class SSHDCommandSender implements ConsoleCommandSender, CommandSender
+// This is gonna be a mess.
+public class SSHDCommandSender implements ConsoleCommandSender, CommandSource
{
private final PermissibleBase perm = new PermissibleBase(this);
private final SSHDConversationTracker conversationTracker = new SSHDConversationTracker();
diff --git a/src/main/java/com/ryanmichela/sshd/utils/Config.java b/src/main/java/com/ryanmichela/sshd/utils/Config.java
new file mode 100644
index 0000000..732a76d
--- /dev/null
+++ b/src/main/java/com/ryanmichela/sshd/utils/Config.java
@@ -0,0 +1,124 @@
+package com.ryanmichela.sshd.utils;
+
+import ninja.leaping.configurate.loader.ConfigurationLoader;
+import ninja.leaping.configurate.commented.CommentedConfigurationNode;
+import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
+import org.spongepowered.api.config.DefaultConfig;
+import com.google.inject.Inject;
+import com.ryanmichela.sshd.SshdPlugin;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import java.io.IOException;
+
+public class Config
+{
+ // Give us a config!
+ @Inject
+ @DefaultConfig(sharedRoot = true)
+ // idk what to do with this one.
+ private ConfigurationLoader configLoader = HoconConfigurationLoader.builder().setPath(SshdPlugin.instance.defaultConfig).build();
+
+ public CommentedConfigurationNode configNode;
+
+
+ public void setup()
+ {
+ // I'm not sure if this will even work, the sponge config API is confusing.
+ if (!Files.exists((Path) SshdPlugin.instance.config.configLoader.getDefaultOptions()))
+ {
+ try
+ {
+ Files.createFile((Path) SshdPlugin.instance.config.configLoader.getDefaultOptions());
+ this.load();
+ this.populate();
+ this.save();
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ else
+ this.load();
+ }
+
+ public void load()
+ {
+ try
+ {
+ configNode = this.configLoader.load();
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void save()
+ {
+ try
+ {
+ this.configLoader.save(this.configNode);
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void populate()
+ {
+ this.configNode.getNode("ListenAddress").setValue("all").setComment
+ ("The IP addresses(s) the SSH server will listen on. Use a comma separated list for multiple addresses.\n" +
+ "Leave as \"all\" for all addresses.");
+ this.configNode.getNode("Port").setValue("1025").setComment(
+ "# The port the SSH server will listen on. Note that anything above 1024 will require you to run\n" +
+ "# the whole minecraft server with elevated privileges, this is not recommended and you should\n" +
+ "# use iptables to route packets from a lower port.");
+ this.configNode.getNode("Mode").setValue("DEFAULT").setComment("Operational mode. Don't touch if you don't know what you're doing. Can be either DEFAULT or RPC");
+ this.configNode.getNode("EnableSFTP").setValue("true").setComment(
+ "# Enable built-in SFTP server or not. You'll be able to connect and upload/download files via SFTP protocol.\n" +
+ "# Might be useful for testing purposes as well , i. e. docker containers.");
+ this.configNode.getNode("LoginRetries").setValue("3").setComment(
+ "# Number of times a person can fail to use an SSH key or enter a password\n" +
+ "# before it terminates the connection.");
+
+ this.configNode.getNode("PasswordType").setValue("bcrypt").setComment
+ ("########################################################################################\n" +
+ "# By default, only public key authentication is enabled. This is the most secure mode.\n" +
+ "# To authorize a user to login with their public key, install their key using the\n" +
+ "# OpenSSH authorized_keys file format in the authorized_users directory. Name the key\n" +
+ "# file with the user's username and no extension. Note: If you want to let a user have\n" +
+ "# many keys, you can append the keys to their file in authorized_users.\n" +
+ "########################################################################################\n" +
+ "For less secure username and password based authentication, complete the sections below.\n" +
+ "\n" +
+ "# Type of hashing to use for the passwords below.\n" +
+ "# Options are: PLAIN (insecure), bcrypt, pbkdf2, sha256\n" +
+ "#\n" +
+ "# You can use the console/in-game command `/mkpasswd [hash] PASSWORD` to\n" +
+ "# generate a password hash string then copy it for your passwords below.\n" +
+ "# You can also use `/mkpasswd help` to see what algorithms are supported.");
+ //this.configNode.getNode("").setValue("").setComment("");
+
+
+ /*
+ this.Mode = config.configNode.getNode("Mode").getString();
+ this.PasswordType = config.configNode.getNode("PasswordType").getString();
+ this.ListenAddress = config.configNode.getNode("ListenAddress").getString();
+ this.Port = config.configNode.getNode("Port").getInt();
+ this.LoginRetries = config.configNode.getNode("LoginRetries").getInt();
+ this.EnableSFTP = config.configNode.getNode("EnableSFTP").getBoolean();
+
+ this.configNode.getNode("mysql").setComment("MySQL database for Whitelisting");
+ this.configNode.getNode("mysql", "port").setValue(3306).setComment("MySQL server port");
+ this.configNode.getNode("mysql", "host").setValue("localhost").setComment("MySQL server to connect to");
+ this.configNode.getNode("mysql", "database").setValue("WhitelistSync").setComment("MySQL database for Whitelisting");
+ this.configNode.getNode("mysql", "username").setValue("Whitelist").setComment("MySQL username for the database");
+ this.configNode.getNode("mysql", "password").setValue("letmein").setComment("MySQL password for the database");
+ */
+ }
+}
diff --git a/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java b/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java
index 8307da8..0d9d0b6 100644
--- a/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java
+++ b/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java
@@ -12,339 +12,411 @@ import java.util.logging.Level;
/**
* Copyright 2013 Ryan Michela
*/
-public class PluginSlf4jFactory implements ILoggerFactory {
- @Override
- public Logger getLogger(String name) {
- return new PluginSlf4jAdapter(name);
- }
-
- public class PluginSlf4jAdapter implements Logger {
- private String name;
-
- private boolean isEnabled(Level level) {
- return SshdPlugin.instance != null && SshdPlugin.instance.getLogger().isLoggable(level);
- }
-
- private void log(Level level, String s, Object[] objects) {
- if (SshdPlugin.instance != null && isEnabled(level)) {
- FormattingTuple ft = MessageFormatter.arrayFormat(s, objects);
- SshdPlugin.instance.getLogger().log(level, ft.getMessage(), ft.getThrowable());
- }
- }
-
- private void log(Level level, String s, Throwable throwable) {
- if (SshdPlugin.instance != null && isEnabled(level)) {
- SshdPlugin.instance.getLogger().log(level, s, throwable);
- }
- }
-
- public PluginSlf4jAdapter(String name) {
- this.name = name;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public boolean isTraceEnabled() {
- return isEnabled(Level.FINEST);
- }
-
- @Override
- public void trace(String s) {
- trace(s, new Object[]{});
- }
-
- @Override
- public void trace(String s, Object o) {
- trace(s, new Object[]{o});
- }
-
- @Override
- public void trace(String s, Object o, Object o1) {
- trace(s, new Object[]{o, o1});
- }
-
- @Override
- public void trace(String s, Object[] objects) {
- log(Level.FINEST, s, objects);
- }
-
- @Override
- public void trace(String s, Throwable throwable) {
- log(Level.FINEST, s, throwable);
- }
-
- @Override
- public boolean isTraceEnabled(Marker marker) {
- return isTraceEnabled();
- }
-
- @Override
- public void trace(Marker marker, String s) {
- trace(s);
- }
-
- @Override
- public void trace(Marker marker, String s, Object o) {
- trace(s, o);
- }
-
- @Override
- public void trace(Marker marker, String s, Object o, Object o1) {
- trace(s, o, o1);
- }
-
- @Override
- public void trace(Marker marker, String s, Object[] objects) {
- trace(s, objects);
- }
-
- @Override
- public void trace(Marker marker, String s, Throwable throwable) {
- trace(s, throwable);
- }
-
- @Override
- public boolean isDebugEnabled() {
- return isEnabled(Level.FINE);
- }
-
- @Override
- public void debug(String s) {
- debug(s, new Object[]{});
- }
-
- @Override
- public void debug(String s, Object o) {
- debug(s, new Object[]{o});
- }
-
- @Override
- public void debug(String s, Object o, Object o1) {
- debug(s, new Object[]{o, o1});
- }
-
- @Override
- public void debug(String s, Object[] objects) {
- log(Level.FINE, s, objects);
- }
-
- @Override
- public void debug(String s, Throwable throwable) {
- log(Level.FINE, s, throwable);
- }
-
- @Override
- public boolean isDebugEnabled(Marker marker) {
- return isDebugEnabled();
- }
-
- @Override
- public void debug(Marker marker, String s) {
- debug(s);
- }
-
- @Override
- public void debug(Marker marker, String s, Object o) {
- debug(s, o);
- }
-
- @Override
- public void debug(Marker marker, String s, Object o, Object o1) {
- debug(s, o, o1);
- }
-
- @Override
- public void debug(Marker marker, String s, Object[] objects) {
- debug(s, objects);
- }
-
- @Override
- public void debug(Marker marker, String s, Throwable throwable) {
- debug(s, throwable);
- }
-
- @Override
- public boolean isInfoEnabled() {
- return isEnabled(Level.INFO);
- }
-
- @Override
- public void info(String s) {
- info(s, new Object[]{});
- }
-
- @Override
- public void info(String s, Object o) {
- info(s, new Object[]{o});
- }
-
- @Override
- public void info(String s, Object o, Object o1) {
- info(s, new Object[]{o, o1});
- }
-
- @Override
- public void info(String s, Object[] objects) {
- log(Level.INFO, s, objects);
- }
-
- @Override
- public void info(String s, Throwable throwable) {
- log(Level.INFO, s, throwable);
- }
-
- @Override
- public boolean isInfoEnabled(Marker marker) {
- return isInfoEnabled();
- }
-
- @Override
- public void info(Marker marker, String s) {
- info(s);
- }
-
- @Override
- public void info(Marker marker, String s, Object o) {
- info(s, o);
- }
-
- @Override
- public void info(Marker marker, String s, Object o, Object o1) {
- info(s, o, o1);
- }
-
- @Override
- public void info(Marker marker, String s, Object[] objects) {
- info(s, objects);
- }
-
- @Override
- public void info(Marker marker, String s, Throwable throwable) {
- info(s, throwable);
- }
-
- @Override
- public boolean isWarnEnabled() {
- return isEnabled(Level.WARNING);
- }
-
- @Override
- public void warn(String s) {
- warn(s, new Object[]{});
- }
-
- @Override
- public void warn(String s, Object o) {
- warn(s, new Object[]{o});
- }
-
- @Override
- public void warn(String s, Object o, Object o1) {
- warn(s, new Object[]{o, o1});
- }
-
- @Override
- public void warn(String s, Object[] objects) {
- log(Level.WARNING, s, objects);
- }
-
- @Override
- public void warn(String s, Throwable throwable) {
- log(Level.WARNING, s, throwable);
- }
-
- @Override
- public boolean isWarnEnabled(Marker marker) {
- return isWarnEnabled();
- }
-
- @Override
- public void warn(Marker marker, String s) {
- warn(s);
- }
-
- @Override
- public void warn(Marker marker, String s, Object o) {
- warn(s, o);
- }
-
- @Override
- public void warn(Marker marker, String s, Object o, Object o1) {
- warn(s, o, o1);
- }
-
- @Override
- public void warn(Marker marker, String s, Object[] objects) {
- warn(s, objects);
- }
-
- @Override
- public void warn(Marker marker, String s, Throwable throwable) {
- warn(s, throwable);
- }
-
- @Override
- public boolean isErrorEnabled() {
- return isEnabled(Level.SEVERE);
- }
-
- @Override
- public void error(String s) {
- error(s, new Object[]{});
- }
-
- @Override
- public void error(String s, Object o) {
- error(s, new Object[]{o});
- }
-
- @Override
- public void error(String s, Object o, Object o1) {
- error(s, new Object[]{o, o1});
- }
-
- @Override
- public void error(String s, Object[] objects) {
- log(Level.SEVERE, s, objects);
- }
-
- @Override
- public void error(String s, Throwable throwable) {
- log(Level.SEVERE, s, throwable);
- }
-
- @Override
- public boolean isErrorEnabled(Marker marker) {
- return isErrorEnabled();
- }
-
- @Override
- public void error(Marker marker, String s) {
- error(s);
- }
-
- @Override
- public void error(Marker marker, String s, Object o) {
- error(s, o);
- }
-
- @Override
- public void error(Marker marker, String s, Object o, Object o1) {
- error(s, o, o1);
- }
-
- @Override
- public void error(Marker marker, String s, Object[] objects) {
- error(s, objects);
- }
-
- @Override
- public void error(Marker marker, String s, Throwable throwable) {
- error(s, throwable);
- }
- }
+// figure out logging...
+public class PluginSlf4jFactory implements ILoggerFactory
+{
+ @Override
+ public Logger getLogger(String name)
+ {
+ return new PluginSlf4jAdapter(name);
+ }
+
+ public class PluginSlf4jAdapter implements Logger
+ {
+ private String name;
+
+ private boolean isEnabled(Level level)
+ {
+ // ???
+ return SshdPlugin.instance != null && SshdPlugin.instance.logger.isLoggable(level);
+ }
+
+ private void log(Level level, String s, Object[] objects)
+ {
+ if (SshdPlugin.instance != null && isEnabled(level))
+ {
+ FormattingTuple ft = MessageFormatter.arrayFormat(s, objects);
+ SshdPlugin.instance.getLogger().log(level, ft.getMessage(), ft.getThrowable());
+ }
+ }
+
+ private void log(Level level, String s, Throwable throwable)
+ {
+ if (SshdPlugin.instance != null && isEnabled(level))
+ {
+ SshdPlugin.instance.logger.log(level, s, throwable);
+ }
+ }
+
+ public PluginSlf4jAdapter(String name)
+ {
+ this.name = name;
+ }
+
+ @Override
+ public String getName()
+ {
+ return name;
+ }
+
+ @Override
+ public boolean isTraceEnabled()
+ {
+ return isEnabled(Level.FINEST);
+ }
+
+ @Override
+ public void trace(String s)
+ {
+ trace(s, new Object[]{});
+ }
+
+ @Override
+ public void trace(String s, Object o)
+ {
+ trace(s, new Object[]{o});
+ }
+
+ @Override
+ public void trace(String s, Object o, Object o1)
+ {
+ trace(s, new Object[]{o, o1});
+ }
+
+ @Override
+ public void trace(String s, Object[] objects)
+ {
+ log(Level.FINEST, s, objects);
+ }
+
+ @Override
+ public void trace(String s, Throwable throwable)
+ {
+ log(Level.FINEST, s, throwable);
+ }
+
+ @Override
+ public boolean isTraceEnabled(Marker marker)
+ {
+ return isTraceEnabled();
+ }
+
+ @Override
+ public void trace(Marker marker, String s)
+ {
+ trace(s);
+ }
+
+ @Override
+ public void trace(Marker marker, String s, Object o)
+ {
+ trace(s, o);
+ }
+
+ @Override
+ public void trace(Marker marker, String s, Object o, Object o1)
+ {
+ trace(s, o, o1);
+ }
+
+ @Override
+ public void trace(Marker marker, String s, Object[] objects)
+ {
+ trace(s, objects);
+ }
+
+ @Override
+ public void trace(Marker marker, String s, Throwable throwable)
+ {
+ trace(s, throwable);
+ }
+
+ @Override
+ public boolean isDebugEnabled()
+ {
+ return isEnabled(Level.FINE);
+ }
+
+ @Override
+ public void debug(String s)
+ {
+ debug(s, new Object[]{});
+ }
+
+ @Override
+ public void debug(String s, Object o)
+ {
+ debug(s, new Object[]{o});
+ }
+
+ @Override
+ public void debug(String s, Object o, Object o1)
+ {
+ debug(s, new Object[]{o, o1});
+ }
+
+ @Override
+ public void debug(String s, Object[] objects)
+ {
+ log(Level.FINE, s, objects);
+ }
+
+ @Override
+ public void debug(String s, Throwable throwable)
+ {
+ log(Level.FINE, s, throwable);
+ }
+
+ @Override
+ public boolean isDebugEnabled(Marker marker)
+ {
+ return isDebugEnabled();
+ }
+
+ @Override
+ public void debug(Marker marker, String s)
+ {
+ debug(s);
+ }
+
+ @Override
+ public void debug(Marker marker, String s, Object o)
+ {
+ debug(s, o);
+ }
+
+ @Override
+ public void debug(Marker marker, String s, Object o, Object o1)
+ {
+ debug(s, o, o1);
+ }
+
+ @Override
+ public void debug(Marker marker, String s, Object[] objects)
+ {
+ debug(s, objects);
+ }
+
+ @Override
+ public void debug(Marker marker, String s, Throwable throwable)
+ {
+ debug(s, throwable);
+ }
+
+ @Override
+ public boolean isInfoEnabled()
+ {
+ return isEnabled(Level.INFO);
+ }
+
+ @Override
+ public void info(String s)
+ {
+ info(s, new Object[]{});
+ }
+
+ @Override
+ public void info(String s, Object o)
+ {
+ info(s, new Object[]{o});
+ }
+
+ @Override
+ public void info(String s, Object o, Object o1)
+ {
+ info(s, new Object[]{o, o1});
+ }
+
+ @Override
+ public void info(String s, Object[] objects)
+ {
+ log(Level.INFO, s, objects);
+ }
+
+ @Override
+ public void info(String s, Throwable throwable)
+ {
+ log(Level.INFO, s, throwable);
+ }
+
+ @Override
+ public boolean isInfoEnabled(Marker marker)
+ {
+ return isInfoEnabled();
+ }
+
+ @Override
+ public void info(Marker marker, String s)
+ {
+ info(s);
+ }
+
+ @Override
+ public void info(Marker marker, String s, Object o)
+ {
+ info(s, o);
+ }
+
+ @Override
+ public void info(Marker marker, String s, Object o, Object o1)
+ {
+ info(s, o, o1);
+ }
+
+ @Override
+ public void info(Marker marker, String s, Object[] objects)
+ {
+ info(s, objects);
+ }
+
+ @Override
+ public void info(Marker marker, String s, Throwable throwable)
+ {
+ info(s, throwable);
+ }
+
+ @Override
+ public boolean isWarnEnabled()
+ {
+ return isEnabled(Level.WARNING);
+ }
+
+ @Override
+ public void warn(String s)
+ {
+ warn(s, new Object[]{});
+ }
+
+ @Override
+ public void warn(String s, Object o)
+ {
+ warn(s, new Object[]{o});
+ }
+
+ @Override
+ public void warn(String s, Object o, Object o1)
+ {
+ warn(s, new Object[]{o, o1});
+ }
+
+ @Override
+ public void warn(String s, Object[] objects)
+ {
+ log(Level.WARNING, s, objects);
+ }
+
+ @Override
+ public void warn(String s, Throwable throwable)
+ {
+ log(Level.WARNING, s, throwable);
+ }
+
+ @Override
+ public boolean isWarnEnabled(Marker marker)
+ {
+ return isWarnEnabled();
+ }
+
+ @Override
+ public void warn(Marker marker, String s)
+ {
+ warn(s);
+ }
+
+ @Override
+ public void warn(Marker marker, String s, Object o)
+ {
+ warn(s, o);
+ }
+
+ @Override
+ public void warn(Marker marker, String s, Object o, Object o1)
+ {
+ warn(s, o, o1);
+ }
+
+ @Override
+ public void warn(Marker marker, String s, Object[] objects)
+ {
+ warn(s, objects);
+ }
+
+ @Override
+ public void warn(Marker marker, String s, Throwable throwable)
+ {
+ warn(s, throwable);
+ }
+
+ @Override
+ public boolean isErrorEnabled()
+ {
+ return isEnabled(Level.SEVERE);
+ }
+
+ @Override
+ public void error(String s)
+ {
+ error(s, new Object[]{});
+ }
+
+ @Override
+ public void error(String s, Object o)
+ {
+ error(s, new Object[]{o});
+ }
+
+ @Override
+ public void error(String s, Object o, Object o1)
+ {
+ error(s, new Object[]{o, o1});
+ }
+
+ @Override
+ public void error(String s, Object[] objects)
+ {
+ log(Level.SEVERE, s, objects);
+ }
+
+ @Override
+ public void error(String s, Throwable throwable)
+ {
+ log(Level.SEVERE, s, throwable);
+ }
+
+ @Override
+ public boolean isErrorEnabled(Marker marker)
+ {
+ return isErrorEnabled();
+ }
+
+ @Override
+ public void error(Marker marker, String s)
+ {
+ error(s);
+ }
+
+ @Override
+ public void error(Marker marker, String s, Object o)
+ {
+ error(s, o);
+ }
+
+ @Override
+ public void error(Marker marker, String s, Object o, Object o1)
+ {
+ error(s, o, o1);
+ }
+
+ @Override
+ public void error(Marker marker, String s, Object[] objects)
+ {
+ error(s, objects);
+ }
+
+ @Override
+ public void error(Marker marker, String s, Throwable throwable)
+ {
+ error(s, throwable);
+ }
+ }
}