Commit | Line | Data |
---|---|---|
7131093c FT |
1 | package dolda.dolcon; |
2 | ||
3 | import java.util.List; | |
4 | import dolda.dolcon.protocol.Response; | |
5 | import dolda.dolcon.protocol.Command; | |
6 | ||
7 | public 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 | } |