Java: Hopefully working HubListeners.
[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) {
7131093c
FT
15 if(name.contains("pam"))
16 return("pam");
17 return(null);
18 }
19
20 public Command step(Response resp) throws ProtocolException {
21 if((password != null) && (resp.code == 301)) {
22 try {
23 return(new Command("pass", password));
24 } finally {
25 password = null;
26 }
27 } else {
28 throw(new ResponseException(resp, 0));
29 }
30 }
31}