X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Fjava%2Fdolda%2Fdolcon%2FInteractiveAuth.java;fp=lib%2Fjava%2Fdolda%2Fdolcon%2FInteractiveAuth.java;h=0da9f2a69d7eeb15bd9a6f920836d94f19ee3d4c;hb=7131093cf84874bc7290c18cf34a3ae4d36cf2bd;hp=0000000000000000000000000000000000000000;hpb=59b214d63f3e51473177f573bdc4c8edaa08f9ea;p=doldaconnect.git diff --git a/lib/java/dolda/dolcon/InteractiveAuth.java b/lib/java/dolda/dolcon/InteractiveAuth.java new file mode 100644 index 0000000..0da9f2a --- /dev/null +++ b/lib/java/dolda/dolcon/InteractiveAuth.java @@ -0,0 +1,34 @@ +package dolda.dolcon; + +import java.util.List; +import dolda.dolcon.protocol.Response; +import dolda.dolcon.protocol.Command; + +public abstract class InteractiveAuth implements Authenticator { + public String handles(List name) { + if(name.contains("pam")) + return("pam"); + return(null); + } + + public Command step(Response resp) throws AuthException, ProtocolException, InterruptedException { + if(resp.code == 301) { + return(new Command("pass", promptnoecho(resp.token(0, 0)))); + } else if(resp.code == 302) { + return(new Command("pass", promptecho(resp.token(0, 0)))); + } else if(resp.code == 303) { + info(resp.token(0, 0)); + return(new Command("pass", "")); + } else if(resp.code == 304) { + error(resp.token(0, 0)); + return(new Command("pass", "")); + } else { + throw(new ResponseException(resp, 0)); + } + } + + public abstract String promptecho(String msg) throws AuthException; + public abstract String promptnoecho(String msg) throws AuthException; + public abstract void info(String msg) throws AuthException; + public abstract void error(String msg) throws AuthException; +}