diff options
Diffstat (limited to 'src/main/java/com/c2kernel/process/ClientShell.java')
| -rw-r--r-- | src/main/java/com/c2kernel/process/ClientShell.java | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/main/java/com/c2kernel/process/ClientShell.java b/src/main/java/com/c2kernel/process/ClientShell.java index c20c1d4..f0c3a0d 100644 --- a/src/main/java/com/c2kernel/process/ClientShell.java +++ b/src/main/java/com/c2kernel/process/ClientShell.java @@ -3,6 +3,7 @@ package com.c2kernel.process; import java.util.Scanner;
import com.c2kernel.entity.proxy.AgentProxy;
+import com.c2kernel.process.auth.Authenticator;
import com.c2kernel.scripting.Script;
public class ClientShell extends StandardClient {
@@ -10,8 +11,8 @@ public class ClientShell extends StandardClient { AgentProxy user;
Script console;
- public ClientShell(String username, String pass) throws Exception {
- user = Gateway.connect(username, pass);
+ public ClientShell(AgentProxy user) throws Exception {
+ this.user = user;
console = new Script("javascript", user, System.out);
}
@@ -38,27 +39,12 @@ public class ClientShell extends StandardClient { public static void main(String[] args) throws Exception {
Gateway.init(readC2KArgs(args));
- @SuppressWarnings("resource") // closing the scanner closes system.in
- Scanner scan = new Scanner(System.in);
- int loginAttempts = 0;
- ClientShell shell = null;
- while (shell == null && loginAttempts++ < 3) {
- System.out.print("User:");
- String username = scan.nextLine();
- System.out.print("Password:");
- String pass = scan.nextLine();
- try {
- shell = new ClientShell(username, pass);
- } catch (Exception ex) {
- System.err.println(ex.getMessage());
- }
- }
- if (shell == null) {
- System.err.println("Bye");
- System.exit(0);
- }
+ String authClassName = Gateway.getProperty("cli.auth");
+ Class<?> authClass = Class.forName(authClassName);
+ Authenticator auth = (Authenticator)authClass.newInstance();
+ AgentProxy user = auth.authenticate(Gateway.getProperty("Name"));
+ ClientShell shell = new ClientShell(user);
shell.run();
-
}
}
|
