Java: Added a session handler with authentication capability.
[doldaconnect.git] / lib / java / dolda / dolcon / PasswordAuth.java
CommitLineData
7131093c
FT
1package dolda.dolcon;
2
3import java.util.List;
4import dolda.dolcon.protocol.Response;
5import dolda.dolcon.protocol.Command;
6
7public class PasswordAuth implements Authenticator {
8 private String password;
9
10 public PasswordAuth(String password) {
11 this.password = password;
12 }
13
14 public String handles(List<String> name) {
15 System.out.println(name);
16 if(name.contains("pam"))
17 return("pam");
18 return(null);
19 }
20
21 public Command step(Response resp) throws ProtocolException {
22 if((password != null) && (resp.code == 301)) {
23 try {
24 return(new Command("pass", password));
25 } finally {
26 password = null;
27 }
28 } else {
29 throw(new ResponseException(resp, 0));
30 }
31 }
32}