| 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) { |
| 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 | } |