mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GP-3966 improved console password prompt
This commit is contained in:
parent
902c5f72b8
commit
fc0a541562
1 changed files with 23 additions and 3 deletions
|
@ -17,12 +17,13 @@ package ghidra.framework.client;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.Authenticator;
|
import java.net.*;
|
||||||
import java.net.PasswordAuthentication;
|
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
|
|
||||||
import javax.security.auth.callback.*;
|
import javax.security.auth.callback.*;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import ghidra.framework.remote.AnonymousCallback;
|
import ghidra.framework.remote.AnonymousCallback;
|
||||||
import ghidra.framework.remote.SSHSignatureCallback;
|
import ghidra.framework.remote.SSHSignatureCallback;
|
||||||
import ghidra.framework.remote.security.SSHKeyManager;
|
import ghidra.framework.remote.security.SSHKeyManager;
|
||||||
|
@ -45,12 +46,31 @@ public class HeadlessClientAuthenticator implements ClientAuthenticator {
|
||||||
@Override
|
@Override
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
Msg.debug(this, "PasswordAuthentication requested for " + getRequestingURL());
|
Msg.debug(this, "PasswordAuthentication requested for " + getRequestingURL());
|
||||||
|
String usage = null;
|
||||||
String prompt = getRequestingPrompt();
|
String prompt = getRequestingPrompt();
|
||||||
|
if ("security".equals(prompt)) {
|
||||||
|
prompt = null; // squash generic "security" prompt
|
||||||
|
}
|
||||||
|
URL requestingURL = getRequestingURL();
|
||||||
|
if (requestingURL != null) {
|
||||||
|
URL minimalURL = null;
|
||||||
|
try {
|
||||||
|
minimalURL = new URL(requestingURL, "/");
|
||||||
|
}
|
||||||
|
catch (MalformedURLException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
usage = "Access password requested for " +
|
||||||
|
(minimalURL != null ? minimalURL.toExternalForm()
|
||||||
|
: requestingURL.getAuthority());
|
||||||
|
prompt = "Password:";
|
||||||
|
}
|
||||||
if (prompt == null) {
|
if (prompt == null) {
|
||||||
|
// Assume Ghidra Server access
|
||||||
String host = getRequestingHost();
|
String host = getRequestingHost();
|
||||||
prompt = (host != null ? (host + " ") : "") + "(" + userID + ") Password:";
|
prompt = (host != null ? (host + " ") : "") + "(" + userID + ") Password:";
|
||||||
}
|
}
|
||||||
return new PasswordAuthentication(userID, getPassword(null, prompt));
|
return new PasswordAuthentication(userID, getPassword(usage, prompt));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue