1 package org.apache.maven.wagon.providers.ssh;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import org.apache.sshd.server.PasswordAuthenticator;
22 import org.apache.sshd.server.session.ServerSession;
23 import org.codehaus.plexus.util.StringUtils;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28
29
30
31 public class TestPasswordAuthenticator
32 implements PasswordAuthenticator
33 {
34 public List<PasswordAuthenticatorRequest> passwordAuthenticatorRequests =
35 new ArrayList<PasswordAuthenticatorRequest>();
36
37 public boolean authenticate( String username, String password, ServerSession session )
38 {
39 passwordAuthenticatorRequests.add( new PasswordAuthenticatorRequest( username, password ) );
40 return StringUtils.equals( username, TestData.getUserName() ) && StringUtils.equals( password,
41 TestData.getUserPassword() );
42 }
43
44 public static class PasswordAuthenticatorRequest
45 {
46 public String username;
47
48 public String password;
49
50 public PasswordAuthenticatorRequest( String username, String password )
51 {
52 this.username = username;
53 this.password = password;
54 }
55
56 @Override
57 public String toString()
58 {
59 final StringBuilder sb = new StringBuilder();
60 sb.append( "PasswordAuthenticatorRequest" );
61 sb.append( "{username='" ).append( username ).append( '\'' );
62 sb.append( ", password='" ).append( password ).append( '\'' );
63 sb.append( '}' );
64 return sb.toString();
65 }
66 }
67 }