Methods Summary |
---|
private static final java.lang.String | get(java.io.BufferedReader in, java.lang.String name, java.lang.String value)
PrintStream p = System.out;
p.print(name + ": ");
if (value != null)
p.print("[" + value + "] ");
p.flush();
try {
String s = in.readLine();
if (s.length() == 0)
return value;
else
return s;
} catch (IOException e) {
return value;
}
|
protected javax.mail.PasswordAuthentication | getPasswordAuthentication()
BufferedReader in = new BufferedReader(
new InputStreamReader((System.in)));
StringBuffer sb = new StringBuffer();
sb.append("Connecting to ");
sb.append(getRequestingProtocol());
sb.append(" mail service on host ");
sb.append(getRequestingSite().getHostName());
int port = getRequestingPort();
if (port > 0) {
sb.append(", port ");
sb.append(port);
}
sb.append(".");
System.out.println(sb.toString());
String prompt = getRequestingPrompt();
if (prompt != null)
System.out.println(prompt);
System.out.println();
String userName = get(in, "User Name", getDefaultUserName());
String password = get(in, "Password", null);
if (userName == null)
return null;
else
return new PasswordAuthentication(userName, password);
|
public static void | main(java.lang.String[] argv)
Session sess = Session.getInstance(System.getProperties(),
new TtyAuthenticator());
PasswordAuthentication pw = sess.requestPasswordAuthentication(
InetAddress.getByName(argv[0]),
Integer.parseInt(argv[1]), argv[2], z(argv[3]), z(argv[4]));
System.out.println("User: " + n(pw.getUserName()));
System.out.println("Password: " + n(pw.getPassword()));
|
private static final java.lang.String | n(java.lang.String s)
return s == null ? "<null>" : s;
|
private static final java.lang.String | z(java.lang.String s)
return s.length() > 0 ? s : null;
|