48
48
import net .schmizz .sshj .userauth .keyprovider .KeyFormat ;
49
49
import net .schmizz .sshj .userauth .keyprovider .KeyProviderUtil ;
50
50
import net .schmizz .sshj .userauth .keyprovider .OpenSSHKeyFile ;
51
- import net .schmizz .sshj .userauth .keyprovider .PKCS5KeyFile ;
52
51
import net .schmizz .sshj .userauth .keyprovider .PKCS8KeyFile ;
53
52
import net .schmizz .sshj .userauth .keyprovider .PuTTYKeyFile ;
54
53
import net .schmizz .sshj .userauth .password .PasswordFinder ;
@@ -76,39 +75,39 @@ public String authenticate(final Host bookmark, final LoginCallback prompt, fina
76
75
log .info (String .format ("Reading private key %s with key format %s" , identity , format ));
77
76
}
78
77
provider .init (
79
- new InputStreamReader (identity .getInputStream (), StandardCharsets .UTF_8 ),
80
- new PasswordFinder () {
81
- @ Override
82
- public char [] reqPassword (Resource <?> resource ) {
83
- if (StringUtils .isEmpty (credentials .getIdentityPassphrase ())) {
84
- try {
85
- // Use password prompt
86
- final Credentials input = prompt .prompt (bookmark ,
87
- LocaleFactory .localizedString ("Private key password protected" , "Credentials" ),
88
- String .format ("%s (%s)" ,
89
- LocaleFactory .localizedString ("Enter the passphrase for the private key file" , "Credentials" ),
90
- identity .getAbbreviatedPath ()),
91
- new LoginOptions ()
92
- .icon (bookmark .getProtocol ().disk ())
93
- .user (false ).password (true )
94
- );
95
- credentials .setSaved (input .isSaved ());
96
- credentials .setIdentityPassphrase (input .getPassword ());
97
- }
98
- catch (LoginCanceledException e ) {
99
- // Return null if user cancels
100
- return StringUtils .EMPTY .toCharArray ();
78
+ new InputStreamReader (identity .getInputStream (), StandardCharsets .UTF_8 ),
79
+ new PasswordFinder () {
80
+ @ Override
81
+ public char [] reqPassword (Resource <?> resource ) {
82
+ if (StringUtils .isEmpty (credentials .getIdentityPassphrase ())) {
83
+ try {
84
+ // Use password prompt
85
+ final Credentials input = prompt .prompt (bookmark ,
86
+ LocaleFactory .localizedString ("Private key password protected" , "Credentials" ),
87
+ String .format ("%s (%s)" ,
88
+ LocaleFactory .localizedString ("Enter the passphrase for the private key file" , "Credentials" ),
89
+ identity .getAbbreviatedPath ()),
90
+ new LoginOptions ()
91
+ .icon (bookmark .getProtocol ().disk ())
92
+ .user (false ).password (true )
93
+ );
94
+ credentials .setSaved (input .isSaved ());
95
+ credentials .setIdentityPassphrase (input .getPassword ());
96
+ }
97
+ catch (LoginCanceledException e ) {
98
+ // Return null if user cancels
99
+ return StringUtils .EMPTY .toCharArray ();
100
+ }
101
101
}
102
+ config .setPassword (credentials .getIdentityPassphrase ());
103
+ return credentials .getIdentityPassphrase ().toCharArray ();
102
104
}
103
- config .setPassword (credentials .getIdentityPassphrase ());
104
- return credentials .getIdentityPassphrase ().toCharArray ();
105
- }
106
105
107
- @ Override
108
- public boolean shouldRetry (Resource <?> resource ) {
109
- return false ;
106
+ @ Override
107
+ public boolean shouldRetry (Resource <?> resource ) {
108
+ return false ;
109
+ }
110
110
}
111
- }
112
111
);
113
112
return this .computeFingerprint (provider );
114
113
}
@@ -137,8 +136,6 @@ private String computeFingerprint(final FileKeyProvider provider) throws Backgro
137
136
138
137
private FileKeyProvider buildProvider (final Local identity , final KeyFormat format ) throws InteroperabilityException {
139
138
switch (format ) {
140
- case PKCS5 :
141
- return new PKCS5KeyFile .Factory ().create ();
142
139
case PKCS8 :
143
140
return new PKCS8KeyFile .Factory ().create ();
144
141
case OpenSSH :
@@ -156,8 +153,8 @@ private KeyFormat detectKeyFormat(final Local identity) throws BackgroundExcepti
156
153
final KeyFormat format ;
157
154
try (InputStream is = identity .getInputStream ()) {
158
155
format = KeyProviderUtil .detectKeyFileFormat (
159
- new InputStreamReader (is , StandardCharsets .UTF_8 ),
160
- true );
156
+ new InputStreamReader (is , StandardCharsets .UTF_8 ),
157
+ true );
161
158
}
162
159
catch (IOException e ) {
163
160
throw new DefaultIOExceptionMappingService ().map (e );
0 commit comments