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 | 0 | public class TestPasswordAuthenticator |
32 | |
implements PasswordAuthenticator |
33 | |
{ |
34 | 0 | public List<PasswordAuthenticatorRequest> passwordAuthenticatorRequests = |
35 | |
new ArrayList<PasswordAuthenticatorRequest>(); |
36 | |
|
37 | |
public boolean authenticate( String username, String password, ServerSession session ) |
38 | |
{ |
39 | 0 | passwordAuthenticatorRequests.add( new PasswordAuthenticatorRequest( username, password ) ); |
40 | 0 | return StringUtils.equals( username, TestData.getUserName() ) && StringUtils.equals( password, |
41 | |
TestData.getUserPassword() ); |
42 | |
} |
43 | |
|
44 | 0 | public static class PasswordAuthenticatorRequest |
45 | |
{ |
46 | |
public String username; |
47 | |
|
48 | |
public String password; |
49 | |
|
50 | |
public PasswordAuthenticatorRequest( String username, String password ) |
51 | 0 | { |
52 | 0 | this.username = username; |
53 | 0 | this.password = password; |
54 | 0 | } |
55 | |
|
56 | |
@Override |
57 | |
public String toString() |
58 | |
{ |
59 | 0 | final StringBuilder sb = new StringBuilder(); |
60 | 0 | sb.append( "PasswordAuthenticatorRequest" ); |
61 | 0 | sb.append( "{username='" ).append( username ).append( '\'' ); |
62 | 0 | sb.append( ", password='" ).append( password ).append( '\'' ); |
63 | 0 | sb.append( '}' ); |
64 | 0 | return sb.toString(); |
65 | |
} |
66 | |
} |
67 | |
} |