1 package org.apache.maven.wagon.providers.ssh.jsch;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import com.jcraft.jsch.UserInfo;
23 import org.apache.maven.wagon.authentication.AuthenticationInfo;
24 import org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo;
25
26
27
28
29
30
31 class WagonUserInfo
32 implements UserInfo
33 {
34 private final InteractiveUserInfo userInfo;
35
36 private String password;
37
38 private String passphrase;
39
40 WagonUserInfo( AuthenticationInfo authInfo, InteractiveUserInfo userInfo )
41 {
42 this.userInfo = userInfo;
43
44 this.password = authInfo.getPassword();
45
46 this.passphrase = authInfo.getPassphrase();
47 }
48
49 public String getPassphrase()
50 {
51 return passphrase;
52 }
53
54 public String getPassword()
55 {
56 return password;
57 }
58
59 public boolean promptPassphrase( String message )
60 {
61 if ( passphrase == null && userInfo != null )
62 {
63 passphrase = userInfo.promptPassphrase( message );
64 }
65 return passphrase != null;
66 }
67
68 public boolean promptPassword( String message )
69 {
70 if ( password == null && userInfo != null )
71 {
72 password = userInfo.promptPassword( message );
73 }
74 return password != null;
75 }
76
77 public boolean promptYesNo( String message )
78 {
79 return userInfo != null && userInfo.promptYesNo( message );
80 }
81
82 public void showMessage( String message )
83 {
84 if ( userInfo != null )
85 {
86 userInfo.showMessage( message );
87 }
88 }
89 }